--- branches/dev-api-4/xvidcore/examples/xvid_encraw.c 2003/04/08 14:01:35 977 +++ branches/dev-api-4/xvidcore/examples/xvid_encraw.c 2003/04/19 11:26:47 991 @@ -19,7 +19,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.15 2003-04-08 14:01:35 suxen_drol Exp $ + * $Id: xvid_encraw.c,v 1.11.2.18 2003-04-19 11:26:47 chl Exp $ * ****************************************************************************/ @@ -174,6 +174,7 @@ double enctime; double totalenctime = 0.; + float totalPSNR[3] = {0., 0., 0.}; int totalsize; int result; @@ -394,7 +395,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, length= %7d", !result ? input_num : -1, key, (float) enctime, (int) m4v_size); if (stats_type > 0) { /* !XVID_TYPE_NOTHING */ @@ -417,7 +418,7 @@ break; } - printf(" | type=%s, quant=%2d, length=%7d", type, stats_quant, + printf(" | type=%s, quant= %2d, length= %7d", type, stats_quant, stats_length); #define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))) @@ -427,6 +428,10 @@ 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); } } @@ -483,13 +488,21 @@ if (input_num > 0) { totalsize /= input_num; totalenctime /= input_num; + totalPSNR[0] /= input_num; + totalPSNR[1] /= input_num; + totalPSNR[2] /= input_num; } else { totalsize = -1; totalenctime = -1; } - printf("Avg: enctime(ms) =%7.2f, fps =%7.2f, length(bytes) = %7d\n", + printf("Avg: enctime(ms) =%7.2f, fps =%7.2f, length(bytes) = %7d, ", totalenctime, 1000 / totalenctime, (int) totalsize); + if (ARG_STATS) { + printf("psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f", + totalPSNR[0],totalPSNR[1],totalPSNR[2]); + } + printf("\n"); /***************************************************************************** @@ -768,8 +781,8 @@ xvid_enc_create.num_plugins = 0; if (ARG_BITRATE) { - cbr.version = XVID_VERSION; memset(&cbr, 0, sizeof(xvid_plugin_cbr_t)); + cbr.version = XVID_VERSION; cbr.bitrate = ARG_BITRATE; plugins[xvid_enc_create.num_plugins].func = xvid_plugin_cbr; @@ -778,6 +791,7 @@ } if (ARG_QUANTI) { + memset(&rcfixed, 0, sizeof(xvid_plugin_fixed_t)); rcfixed.version = XVID_VERSION; /* We will use a 1/10 precision, just to make sure it works */ rcfixed.quant_base = 10; @@ -789,8 +803,8 @@ } if (ARG_PASS2) { - rc2pass2.version = XVID_VERSION; memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t)); + rc2pass2.version = XVID_VERSION; rc2pass2.filename = ARG_PASS2; rc2pass2.bitrate = ARG_PASS2_BITRATE; @@ -800,8 +814,8 @@ } if (ARG_PASS1) { - rc2pass1.version = XVID_VERSION; memset(&rc2pass1, 0, sizeof(xvid_plugin_2pass1_t)); + rc2pass1.version = XVID_VERSION; rc2pass1.filename = ARG_PASS1; plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass1;