--- trunk/xvidcore/examples/xvid_encraw.c 2006/10/13 15:16:25 1737 +++ 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.30 2006-10-13 15:16:25 Skal Exp $ + * $Id: xvid_encraw.c,v 1.32 2006-10-30 11:21:42 Skal Exp $ * ****************************************************************************/ @@ -165,7 +165,7 @@ static frame_stats_t framestats[7]; static int ARG_STATS = 0; -static int ARG_SSIM = 0; +static int ARG_SSIM = -1; static char* ARG_SSIM_PATH = NULL; static int ARG_DUMP = 0; static int ARG_LUMIMASKING = 0; @@ -581,7 +581,11 @@ } else if (strcmp("-stats", argv[i]) == 0) { ARG_STATS = 1; } else if (strcmp("-ssim", argv[i]) == 0) { - ARG_SSIM = 1; + 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]; @@ -1197,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, @@ -1204,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 { @@ -1231,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; @@ -1568,7 +1572,7 @@ 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 [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"); @@ -1903,11 +1907,12 @@ xvid_enc_create.num_plugins++; } - if (ARG_SSIM || ARG_SSIM_PATH != NULL) { + if (ARG_SSIM>=0 || ARG_SSIM_PATH != NULL) { plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim; - ssim.b_printstat = ARG_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++; }