--- branches/dev-api-4/xvidcore/examples/xvid_encraw.c 2003/05/15 17:53:11 1027 +++ branches/dev-api-4/xvidcore/examples/xvid_encraw.c 2003/06/09 13:55:56 1054 @@ -3,7 +3,9 @@ * XVID MPEG-4 VIDEO CODEC * - Console based test application - * - * Copyright(C) 2002-2003 Christoph Lampert + * Copyright(C) 2002-2003 Christoph Lampert + * 2002-2003 Edouard Gomez + * 2003 Peter Ross * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +21,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.24 2003-05-15 17:53:11 edgomez Exp $ + * $Id: xvid_encraw.c,v 1.11.2.27 2003-06-09 13:49:25 edgomez Exp $ * ****************************************************************************/ @@ -31,6 +33,8 @@ * * The program is plain C and needs no libraries except for libxvidcore, * and maths-lib. + * + * Use ./xvid_encraw -help for a list of options * ************************************************************************/ @@ -131,6 +135,7 @@ static int ARG_QUALITY = ME_ELEMENTS - 1; static float ARG_FRAMERATE = 25.00f; static int ARG_MAXFRAMENR = ABS_MAXFRAMENR; +static int ARG_MAXKEYINTERVAL = 0; static char *ARG_INPUTFILE = NULL; static int ARG_INPUTTYPE = 0; static int ARG_SAVEMPEGSTREAM = 0; @@ -142,6 +147,7 @@ static int ARG_MAXBFRAMES = 0; static int ARG_PACKED = 0; static int ARG_DEBUG = 0; +static int ARG_VOPDEBUG = 0; #define IMAGE_SIZE(x,y) ((x)*(y)*3/2) @@ -291,6 +297,9 @@ } else if (strcmp("-framerate", argv[i]) == 0 && i < argc - 1) { i++; ARG_FRAMERATE = (float) atof(argv[i]); + } else if (strcmp("-max_key_interval", argv[i]) == 0 && i < argc - 1) { + i++; + ARG_MAXKEYINTERVAL = atoi(argv[i]); } else if (strcmp("-i", argv[i]) == 0 && i < argc - 1) { i++; ARG_INPUTFILE = argv[i]; @@ -309,10 +318,13 @@ } else if (strcmp("-save", argv[i]) == 0) { ARG_SAVEMPEGSTREAM = 1; } else if (strcmp("-debug", argv[i]) == 0) { - ARG_DEBUG = 1; + i++; + if (sscanf(argv[i],"0x%x", &ARG_DEBUG) || sscanf(argv[i],"%d", &ARG_DEBUG)) ; } else if (strcmp("-o", argv[i]) == 0 && i < argc - 1) { i++; ARG_OUTPUTFILE = argv[i]; + } else if (strcmp("-vop_debug", argv[i]) == 0) { + ARG_VOPDEBUG = 1; } else if (strcmp("-help", argv[i])) { usage(); return (0); @@ -446,7 +458,7 @@ /* Write the Frame statistics */ - printf("%5d: key=%i, time= %6.0f, length= %7d", !result ? input_num : -1, + printf("%5d: key=%i, time= %6.0f, len= %7d", !result ? input_num : -1, key, (float) enctime, (int) m4v_size); if (stats_type > 0) { /* !XVID_TYPE_NOTHING */ @@ -469,7 +481,7 @@ break; } - printf(" | type=%s, quant= %2d, length= %7d", type, stats_quant, + printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant, stats_length); #define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))) @@ -642,14 +654,16 @@ fprintf(stderr, " -pass2 filename : twopass mode (2nd pass)\n"); fprintf(stderr, " -zq starting_frame float : bitrate zone; quant\n"); fprintf(stderr, " -zw starting_frame float : bitrate zone; weight\n"); - fprintf(stderr, "\n"); + fprintf(stderr, " -max_key_interval integer : maximum keyframe interval\n"); + fprintf(stderr, "\n"); fprintf(stderr, "Other options\n"); fprintf(stderr, " -asm : use assembly optmized code\n"); fprintf(stderr, " -quality integer: quality ([0..%d])\n", ME_ELEMENTS - 1); fprintf(stderr, " -packed : packed mode\n"); fprintf(stderr, " -lumimasking : use lumimasking algorithm\n"); fprintf(stderr, " -stats : print stats about encoded frames\n"); - fprintf(stderr, " -debug : print all MB dquants\n"); + fprintf(stderr, " -debug : activates xvidcore internal debugging output\n"); + fprintf(stderr, " -vop_debug : print some info directly into encoded frames\n"); fprintf(stderr, " -help : prints this help message\n"); fprintf(stderr, "\n"); fprintf(stderr, "NB: You can define %d zones repeating the -z[qw] option as many times as needed.\n", MAX_ZONES); @@ -803,6 +817,7 @@ /* Set version -- version checking will done by xvidcore */ memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init)); xvid_gbl_init.version = XVID_VERSION; + xvid_gbl_init.debug = ARG_DEBUG; /* Do we have to enable ASM optimizations ? */ @@ -882,11 +897,13 @@ xvid_enc_create.num_plugins++; } +#if 0 if (ARG_DEBUG) { plugins[xvid_enc_create.num_plugins].func = rawenc_debug; plugins[xvid_enc_create.num_plugins].param = NULL; xvid_enc_create.num_plugins++; } +#endif /* No fancy thread tests */ xvid_enc_create.num_threads = 0; @@ -901,7 +918,11 @@ } /* Maximum key frame interval */ - xvid_enc_create.max_key_interval = (int) ARG_FRAMERATE *10; + if (ARG_MAXKEYINTERVAL > 0) { + xvid_enc_create.max_key_interval = ARG_MAXKEYINTERVAL; + }else { + xvid_enc_create.max_key_interval = (int) ARG_FRAMERATE *10; + } /* Bframes settings */ xvid_enc_create.max_bframes = ARG_MAXBFRAMES; @@ -981,6 +1002,9 @@ /* Set up core's general features */ xvid_enc_frame.vop_flags = vop_presets[ARG_QUALITY]; + if (ARG_VOPDEBUG) { + xvid_enc_frame.vop_flags |= XVID_VOP_DEBUG; + } /* Frame type -- let core decide for us */ xvid_enc_frame.type = XVID_TYPE_AUTO;