--- trunk/xvidcore/examples/xvid_encraw.c 2006/07/08 14:19:04 1712 +++ trunk/xvidcore/examples/xvid_encraw.c 2006/10/30 11:21:42 1743 @@ -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.26 2006-07-08 14:19:04 Skal Exp $ + * $Id: xvid_encraw.c,v 1.32 2006-10-30 11:21:42 Skal Exp $ * ****************************************************************************/ @@ -165,6 +165,8 @@ static frame_stats_t framestats[7]; static int ARG_STATS = 0; +static int ARG_SSIM = -1; +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; @@ -578,6 +580,15 @@ ARG_INPUTFILE = argv[i]; } else if (strcmp("-stats", argv[i]) == 0) { ARG_STATS = 1; + } else if (strcmp("-ssim", argv[i]) == 0) { + ARG_SSIM = 2; + if ((i < argc - 1) && (*argv[i+1] != '-')) { + i++; + ARG_SSIM = atoi(argv[i]); + } + } 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]; @@ -1190,6 +1201,7 @@ framestats[5].size += stats_length; } +#define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))) if (ARG_PROGRESS == 0) { printf("%5d: key=%i, time= %6.0f, len= %7d", !result ? input_num : -1, @@ -1197,17 +1209,11 @@ 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))))) if (ARG_STATS) { printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f", - SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, - YDIM / 2), + SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, YDIM / 2), SSE2PSNR(sse[2], XDIM / 2, YDIM / 2)); - - totalPSNR[0] += SSE2PSNR(sse[0], XDIM, YDIM); - totalPSNR[1] += SSE2PSNR(sse[1], XDIM/2, YDIM/2); - totalPSNR[2] += SSE2PSNR(sse[2], XDIM/2, YDIM/2); } printf("\n"); } else { @@ -1224,8 +1230,13 @@ } } - } + if (ARG_STATS) { + totalPSNR[0] += SSE2PSNR(sse[0], XDIM, YDIM); + totalPSNR[1] += SSE2PSNR(sse[1], XDIM/2, YDIM/2); + totalPSNR[2] += SSE2PSNR(sse[2], XDIM/2, YDIM/2); + } #undef SSE2PSNR + } if (m4v_size < 0) break; @@ -1561,6 +1572,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 [integer] : prints ssim for every frame (accurate: 0 fast: 4) (2)\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"); @@ -1763,8 +1776,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; @@ -1893,6 +1907,16 @@ xvid_enc_create.num_plugins++; } + if (ARG_SSIM>=0 || ARG_SSIM_PATH != NULL) { + plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim; + ssim.b_printstat = 1; + ssim.stat_path = ARG_SSIM_PATH; + ssim.b_visualize = 0; + ssim.acc = ARG_SSIM; + 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;