22 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
* |
* |
25 |
* $Id: xvid_encraw.c,v 1.48 2010-12-30 11:46:17 Isibaar Exp $ |
* $Id$ |
26 |
* |
* |
27 |
****************************************************************************/ |
****************************************************************************/ |
28 |
|
|
200 |
static char *ARG_PASS2 = 0; |
static char *ARG_PASS2 = 0; |
201 |
//static int ARG_QUALITY = ME_ELEMENTS - 1; |
//static int ARG_QUALITY = ME_ELEMENTS - 1; |
202 |
static int ARG_QUALITY = 6; |
static int ARG_QUALITY = 6; |
203 |
static float ARG_FRAMERATE = 25.00f; |
static float ARG_FRAMERATE = 0.f; |
204 |
static int ARG_DWRATE = 25; |
static int ARG_DWRATE = 25; |
205 |
static int ARG_DWSCALE = 1; |
static int ARG_DWSCALE = 1; |
206 |
static int ARG_MAXFRAMENR = ABS_MAXFRAMENR; |
static int ARG_MAXFRAMENR = ABS_MAXFRAMENR; |
353 |
|
|
354 |
/* Is there a dumb Xvid coder ? */ |
/* Is there a dumb Xvid coder ? */ |
355 |
if(ME_ELEMENTS != VOP_ELEMENTS) { |
if(ME_ELEMENTS != VOP_ELEMENTS) { |
356 |
fprintf(stderr, "Presets' arrays should have the same number of elements -- Please fill a bug to xvid-devel@xvid.org\n"); |
fprintf(stderr, "Presets' arrays should have the same number of elements -- Please file a bug to xvid-devel@xvid.org\n"); |
357 |
return(-1); |
return(-1); |
358 |
} |
} |
359 |
|
|
753 |
i++; |
i++; |
754 |
else |
else |
755 |
ARG_PROGRESS = 10; |
ARG_PROGRESS = 10; |
756 |
} else if (strcmp("-help", argv[i])) { |
} else if (strcmp("-help", argv[i]) == 0) { |
757 |
usage(); |
usage(); |
758 |
return (0); |
return (0); |
759 |
} else { |
} else { |
951 |
} |
} |
952 |
|
|
953 |
if (ARG_FRAMERATE <= 0) { |
if (ARG_FRAMERATE <= 0) { |
954 |
fprintf(stderr, "Wrong Framerate %f\n", ARG_FRAMERATE); |
ARG_FRAMERATE = 25.00f; /* default value */ |
|
return (-1); |
|
955 |
} |
} |
956 |
|
|
957 |
if (ARG_TARGETSIZE) { |
if (ARG_TARGETSIZE) { |
1063 |
totalenctime = MAX(totalenctime, enc_data[k].totalenctime); |
totalenctime = MAX(totalenctime, enc_data[k].totalenctime); |
1064 |
|
|
1065 |
for (i=0; i < 3; i++) totalPSNR[i] += enc_data[k].totalPSNR[i]; |
for (i=0; i < 3; i++) totalPSNR[i] += enc_data[k].totalPSNR[i]; |
1066 |
for (i=0; i < 8; i++) { |
for (i=0; i < 7; i++) { |
1067 |
int l; |
int l; |
1068 |
framestats[i].count += enc_data[k].framestats[i].count; |
framestats[i].count += enc_data[k].framestats[i].count; |
1069 |
framestats[i].size += enc_data[k].framestats[i].size; |
framestats[i].size += enc_data[k].framestats[i].size; |
1409 |
myAVIStreamInfo.dwRate = ARG_DWRATE; |
myAVIStreamInfo.dwRate = ARG_DWRATE; |
1410 |
myAVIStreamInfo.dwLength = ARG_MAXFRAMENR; |
myAVIStreamInfo.dwLength = ARG_MAXFRAMENR; |
1411 |
myAVIStreamInfo.dwQuality = 10000; |
myAVIStreamInfo.dwQuality = 10000; |
1412 |
SetRect(&myAVIStreamInfo.rcFrame, 0, 0, YDIM, XDIM); |
SetRect(&myAVIStreamInfo.rcFrame, 0, 0, XDIM, YDIM); |
1413 |
|
|
1414 |
if (avierr=AVIFileOpen(&myAVIFile, ARG_AVIOUTPUTFILE, OF_CREATE|OF_WRITE, NULL)) { |
if (avierr=AVIFileOpen(&myAVIFile, ARG_AVIOUTPUTFILE, OF_CREATE|OF_WRITE, NULL)) { |
1415 |
fprintf(stderr, "AVIFileOpen failed opening output file %s, error code %d\n", ARG_AVIOUTPUTFILE, avierr); |
fprintf(stderr, "AVIFileOpen failed opening output file %s, error code %d\n", ARG_AVIOUTPUTFILE, avierr); |
1830 |
#ifdef XVID_AVI_OUTPUT |
#ifdef XVID_AVI_OUTPUT |
1831 |
fprintf(stderr, " -avi string: save an AVI file for the complete sequence\n"); |
fprintf(stderr, " -avi string: save an AVI file for the complete sequence\n"); |
1832 |
#endif |
#endif |
1833 |
|
#ifdef XVID_MKV_OUTPUT |
1834 |
fprintf(stderr, " -mkv string: save a MKV file for the complete sequence\n"); |
fprintf(stderr, " -mkv string: save a MKV file for the complete sequence\n"); |
1835 |
|
#endif |
1836 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
1837 |
fprintf(stderr, "BFrames options:\n"); |
fprintf(stderr, "BFrames options:\n"); |
1838 |
fprintf(stderr, " -max_bframes integer: max bframes (2)\n"); |
fprintf(stderr, " -max_bframes integer: max bframes (2)\n"); |
1840 |
fprintf(stderr, " -bquant_offset integer: bframe quantizer offset (100)\n"); |
fprintf(stderr, " -bquant_offset integer: bframe quantizer offset (100)\n"); |
1841 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
1842 |
fprintf(stderr, "Rate control options:\n"); |
fprintf(stderr, "Rate control options:\n"); |
1843 |
fprintf(stderr, " -framerate float : target framerate (25.0)\n"); |
fprintf(stderr, " -framerate float : target framerate (auto)\n"); |
1844 |
fprintf(stderr, " -bitrate [integer] : target bitrate in kbps (700)\n"); |
fprintf(stderr, " -bitrate [integer] : target bitrate in kbps (700)\n"); |
1845 |
fprintf(stderr, " -size integer : target size in kilobytes\n"); |
fprintf(stderr, " -size integer : target size in kilobytes\n"); |
1846 |
fprintf(stderr, " -single : single pass mode (default)\n"); |
fprintf(stderr, " -single : single pass mode (default)\n"); |
1938 |
return (1); |
return (1); |
1939 |
|
|
1940 |
fscanf(handle, "%d %d %d", &xsize, &ysize, &depth); |
fscanf(handle, "%d %d %d", &xsize, &ysize, &depth); |
1941 |
|
fread(&dummy, 1, 1, handle); |
1942 |
if ((xsize > 4096) || (ysize > 4096*3/2) || (depth != 255)) { |
if ((xsize > 4096) || (ysize > 4096*3/2) || (depth != 255)) { |
1943 |
fprintf(stderr, "%d %d %d\n", xsize, ysize, depth); |
fprintf(stderr, "%d %d %d\n", xsize, ysize, depth); |
1944 |
return (2); |
return (2); |
1956 |
unsigned char *image) |
unsigned char *image) |
1957 |
{ |
{ |
1958 |
int i; |
int i; |
|
char dummy; |
|
1959 |
|
|
1960 |
unsigned char *y = image; |
unsigned char *y = image; |
1961 |
unsigned char *u = image + XDIM * YDIM; |
unsigned char *u = image + XDIM * YDIM; |
1976 |
v += XDIM / 2; |
v += XDIM / 2; |
1977 |
} |
} |
1978 |
|
|
|
/* I don't know why, but this seems needed */ |
|
|
fread(&dummy, 1, 1, handle); |
|
|
|
|
1979 |
return (0); |
return (0); |
1980 |
} |
} |
1981 |
#else |
#else |