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 = -1; |
169 |
|
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; |
172 |
static int ARG_BITRATE = 0; |
static int ARG_BITRATE = 0; |
176 |
static char *ARG_PASS2 = 0; |
static char *ARG_PASS2 = 0; |
177 |
//static int ARG_QUALITY = ME_ELEMENTS - 1; |
//static int ARG_QUALITY = ME_ELEMENTS - 1; |
178 |
static int ARG_QUALITY = 6; |
static int ARG_QUALITY = 6; |
179 |
static float ARG_FRAMERATE = 0.00f; |
static float ARG_FRAMERATE = 25.00f; |
180 |
static int ARG_DWRATE = 25; |
static int ARG_DWRATE = 25; |
181 |
static int ARG_DWSCALE = 1; |
static int ARG_DWSCALE = 1; |
182 |
static int ARG_MAXFRAMENR = ABS_MAXFRAMENR; |
static int ARG_MAXFRAMENR = ABS_MAXFRAMENR; |
391 |
} else if (strcmp("-h", argv[i]) == 0 && i < argc - 1) { |
} else if (strcmp("-h", argv[i]) == 0 && i < argc - 1) { |
392 |
i++; |
i++; |
393 |
YDIM = atoi(argv[i]); |
YDIM = atoi(argv[i]); |
394 |
|
} else if (strcmp("-csp",argv[i]) == 0 && i < argc - 1) { |
395 |
|
i++; |
396 |
|
if (strcmp(argv[i],"i420") == 0){ |
397 |
|
ARG_COLORSPACE = XVID_CSP_I420; |
398 |
|
} else if(strcmp(argv[i],"yv12") == 0){ |
399 |
|
ARG_COLORSPACE = XVID_CSP_YV12; |
400 |
|
} else { |
401 |
|
printf("Invalid colorspace\n"); |
402 |
|
return 0; |
403 |
|
} |
404 |
} else if (strcmp("-bitrate", argv[i]) == 0) { |
} else if (strcmp("-bitrate", argv[i]) == 0) { |
405 |
if (i < argc - 1) |
if (i < argc - 1) |
406 |
ARG_BITRATE = atoi(argv[i+1]); |
ARG_BITRATE = atoi(argv[i+1]); |
590 |
ARG_INPUTFILE = argv[i]; |
ARG_INPUTFILE = argv[i]; |
591 |
} else if (strcmp("-stats", argv[i]) == 0) { |
} else if (strcmp("-stats", argv[i]) == 0) { |
592 |
ARG_STATS = 1; |
ARG_STATS = 1; |
593 |
|
} else if (strcmp("-ssim", argv[i]) == 0) { |
594 |
|
ARG_SSIM = 2; |
595 |
|
if ((i < argc - 1) && (*argv[i+1] != '-')) { |
596 |
|
i++; |
597 |
|
ARG_SSIM = atoi(argv[i]); |
598 |
|
} |
599 |
|
} else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) { |
600 |
|
i++; |
601 |
|
ARG_SSIM_PATH = argv[i]; |
602 |
} else if (strcmp("-timecode", argv[i]) == 0 && i < argc -1) { |
} else if (strcmp("-timecode", argv[i]) == 0 && i < argc -1) { |
603 |
i++; |
i++; |
604 |
ARG_TIMECODEFILE = argv[i]; |
ARG_TIMECODEFILE = argv[i]; |
605 |
} else if (strcmp("-dump", argv[i]) == 0) { |
} else if (strcmp("-dump", argv[i]) == 0) { |
606 |
ARG_DUMP = 1; |
ARG_DUMP = 1; |
607 |
} else if (strcmp("-lumimasking", argv[i]) == 0) { |
} else if (strcmp("-masking", argv[i]) == 0 && i < argc -1) { |
608 |
ARG_LUMIMASKING = 1; |
i++; |
609 |
|
ARG_LUMIMASKING = atoi(argv[i]); |
610 |
} else if (strcmp("-type", argv[i]) == 0 && i < argc - 1) { |
} else if (strcmp("-type", argv[i]) == 0 && i < argc - 1) { |
611 |
i++; |
i++; |
612 |
ARG_INPUTTYPE = atoi(argv[i]); |
ARG_INPUTTYPE = atoi(argv[i]); |
1212 |
framestats[5].size += stats_length; |
framestats[5].size += stats_length; |
1213 |
} |
} |
1214 |
|
|
1215 |
|
#define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))) |
1216 |
|
|
1217 |
if (ARG_PROGRESS == 0) { |
if (ARG_PROGRESS == 0) { |
1218 |
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, |
1220 |
printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant, |
printf(" | type=%s, quant= %2d, len= %7d", type, stats_quant, |
1221 |
stats_length); |
stats_length); |
1222 |
|
|
|
#define SSE2PSNR(sse, width, height) ((!(sse))?0.0f : 48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))) |
|
1223 |
|
|
1224 |
if (ARG_STATS) { |
if (ARG_STATS) { |
1225 |
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", |
1226 |
SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, |
SSE2PSNR(sse[0], XDIM, YDIM), SSE2PSNR(sse[1], XDIM / 2, YDIM / 2), |
|
YDIM / 2), |
|
1227 |
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); |
|
1228 |
} |
} |
1229 |
printf("\n"); |
printf("\n"); |
1230 |
} else { |
} else { |
1241 |
} |
} |
1242 |
} |
} |
1243 |
|
|
1244 |
|
if (ARG_STATS) { |
1245 |
|
totalPSNR[0] += SSE2PSNR(sse[0], XDIM, YDIM); |
1246 |
|
totalPSNR[1] += SSE2PSNR(sse[1], XDIM/2, YDIM/2); |
1247 |
|
totalPSNR[2] += SSE2PSNR(sse[2], XDIM/2, YDIM/2); |
1248 |
} |
} |
1249 |
#undef SSE2PSNR |
#undef SSE2PSNR |
1250 |
|
} |
1251 |
|
|
1252 |
if (m4v_size < 0) |
if (m4v_size < 0) |
1253 |
break; |
break; |
1520 |
#endif |
#endif |
1521 |
fprintf(stderr, " -w integer: frame width ([1.2048])\n"); |
fprintf(stderr, " -w integer: frame width ([1.2048])\n"); |
1522 |
fprintf(stderr, " -h integer: frame height ([1.2048])\n"); |
fprintf(stderr, " -h integer: frame height ([1.2048])\n"); |
1523 |
|
fprintf(stderr, " -csp string : colorspace of raw input file i420, yv12 (default)\n"); |
1524 |
fprintf(stderr, " -frames integer: number of frames to encode\n"); |
fprintf(stderr, " -frames integer: number of frames to encode\n"); |
1525 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
1526 |
fprintf(stderr, "Output options:\n"); |
fprintf(stderr, "Output options:\n"); |
1582 |
fprintf(stderr, " -interlaced [integer] : interlaced encoding (BFF:1, TFF:2) (1)\n"); |
fprintf(stderr, " -interlaced [integer] : interlaced encoding (BFF:1, TFF:2) (1)\n"); |
1583 |
fprintf(stderr, " -nopacked : Disable packed mode\n"); |
fprintf(stderr, " -nopacked : Disable packed mode\n"); |
1584 |
fprintf(stderr, " -noclosed_gop : Disable closed GOP mode\n"); |
fprintf(stderr, " -noclosed_gop : Disable closed GOP mode\n"); |
1585 |
fprintf(stderr, " -lumimasking : use lumimasking algorithm\n"); |
fprintf(stderr, " -masking [integer] : HVS masking mode (None:0, Lumi:1, Variance:2) (0)\n"); |
1586 |
fprintf(stderr, " -stats : print stats about encoded frames\n"); |
fprintf(stderr, " -stats : print stats about encoded frames\n"); |
1587 |
|
fprintf(stderr, " -ssim [integer] : prints ssim for every frame (accurate: 0 fast: 4) (2)\n"); |
1588 |
|
fprintf(stderr, " -ssim_file filename : outputs the ssim stats into a file\n"); |
1589 |
fprintf(stderr, " -debug : activates xvidcore internal debugging output\n"); |
fprintf(stderr, " -debug : activates xvidcore internal debugging output\n"); |
1590 |
fprintf(stderr, " -vop_debug : print some info directly into encoded frames\n"); |
fprintf(stderr, " -vop_debug : print some info directly into encoded frames\n"); |
1591 |
fprintf(stderr, " -nochromame : Disable chroma motion estimation\n"); |
fprintf(stderr, " -nochromame : Disable chroma motion estimation\n"); |
1788 |
xvid_plugin_single_t single; |
xvid_plugin_single_t single; |
1789 |
xvid_plugin_2pass1_t rc2pass1; |
xvid_plugin_2pass1_t rc2pass1; |
1790 |
xvid_plugin_2pass2_t rc2pass2; |
xvid_plugin_2pass2_t rc2pass2; |
1791 |
|
xvid_plugin_ssim_t ssim; |
1792 |
|
xvid_plugin_lumimasking_t masking; |
1793 |
//xvid_plugin_fixed_t rcfixed; |
//xvid_plugin_fixed_t rcfixed; |
1794 |
xvid_enc_plugin_t plugins[7]; |
xvid_enc_plugin_t plugins[8]; |
1795 |
xvid_gbl_init_t xvid_gbl_init; |
xvid_gbl_init_t xvid_gbl_init; |
1796 |
xvid_enc_create_t xvid_enc_create; |
xvid_enc_create_t xvid_enc_create; |
1797 |
int i; |
int i; |
1909 |
|
|
1910 |
|
|
1911 |
if (ARG_LUMIMASKING) { |
if (ARG_LUMIMASKING) { |
1912 |
|
memset(&masking, 0, sizeof(xvid_plugin_lumimasking_t)); |
1913 |
|
masking.method = (ARG_LUMIMASKING==2); |
1914 |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; |
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; |
1915 |
plugins[xvid_enc_create.num_plugins].param = NULL; |
plugins[xvid_enc_create.num_plugins].param = &masking; |
1916 |
xvid_enc_create.num_plugins++; |
xvid_enc_create.num_plugins++; |
1917 |
} |
} |
1918 |
|
|
1922 |
xvid_enc_create.num_plugins++; |
xvid_enc_create.num_plugins++; |
1923 |
} |
} |
1924 |
|
|
1925 |
|
if (ARG_SSIM>=0 || ARG_SSIM_PATH != NULL) { |
1926 |
|
memset(&ssim, 0, sizeof(xvid_plugin_ssim_t)); |
1927 |
|
|
1928 |
|
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim; |
1929 |
|
|
1930 |
|
if( ARG_SSIM >=0){ |
1931 |
|
ssim.b_printstat = 1; |
1932 |
|
ssim.acc = ARG_SSIM; |
1933 |
|
} else { |
1934 |
|
ssim.b_printstat = 0; |
1935 |
|
ssim.acc = 2; |
1936 |
|
} |
1937 |
|
|
1938 |
|
if(ARG_SSIM_PATH != NULL){ |
1939 |
|
ssim.stat_path = ARG_SSIM_PATH; |
1940 |
|
} |
1941 |
|
|
1942 |
|
ssim.cpu_flags = xvid_gbl_init.cpu_flags; |
1943 |
|
ssim.b_visualize = 0; |
1944 |
|
plugins[xvid_enc_create.num_plugins].param = &ssim; |
1945 |
|
xvid_enc_create.num_plugins++; |
1946 |
|
} |
1947 |
|
|
1948 |
#if 0 |
#if 0 |
1949 |
if (ARG_DEBUG) { |
if (ARG_DEBUG) { |
1950 |
plugins[xvid_enc_create.num_plugins].func = rawenc_debug; |
plugins[xvid_enc_create.num_plugins].func = rawenc_debug; |
2028 |
fprintf(stderr, "SSE "); |
fprintf(stderr, "SSE "); |
2029 |
if (xvid_gbl_info.cpu_flags & XVID_CPU_SSE2) |
if (xvid_gbl_info.cpu_flags & XVID_CPU_SSE2) |
2030 |
fprintf(stderr, "SSE2 "); |
fprintf(stderr, "SSE2 "); |
2031 |
|
if (xvid_gbl_info.cpu_flags & XVID_CPU_SSE3) |
2032 |
|
fprintf(stderr, "SSE3 "); |
2033 |
|
if (xvid_gbl_info.cpu_flags & XVID_CPU_SSE41) |
2034 |
|
fprintf(stderr, "SSE41 "); |
2035 |
if (xvid_gbl_info.cpu_flags & XVID_CPU_3DNOW) |
if (xvid_gbl_info.cpu_flags & XVID_CPU_3DNOW) |
2036 |
fprintf(stderr, "3DNOW "); |
fprintf(stderr, "3DNOW "); |
2037 |
if (xvid_gbl_info.cpu_flags & XVID_CPU_3DNOWEXT) |
if (xvid_gbl_info.cpu_flags & XVID_CPU_3DNOWEXT) |
2087 |
if (image) { |
if (image) { |
2088 |
xvid_enc_frame.input.plane[0] = image; |
xvid_enc_frame.input.plane[0] = image; |
2089 |
#ifndef READ_PNM |
#ifndef READ_PNM |
|
if (ARG_INPUTTYPE==2) |
|
2090 |
xvid_enc_frame.input.csp = ARG_COLORSPACE; |
xvid_enc_frame.input.csp = ARG_COLORSPACE; |
|
else |
|
|
xvid_enc_frame.input.csp = XVID_CSP_I420; |
|
2091 |
xvid_enc_frame.input.stride[0] = XDIM; |
xvid_enc_frame.input.stride[0] = XDIM; |
2092 |
#else |
#else |
2093 |
xvid_enc_frame.input.csp = XVID_CSP_BGR; |
xvid_enc_frame.input.csp = XVID_CSP_BGR; |