19 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $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 $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
87 |
|
|
88 |
static int ARG_STATS = 0; |
static int ARG_STATS = 0; |
89 |
static int ARG_DUMP = 0; |
static int ARG_DUMP = 0; |
90 |
|
static int ARG_LUMIMASKING = 0; |
91 |
static int ARG_BITRATE = 900; |
static int ARG_BITRATE = 900; |
92 |
static int ARG_QUANTI = 0; |
static int ARG_QUANTI = 0; |
93 |
static int ARG_QUALITY = 5; |
static int ARG_QUALITY = 5; |
239 |
else if (strcmp("-dump", argv[i]) == 0) { |
else if (strcmp("-dump", argv[i]) == 0) { |
240 |
ARG_DUMP = 1; |
ARG_DUMP = 1; |
241 |
} |
} |
242 |
|
else if (strcmp("-lumimasking", argv[i]) == 0) { |
243 |
|
ARG_LUMIMASKING = 1; |
244 |
|
} |
245 |
else if (strcmp("-t", argv[i]) == 0 && i < argc - 1 ) { |
else if (strcmp("-t", argv[i]) == 0 && i < argc - 1 ) { |
246 |
i++; |
i++; |
247 |
ARG_INPUTTYPE = atoi(argv[i]); |
ARG_INPUTTYPE = atoi(argv[i]); |
427 |
} |
} |
428 |
|
|
429 |
printf(" | type=%s quant=%2d, length=%7d", type, stats_quant, stats_length); |
printf(" | type=%s quant=%2d, length=%7d", type, stats_quant, stats_length); |
430 |
|
|
431 |
|
if(ARG_STATS) { |
432 |
|
printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f", |
433 |
|
(stats[0] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[0]/((float)(XDIM)*(YDIM))), |
434 |
|
(stats[1] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[1]/((float)(XDIM)*(YDIM)/4)), |
435 |
|
(stats[2] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[2]/((float)(XDIM)*(YDIM)/4))); |
436 |
|
} |
437 |
|
|
438 |
} |
} |
439 |
|
|
440 |
printf("\n"); |
printf("\n"); |
484 |
* Calculate totals and averages for output, print results |
* Calculate totals and averages for output, print results |
485 |
****************************************************************************/ |
****************************************************************************/ |
486 |
|
|
487 |
|
printf("Tot: enctime(ms) =%7.2f, length(bytes) = %7d\n", |
488 |
|
totalenctime, (int)totalsize); |
489 |
|
|
490 |
if (input_num > 0) { |
if (input_num > 0) { |
491 |
totalsize /= input_num; |
totalsize /= input_num; |
492 |
totalenctime /= input_num; |
totalenctime /= input_num; |
571 |
fprintf(stderr, " -t integer : input data type (yuv=0, pgm=1)\n"); |
fprintf(stderr, " -t integer : input data type (yuv=0, pgm=1)\n"); |
572 |
fprintf(stderr, " -n integer : number of frames to encode\n"); |
fprintf(stderr, " -n integer : number of frames to encode\n"); |
573 |
fprintf(stderr, " -q integer : quality ([0..5])\n"); |
fprintf(stderr, " -q integer : quality ([0..5])\n"); |
574 |
fprintf(stderr, " -d boolean : save decoder output (0 False*, !=0 True)\n"); |
fprintf(stderr, " -dump : save decoder output\n"); |
575 |
fprintf(stderr, " -m : save mpeg4 raw stream\n"); |
fprintf(stderr, " -m : save mpeg4 raw stream\n"); |
576 |
fprintf(stderr, " -o string : output container filename (only usefull when -m 1 is used) :\n"); |
fprintf(stderr, " -o string : output container filename (only usefull when -m 1 is used) :\n"); |
577 |
fprintf(stderr, " When this option is not used : one file per encoded frame\n"); |
fprintf(stderr, " When this option is not used : one file per encoded frame\n"); |
666 |
switch(opt) |
switch(opt) |
667 |
{ |
{ |
668 |
case XVID_PLG_INFO : |
case XVID_PLG_INFO : |
669 |
|
{ |
670 |
|
xvid_plg_info_t * info = (xvid_plg_info_t*)param1; |
671 |
|
info->flags = XVID_REQDQUANTS; |
672 |
|
return 0; |
673 |
|
} |
674 |
|
|
675 |
case XVID_PLG_CREATE : |
case XVID_PLG_CREATE : |
676 |
case XVID_PLG_DESTROY : |
case XVID_PLG_DESTROY : |
677 |
case XVID_PLG_BEFORE : |
case XVID_PLG_BEFORE : |
680 |
case XVID_PLG_AFTER : |
case XVID_PLG_AFTER : |
681 |
{ |
{ |
682 |
xvid_plg_data_t * data = (xvid_plg_data_t*)param1; |
xvid_plg_data_t * data = (xvid_plg_data_t*)param1; |
683 |
printf("type=%i, quant=%i, length=%i\n", data->type, data->quant, data->length); |
int i,j; |
684 |
|
|
685 |
|
printf("---[ frame: %5i quant: %2i length: %6i ]---\n", data->frame_num, data->quant, data->length); |
686 |
|
for (j=0; j<data->mb_height; j++) { |
687 |
|
for (i = 0; i<data->mb_width; i++) |
688 |
|
printf("%2i ", data->dquant[j*data->dquant_stride + i]); |
689 |
|
printf("\n"); |
690 |
|
} |
691 |
|
|
692 |
return 0; |
return 0; |
693 |
} |
} |
694 |
} |
} |
750 |
|
|
751 |
xvid_enc_create.plugins = plugins; |
xvid_enc_create.plugins = plugins; |
752 |
xvid_enc_create.num_plugins = 0; |
xvid_enc_create.num_plugins = 0; |
753 |
if (ARG_STATS) { |
|
754 |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_psnr; |
if (ARG_LUMIMASKING) { |
755 |
|
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; |
756 |
plugins[xvid_enc_create.num_plugins].param = NULL; |
plugins[xvid_enc_create.num_plugins].param = NULL; |
757 |
xvid_enc_create.num_plugins++; |
xvid_enc_create.num_plugins++; |
758 |
} |
} |
759 |
|
|
760 |
if (ARG_DUMP) { |
if (ARG_DUMP) { |
761 |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_dump; |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_dump; |
762 |
plugins[xvid_enc_create.num_plugins].param = NULL; |
plugins[xvid_enc_create.num_plugins].param = NULL; |
763 |
xvid_enc_create.num_plugins++; |
xvid_enc_create.num_plugins++; |
764 |
} |
} |
765 |
|
|
766 |
|
/* plugins[xvid_enc_create.num_plugins].func = rawenc_debug; |
767 |
|
plugins[xvid_enc_create.num_plugins].param = NULL; |
768 |
|
xvid_enc_create.num_plugins++; */ |
769 |
|
|
770 |
/* No fancy thread tests */ |
/* No fancy thread tests */ |
771 |
xvid_enc_create.num_threads = 0; |
xvid_enc_create.num_threads = 0; |
772 |
|
|
793 |
/* Global encoder options */ |
/* Global encoder options */ |
794 |
xvid_enc_create.global = 0; |
xvid_enc_create.global = 0; |
795 |
if (ARG_PACKED) xvid_enc_create.global |= XVID_PACKED; |
if (ARG_PACKED) xvid_enc_create.global |= XVID_PACKED; |
796 |
|
if (ARG_STATS) xvid_enc_create.global |= XVID_EXTRASTATS_ENABLE; |
797 |
|
|
798 |
/* I use a small value here, since will not encode whole movies, but short clips */ |
/* I use a small value here, since will not encode whole movies, but short clips */ |
799 |
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); |
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); |
849 |
|
|
850 |
/* Set up core's general features */ |
/* Set up core's general features */ |
851 |
xvid_enc_frame.vol_flags = vol_presets[ARG_QUALITY]; |
xvid_enc_frame.vol_flags = vol_presets[ARG_QUALITY]; |
852 |
|
if (ARG_STATS) xvid_enc_frame.vol_flags |= XVID_EXTRASTATS; |
853 |
|
|
854 |
/* Set up core's general features */ |
/* Set up core's general features */ |
855 |
xvid_enc_frame.vop_flags = vop_presets[ARG_QUALITY]; |
xvid_enc_frame.vop_flags = vop_presets[ARG_QUALITY]; |
859 |
|
|
860 |
/* Force the right quantizer */ |
/* Force the right quantizer */ |
861 |
xvid_enc_frame.quant = ARG_QUANTI; |
xvid_enc_frame.quant = ARG_QUANTI; |
|
xvid_enc_frame.bquant = 0; |
|
862 |
|
|
863 |
/* Set up motion estimation flags */ |
/* Set up motion estimation flags */ |
864 |
xvid_enc_frame.motion = motion_presets[ARG_QUALITY]; |
xvid_enc_frame.motion = motion_presets[ARG_QUALITY]; |