--- trunk/xvidcore/examples/xvid_stat.c 2002/04/13 22:21:46 119 +++ trunk/xvidcore/examples/xvid_stat.c 2002/06/14 15:36:22 211 @@ -65,32 +65,34 @@ #include // needed for log10 #include // only needed for gettimeofday -#include "xvid.h" /* comes with XviD */ +#include "../src/xvid.h" /* comes with XviD */ int motion_presets[7] = { 0, // Q 0 PMV_EARLYSTOP16, // Q 1 PMV_EARLYSTOP16, // Q 2 PMV_EARLYSTOP16 | PMV_HALFPELREFINE16, // Q 3 - PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8, // Q 4 - PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 // Q 5 - | PMV_HALFPELREFINE8, + PMV_EARLYSTOP16 | PMV_HALFPELREFINE16, // Q 4 + PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 // Q 5 + | PMV_HALFPELREFINE8, PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 // Q 6 | PMV_USESQUARES16 | PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 }; int general_presets[7] = { XVID_H263QUANT, /* or use XVID_MPEGQUANT */ // Q 0 - XVID_H263QUANT, // Q 1 - XVID_H263QUANT, // Q 2 + XVID_MPEGQUANT, // Q 1 + XVID_H263QUANT, // Q 2 XVID_H263QUANT | XVID_HALFPEL, // Q 3 XVID_H263QUANT | XVID_HALFPEL | XVID_INTER4V, // Q 4 XVID_H263QUANT | XVID_HALFPEL | XVID_INTER4V, // Q 5 - XVID_H263QUANT |XVID_HALFPEL | XVID_INTER4V }; // Q 6 + XVID_H263QUANT | XVID_HALFPEL | XVID_INTER4V }; // Q 6 /* my default values for encoding */ +#define ABS_MAXFRAMENR 9999 // max number of frames + int ARG_BITRATE=900; int ARG_QUANTI=0; @@ -99,6 +101,8 @@ int ARG_MAXQUANT=31; float ARG_FRAMERATE=25.00; +int ARG_MAXFRAMENR=ABS_MAXFRAMENR; + #define MAX(A,B) ( ((A)>(B)) ? (A) : (B) ) #define SMALL_EPS 1e-10 @@ -117,8 +121,6 @@ int pgmflag = 0; // a flag, if input is in PGM format, overwritten in init-phase char filepath[256] = "./"; // the path where to save output -#define MAXFILENR 9999 // max number of frames (this should be made into an option!) - void *enc_handle = NULL; // internal structures (handles) for encoding void *dec_handle = NULL; // and decoding @@ -260,14 +262,24 @@ #define FRAMERATE_INCR 1001 -int enc_init() +int enc_init(int use_assembler) { /* initialize encoder for first use, pass all needed parameters to the codec */ int xerr; XVID_INIT_PARAM xinit; XVID_ENC_PARAM xparam; - xinit.cpu_flags = XVID_CPU_FORCE; + if(use_assembler) + +#ifdef ARCH_IA64 + xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64; +#else + xinit.cpu_flags = 0; +#endif + + else + xinit.cpu_flags = XVID_CPU_FORCE; + xvid_init(NULL, 0, &xinit, NULL); xparam.width = XDIM; @@ -282,11 +294,14 @@ xparam.fincr = FRAMERATE_INCR; xparam.fbase = (int)(FRAMERATE_INCR * ARG_FRAMERATE); } - xparam.bitrate = ARG_BITRATE*1000; + xparam.rc_reaction_delay_factor = 16; + xparam.rc_averaging_period = 100; + xparam.rc_buffer = 10; + xparam.rc_bitrate = ARG_BITRATE*1000; xparam.min_quantizer = 1; xparam.max_quantizer = 31; xparam.max_key_interval = (int)ARG_FRAMERATE*10; - xparam.rc_buffersize = 2; + /* I use a small value here, since will not encode whole movies, but short clips */ xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xparam, NULL); @@ -345,14 +360,24 @@ /* Routines for decoding: init encoder, frame step, release encoder */ /*********************************************************************/ -int dec_init() /* init decoder before first run */ +int dec_init(int use_assembler) /* init decoder before first run */ { int xerr; XVID_INIT_PARAM xinit; XVID_DEC_PARAM xparam; - xinit.cpu_flags = 0; + if(use_assembler) + +#ifdef ARCH_IA64 + xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64; +#else + xinit.cpu_flags = 0; +#endif + + else + xinit.cpu_flags = XVID_CPU_FORCE; + xvid_init(NULL, 0, &xinit, NULL); xparam.width = XDIM; xparam.height = YDIM; @@ -407,9 +432,9 @@ int status; int m4v_size; - int frame_type[MAXFILENR]; - int Iframes=0, Pframes=0, Bframes=0; - double framepsnr[MAXFILENR]; + int frame_type[ABS_MAXFRAMENR]; + int Iframes=0, Pframes=0, Bframes=0, use_assembler=0; + double framepsnr[ABS_MAXFRAMENR]; double Ipsnr=0.,Imaxpsnr=0.,Iminpsnr=999.,Ivarpsnr=0.; double Ppsnr=0.,Pmaxpsnr=0.,Pminpsnr=999.,Pvarpsnr=0.; @@ -424,6 +449,8 @@ { pgmflag = 1; + if (argc==2 && !strcmp(argv[1],"-asm")) + use_assembler = 1; if (argc>=3) { XDIM = atoi(argv[1]); YDIM = atoi(argv[2]); @@ -471,6 +498,13 @@ printf("Framerate %6.3f fps\n",ARG_FRAMERATE); } + if (argc>=7) + { ARG_MAXFRAMENR = atoi(argv[6]); + if ( (ARG_MAXFRAMENR <= 0) ) + { fprintf(stderr,"Wrong number of frames\n"); return -1; } + printf("max. Framenr. %d\n",ARG_MAXFRAMENR); + } + /* now we know the sizes, so allocate memory */ in_buffer = (unsigned char *) malloc(XDIM*YDIM); @@ -493,14 +527,14 @@ /*********************************************************************/ - status = enc_init(); + status = enc_init(use_assembler); if (status) { printf("Encore INIT problem, return value %d\n", status); goto release_all; } - status = dec_init(); + status = dec_init(use_assembler); if (status) { printf("Decore INIT problem, return value %d\n", status); @@ -588,7 +622,7 @@ filenr++; - } while ( (!status) && (filenr