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.2 2003-03-09 16:45:24 edgomez Exp $ |
* $Id: xvid_encraw.c,v 1.11.2.3 2003-03-11 01:08:10 edgomez Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
84 |
/* Maximum number of frames to encode */ |
/* Maximum number of frames to encode */ |
85 |
#define ABS_MAXFRAMENR 9999 |
#define ABS_MAXFRAMENR 9999 |
86 |
|
|
87 |
|
static int ARG_STATS = 0; |
88 |
static int ARG_BITRATE = 900; |
static int ARG_BITRATE = 900; |
89 |
static int ARG_QUANTI = 0; |
static int ARG_QUANTI = 0; |
90 |
static int ARG_QUALITY = 5; |
static int ARG_QUALITY = 5; |
218 |
i++; |
i++; |
219 |
ARG_INPUTFILE = argv[i]; |
ARG_INPUTFILE = argv[i]; |
220 |
} |
} |
221 |
|
else if (strcmp("-s", argv[i]) == 0) { |
222 |
|
ARG_STATS = 1; |
223 |
|
} |
224 |
else if (strcmp("-t", argv[i]) == 0 && i < argc - 1 ) { |
else if (strcmp("-t", argv[i]) == 0 && i < argc - 1 ) { |
225 |
i++; |
i++; |
226 |
ARG_INPUTTYPE = atoi(argv[i]); |
ARG_INPUTTYPE = atoi(argv[i]); |
233 |
i++; |
i++; |
234 |
ARG_QUANTI = atoi(argv[i]); |
ARG_QUANTI = atoi(argv[i]); |
235 |
} |
} |
236 |
else if (strcmp("-m", argv[i]) == 0 && i < argc - 1 ) { |
else if (strcmp("-m", argv[i]) == 0) { |
237 |
i++; |
ARG_SAVEMPEGSTREAM = 1; |
|
ARG_SAVEMPEGSTREAM = atoi(argv[i]); |
|
238 |
} |
} |
239 |
else if (strcmp("-o", argv[i]) == 0 && i < argc - 1 ) { |
else if (strcmp("-o", argv[i]) == 0 && i < argc - 1 ) { |
240 |
i++; |
i++; |
394 |
break; |
break; |
395 |
} |
} |
396 |
|
|
397 |
printf("Frame %5d: type = %s, enctime(ms) =%6.1f, length(bytes) =%7d, " |
printf("Frame %5d: type = %s, enctime(ms) =%6.1f, length(bytes) =%7d", |
|
"psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f\n", |
|
398 |
(int)filenr, |
(int)filenr, |
399 |
type, |
type, |
400 |
(float)enctime, |
(float)enctime, |
401 |
(int)m4v_size, |
(int)m4v_size); |
402 |
|
|
403 |
|
if(ARG_STATS) { |
404 |
|
printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f", |
405 |
(stats[0] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[0]/((float)(XDIM)*(YDIM))), |
(stats[0] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[0]/((float)(XDIM)*(YDIM))), |
406 |
(stats[1] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[1]/((float)(XDIM)*(YDIM)/4)), |
(stats[1] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[1]/((float)(XDIM)*(YDIM)/4)), |
407 |
(stats[2] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[2]/((float)(XDIM)*(YDIM)/4))); |
(stats[2] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[2]/((float)(XDIM)*(YDIM)/4))); |
408 |
|
} |
409 |
|
|
410 |
|
printf("\n"); |
411 |
|
|
412 |
/* Update encoding time stats */ |
/* Update encoding time stats */ |
413 |
totalenctime += enctime; |
totalenctime += enctime; |
524 |
fprintf(stderr, " -bqo integer : bframe quantizer offset (default=100)\n"); |
fprintf(stderr, " -bqo integer : bframe quantizer offset (default=100)\n"); |
525 |
fprintf(stderr, " -f float : target framerate (>0)\n"); |
fprintf(stderr, " -f float : target framerate (>0)\n"); |
526 |
fprintf(stderr, " -i string : input filename (default=stdin)\n"); |
fprintf(stderr, " -i string : input filename (default=stdin)\n"); |
527 |
|
fprintf(stderr, " -s : print stats about encoded frames\n"); |
528 |
fprintf(stderr, " -t integer : input data type (yuv=0, pgm=1)\n"); |
fprintf(stderr, " -t integer : input data type (yuv=0, pgm=1)\n"); |
529 |
fprintf(stderr, " -n integer : number of frames to encode\n"); |
fprintf(stderr, " -n integer : number of frames to encode\n"); |
530 |
fprintf(stderr, " -q integer : quality ([0..5])\n"); |
fprintf(stderr, " -q integer : quality ([0..5])\n"); |
531 |
fprintf(stderr, " -d boolean : save decoder output (0 False*, !=0 True)\n"); |
fprintf(stderr, " -d boolean : save decoder output (0 False*, !=0 True)\n"); |
532 |
fprintf(stderr, " -m boolean : save mpeg4 raw stream (0 False*, !=0 True)\n"); |
fprintf(stderr, " -m : save mpeg4 raw stream\n"); |
533 |
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"); |
534 |
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"); |
535 |
fprintf(stderr, " When this option is used : save to 'string' file\n"); |
fprintf(stderr, " When this option is used : save to 'string' file\n"); |
684 |
xvid_enc_create.frame_drop_ratio = 0; |
xvid_enc_create.frame_drop_ratio = 0; |
685 |
|
|
686 |
/* Global encoder options */ |
/* Global encoder options */ |
687 |
xvid_enc_create.global = XVID_EXTRASTATS_ENABLE; |
xvid_enc_create.global = (ARG_STATS)?XVID_EXTRASTATS_ENABLE:0; |
688 |
|
|
689 |
/* 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 */ |
690 |
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); |
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); |
755 |
xvid_enc_stats[0].sse_u = 0; |
xvid_enc_stats[0].sse_u = 0; |
756 |
|
|
757 |
/* Encode the frame */ |
/* Encode the frame */ |
758 |
xvid_enc_frame.vop_flags |= XVID_EXTRASTATS; |
xvid_enc_frame.vop_flags |= (ARG_STATS)?XVID_EXTRASTATS:0; |
759 |
ret = xvid_encore(enc_handle, XVID_ENC_ENCODE, &xvid_enc_frame, &xvid_enc_stats); |
ret = xvid_encore(enc_handle, XVID_ENC_ENCODE, &xvid_enc_frame, &xvid_enc_stats); |
760 |
|
|
761 |
*frametype = xvid_enc_stats[0].type; |
*frametype = xvid_enc_stats[0].type; |