--- xvid_encraw.c 2003/03/15 14:32:56 1.11.2.6 +++ xvid_encraw.c 2003/03/16 12:04:13 1.11.2.8 @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: xvid_encraw.c,v 1.11.2.6 2003/03/15 14:32:56 suxen_drol Exp $ + * $Id: xvid_encraw.c,v 1.11.2.8 2003/03/16 12:04:13 suxen_drol Exp $ * ****************************************************************************/ @@ -87,6 +87,7 @@ static int ARG_STATS = 0; static int ARG_DUMP = 0; +static int ARG_LUMIMASKING = 0; static int ARG_BITRATE = 900; static int ARG_QUANTI = 0; static int ARG_QUALITY = 5; @@ -238,6 +239,9 @@ else if (strcmp("-dump", argv[i]) == 0) { ARG_DUMP = 1; } + else if (strcmp("-lumimasking", argv[i]) == 0) { + ARG_LUMIMASKING = 1; + } else if (strcmp("-t", argv[i]) == 0 && i < argc - 1 ) { i++; ARG_INPUTTYPE = atoi(argv[i]); @@ -423,6 +427,14 @@ } printf(" | type=%s quant=%2d, length=%7d", type, stats_quant, stats_length); + + if(ARG_STATS) { + printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f", + (stats[0] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[0]/((float)(XDIM)*(YDIM))), + (stats[1] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[1]/((float)(XDIM)*(YDIM)/4)), + (stats[2] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[2]/((float)(XDIM)*(YDIM)/4))); + } + } printf("\n"); @@ -472,6 +484,9 @@ * Calculate totals and averages for output, print results ****************************************************************************/ + printf("Tot: enctime(ms) =%7.2f, length(bytes) = %7d\n", + totalenctime, (int)totalsize); + if (input_num > 0) { totalsize /= input_num; totalenctime /= input_num; @@ -556,7 +571,7 @@ fprintf(stderr, " -t integer : input data type (yuv=0, pgm=1)\n"); fprintf(stderr, " -n integer : number of frames to encode\n"); fprintf(stderr, " -q integer : quality ([0..5])\n"); - fprintf(stderr, " -d boolean : save decoder output (0 False*, !=0 True)\n"); + fprintf(stderr, " -dump : save decoder output\n"); fprintf(stderr, " -m : save mpeg4 raw stream\n"); fprintf(stderr, " -o string : output container filename (only usefull when -m 1 is used) :\n"); fprintf(stderr, " When this option is not used : one file per encoded frame\n"); @@ -651,17 +666,31 @@ switch(opt) { case XVID_PLG_INFO : + { + xvid_plg_info_t * info = (xvid_plg_info_t*)param1; + info->flags = XVID_REQDQUANTS; + return 0; + } + case XVID_PLG_CREATE : case XVID_PLG_DESTROY : case XVID_PLG_BEFORE : - return 0; + return 0; case XVID_PLG_AFTER : - { - xvid_plg_data_t * data = (xvid_plg_data_t*)param1; - printf("type=%i, quant=%i, length=%i\n", data->type, data->quant, data->length); - return 0; - } + { + xvid_plg_data_t * data = (xvid_plg_data_t*)param1; + int i,j; + + printf("---[ frame: %5i quant: %2i length: %6i ]---\n", data->frame_num, data->quant, data->length); + for (j=0; jmb_height; j++) { + for (i = 0; imb_width; i++) + printf("%2i ", data->dquant[j*data->dquant_stride + i]); + printf("\n"); + } + + return 0; + } } return XVID_ERR_FAIL; @@ -676,7 +705,7 @@ int xerr; xvid_enc_plugin_t plugins[2]; - + xvid_gbl_init_t xvid_gbl_init; xvid_enc_create_t xvid_enc_create; @@ -721,17 +750,23 @@ xvid_enc_create.plugins = plugins; xvid_enc_create.num_plugins = 0; - if (ARG_STATS) { - plugins[xvid_enc_create.num_plugins].func = xvid_plugin_psnr; + + if (ARG_LUMIMASKING) { + plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; plugins[xvid_enc_create.num_plugins].param = NULL; - xvid_enc_create.num_plugins++; + xvid_enc_create.num_plugins++; } + if (ARG_DUMP) { plugins[xvid_enc_create.num_plugins].func = xvid_plugin_dump; plugins[xvid_enc_create.num_plugins].param = NULL; xvid_enc_create.num_plugins++; } +/* plugins[xvid_enc_create.num_plugins].func = rawenc_debug; + plugins[xvid_enc_create.num_plugins].param = NULL; + xvid_enc_create.num_plugins++; */ + /* No fancy thread tests */ xvid_enc_create.num_threads = 0; @@ -758,6 +793,7 @@ /* Global encoder options */ xvid_enc_create.global = 0; if (ARG_PACKED) xvid_enc_create.global |= XVID_PACKED; + if (ARG_STATS) xvid_enc_create.global |= XVID_EXTRASTATS_ENABLE; /* I use a small value here, since will not encode whole movies, but short clips */ xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); @@ -813,6 +849,7 @@ /* Set up core's general features */ xvid_enc_frame.vol_flags = vol_presets[ARG_QUALITY]; + if (ARG_STATS) xvid_enc_frame.vol_flags |= XVID_EXTRASTATS; /* Set up core's general features */ xvid_enc_frame.vop_flags = vop_presets[ARG_QUALITY]; @@ -822,7 +859,6 @@ /* Force the right quantizer */ xvid_enc_frame.quant = ARG_QUANTI; - xvid_enc_frame.bquant = 0; /* Set up motion estimation flags */ xvid_enc_frame.motion = motion_presets[ARG_QUALITY];