--- trunk/xvidcore/examples/xvid_encraw.c 2006/06/16 10:08:28 1710 +++ trunk/xvidcore/examples/xvid_encraw.c 2006/10/13 15:16:25 1737 @@ -21,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.25 2006-06-16 10:08:28 syskin Exp $ + * $Id: xvid_encraw.c,v 1.30 2006-10-13 15:16:25 Skal Exp $ * ****************************************************************************/ @@ -39,7 +39,7 @@ ************************************************************************/ #include -#include +//#include #include #include #include @@ -165,6 +165,8 @@ static frame_stats_t framestats[7]; static int ARG_STATS = 0; +static int ARG_SSIM = 0; +static char* ARG_SSIM_PATH = NULL; static int ARG_DUMP = 0; static int ARG_LUMIMASKING = 0; static int ARG_BITRATE = 0; @@ -174,7 +176,7 @@ static char *ARG_PASS2 = 0; //static int ARG_QUALITY = ME_ELEMENTS - 1; static int ARG_QUALITY = 6; -static float ARG_FRAMERATE = 0.00f; +static float ARG_FRAMERATE = 25.00f; static int ARG_DWRATE = 25; static int ARG_DWSCALE = 1; static int ARG_MAXFRAMENR = ABS_MAXFRAMENR; @@ -196,6 +198,8 @@ static PAVIFILE avi_file = NULL; static LPBITMAPINFOHEADER info_header = NULL; static PGETFRAME get_frame = NULL; +#else +#define get_frame NULL #endif static char *ARG_TIMECODEFILE = NULL; static int XDIM = 0; @@ -576,6 +580,11 @@ ARG_INPUTFILE = argv[i]; } else if (strcmp("-stats", argv[i]) == 0) { ARG_STATS = 1; + } else if (strcmp("-ssim", argv[i]) == 0) { + ARG_SSIM = 1; + } else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) { + i++; + ARG_SSIM_PATH = argv[i]; } else if (strcmp("-timecode", argv[i]) == 0 && i < argc -1) { i++; ARG_TIMECODEFILE = argv[i]; @@ -648,7 +657,7 @@ i++; ARG_AVIOUTPUTFILE = argv[i]; #else - fprintf("Not compiled with AVI output support.\n"); + fprintf( stderr, "Not compiled with AVI output support.\n"); return(-1); #endif } else if (strcmp("-mkv", argv[i]) == 0 && i < argc - 1) { @@ -965,11 +974,12 @@ } /* Jump to the starting frame */ - if (ARG_INPUTTYPE < 2) + if (ARG_INPUTTYPE == 0) fseek(in_file, ARG_STARTFRAMENR*IMAGE_SIZE(XDIM, YDIM), SEEK_SET); /* now we know the sizes, so allocate memory */ - if (get_frame == NULL) { + if (get_frame == NULL) + { in_buffer = (unsigned char *) malloc(4*XDIM*YDIM); if (!in_buffer) goto free_all_memory; @@ -1124,7 +1134,7 @@ } } else #endif - if (ARG_INPUTTYPE==1) { + if (ARG_INPUTTYPE==1) { /* read PGM data (YUV-format) */ #ifndef READ_PNM result = read_pgmdata(in_file, in_buffer); @@ -1558,6 +1568,8 @@ fprintf(stderr, " -noclosed_gop : Disable closed GOP mode\n"); fprintf(stderr, " -lumimasking : use lumimasking algorithm\n"); fprintf(stderr, " -stats : print stats about encoded frames\n"); + fprintf(stderr, " -ssim : prints the ssim stats for every encoded frame (slow!)\n"); + fprintf(stderr, " -ssim_file filename : outputs the ssim stats into a file\n"); fprintf(stderr, " -debug : activates xvidcore internal debugging output\n"); fprintf(stderr, " -vop_debug : print some info directly into encoded frames\n"); fprintf(stderr, " -nochromame : Disable chroma motion estimation\n"); @@ -1760,8 +1772,9 @@ xvid_plugin_single_t single; xvid_plugin_2pass1_t rc2pass1; xvid_plugin_2pass2_t rc2pass2; + xvid_plugin_ssim_t ssim; //xvid_plugin_fixed_t rcfixed; - xvid_enc_plugin_t plugins[7]; + xvid_enc_plugin_t plugins[8]; xvid_gbl_init_t xvid_gbl_init; xvid_enc_create_t xvid_enc_create; int i; @@ -1890,6 +1903,15 @@ xvid_enc_create.num_plugins++; } + if (ARG_SSIM || ARG_SSIM_PATH != NULL) { + plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim; + ssim.b_printstat = ARG_SSIM; + ssim.stat_path = ARG_SSIM_PATH; + ssim.b_visualize = 0; + plugins[xvid_enc_create.num_plugins].param = &ssim; + xvid_enc_create.num_plugins++; + } + #if 0 if (ARG_DEBUG) { plugins[xvid_enc_create.num_plugins].func = rawenc_debug;