--- trunk/xvidcore/examples/xvid_encraw.c 2010/11/16 14:42:07 1906 +++ branches/release-1_3-branch/xvidcore/examples/xvid_encraw.c 2010/12/28 19:19:57 1928 @@ -22,7 +22,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.44 2010-11-16 14:42:07 Isibaar Exp $ + * $Id: xvid_encraw.c,v 1.46.2.1 2010-12-28 19:19:57 Isibaar Exp $ * ****************************************************************************/ @@ -231,6 +231,7 @@ static int ARG_TURBO = 0; static int ARG_VHQMODE = 1; static int ARG_BVHQ = 0; +static int ARG_QMETRIC = 0; static int ARG_CLOSED_GOP = 1; static int ARG_CHROMAME = 1; static int ARG_PAR = 1; @@ -256,6 +257,7 @@ static int ARG_VBVMAXRATE = 0; static int ARG_VBVPEAKRATE = 0; static int ARG_THREADS = 0; +static int ARG_SLICES = 1; static int ARG_VFR = 0; static int ARG_PROGRESS = 0; static int ARG_COLORSPACE = XVID_CSP_YV12; @@ -446,6 +448,9 @@ } else if (strcmp("-threads", argv[i]) == 0 && i < argc -1) { i++; ARG_THREADS = atoi(argv[i]); + } else if (strcmp("-slices", argv[i]) == 0 && i < argc -1) { + i++; + ARG_SLICES = atoi(argv[i]); } else if (strcmp("-bquant_ratio", argv[i]) == 0 && i < argc - 1) { i++; ARG_BQRATIO = atoi(argv[i]); @@ -480,7 +485,7 @@ memset(&ZONES[NUM_ZONES], 0, sizeof(zone_t)); ZONES[NUM_ZONES].frame = startframe; - ZONES[NUM_ZONES].modifier = atof(options)*100; + ZONES[NUM_ZONES].modifier = (int)atof(options)*100; if (toupper(c)=='Q') ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT; else if (toupper(c)=='W') @@ -493,7 +498,7 @@ if ((frameoptions=strchr(options, ','))!=NULL) { int readchar=0, count; frameoptions++; - while (readchar= (unsigned int)(stop_num-1) && ARG_MAXBFRAMES) { + if ((unsigned int)(input_num+start_num) >= (unsigned int)(stop_num-1) && ARG_MAXBFRAMES) { stats_type = XVID_TYPE_PVOP; } else @@ -1868,6 +1876,7 @@ fprintf(stderr, " -quality integer : quality ([0..%d]) (6)\n", ME_ELEMENTS - 1); fprintf(stderr, " -vhqmode integer : level of R-D optimizations ([0..4]) (1)\n"); fprintf(stderr, " -bvhq : use R-D optimizations for B-frames\n"); + fprintf(stderr, " -metric integer : distortion metric for R-D opt (PSNR:0, PSNRHVSM: 1)\n"); fprintf(stderr, " -qpel : use quarter pixel ME\n"); fprintf(stderr, " -gmc : use global motion compensation\n"); fprintf(stderr, " -qtype integer : quantization type (H263:0, MPEG4:1) (0)\n"); @@ -1879,7 +1888,7 @@ fprintf(stderr, " -stats : print stats about encoded frames\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, " -psnrhvsm : prints psnr-hvs-m metric for every frame\n"); + fprintf(stderr, " -psnrhvsm : prints PSNRHVSM metric for every frame\n"); fprintf(stderr, " -debug : activates xvidcore internal debugging output\n"); fprintf(stderr, " -vop_debug : print some info directly into encoded frames\n"); fprintf(stderr, " -nochromame : Disable chroma motion estimation\n"); @@ -1893,6 +1902,7 @@ fprintf(stderr, " -drop integer : Frame Drop Ratio (0..100) (0)\n"); fprintf(stderr, " -start integer : Starting frame number\n"); fprintf(stderr, " -threads integer : Number of threads\n"); + fprintf(stderr, " -slices integer : Number of slices\n"); fprintf(stderr, " -progress [integer] : Show progress updates every n frames (10)\n"); fprintf(stderr, " -par integer[:integer] : Set Pixel Aspect Ratio.\n"); fprintf(stderr, " 1 = 1:1\n"); @@ -1921,7 +1931,7 @@ int bytes, xsize, ysize, depth; char dummy[2]; - bytes = fread(dummy, 1, 2, handle); + bytes = (int) fread(dummy, 1, 2, handle); if ((bytes < 2) || (dummy[0] != 'P') || (dummy[1] != '5')) return (1); @@ -2260,6 +2270,7 @@ #endif xvid_enc_create.num_threads = ARG_THREADS; + xvid_enc_create.num_slices = ARG_SLICES; /* Frame rate */ xvid_enc_create.fincr = ARG_DWSCALE; @@ -2482,6 +2493,9 @@ if (ARG_BVHQ) xvid_enc_frame.vop_flags |= XVID_VOP_RD_BVOP; + if (ARG_QMETRIC == 1) + xvid_enc_frame.vop_flags |= XVID_VOP_RD_PSNRHVSM; + switch (ARG_VHQMODE) /* this is the same code as for vfw */ { case 1: /* VHQ_MODE_DECISION */ @@ -2577,7 +2591,7 @@ ZONES[NUM_ZONES].frame = 0; ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT; - ZONES[NUM_ZONES].modifier = ARG_CQ; + ZONES[NUM_ZONES].modifier = (int) ARG_CQ; ZONES[NUM_ZONES].type = XVID_TYPE_AUTO; ZONES[NUM_ZONES].greyscale = 0; ZONES[NUM_ZONES].chroma_opt = 0; @@ -2593,7 +2607,7 @@ for(i = 0; i < NUM_ZONES; i++) if (ZONES[i].mode == XVID_ZONE_WEIGHT) { ZONES[i].mode = XVID_ZONE_QUANT; - ZONES[i].modifier = (100*ARG_CQ) / ZONES[i].modifier; + ZONES[i].modifier = (int) ((100*ARG_CQ) / ZONES[i].modifier); } } @@ -2662,7 +2676,7 @@ int i; char* userdata; - for (i=0; i <= (bufsize-sizeof(userdata_start_code)); i++) { + for (i=0; i <= (int)(bufsize-sizeof(userdata_start_code)); i++) { if (memcmp((void*)userdata_start_code, (void*)(buf+i), strlen(userdata_start_code))==0) { if ((userdata = strstr(buf+i+4, "DivX"))!=NULL) { userdata[strlen(userdata)-1] = '\0';