【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了convertpar.cpp提供大家参考,希望对大家有所帮助!
/*************************************************************************
This software module was originally developed by
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.
Sharp 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) 1997.
*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned int UInt;
typedef int Int;
typedef void Void;
typedef int Bool;
typedef double Double;
typedef enum {Q_H263, Q_MPEG} Quantizer;
typedef enum AlphaUsage {RECTANGLE, ONE_BIT, EIGHT_BIT} AlphaUsage;
typedef enum ChromType {FOUR_FOUR_FOUR, FOUR_TWO_TWO, FOUR_TWO_ZERO} ChromType;
typedef enum {BASIC_SPRITE, LOW_LATENCY, PIECE_OBJECT, PIECE_UPDATE} SptMode;
typedef char Char;
Void nextValidLine (FILE *pfPara, UInt* pnLine);
Void readBoolVOLFlag (Bool * rgbTable [2], UInt nVO, FILE * pfCfg, UInt * pnLine, Bool bAnyScalability);
Void readItem(UInt *rguiTable [2], UInt nVO, FILE * pfCfg, UInt * pnLine, Bool bAnyScalability);
#define BASE_LAYER 0
#define ENHN_LAYER 1
#define NO_SCALABILITY 0
#define TEMPORAL_SCALABILITY 1
#define SPATIAL_SCALABILITY 2
#define FALSE 0
#define TRUE 1
#define BLOCK_SQUARE_SIZE 64
#define RC_MPEG4 1
#define RC_TM5 3
Void fatal_error(char *pchError, Bool bFlag = FALSE);
void my_assert(int iFlag)
{
if(!iFlag)
fatal_error("Some assert failed! Check original par file format.\n");
}
int main (Int argc, Char* argv[])
{
UInt nLine = 1;
UInt* pnLine = &nLine;
FILE *pfPara;
FILE *pfOut = stdout;
if (argc != 2 && argc !=3)
{
fprintf (stderr,"Usage: %s old_par_file [new_par_file]\n", argv[0]);
fatal_error("Conversion aborted");
}
if ((pfPara = fopen (argv[1], "r")) == NULL )
{
fprintf (stderr,"Source parameter file not found\n");
fatal_error("Conversion aborted");
}
if(argc==3)
{
if ((pfOut = fopen (argv[2], "w")) == NULL )
{
fprintf (stderr,"Could not open %s for writing.\n", argv[2]);
fatal_error("Conversion aborted");
}
}
// all the parameters to the encoder
Int iVersion;
Int iVTCFlag;
UInt uiFrmWidth, uiFrmHeight;
UInt firstFrm, lastFrm;
Bool bNot8Bit;
UInt uiQuantPrecision;
UInt nBits;
UInt firstVO, lastVO;
UInt nVO;
UInt uiFrmWidth_SS,uiFrmHeight_SS;
UInt uiHor_sampling_m,uiHor_sampling_n;
UInt uiVer_sampling_m,uiVer_sampling_n;
Bool bAnyScalability;
Int iSpatialOption;
char *pchPrefix;
char *pchBmpDir;
char *pchOutBmpDir;
char *pchOutStrFile;
char *pchSptDir;
char *pchSptPntDir;
Int *rgiTemporalScalabilityType;
Bool *rgbSpatialScalability;
Bool *rgbScalability;
Int *rgiEnhancementType;
AlphaUsage *rgfAlphaUsage;
Bool *rgbShapeOnly;
Int *rgiBinaryAlphaTH;
Int *rgbNoCrChange;
Int *rgiBinaryAlphaRR;
Bool *rgbRoundingControlDisable;
Int *rgiInitialRoundingType;
Int *rgiNumPbetweenIVOP;
Int *rgiNumBbetweenPVOP;
Int *rgiGOVperiod;
Bool *rgbDeblockFilterDisable;
Int *rgiTSRate;
Int *rgiEnhcTSRate;
ChromType *rgfChrType;
Bool *rgbAllowSkippedPMBs;
SptMode *rgSpriteMode;
Bool *rgbDumpMB;
Bool *rgbTrace;
UInt *rguiSpriteUsage;
UInt *rguiWarpingAccuracy;
Int *rgiNumPnts;
UInt *rguiRateControl [2];
UInt *rguiBitsBudget [2];
Bool *rgbAdvPredDisable [2];
Bool *rgbErrorResilientDisable [2];
Bool *rgbDataPartitioning [2];
Bool *rgbReversi