?? wvtdecode.cpp
字號:
/*************************************************************************
This software module was originally developed by
Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation
Wei-ge Chen (wchen@microsoft.com), Microsoft Corporation
Bruce Lin (blin@microsoft.com), Microsoft Corporation
Chuang Gu (chuanggu@microsoft.com), Microsoft Corporation
Simon Winder (swinder@microsoft.com), Microsoft Corporation
in the course of development of the MPEG-4 Video (ISO/IEC 14496-2).
This software module is an implementation of a part of one or more MPEG-4 Video tools
as specified by the MPEG-4 Video.
ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications
thereof for use in hardware or software products claiming conformance to the MPEG-4 Video.
Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents.
The original developer of this software module and his/her company,
the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation.
Copyright is not released for non MPEG-4 Video conforming products.
Microsoft retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products.
This copyright notice must be included in all copies or derivative works.
Copyright (c) 1996, 1997.
Module Name:
wvtdecode.cpp
Abstract:
stand-alone wavelet decoder
Revision History:
*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <fstream.h>
#include "typeapi.h"
#include "wavelet.h"
#ifdef __MFC_
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#define new DEBUG_NEW
#endif // __MFC_
void error(char *pchMessage)
{
fprintf(stderr,"Error: %s\n",pchMessage);
exit(1);
}
Bool get_start_code(CInBitStream &bs)
{
Int i=0;
// byte align
bs.flush();
while(bs.peekBits(NUMBITS_TOL_START_CODE)!=TOL_START_CODE)
{
/*if((i%100)==0)
printf("%d");
i++;*/
bs.getBits(8);
if(bs.eof())
return FALSE;
}
bs.getBits(NUMBITS_TOL_START_CODE);
return TRUE;
}
// arguments bitfile outfile spatial_layer snr_layer
int main(int argc,char **argv)
{
Int iSpatialLayer = 0;
Int iSNRLayer = 0;
FILE *pfsOut;
if(argc<3 || argc>5)
{
fprintf(stderr,"Bad parameters\n");
fprintf(stderr,"%s bitfile outfile spatial_layer_select snr_layer_select\n",
argv[0]);
exit(1);
}
if(argc>=4)
iSpatialLayer = atoi(argv[3]);
if(argc==5)
iSNRLayer = atoi(argv[4]);
// create input bitstream
ifstream bitfile(argv[1],ios::in|ios::nocreate|ios::binary);
if(bitfile.is_open()==0)
error("Can't open bitstream file for input");
CInBitStream bs(bitfile);
if((pfsOut = fopen(argv[2],"wb"))==NULL)
error("Can't open yuv file for output");
Int iPrevWidth = 0,iPrevHeight = 0,iPrevDecompLevels = 0;
CWvtTextureCoder *pWvtTextureCoder = NULL;
Int iFrame = 0;
do {
// find start code
if(get_start_code(bs)==FALSE)
break;
// read size and decomp levels
Int iObjectID = bs.getBits(NUMBITS_TOL_ID);
Int iShape = bs.getBits(NUMBITS_TOL_SHAPE);
if(iShape!=0)
error("Unknown shape mode in stream");
Int iWidth = bs.getBits(NUMBITS_TOL_SIZE);
Int iHeight = bs.getBits(NUMBITS_TOL_SIZE);
Int iDecompLevels = bs.getBits(NUMBITS_TOL_DECOMP);
if(iSpatialLayer>=iDecompLevels)
iSpatialLayer=iDecompLevels-1;
// create decoder object anew if needed
if(pWvtTextureCoder==NULL || iWidth!=iPrevWidth ||
iHeight!=iPrevHeight || iDecompLevels!=iPrevDecompLevels)
{
if(pWvtTextureCoder!=NULL)
delete pWvtTextureCoder;
CRct rct(0,0,iWidth,iHeight);
pWvtTextureCoder = new CWvtTextureCoder(rct,iDecompLevels,
DAUBE_9_3);
iPrevDecompLevels = iDecompLevels;
iPrevWidth = iWidth;
iPrevHeight = iHeight;
}
#if(DEBUG_DECODE)
printf("\nFrame number = %d\n",iFrame);
#endif
#if(DEBUG_BITS)
printf("\nObject ID\t\t= %d\n",iObjectID);
printf("Shape mode\t\t= %d\n",iShape);
printf("Width x Height\t\t= (%d x %d)\n",iWidth,iHeight);
printf("Decomp levels\t\t= %d\n",iDecompLevels);
#endif
// decode stream
CVideoObjectPlane *pvop =
pWvtTextureCoder->decode(bs,iSpatialLayer,iSNRLayer);
if(pvop!=NULL)
{
// save vop
pvop->dump(pfsOut,FOUR_TWO_ZERO);
delete pvop;
}
iFrame++;
} while(!bs.eof());
if(pWvtTextureCoder!=NULL)
delete pWvtTextureCoder;
fclose(pfsOut);
bitfile.close();
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -