21 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: xvid_encraw.c,v 1.30 2006-10-13 15:16:25 Skal Exp $ |
* $Id: xvid_encraw.c,v 1.33 2006-11-08 06:55:27 Skal Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
165 |
static frame_stats_t framestats[7]; |
static frame_stats_t framestats[7]; |
166 |
|
|
167 |
static int ARG_STATS = 0; |
static int ARG_STATS = 0; |
168 |
static int ARG_SSIM = 0; |
static int ARG_SSIM = -1; |
169 |
static char* ARG_SSIM_PATH = NULL; |
static char* ARG_SSIM_PATH = NULL; |
170 |
static int ARG_DUMP = 0; |
static int ARG_DUMP = 0; |
171 |
static int ARG_LUMIMASKING = 0; |
static int ARG_LUMIMASKING = 0; |
581 |
} else if (strcmp("-stats", argv[i]) == 0) { |
} else if (strcmp("-stats", argv[i]) == 0) { |
582 |
ARG_STATS = 1; |
ARG_STATS = 1; |
583 |
} else if (strcmp("-ssim", argv[i]) == 0) { |
} else if (strcmp("-ssim", argv[i]) == 0) { |
584 |
ARG_SSIM = 1; |
ARG_SSIM = 2; |
585 |
|
if ((i < argc - 1) && (*argv[i+1] != '-')) { |
586 |
|
i++; |
587 |
|
ARG_SSIM = atoi(argv[i]); |
588 |
|
} |
589 |
} else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) { |
} else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) { |
590 |
i++; |
i++; |
591 |
ARG_SSIM_PATH = argv[i]; |
ARG_SSIM_PATH = argv[i]; |
1201 |
framestats[5].size += stats_length; |
framestats[5].size += stats_length; |
1202 |
} |
} |
1203 |
|
|
1204 |
|
#define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))) |
1205 |
|
|
1206 |
if (ARG_PROGRESS == 0) { |
if (ARG_PROGRESS == 0) { |
1207 |
printf("%5d: key=%i, time= %6.0f, len= %7d", !result ? input_num : -1, |
printf("%5d: key=%i, time= %6.0f, len= %7d", !result ? input_num : -1, |
1209 |
printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant, |
printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant, |
1210 |
stats_length); |
stats_length); |
1211 |
|
|
|
#define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))) |
|
1212 |
|
|
1213 |
if (ARG_STATS) { |
if (ARG_STATS) { |
1214 |
printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f", |
printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f", |
1215 |
SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, |
SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, YDIM / 2), |
|
YDIM / 2), |
|
1216 |
SSE2PSNR(sse[2], 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); |
|
1217 |
} |
} |
1218 |
printf("\n"); |
printf("\n"); |
1219 |
} else { |
} else { |
1230 |
} |
} |
1231 |
} |
} |
1232 |
|
|
1233 |
|
if (ARG_STATS) { |
1234 |
|
totalPSNR[0] += SSE2PSNR(sse[0], XDIM, YDIM); |
1235 |
|
totalPSNR[1] += SSE2PSNR(sse[1], XDIM/2, YDIM/2); |
1236 |
|
totalPSNR[2] += SSE2PSNR(sse[2], XDIM/2, YDIM/2); |
1237 |
} |
} |
1238 |
#undef SSE2PSNR |
#undef SSE2PSNR |
1239 |
|
} |
1240 |
|
|
1241 |
if (m4v_size < 0) |
if (m4v_size < 0) |
1242 |
break; |
break; |
1572 |
fprintf(stderr, " -noclosed_gop : Disable closed GOP mode\n"); |
fprintf(stderr, " -noclosed_gop : Disable closed GOP mode\n"); |
1573 |
fprintf(stderr, " -lumimasking : use lumimasking algorithm\n"); |
fprintf(stderr, " -lumimasking : use lumimasking algorithm\n"); |
1574 |
fprintf(stderr, " -stats : print stats about encoded frames\n"); |
fprintf(stderr, " -stats : print stats about encoded frames\n"); |
1575 |
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"); |
1576 |
fprintf(stderr, " -ssim_file filename : outputs the ssim stats into a file\n"); |
fprintf(stderr, " -ssim_file filename : outputs the ssim stats into a file\n"); |
1577 |
fprintf(stderr, " -debug : activates xvidcore internal debugging output\n"); |
fprintf(stderr, " -debug : activates xvidcore internal debugging output\n"); |
1578 |
fprintf(stderr, " -vop_debug : print some info directly into encoded frames\n"); |
fprintf(stderr, " -vop_debug : print some info directly into encoded frames\n"); |
1907 |
xvid_enc_create.num_plugins++; |
xvid_enc_create.num_plugins++; |
1908 |
} |
} |
1909 |
|
|
1910 |
if (ARG_SSIM || ARG_SSIM_PATH != NULL) { |
if (ARG_SSIM>=0 || ARG_SSIM_PATH != NULL) { |
1911 |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim; |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim; |
1912 |
ssim.b_printstat = ARG_SSIM; |
ssim.b_printstat = 1; |
1913 |
ssim.stat_path = ARG_SSIM_PATH; |
ssim.stat_path = ARG_SSIM_PATH; |
1914 |
ssim.b_visualize = 0; |
ssim.b_visualize = 0; |
1915 |
|
ssim.acc = (ARG_SSIM_PATH != NULL && ARG_SSIM < 0) ? 2 : ARG_SSIM; |
1916 |
plugins[xvid_enc_create.num_plugins].param = &ssim; |
plugins[xvid_enc_create.num_plugins].param = &ssim; |
1917 |
xvid_enc_create.num_plugins++; |
xvid_enc_create.num_plugins++; |
1918 |
} |
} |