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.9 2003-03-20 14:14:52 edgomez Exp $ |
* $Id: xvid_encraw.c,v 1.11.2.12 2003-03-25 11:01:48 suxen_drol Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
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; |
static int ARG_LUMIMASKING = 0; |
91 |
static int ARG_BITRATE = 900; |
static int ARG_BITRATE = 0; |
92 |
|
static char * ARG_PASS1 = 0; |
93 |
|
static char * ARG_PASS2 = 0; |
94 |
static int ARG_QUANTI = 0; |
static int ARG_QUANTI = 0; |
95 |
static int ARG_QUALITY = 5; |
static int ARG_QUALITY = 5; |
96 |
static float ARG_FRAMERATE = 25.00f; |
static float ARG_FRAMERATE = 25.00f; |
208 |
} else if (strcmp("-bitrate", argv[i]) == 0 && i < argc - 1) { |
} else if (strcmp("-bitrate", argv[i]) == 0 && i < argc - 1) { |
209 |
i++; |
i++; |
210 |
ARG_BITRATE = atoi(argv[i]); |
ARG_BITRATE = atoi(argv[i]); |
211 |
|
} else if (strcmp("-pass1", argv[i]) == 0 && i < argc - 1) { |
212 |
|
i++; |
213 |
|
ARG_PASS1 = argv[i]; |
214 |
|
} else if (strcmp("-pass2", argv[i]) == 0 && i < argc - 2) { |
215 |
|
i++; |
216 |
|
ARG_PASS1 = argv[i]; |
217 |
|
i++; |
218 |
|
ARG_PASS2 = argv[i]; |
219 |
} else if (strcmp("-max_bframes", argv[i]) == 0 && i < argc - 1) { |
} else if (strcmp("-max_bframes", argv[i]) == 0 && i < argc - 1) { |
220 |
i++; |
i++; |
221 |
ARG_MAXBFRAMES = atoi(argv[i]); |
ARG_MAXBFRAMES = atoi(argv[i]); |
283 |
return (-1); |
return (-1); |
284 |
} |
} |
285 |
|
|
|
if (ARG_BITRATE <= 0 && ARG_QUANTI == 0) { |
|
|
fprintf(stderr, "Wrong Bitrate\n"); |
|
|
return (-1); |
|
|
} |
|
|
|
|
286 |
if (ARG_FRAMERATE <= 0) { |
if (ARG_FRAMERATE <= 0) { |
287 |
fprintf(stderr, "Wrong Framerate %s \n", argv[5]); |
fprintf(stderr, "Wrong Framerate %s \n", argv[5]); |
288 |
return (-1); |
return (-1); |
390 |
|
|
391 |
/* Write the Frame statistics */ |
/* Write the Frame statistics */ |
392 |
|
|
393 |
printf("%5d: key=%i, time(ms)=%6.1f, length=%7d", |
printf("%5d: key=%i, time=%6.0f, length=%7d", |
394 |
!result ? input_num : -1, |
!result ? input_num : -1, |
395 |
key, |
key, |
396 |
(float) enctime, |
(float) enctime, |
572 |
fprintf(stderr, " -bquant_ratio integer: bframe quantizer ratio (default=150)\n"); |
fprintf(stderr, " -bquant_ratio integer: bframe quantizer ratio (default=150)\n"); |
573 |
fprintf(stderr, " -bquant_offset integer: bframe quantizer offset (default=100)\n"); |
fprintf(stderr, " -bquant_offset integer: bframe quantizer offset (default=100)\n"); |
574 |
fprintf(stderr, " -framerate float : target framerate (>0)\n"); |
fprintf(stderr, " -framerate float : target framerate (>0)\n"); |
575 |
|
fprintf(stderr, " -pass1 filename : stats filename\n"); |
576 |
|
fprintf(stderr, " -pass2 filename1 filename2 : stats amd scaled-stats filename\n"); |
577 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
578 |
fprintf(stderr, "Other options\n"); |
fprintf(stderr, "Other options\n"); |
579 |
fprintf(stderr, " -asm : use assembly optmized code\n"); |
fprintf(stderr, " -asm : use assembly optmized code\n"); |
710 |
|
|
711 |
#define FRAMERATE_INCR 1001 |
#define FRAMERATE_INCR 1001 |
712 |
|
|
713 |
|
|
714 |
/* Initialize encoder for first use, pass all needed parameters to the codec */ |
/* Initialize encoder for first use, pass all needed parameters to the codec */ |
715 |
static int |
static int |
716 |
enc_init(int use_assembler) |
enc_init(int use_assembler) |
717 |
{ |
{ |
718 |
int xerr; |
int xerr; |
719 |
|
xvid_plugin_cbr_t cbr; |
720 |
xvid_enc_plugin_t plugins[2]; |
xvid_plugin_2pass1_t rc2pass1; |
721 |
|
xvid_plugin_2pass2_t rc2pass2; |
722 |
|
xvid_enc_plugin_t plugins[6]; |
723 |
xvid_gbl_init_t xvid_gbl_init; |
xvid_gbl_init_t xvid_gbl_init; |
724 |
xvid_enc_create_t xvid_enc_create; |
xvid_enc_create_t xvid_enc_create; |
725 |
|
|
764 |
xvid_enc_create.plugins = plugins; |
xvid_enc_create.plugins = plugins; |
765 |
xvid_enc_create.num_plugins = 0; |
xvid_enc_create.num_plugins = 0; |
766 |
|
|
767 |
|
if (ARG_BITRATE) { |
768 |
|
cbr.version = XVID_VERSION; |
769 |
|
memset(&cbr, 0, sizeof(xvid_plugin_cbr_t)); |
770 |
|
cbr.bitrate = ARG_BITRATE; |
771 |
|
|
772 |
|
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_cbr; |
773 |
|
plugins[xvid_enc_create.num_plugins].param = &cbr; |
774 |
|
xvid_enc_create.num_plugins++; |
775 |
|
} |
776 |
|
|
777 |
|
if (ARG_PASS1 && ARG_PASS2) { |
778 |
|
rc2pass2.version = XVID_VERSION; |
779 |
|
memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t)); |
780 |
|
rc2pass2.filename1 = ARG_PASS1; |
781 |
|
rc2pass2.filename2 = ARG_PASS2; |
782 |
|
|
783 |
|
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2; |
784 |
|
plugins[xvid_enc_create.num_plugins].param = &rc2pass2; |
785 |
|
xvid_enc_create.num_plugins++; |
786 |
|
} else if (ARG_PASS1) { |
787 |
|
rc2pass1.version = XVID_VERSION; |
788 |
|
memset(&rc2pass1, 0, sizeof(xvid_plugin_2pass1_t)); |
789 |
|
rc2pass1.filename = ARG_PASS1; |
790 |
|
|
791 |
|
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass1; |
792 |
|
plugins[xvid_enc_create.num_plugins].param = &rc2pass1; |
793 |
|
xvid_enc_create.num_plugins++; |
794 |
|
} |
795 |
|
|
796 |
|
|
797 |
if (ARG_LUMIMASKING) { |
if (ARG_LUMIMASKING) { |
798 |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; |
799 |
plugins[xvid_enc_create.num_plugins].param = NULL; |
plugins[xvid_enc_create.num_plugins].param = NULL; |