[svn] / branches / release-1_3-branch / xvidcore / examples / xvid_encraw.c Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/examples/xvid_encraw.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/xvidcore/examples/xvid_encraw.c revision 1913, Sat Dec 18 16:02:08 2010 UTC branches/release-1_3-branch/xvidcore/examples/xvid_encraw.c revision 2129, Wed Jul 8 17:32:58 2015 UTC
# Line 6  Line 6 
6   *  Copyright(C) 2002-2003 Christoph Lampert <gruel@web.de>   *  Copyright(C) 2002-2003 Christoph Lampert <gruel@web.de>
7   *               2002-2003 Edouard Gomez <ed.gomez@free.fr>   *               2002-2003 Edouard Gomez <ed.gomez@free.fr>
8   *               2003      Peter Ross <pross@xvid.org>   *               2003      Peter Ross <pross@xvid.org>
9   *               2003-2010 Michael Militzer <isibaar@xvid.org>   *               2003-2014 Michael Militzer <isibaar@xvid.org>
10   *   *
11   *  This program is free software; you can redistribute it and/or modify   *  This program is free software; you can redistribute it and/or modify
12   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 22  Line 22 
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.46 2010-12-18 16:02:08 Isibaar Exp $   * $Id$
26   *   *
27   ****************************************************************************/   ****************************************************************************/
28    
# Line 40  Line 40 
40   ************************************************************************/   ************************************************************************/
41    
42  #include <stdio.h>  #include <stdio.h>
 //#include <io.h>  
43  #include <stdlib.h>  #include <stdlib.h>
44  #include <string.h>  #include <string.h>
45  #include <math.h>  #include <math.h>
46    #include <ctype.h>
47  #ifndef WIN32  #ifndef WIN32
48  #include <sys/time.h>  #include <sys/time.h>
49  #else  #else
# Line 126  Line 126 
126    
127  #define MAX_ZONES   64  #define MAX_ZONES   64
128  #define MAX_ENC_INSTANCES 4  #define MAX_ENC_INSTANCES 4
129    #define MAX_XDIM 4096
130    #define MAX_YDIM 4096
131  #define DEFAULT_QUANT 400  #define DEFAULT_QUANT 400
132    #define DEFAULT_BITRATE 700000 /* bitrate expressed in bps, not kbps */
133    #define DEFAULT_INTERLACING 1  /* 1:BFF, 2:TFF */
134    #define DEFAULT_SSIM 2
135    #define DEFAULT_PROGRESS 10    /* show progress every 10 frames by default */
136    
137  typedef struct  typedef struct
138  {  {
# Line 157  Line 163 
163          int stop_num;          int stop_num;
164    
165          char *outfilename;      /* output filename */          char *outfilename;      /* output filename */
166            char *outavifilename;   /* output avi filename */
167            char *outmkvfilename;   /* output mkv filename */
168          char *statsfilename1;   /* pass1 statsfile */          char *statsfilename1;   /* pass1 statsfile */
169    
170          int input_num;          int input_num;
# Line 187  Line 195 
195    
196  static  int ARG_NUM_APP_THREADS = 1;  static  int ARG_NUM_APP_THREADS = 1;
197  static  int ARG_CPU_FLAGS = 0;  static  int ARG_CPU_FLAGS = 0;
 static  int ARG_STATS = 0;  
198  static  int ARG_SSIM = -1;  static  int ARG_SSIM = -1;
 static  int ARG_PSNRHVSM = 0;  
199  static  char* ARG_SSIM_PATH = NULL;  static  char* ARG_SSIM_PATH = NULL;
200  static  int ARG_DUMP = 0;  static  int ARG_DUMP = 0;
201  static  int ARG_LUMIMASKING = 0;  static  int ARG_LUMIMASKING = 0;
# Line 200  Line 206 
206  static  char *ARG_PASS2 = 0;  static  char *ARG_PASS2 = 0;
207  //static int ARG_QUALITY = ME_ELEMENTS - 1;  //static int ARG_QUALITY = ME_ELEMENTS - 1;
208  static  int ARG_QUALITY = 6;  static  int ARG_QUALITY = 6;
209  static  float ARG_FRAMERATE = 25.00f;  static  float ARG_FRAMERATE = 0.f;
210  static  int ARG_DWRATE = 25;  static  int ARG_DWRATE = 25;
211  static  int ARG_DWSCALE = 1;  static  int ARG_DWSCALE = 1;
212  static  int ARG_MAXFRAMENR = ABS_MAXFRAMENR;  static  int ARG_MAXFRAMENR = ABS_MAXFRAMENR;
# Line 219  Line 225 
225  static  int ARG_BQRATIO = 150;  static  int ARG_BQRATIO = 150;
226  static  int ARG_BQOFFSET = 100;  static  int ARG_BQOFFSET = 100;
227  static  int ARG_MAXBFRAMES = 2;  static  int ARG_MAXBFRAMES = 2;
 static  int ARG_PACKED = 1;  
228  static  int ARG_DEBUG = 0;  static  int ARG_DEBUG = 0;
 static  int ARG_VOPDEBUG = 0;  
 static  int ARG_TRELLIS = 1;  
229  static  int ARG_QTYPE = 0;  static  int ARG_QTYPE = 0;
230  static  int ARG_QMATRIX = 0;  static  int ARG_QMATRIX = 0;
 static  int ARG_GMC = 0;  
231  static  int ARG_INTERLACING = 0;  static  int ARG_INTERLACING = 0;
 static  int ARG_QPEL = 0;  
 static  int ARG_TURBO = 0;  
232  static  int ARG_VHQMODE = 1;  static  int ARG_VHQMODE = 1;
 static  int ARG_BVHQ = 0;  
233  static  int ARG_QMETRIC = 0;  static  int ARG_QMETRIC = 0;
 static  int ARG_CLOSED_GOP = 1;  
 static  int ARG_CHROMAME = 1;  
234  static  int ARG_PAR = 1;  static  int ARG_PAR = 1;
235  static  int ARG_PARHEIGHT;  static  int ARG_PARHEIGHT;
236  static  int ARG_PARWIDTH;  static  int ARG_PARWIDTH;
# Line 258  Line 255 
255  static  int ARG_VBVPEAKRATE = 0;  static  int ARG_VBVPEAKRATE = 0;
256  static  int ARG_THREADS = 0;  static  int ARG_THREADS = 0;
257  static  int ARG_SLICES = 1;  static  int ARG_SLICES = 1;
 static  int ARG_VFR = 0;  
258  static  int ARG_PROGRESS = 0;  static  int ARG_PROGRESS = 0;
259  static  int ARG_COLORSPACE = XVID_CSP_YV12;  static  int ARG_COLORSPACE = XVID_CSP_YV12;
260          /* the path where to save output */          /* the path where to save output */
261  static char filepath[256] = "./";  static char filepath[256] = "./";
262    
263    /* on/off options */
264    static  int ARG_USE_ASSEMBLER = 1;
265    static  int ARG_TURBO         = 0;
266    static  int ARG_BVHQ          = 0;
267    static  int ARG_QPEL          = 0;
268    static  int ARG_GMC           = 0;
269    static  int ARG_PACKED        = 1;
270    static  int ARG_CLOSED_GOP    = 1;
271    static  int ARG_STATS         = 0;
272    static  int ARG_PSNRHVSM      = 0;
273    static  int ARG_VOPDEBUG      = 0;
274    static  int ARG_CHROMAME      = 1;
275    static  int ARG_TRELLIS       = 1;
276    
277  static  unsigned char qmatrix_intra[64];  static  unsigned char qmatrix_intra[64];
278  static  unsigned char qmatrix_inter[64];  static  unsigned char qmatrix_inter[64];
279    
# Line 345  Line 355 
355    
356          int input_num = 0;          int input_num = 0;
357          int totalsize = 0;          int totalsize = 0;
358          int use_assembler = 1;          int use_assembler = ARG_USE_ASSEMBLER;
359          int i;          int i;
360    
361          printf("xvid_encraw - raw mpeg4 bitstream encoder ");          printf("xvid_encraw - raw mpeg4 bitstream encoder ");
# Line 353  Line 363 
363    
364          /* Is there a dumb Xvid coder ? */          /* Is there a dumb Xvid coder ? */
365          if(ME_ELEMENTS != VOP_ELEMENTS) {          if(ME_ELEMENTS != VOP_ELEMENTS) {
366                  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");
367                  return(-1);                  return(-1);
368          }          }
369    
# Line 396  Line 406 
406                                          ARG_BITRATE *= 1000;                                          ARG_BITRATE *= 1000;
407                          }                          }
408                          else                          else
409                                  ARG_BITRATE = 700000;                                  ARG_BITRATE = DEFAULT_BITRATE;
410                  } else if (strcmp("-size", argv[i]) == 0 && i < argc - 1) {                  } else if (strcmp("-size", argv[i]) == 0 && i < argc - 1) {
411                          i++;                          i++;
412                          ARG_TARGETSIZE = atoi(argv[i]);                          ARG_TARGETSIZE = atoi(argv[i]);
# Line 445  Line 455 
455                          ARG_PACKED = 2;                          ARG_PACKED = 2;
456                  } else if (strcmp("-nochromame", argv[i]) == 0) {                  } else if (strcmp("-nochromame", argv[i]) == 0) {
457                          ARG_CHROMAME = 0;                          ARG_CHROMAME = 0;
458                    } else if (strcmp("-chromame", argv[i]) == 0) {
459                            ARG_CHROMAME = 1;
460                  } else if (strcmp("-threads", argv[i]) == 0 && i < argc -1) {                  } else if (strcmp("-threads", argv[i]) == 0 && i < argc -1) {
461                          i++;                          i++;
462                          ARG_THREADS = atoi(argv[i]);                          ARG_THREADS = atoi(argv[i]);
# Line 485  Line 497 
497                                  memset(&ZONES[NUM_ZONES], 0, sizeof(zone_t));                                  memset(&ZONES[NUM_ZONES], 0, sizeof(zone_t));
498    
499                                  ZONES[NUM_ZONES].frame = startframe;                                  ZONES[NUM_ZONES].frame = startframe;
500                                  ZONES[NUM_ZONES].modifier = atof(options)*100;                                  ZONES[NUM_ZONES].modifier = (int)(atof(options)*100);
501                                  if (toupper(c)=='Q')                                  if (toupper(c)=='Q')
502                                          ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;                                          ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;
503                                  else if (toupper(c)=='W')                                  else if (toupper(c)=='W')
# Line 498  Line 510 
510                                  if ((frameoptions=strchr(options, ','))!=NULL) {                                  if ((frameoptions=strchr(options, ','))!=NULL) {
511                                          int readchar=0, count;                                          int readchar=0, count;
512                                          frameoptions++;                                          frameoptions++;
513                                          while (readchar<strlen(frameoptions)) {                                          while (readchar<(int)strlen(frameoptions)) {
514                                                  if (sscanf(frameoptions+readchar, "%d%n", &(ZONES[NUM_ZONES].bvop_threshold), &count)==1) {                                                  if (sscanf(frameoptions+readchar, "%d%n", &(ZONES[NUM_ZONES].bvop_threshold), &count)==1) {
515                                                          readchar += count;                                                          readchar += count;
516                                                  }                                                  }
# Line 536  Line 548 
548                          else {                          else {
549                                  ZONES[NUM_ZONES].mode = XVID_ZONE_WEIGHT;                                  ZONES[NUM_ZONES].mode = XVID_ZONE_WEIGHT;
550                          }                          }
551                          ZONES[NUM_ZONES].modifier = atof(argv[i+2])*100;                          ZONES[NUM_ZONES].modifier = (int)(atof(argv[i+2])*100);
552                          i++;                          i++;
553              ZONES[NUM_ZONES].frame = atoi(argv[i]);              ZONES[NUM_ZONES].frame = atoi(argv[i]);
554                          i++;                          i++;
# Line 563  Line 575 
575                          int exponent;                          int exponent;
576                          i++;                          i++;
577                          ARG_FRAMERATE = (float) atof(argv[i]);                          ARG_FRAMERATE = (float) atof(argv[i]);
578                          exponent = strcspn(argv[i], ".");                          exponent = (int) strcspn(argv[i], ".");
579                          if (exponent<strlen(argv[i]))                          if (exponent<(int)strlen(argv[i]))
580                                  exponent=pow(10.0, (int)(strlen(argv[i])-1-exponent));                                  exponent=(int)pow(10.0, (int)(strlen(argv[i])-1-exponent));
581                          else                          else
582                                  exponent=1;                                  exponent=1;
583                          ARG_DWRATE = atof(argv[i])*exponent;                          ARG_DWRATE = (int)(atof(argv[i])*exponent);
584                          ARG_DWSCALE = exponent;                          ARG_DWSCALE = exponent;
585                          exponent = gcd(ARG_DWRATE, ARG_DWSCALE);                          exponent = gcd(ARG_DWRATE, ARG_DWSCALE);
586                          ARG_DWRATE /= exponent;                          ARG_DWRATE /= exponent;
# Line 581  Line 593 
593                          ARG_INPUTFILE = argv[i];                          ARG_INPUTFILE = argv[i];
594                  } else if (strcmp("-stats", argv[i]) == 0) {                  } else if (strcmp("-stats", argv[i]) == 0) {
595                          ARG_STATS = 1;                          ARG_STATS = 1;
596                    } else if (strcmp("-nostats", argv[i]) == 0) {
597                            ARG_STATS = 0;
598                  } else if (strcmp("-ssim", argv[i]) == 0) {                  } else if (strcmp("-ssim", argv[i]) == 0) {
599                          ARG_SSIM = 2;                          ARG_SSIM = DEFAULT_SSIM;
600                          if ((i < argc - 1) && (*argv[i+1] != '-')) {                          if ((i < argc - 1) && (*argv[i+1] != '-')) {
601                                  i++;                                  i++;
602                                  ARG_SSIM = atoi(argv[i]);                                  ARG_SSIM = atoi(argv[i]);
603                          }                          }
604                  } else if (strcmp("-psnrhvsm", argv[i]) == 0) {                  } else if (strcmp("-psnrhvsm", argv[i]) == 0) {
605                          ARG_PSNRHVSM = 1;                          ARG_PSNRHVSM = 1;
606                    } else if (strcmp("-nopsnrhvsm", argv[i]) == 0) {
607                            ARG_PSNRHVSM = 0;
608                  } else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) {                  } else if (strcmp("-ssim_file", argv[i]) == 0 && i < argc -1) {
609                          i++;                          i++;
610                          ARG_SSIM_PATH = argv[i];                          ARG_SSIM_PATH = argv[i];
# Line 679  Line 695 
695  #endif  #endif
696                  } else if (strcmp("-vop_debug", argv[i]) == 0) {                  } else if (strcmp("-vop_debug", argv[i]) == 0) {
697                          ARG_VOPDEBUG = 1;                          ARG_VOPDEBUG = 1;
698                    } else if (strcmp("-novop_debug", argv[i]) == 0) {
699                            ARG_VOPDEBUG = 0;
700                    } else if (strcmp("-trellis", argv[i]) == 0) {
701                            ARG_TRELLIS = 1;
702                  } else if (strcmp("-notrellis", argv[i]) == 0) {                  } else if (strcmp("-notrellis", argv[i]) == 0) {
703                          ARG_TRELLIS = 0;                          ARG_TRELLIS = 0;
704                  } else if (strcmp("-bvhq", argv[i]) == 0) {                  } else if (strcmp("-bvhq", argv[i]) == 0) {
705                          ARG_BVHQ = 1;                          ARG_BVHQ = 1;
706                    } else if (strcmp("-nobvhq", argv[i]) == 0) {
707                            ARG_BVHQ = 0;
708                  } else if (strcmp("-qpel", argv[i]) == 0) {                  } else if (strcmp("-qpel", argv[i]) == 0) {
709                          ARG_QPEL = 1;                          ARG_QPEL = 1;
710                    } else if (strcmp("-noqpel", argv[i]) == 0) {
711                            ARG_QPEL = 0;
712                  } else if (strcmp("-turbo", argv[i]) == 0) {                  } else if (strcmp("-turbo", argv[i]) == 0) {
713                          ARG_TURBO = 1;                          ARG_TURBO = 1;
714                    } else if (strcmp("-noturbo", argv[i]) == 0) {
715                            ARG_TURBO = 0;
716                  } else if (strcmp("-gmc", argv[i]) == 0) {                  } else if (strcmp("-gmc", argv[i]) == 0) {
717                          ARG_GMC = 1;                          ARG_GMC = 1;
718                    } else if (strcmp("-nogmc", argv[i]) == 0) {
719                            ARG_GMC = 0;
720                  } else if (strcmp("-interlaced", argv[i]) == 0) {                  } else if (strcmp("-interlaced", argv[i]) == 0) {
721                          if ((i < argc - 1) && (*argv[i+1] != '-')) {                          if ((i < argc - 1) && (*argv[i+1] != '-')) {
722                                  i++;                                  i++;
723                                  ARG_INTERLACING = atoi(argv[i]);                                  ARG_INTERLACING = atoi(argv[i]);
724                          } else {                          } else {
725                                  ARG_INTERLACING = 1;                                  ARG_INTERLACING = DEFAULT_INTERLACING;
726                          }                          }
727                  } else if (strcmp("-noclosed_gop", argv[i]) == 0) {                  } else if (strcmp("-noclosed_gop", argv[i]) == 0) {
728                          ARG_CLOSED_GOP = 0;                          ARG_CLOSED_GOP = 0;
# Line 752  Line 780 
780                          if (ARG_PROGRESS > 0)                          if (ARG_PROGRESS > 0)
781                                  i++;                                  i++;
782                          else                          else
783                                  ARG_PROGRESS = 10;                                  ARG_PROGRESS = DEFAULT_PROGRESS;
784                  } else if (strcmp("-help", argv[i])) {                  } else if (strcmp("-help", argv[i]) == 0) {
785                        if (i < argc - 1 && strcmp("zones", argv[i+1]) == 0) {
786                                    fprintf(stderr, "Zones options\n\
787    NB: You can define up to %d zones using the -zones option as described below.\n\
788    \n\
789     -zones start,mode,value[,options][/start,mode,value[,options]]...\n\
790    \n\
791     Parameters of a zone use the comma (,) as a delimiter. Multiple zones are\n\
792     separated by a slash (/). The end of each zone is defined by either the start\n\
793     of the following zone or the last frame of the input file.\n\
794    \n\
795     start     : start frame of the zone\n\
796     mode      : weight zone = w, quantizer zone = q\n\
797     value     : depending on mode either the zone's weight or quantizer\n\
798     options   : enable certain encoder features for the zone. Each feature is\n\
799                 represented by a single letter. An integer number stands for\n\
800                 b-frame sensitivity. To enable multiple features at the same time\n\
801                 combine the appropriate symbols without any delimiting characters.\n\
802                 K = begin with keyframe\n\
803                 O = enable chroma optimizer\n\
804                 G = greyscale encoding\n\
805                 C = cartoon mode\n\
806           integer = b-frame sensitivity\n\
807    \n\
808     Example:\n\
809      to create a first zone starting at frame 0 with weight 1.0, all options\n\
810      enabled and b-frame sensitivity -5, and a second zone starting at frame 1000\n\
811      with constant quant 4 and no options enabled you would use the -zones option\n\
812      like this:\n\
813    \n\
814      -zones 0,w,1.0,-5KOGC/1000,q,4\n\n", MAX_ZONES);
815                            } else
816                          usage();                          usage();
817                          return (0);                          return (0);
818                  } else {                  } else {
# Line 767  Line 826 
826   *                            Arguments checking   *                            Arguments checking
827   ****************************************************************************/   ****************************************************************************/
828    
829          if (XDIM <= 0 || XDIM >= 4096 || YDIM <= 0 || YDIM >= 4096) {          if (XDIM <= 0 || XDIM >= MAX_XDIM || YDIM <= 0 || YDIM >= MAX_YDIM) {
830                  fprintf(stderr,                  fprintf(stderr,
831                                  "Trying to retrieve width and height from input header\n");                                  "Trying to retrieve width and height from input header\n");
832                  if (!ARG_INPUTTYPE)                  if (!ARG_INPUTTYPE)
# Line 776  Line 835 
835    
836          if (ARG_QUALITY < 0 ) {          if (ARG_QUALITY < 0 ) {
837                  ARG_QUALITY = 0;                  ARG_QUALITY = 0;
838          } else if (ARG_QUALITY >= ME_ELEMENTS) {          } else if (ARG_QUALITY >= (int) ME_ELEMENTS) {
839                  ARG_QUALITY = ME_ELEMENTS - 1;                  ARG_QUALITY = ME_ELEMENTS - 1;
840          }          }
841    
# Line 869  Line 928 
928                if (avi_info.fccHandler != MAKEFOURCC('Y', 'V', '1', '2')) {                if (avi_info.fccHandler != MAKEFOURCC('Y', 'V', '1', '2')) {
929                            LONG size;                            LONG size;
930                            fprintf(stderr, "Non YV12 input colorspace %c%c%c%c! Attempting conversion...\n",                            fprintf(stderr, "Non YV12 input colorspace %c%c%c%c! Attempting conversion...\n",
931                                    avi_info.fccHandler%256, (avi_info.fccHandler>>8)%256, (avi_info.fccHandler>>16)%256,                                    (char)avi_info.fccHandler%256, (char)(avi_info.fccHandler>>8)%256, (char)(avi_info.fccHandler>>16)%256,
932                                    (avi_info.fccHandler>>24)%256);                                    (char)(avi_info.fccHandler>>24)%256);
933                            size = sizeof(myBitmapInfoHeader);                            size = sizeof(myBitmapInfoHeader);
934                            AVIStreamReadFormat(avi_in_stream, 0, &myBitmapInfoHeader, &size);                            AVIStreamReadFormat(avi_in_stream, 0, &myBitmapInfoHeader, &size);
935                            if (size==0)                            if (size==0)
936                                    fprintf(stderr, "AVIStreamReadFormat read 0 bytes.\n");                                    fprintf(stderr, "AVIStreamReadFormat read 0 bytes.\n");
937                            else {                            else {
938                                    fprintf(stderr, "AVIStreamReadFormat read %d bytes.\n", size);                                    fprintf(stderr, "AVIStreamReadFormat read %d bytes.\n", (int)size);
939                                    fprintf(stderr, "width = %d, height = %d, planes = %d\n", myBitmapInfoHeader.biWidth,                                    fprintf(stderr, "width = %d, height = %d, planes = %d\n", (int)myBitmapInfoHeader.biWidth,
940                                            myBitmapInfoHeader.biHeight, myBitmapInfoHeader.biPlanes);                                            (int)myBitmapInfoHeader.biHeight, myBitmapInfoHeader.biPlanes);
941                                    fprintf(stderr, "Compression = %c%c%c%c, %d\n",                                    fprintf(stderr, "Compression = %c%c%c%c, %d\n",
942                                            myBitmapInfoHeader.biCompression%256, (myBitmapInfoHeader.biCompression>>8)%256,                                            (char)myBitmapInfoHeader.biCompression%256, (char)(myBitmapInfoHeader.biCompression>>8)%256,
943                                            (myBitmapInfoHeader.biCompression>>16)%256, (myBitmapInfoHeader.biCompression>>24)%256,                                            (char)(myBitmapInfoHeader.biCompression>>16)%256, (char)(myBitmapInfoHeader.biCompression>>24)%256,
944                                            myBitmapInfoHeader.biCompression);                                            (int)myBitmapInfoHeader.biCompression);
945                                    fprintf(stderr, "Bits Per Pixel = %d\n", myBitmapInfoHeader.biBitCount);                                    fprintf(stderr, "Bits Per Pixel = %d\n", myBitmapInfoHeader.biBitCount);
946                                    myBitmapInfoHeader.biCompression = MAKEFOURCC('Y', 'V', '1', '2');                                    myBitmapInfoHeader.biCompression = MAKEFOURCC('Y', 'V', '1', '2');
947                                    myBitmapInfoHeader.biBitCount = 12;                                    myBitmapInfoHeader.biBitCount = 12;
# Line 900  Line 959 
959                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);
960                                  if (temp != NULL) {                                  if (temp != NULL) {
961                                          int i;                                          int i;
962                                          for (i = 0; i < ((DWORD*)temp)[0]; i++) {                                          for (i = 0; i < (int)((DWORD*)temp)[0]; i++) {
963                                                  fprintf(stderr, "%2d ", temp[i]);                                                  fprintf(stderr, "%2d ", temp[i]);
964                                          }                                          }
965                                          fprintf(stderr, "\n");                                          fprintf(stderr, "\n");
# Line 916  Line 975 
975            if (ARG_MAXFRAMENR<0)            if (ARG_MAXFRAMENR<0)
976                          ARG_MAXFRAMENR = avi_info.dwLength-ARG_STARTFRAMENR;                          ARG_MAXFRAMENR = avi_info.dwLength-ARG_STARTFRAMENR;
977                    else                    else
978                          ARG_MAXFRAMENR = min(ARG_MAXFRAMENR, avi_info.dwLength-ARG_STARTFRAMENR);                          ARG_MAXFRAMENR = min(ARG_MAXFRAMENR, (int) (avi_info.dwLength-ARG_STARTFRAMENR));
979    
980                    XDIM = avi_info.rcFrame.right - avi_info.rcFrame.left;                    XDIM = avi_info.rcFrame.right - avi_info.rcFrame.left;
981                    YDIM = avi_info.rcFrame.bottom - avi_info.rcFrame.top;                    YDIM = avi_info.rcFrame.bottom - avi_info.rcFrame.top;
# Line 936  Line 995 
995  #endif  #endif
996                  {                  {
997                          FILE *in_file = fopen(ARG_INPUTFILE, "rb");                          FILE *in_file = fopen(ARG_INPUTFILE, "rb");
                         int pos = 0;  
998                          if (in_file == NULL) {                          if (in_file == NULL) {
999                                  fprintf(stderr, "Error opening input file %s\n", ARG_INPUTFILE);                                  fprintf(stderr, "Error opening input file %s\n", ARG_INPUTFILE);
1000                                  return (-1);                                  return (-1);
1001                          }                          }
1002  #ifdef USE_APP_LEVEL_THREADING  #ifdef USE_APP_LEVEL_THREADING
1003                            {
1004                                    int pos;
1005                          fseek(in_file, 0, SEEK_END); /* Determine input size */                          fseek(in_file, 0, SEEK_END); /* Determine input size */
1006                          pos = ftell(in_file);                          pos = ftell(in_file);
1007                          ARG_MAXFRAMENR = pos / IMAGE_SIZE(XDIM, YDIM); /* PGM, header size ?? */                          ARG_MAXFRAMENR = pos / IMAGE_SIZE(XDIM, YDIM); /* PGM, header size ?? */
1008                            }
1009  #endif  #endif
1010                          fclose(in_file);                          fclose(in_file);
1011                  }                  }
1012          }          }
1013    
1014          if (ARG_FRAMERATE <= 0) {          if (ARG_FRAMERATE <= 0) {
1015                  fprintf(stderr, "Wrong Framerate %f\n", ARG_FRAMERATE);                  ARG_FRAMERATE = 25.00f; /* default value */
                 return (-1);  
1016          }          }
1017    
1018          if (ARG_TARGETSIZE) {          if (ARG_TARGETSIZE) {
# Line 963  Line 1023 
1023                                  fprintf(stderr, "Parameter conflict: Do not specify both -bitrate and -size\n");                                  fprintf(stderr, "Parameter conflict: Do not specify both -bitrate and -size\n");
1024                                  goto release_all;                                  goto release_all;
1025                  } else                  } else
1026                          ARG_BITRATE = ((ARG_TARGETSIZE * 8) / (ARG_MAXFRAMENR / ARG_FRAMERATE)) * 1024;                          ARG_BITRATE = (int) (((ARG_TARGETSIZE * 8) / (ARG_MAXFRAMENR / ARG_FRAMERATE)) * 1024);
1027          }          }
1028    
1029                  /* Set constant quant to default if no bitrate given for single pass */                  /* Set constant quant to default if no bitrate given for single pass */
# Line 976  Line 1036 
1036  #ifdef USE_APP_LEVEL_THREADING  #ifdef USE_APP_LEVEL_THREADING
1037          if (ARG_INPUTFILE == NULL || strcmp(ARG_INPUTFILE, "stdin") == 0 ||          if (ARG_INPUTFILE == NULL || strcmp(ARG_INPUTFILE, "stdin") == 0 ||
1038              ARG_NUM_APP_THREADS <= 1 || ARG_THREADS != 0 ||              ARG_NUM_APP_THREADS <= 1 || ARG_THREADS != 0 ||
1039              ARG_TIMECODEFILE != NULL || ARG_AVIOUTPUTFILE != NULL ||              ARG_TIMECODEFILE != NULL || ARG_INPUTTYPE == 1)             /* TODO: PGM input */
             ARG_INPUTTYPE == 1 || ARG_MKVOUTPUTFILE != NULL)            /* TODO: PGM input */  
1040  #endif /* Spawn just one encoder instance */  #endif /* Spawn just one encoder instance */
1041          {          {
1042                  enc_sequence_data_t enc_data;                  enc_sequence_data_t enc_data;
# Line 987  Line 1046 
1046                  ARG_NUM_APP_THREADS = 1;                  ARG_NUM_APP_THREADS = 1;
1047    
1048                  enc_data.outfilename = ARG_OUTPUTFILE;                  enc_data.outfilename = ARG_OUTPUTFILE;
1049                    enc_data.outavifilename = ARG_AVIOUTPUTFILE;
1050                    enc_data.outmkvfilename = ARG_MKVOUTPUTFILE;
1051                  enc_data.statsfilename1 = ARG_PASS1;                  enc_data.statsfilename1 = ARG_PASS1;
1052                  enc_data.start_num = ARG_STARTFRAMENR;                  enc_data.start_num = ARG_STARTFRAMENR;
1053                  enc_data.stop_num = ARG_MAXFRAMENR;                  enc_data.stop_num = ARG_MAXFRAMENR;
# Line 1009  Line 1070 
1070    
1071                  enc_sequence_data_t enc_data[MAX_ENC_INSTANCES];                  enc_sequence_data_t enc_data[MAX_ENC_INSTANCES];
1072                  char outfile[MAX_ENC_INSTANCES][256];                  char outfile[MAX_ENC_INSTANCES][256];
1073                    char outavifile[MAX_ENC_INSTANCES][256];
1074                    char outmkvfile[MAX_ENC_INSTANCES][256];
1075                  char statsfilename[MAX_ENC_INSTANCES][256];                  char statsfilename[MAX_ENC_INSTANCES][256];
1076    
1077                  for (k = 0; k < MAX_ENC_INSTANCES; k++)                  for (k = 0; k < MAX_ENC_INSTANCES; k++)
# Line 1023  Line 1086 
1086                          ARG_THREADS = -1;                          ARG_THREADS = -1;
1087    
1088                  enc_data[0].outfilename = ARG_OUTPUTFILE;                  enc_data[0].outfilename = ARG_OUTPUTFILE;
1089                    enc_data[0].outavifilename = ARG_AVIOUTPUTFILE;
1090                    enc_data[0].outmkvfilename = ARG_MKVOUTPUTFILE;
1091                  enc_data[0].statsfilename1 = ARG_PASS1;                  enc_data[0].statsfilename1 = ARG_PASS1;
1092                  enc_data[0].start_num = ARG_STARTFRAMENR;                  enc_data[0].start_num = ARG_STARTFRAMENR;
1093                  enc_data[0].stop_num = (ARG_MAXFRAMENR-ARG_STARTFRAMENR)/ARG_NUM_APP_THREADS;                  enc_data[0].stop_num = (ARG_MAXFRAMENR-ARG_STARTFRAMENR)/ARG_NUM_APP_THREADS;
1094    
1095                  for (k = 1; k < ARG_NUM_APP_THREADS; k++) {                  for (k = 1; k < ARG_NUM_APP_THREADS; k++) {
1096                            if (ARG_OUTPUTFILE) {
1097                          sprintf(outfile[k], "%s.%03d", ARG_OUTPUTFILE, k);                          sprintf(outfile[k], "%s.%03d", ARG_OUTPUTFILE, k);
1098                          enc_data[k].outfilename = outfile[k];                          enc_data[k].outfilename = outfile[k];
1099                            }
1100                            else
1101                                    enc_data[k].outfilename = NULL;
1102    
1103                            if (ARG_AVIOUTPUTFILE) {
1104                                    sprintf(outavifile[k], "%.*s_%03d.avi", strlen(ARG_AVIOUTPUTFILE) - 4, ARG_AVIOUTPUTFILE, k);
1105                                    enc_data[k].outavifilename = outavifile[k];
1106                            }
1107                            else
1108                                    enc_data[k].outavifilename = NULL;
1109    
1110                            if (ARG_MKVOUTPUTFILE) {
1111                                    sprintf(outmkvfile[k], "%.*s_%03d.mkv", strlen(ARG_MKVOUTPUTFILE) - 4, ARG_MKVOUTPUTFILE, k);
1112                                    enc_data[k].outmkvfilename = outmkvfile[k];
1113                            }
1114                            else
1115                                    enc_data[k].outmkvfilename = NULL;
1116    
1117                          if (ARG_PASS1) {                          if (ARG_PASS1) {
1118                                  sprintf(statsfilename[k], "%s.%03d", ARG_PASS1, k);                                  sprintf(statsfilename[k], "%s.%03d", ARG_PASS1, k);
1119                                  enc_data[k].statsfilename1 = statsfilename[k];                                  enc_data[k].statsfilename1 = statsfilename[k];
# Line 1064  Line 1148 
1148                          totalenctime = MAX(totalenctime, enc_data[k].totalenctime);                          totalenctime = MAX(totalenctime, enc_data[k].totalenctime);
1149    
1150                          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];
1151                          for (i=0; i < 8; i++) {                          for (i=0; i < 7; i++) {
1152                                  int l;                                  int l;
1153                                  framestats[i].count += enc_data[k].framestats[i].count;                                  framestats[i].count += enc_data[k].framestats[i].count;
1154                                  framestats[i].size += enc_data[k].framestats[i].size;                                  framestats[i].size += enc_data[k].framestats[i].size;
# Line 1174  Line 1258 
1258          int start_num = h->start_num;          int start_num = h->start_num;
1259          int stop_num = h->stop_num;          int stop_num = h->stop_num;
1260          char *outfilename = h->outfilename;          char *outfilename = h->outfilename;
1261            char *outavifilename = h->outavifilename;
1262            char *outmkvfilename = h->outmkvfilename;
1263          float *totalPSNR = h->totalPSNR;          float *totalPSNR = h->totalPSNR;
1264    
1265          int input_num;          int input_num;
# Line 1188  Line 1274 
1274    
1275          int result;          int result;
1276          int output_num;          int output_num;
         int nvop_counter;  
1277          int m4v_size;          int m4v_size;
1278          int key;          int key;
1279          int stats_type;          int stats_type;
# Line 1211  Line 1296 
1296          PAVIFILE avi_in = NULL;          PAVIFILE avi_in = NULL;
1297          PAVISTREAM avi_in_stream = NULL;          PAVISTREAM avi_in_stream = NULL;
1298          PGETFRAME get_frame = NULL;          PGETFRAME get_frame = NULL;
         BITMAPINFOHEADER myBitmapInfoHeader;  
1299  #else  #else
1300  #define get_frame NULL  #define get_frame NULL
1301  #endif  #endif
# Line 1222  Line 1306 
1306          AVISTREAMINFO myAVIStreamInfo;          AVISTREAMINFO myAVIStreamInfo;
1307  #endif  #endif
1308  #if defined(XVID_AVI_INPUT) || defined(XVID_AVI_OUTPUT)  #if defined(XVID_AVI_INPUT) || defined(XVID_AVI_OUTPUT)
1309            BITMAPINFOHEADER myBitmapInfoHeader;
1310          if (ARG_NUM_APP_THREADS > 1)          if (ARG_NUM_APP_THREADS > 1)
1311                  CoInitializeEx(0, COINIT_MULTITHREADED);                  CoInitializeEx(0, COINIT_MULTITHREADED);
1312          AVIFileInit();          AVIFileInit();
# Line 1269  Line 1354 
1354                if (avi_info.fccHandler != MAKEFOURCC('Y', 'V', '1', '2')) {                if (avi_info.fccHandler != MAKEFOURCC('Y', 'V', '1', '2')) {
1355                            LONG size;                            LONG size;
1356                            fprintf(stderr, "Non YV12 input colorspace %c%c%c%c! Attempting conversion...\n",                            fprintf(stderr, "Non YV12 input colorspace %c%c%c%c! Attempting conversion...\n",
1357                                    avi_info.fccHandler%256, (avi_info.fccHandler>>8)%256, (avi_info.fccHandler>>16)%256,                                    (char)avi_info.fccHandler%256, (char)(avi_info.fccHandler>>8)%256, (char)(avi_info.fccHandler>>16)%256,
1358                                    (avi_info.fccHandler>>24)%256);                                    (char)(avi_info.fccHandler>>24)%256);
1359                            size = sizeof(myBitmapInfoHeader);                            size = sizeof(myBitmapInfoHeader);
1360                            AVIStreamReadFormat(avi_in_stream, 0, &myBitmapInfoHeader, &size);                            AVIStreamReadFormat(avi_in_stream, 0, &myBitmapInfoHeader, &size);
1361                            if (size==0)                            if (size==0)
1362                                    fprintf(stderr, "AVIStreamReadFormat read 0 bytes.\n");                                    fprintf(stderr, "AVIStreamReadFormat read 0 bytes.\n");
1363                            else {                            else {
1364                                    fprintf(stderr, "AVIStreamReadFormat read %d bytes.\n", size);                                    fprintf(stderr, "AVIStreamReadFormat read %d bytes.\n", (int)size);
1365                                    fprintf(stderr, "width = %d, height = %d, planes = %d\n", myBitmapInfoHeader.biWidth,                                    fprintf(stderr, "width = %d, height = %d, planes = %d\n", (int)myBitmapInfoHeader.biWidth,
1366                                            myBitmapInfoHeader.biHeight, myBitmapInfoHeader.biPlanes);                                            (int)myBitmapInfoHeader.biHeight, myBitmapInfoHeader.biPlanes);
1367                                    fprintf(stderr, "Compression = %c%c%c%c, %d\n",                                    fprintf(stderr, "Compression = %c%c%c%c, %d\n",
1368                                            myBitmapInfoHeader.biCompression%256, (myBitmapInfoHeader.biCompression>>8)%256,                                            (char)myBitmapInfoHeader.biCompression%256, (char)(myBitmapInfoHeader.biCompression>>8)%256,
1369                                            (myBitmapInfoHeader.biCompression>>16)%256, (myBitmapInfoHeader.biCompression>>24)%256,                                            (char)(myBitmapInfoHeader.biCompression>>16)%256, (char)(myBitmapInfoHeader.biCompression>>24)%256,
1370                                            myBitmapInfoHeader.biCompression);                                            (int)myBitmapInfoHeader.biCompression);
1371                                    fprintf(stderr, "Bits Per Pixel = %d\n", myBitmapInfoHeader.biBitCount);                                    fprintf(stderr, "Bits Per Pixel = %d\n", myBitmapInfoHeader.biBitCount);
1372                                    myBitmapInfoHeader.biCompression = MAKEFOURCC('Y', 'V', '1', '2');                                    myBitmapInfoHeader.biCompression = MAKEFOURCC('Y', 'V', '1', '2');
1373                                    myBitmapInfoHeader.biBitCount = 12;                                    myBitmapInfoHeader.biBitCount = 12;
# Line 1300  Line 1385 
1385                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);                                  temp = (unsigned char*)AVIStreamGetFrame(get_frame, 0);
1386                                  if (temp != NULL) {                                  if (temp != NULL) {
1387                                          int i;                                          int i;
1388                                          for (i = 0; i < ((DWORD*)temp)[0]; i++) {                                          for (i = 0; i < (int)((DWORD*)temp)[0]; i++) {
1389                                                  fprintf(stderr, "%2d ", temp[i]);                                                  fprintf(stderr, "%2d ", temp[i]);
1390                                          }                                          }
1391                                          fprintf(stderr, "\n");                                          fprintf(stderr, "\n");
# Line 1391  Line 1476 
1476                  }                  }
1477    
1478  #ifdef XVID_AVI_OUTPUT  #ifdef XVID_AVI_OUTPUT
1479                  if (ARG_AVIOUTPUTFILE != NULL ) {                  if (outavifilename != NULL ) {
1480                          {                          {
1481                                  /* Open the .avi output then close it */                                  /* Open the .avi output then close it */
1482                                  /* Resets the file size to 0, which AVIFile doesn't seem to do */                                  /* Resets the file size to 0, which AVIFile doesn't seem to do */
1483                                  FILE *scrub;                                  FILE *scrub;
1484                                  if ((scrub = fopen(ARG_AVIOUTPUTFILE, "w+b")) == NULL) {                                  if ((scrub = fopen(outavifilename, "w+b")) == NULL) {
1485                                          fprintf(stderr, "Error opening output file %s\n", ARG_AVIOUTPUTFILE);                                          fprintf(stderr, "Error opening output file %s\n", outavifilename);
1486                                          goto release_all;                                          goto release_all;
1487                                  }                                  }
1488                                  else                                  else
# Line 1408  Line 1493 
1493                          myAVIStreamInfo.fccHandler = MAKEFOURCC('x', 'v', 'i', 'd');                          myAVIStreamInfo.fccHandler = MAKEFOURCC('x', 'v', 'i', 'd');
1494                          myAVIStreamInfo.dwScale = ARG_DWSCALE;                          myAVIStreamInfo.dwScale = ARG_DWSCALE;
1495                          myAVIStreamInfo.dwRate = ARG_DWRATE;                          myAVIStreamInfo.dwRate = ARG_DWRATE;
1496                          myAVIStreamInfo.dwLength = ARG_MAXFRAMENR;                          myAVIStreamInfo.dwLength = (h->stop_num - h->start_num);
1497                          myAVIStreamInfo.dwQuality = 10000;                          myAVIStreamInfo.dwQuality = 10000;
1498                          SetRect(&myAVIStreamInfo.rcFrame, 0, 0, YDIM, XDIM);                          SetRect(&myAVIStreamInfo.rcFrame, 0, 0, XDIM, YDIM);
1499    
1500                          if (avierr=AVIFileOpen(&myAVIFile, ARG_AVIOUTPUTFILE, OF_CREATE|OF_WRITE, NULL)) {                          if ((avierr=AVIFileOpen(&myAVIFile, outavifilename, OF_CREATE|OF_WRITE, NULL))) {
1501                                  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", outavifilename, avierr);
1502                                  goto release_all;                                  goto release_all;
1503                          }                          }
1504    
1505                          if (avierr=AVIFileCreateStream(myAVIFile, &myAVIStream, &myAVIStreamInfo)) {                          if ((avierr=AVIFileCreateStream(myAVIFile, &myAVIStream, &myAVIStreamInfo))) {
1506                                  fprintf(stderr, "AVIFileCreateStream failed, error code %d\n", avierr);                                  fprintf(stderr, "AVIFileCreateStream failed, error code %d\n", avierr);
1507                                  goto release_all;                                  goto release_all;
1508                          }                          }
# Line 1430  Line 1515 
1515                          myBitmapInfoHeader.biCompression = MAKEFOURCC('X', 'V', 'I', 'D');                          myBitmapInfoHeader.biCompression = MAKEFOURCC('X', 'V', 'I', 'D');
1516                          myBitmapInfoHeader.biBitCount = 12;                          myBitmapInfoHeader.biBitCount = 12;
1517                          myBitmapInfoHeader.biSizeImage = 6*XDIM*YDIM;                          myBitmapInfoHeader.biSizeImage = 6*XDIM*YDIM;
1518                          if (avierr=AVIStreamSetFormat(myAVIStream, 0, &myBitmapInfoHeader, sizeof(BITMAPINFOHEADER))) {                          if ((avierr=AVIStreamSetFormat(myAVIStream, 0, &myBitmapInfoHeader, sizeof(BITMAPINFOHEADER)))) {
1519                                  fprintf(stderr, "AVIStreamSetFormat failed, error code %d\n", avierr);                                  fprintf(stderr, "AVIStreamSetFormat failed, error code %d\n", avierr);
1520                                  goto release_all;                                  goto release_all;
1521                          }                          }
1522                  }                  }
1523  #endif  #endif
1524  #ifdef XVID_MKV_OUTPUT  #ifdef XVID_MKV_OUTPUT
1525                  if (ARG_MKVOUTPUTFILE != NULL) {                  if (outmkvfilename != NULL) {
1526                          {                          {
1527                                  /* Open the .mkv output then close it */                                  /* Open the .mkv output then close it */
1528                                  /* Just to make sure we can write to it */                                  /* Just to make sure we can write to it */
1529                                  FILE *scrub;                                  FILE *scrub;
1530                                  if ((scrub = fopen(ARG_MKVOUTPUTFILE, "w+b")) == NULL) {                                  if ((scrub = fopen(outmkvfilename, "w+b")) == NULL) {
1531                                          fprintf(stderr, "Error opening output file %s\n", ARG_MKVOUTPUTFILE);                                          fprintf(stderr, "Error opening output file %s\n", outmkvfilename);
1532                                          goto release_all;                                          goto release_all;
1533                                  }                                  }
1534                                  else                                  else
1535                                          fclose(scrub);                                          fclose(scrub);
1536                          }                          }
1537    
1538                          MKVFileOpen(&myMKVFile, ARG_MKVOUTPUTFILE, OF_CREATE|OF_WRITE, NULL);                          MKVFileOpen(&myMKVFile, outmkvfilename, OF_CREATE|OF_WRITE, NULL);
1539                          if (ARG_PAR) {                          if (ARG_PAR) {
1540                                  myMKVStreamInfo.display_height = YDIM*height_ratios[ARG_PAR];                                  myMKVStreamInfo.display_height = YDIM*height_ratios[ARG_PAR];
1541                                  myMKVStreamInfo.display_width = XDIM*width_ratios[ARG_PAR];                                  myMKVStreamInfo.display_width = XDIM*width_ratios[ARG_PAR];
# Line 1463  Line 1548 
1548                          myMKVStreamInfo.width = XDIM;                          myMKVStreamInfo.width = XDIM;
1549                          myMKVStreamInfo.framerate = ARG_DWRATE;                          myMKVStreamInfo.framerate = ARG_DWRATE;
1550                          myMKVStreamInfo.framescale = ARG_DWSCALE;                          myMKVStreamInfo.framescale = ARG_DWSCALE;
1551                          myMKVStreamInfo.length = ARG_MAXFRAMENR;                          myMKVStreamInfo.length = (h->stop_num - h->start_num);
1552                          MKVFileCreateStream(myMKVFile, &myMKVStream, &myMKVStreamInfo);                          MKVFileCreateStream(myMKVFile, &myMKVStream, &myMKVStreamInfo);
1553                  }                  }
1554  #endif  #endif
# Line 1483  Line 1568 
1568          input_num = 0;                      /* input frame counter */          input_num = 0;                      /* input frame counter */
1569          output_num = start_num;             /* output frame counter */          output_num = start_num;             /* output frame counter */
1570    
         nvop_counter = 0;  
   
1571          do {          do {
1572    
1573                  char *type;                  char *type;
# Line 1527  Line 1610 
1610   *                       Encode and decode this frame   *                       Encode and decode this frame
1611   ****************************************************************************/   ****************************************************************************/
1612    
1613                  if ((input_num+start_num) >= (unsigned int)(stop_num-1) && ARG_MAXBFRAMES) {                  if ((unsigned int)(input_num+start_num) >= (unsigned int)(stop_num-1) && ARG_MAXBFRAMES) {
1614                          stats_type = XVID_TYPE_PVOP;                          stats_type = XVID_TYPE_PVOP;
1615                  }                  }
1616                  else                  else
# Line 1631  Line 1714 
1714                                  }                                  }
1715                          }                          }
1716                          else                          else
1717                                  sprintf(timecode, "%f", ((double)ARG_DWSCALE/ARG_DWRATE)*1000*output_num);                                  sprintf(timecode, "%f", ((double)ARG_DWSCALE/ARG_DWRATE)*1000*(output_num-start_num));
1718    
1719                          /* Save single files */                          /* Save single files */
1720                          if (ARG_SAVEINDIVIDUAL) {                          if (ARG_SAVEINDIVIDUAL) {
# Line 1642  Line 1725 
1725                                  fclose(out);                                  fclose(out);
1726                          }                          }
1727  #ifdef XVID_AVI_OUTPUT  #ifdef XVID_AVI_OUTPUT
1728                          if (ARG_AVIOUTPUTFILE && myAVIStream) {                          if (outavifilename && myAVIStream) {
1729                                  int output_frame;                                  int output_frame;
1730    
1731                                  if (time_file == NULL)                                  if (time_file == NULL)
1732                                          output_frame = output_num;                                          output_frame = (output_num-start_num);
1733                                  else {                                  else {
1734                                          output_frame = (int)(atof(timecode)/1000/((double)ARG_DWSCALE/ARG_DWRATE)+.5);                                          output_frame = (int)(atof(timecode)/1000/((double)ARG_DWSCALE/ARG_DWRATE)+.5);
1735                                  }                                  }
# Line 1665  Line 1748 
1748                                                  fwrite(mp4_buffer, 1, m4v_size, out_file);                                                  fwrite(mp4_buffer, 1, m4v_size, out_file);
1749                                  }                                  }
1750  #ifdef XVID_MKV_OUTPUT  #ifdef XVID_MKV_OUTPUT
1751                                  if (ARG_MKVOUTPUTFILE && myMKVStream) {                                  if (outmkvfilename && myMKVStream) {
1752                                          MKVStreamWrite(myMKVStream, atof(timecode), 1, (ARG_PACKED && fakenvop && (m4v_size <= 8)) ? NULL : mp4_buffer, m4v_size, key ? AVIIF_KEYFRAME : 0, NULL, NULL);                                          MKVStreamWrite(myMKVStream, atof(timecode), 1, (ARG_PACKED && fakenvop && (m4v_size <= 8)) ? NULL : mp4_buffer, m4v_size, key ? AVIIF_KEYFRAME : 0, NULL, NULL);
1753                                  }                                  }
1754  #endif  #endif
# Line 1726  Line 1809 
1809  #endif  #endif
1810    
1811    free_all_memory:    free_all_memory:
1812            if (out_buffer)
1813          free(out_buffer);          free(out_buffer);
1814            if (mp4_buffer)
1815          free(mp4_buffer);          free(mp4_buffer);
1816            if ((in_buffer) && (get_frame == NULL))
1817          free(in_buffer);          free(in_buffer);
1818  }  }
1819    
# Line 1815  Line 1901 
1901          fprintf(stderr, "Input options:\n");          fprintf(stderr, "Input options:\n");
1902          fprintf(stderr, " -i      string : input filename (stdin)\n");          fprintf(stderr, " -i      string : input filename (stdin)\n");
1903  #ifdef XVID_AVI_INPUT  #ifdef XVID_AVI_INPUT
1904          fprintf(stderr, " -type   integer: input data type (yuv=0, pgm=1, avi/avs=2)\n");          fprintf(stderr, " -type   integer : input data type (yuv=0, pgm=1, avi/avs=2) (");
1905  #else  #else
1906          fprintf(stderr, " -type   integer: input data type (yuv=0, pgm=1)\n");          fprintf(stderr, " -type   integer : input data type (yuv=0, pgm=1) (");
1907  #endif  #endif
1908          fprintf(stderr, " -w      integer: frame width ([1.2048])\n");          fprintf(stderr, "%d)\n", ARG_INPUTTYPE);
1909          fprintf(stderr, " -h      integer: frame height ([1.2048])\n");          fprintf(stderr, " -w      integer : frame width ([1.%d])\n", MAX_XDIM);
1910          fprintf(stderr, " -csp    string : colorspace of raw input file i420, yv12 (default)\n");          fprintf(stderr, " -h      integer : frame height ([1.%d])\n", MAX_YDIM);
1911          fprintf(stderr, " -frames integer: number of frames to encode\n");          fprintf(stderr, " -csp    string  : colorspace of raw input file i420%s, yv12%s\n", (ARG_COLORSPACE == XVID_CSP_I420)?" (default)":"", (ARG_COLORSPACE == XVID_CSP_YV12)?" (default)":"");
1912          fprintf(stderr, "\n");          fprintf(stderr, " -frames integer : number of frames to encode (");
1913            if (ARG_MAXFRAMENR==-1)
1914                    fprintf(stderr, "all)");
1915            else
1916                    fprintf(stderr, "%d)", ARG_MAXFRAMENR);
1917            fprintf(stderr, "\n\n");
1918          fprintf(stderr, "Output options:\n");          fprintf(stderr, "Output options:\n");
1919          fprintf(stderr, " -dump      : save decoder output\n");          fprintf(stderr, " -dump      : save decoder output\n");
1920          fprintf(stderr, " -save      : save an Elementary Stream file per frame\n");          fprintf(stderr, " -save      : save an Elementary Stream file per frame\n");
# Line 1831  Line 1922 
1922  #ifdef XVID_AVI_OUTPUT  #ifdef XVID_AVI_OUTPUT
1923          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");
1924  #endif  #endif
1925    #ifdef XVID_MKV_OUTPUT
1926          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");
1927          fprintf(stderr, "\n");  #endif
         fprintf(stderr, "BFrames options:\n");  
         fprintf(stderr, " -max_bframes   integer: max bframes (2)\n");  
         fprintf(stderr, " -bquant_ratio  integer: bframe quantizer ratio (150)\n");  
         fprintf(stderr, " -bquant_offset integer: bframe quantizer offset (100)\n");  
1928          fprintf(stderr, "\n");          fprintf(stderr, "\n");
1929          fprintf(stderr, "Rate control options:\n");          fprintf(stderr, "Rate control options:\n");
1930          fprintf(stderr, " -framerate float               : target framerate (25.0)\n");          fprintf(stderr, " -framerate        float      : target framerate (auto)\n");
1931          fprintf(stderr, " -bitrate   [integer]           : target bitrate in kbps (700)\n");          fprintf(stderr, " -bitrate          [integer]  : target bitrate in kbps (%d)\n", DEFAULT_BITRATE/1000);
1932          fprintf(stderr, " -size      integer                     : target size in kilobytes\n");          fprintf(stderr, " -size      integer                     : target size in kilobytes\n");
1933      fprintf(stderr,     " -single                        : single pass mode (default)\n");          fprintf(stderr, " -single                      : single pass mode%s\n", (ARG_SINGLE)?" (default)":"");
1934          fprintf(stderr, " -cq        float               : single pass constant quantizer\n");          fprintf(stderr, " -cq        float               : single pass constant quantizer\n");
1935          fprintf(stderr, " -pass1     [filename]          : twopass mode (first pass)\n");          fprintf(stderr, " -pass1     [filename]          : twopass mode (first pass)\n");
1936          fprintf(stderr, " -full1pass                     : perform full first pass\n");          fprintf(stderr, " -full1pass                   : perform full quality first pass (disabled)\n");
1937          fprintf(stderr, " -pass2     [filename]          : twopass mode (2nd pass)\n");          fprintf(stderr, " -pass2     [filename]          : twopass mode (2nd pass)\n");
1938            fprintf(stderr, " -max_key_interval integer    : maximum keyframe interval (%d)\n", ARG_MAXKEYINTERVAL);
1939            fprintf(stderr, " -zones            [zones]    : use `-help zones' for usage guidelines\n");
1940          fprintf(stderr, " -zq starting_frame float       : bitrate zone; quant\n");          fprintf(stderr, " -zq starting_frame float       : bitrate zone; quant\n");
1941          fprintf(stderr, " -zw starting_frame float       : bitrate zone; weight\n");          fprintf(stderr, " -zw starting_frame float       : bitrate zone; weight\n");
     fprintf(stderr, " -max_key_interval integer      : maximum keyframe interval (300)\n");  
1942      fprintf(stderr, "\n");      fprintf(stderr, "\n");
1943          fprintf(stderr, "Single Pass options:\n");          fprintf(stderr, "Single Pass options:\n");
1944          fprintf(stderr, "-reaction   integer             : reaction delay factor (16)\n");          fprintf(stderr, " -reaction         integer    : reaction delay factor (%d)\n", ARG_REACTION);
1945          fprintf(stderr, "-averaging  integer             : averaging period (100)\n");          fprintf(stderr, " -averaging        integer    : averaging period (%d)\n", ARG_AVERAGING);
1946          fprintf(stderr, "-smoother   integer             : smoothing buffer (100)\n");          fprintf(stderr, " -smoother         integer    : smoothing buffer (%d)\n", ARG_SMOOTHER);
1947          fprintf(stderr, "\n");          fprintf(stderr, "\n");
1948          fprintf(stderr, "Second Pass options:\n");          fprintf(stderr, "Second Pass options:\n");
1949          fprintf(stderr, "-kboost     integer             : I frame boost (10)\n");          fprintf(stderr, " -kboost           integer    : I frame boost (%d)\n", ARG_KBOOST);
1950          fprintf(stderr, "-kthresh    integer             : I frame reduction threshold (1)\n");          fprintf(stderr, " -kthresh          integer    : I frame reduction threshold (%d)\n", ARG_KTHRESH);
1951          fprintf(stderr, "-kreduction integer             : I frame reduction amount (20)\n");          fprintf(stderr, " -kreduction       integer    : I frame reduction amount (%d)\n", ARG_KREDUCTION);
1952          fprintf(stderr, "-ostrength  integer             : overflow control strength (5)\n");          fprintf(stderr, " -ostrength        integer    : overflow control strength (%d)\n", ARG_OVERSTRENGTH);
1953          fprintf(stderr, "-oimprove   integer             : max overflow improvement (5)\n");          fprintf(stderr, " -oimprove         integer    : max overflow improvement (%d)\n", ARG_OVERIMPROVE);
1954          fprintf(stderr, "-odegrade   integer             : max overflow degradation (5)\n");          fprintf(stderr, " -odegrade         integer    : max overflow degradation (%d)\n", ARG_OVERDEGRADE);
1955          fprintf(stderr, "-chigh      integer             : high bitrate scenes degradation (0)\n");          fprintf(stderr, " -chigh            integer    : high bitrate scenes degradation (%d)\n", ARG_CHIGH);
1956          fprintf(stderr, "-clow       integer             : low bitrate scenes improvement (0)\n");          fprintf(stderr, " -clow             integer    : low bitrate scenes improvement (%d)\n", ARG_CLOW);
1957          fprintf(stderr, "-overhead   integer             : container frame overhead (0)\n");          fprintf(stderr, " -overhead         integer    : container frame overhead (%d)\n", ARG_OVERHEAD);
1958          fprintf(stderr, "-vbvsize    integer             : use vbv buffer size\n");          fprintf(stderr, "-vbvsize    integer             : use vbv buffer size\n");
1959          fprintf(stderr, "-vbvmax     integer             : vbv max bitrate\n");          fprintf(stderr, "-vbvmax     integer             : vbv max bitrate\n");
1960          fprintf(stderr, "-vbvpeak    integer             : vbv peak bitrate over 1 second\n");          fprintf(stderr, "-vbvpeak    integer             : vbv peak bitrate over 1 second\n");
1961          fprintf(stderr, "\n");          fprintf(stderr, "\n");
1962            fprintf(stderr, "BFrames options:\n");
1963            fprintf(stderr, " -max_bframes      integer    : max bframes (%d)\n", ARG_MAXBFRAMES);
1964            fprintf(stderr, " -bquant_ratio     integer    : bframe quantizer ratio (%d)\n", ARG_BQRATIO);
1965            fprintf(stderr, " -bquant_offset    integer    : bframe quantizer offset (%d)\n", ARG_BQOFFSET);
1966            fprintf(stderr, "\n");
1967          fprintf(stderr, "Other options\n");          fprintf(stderr, "Other options\n");
1968          fprintf(stderr, " -noasm                         : do not use assembly optmized code\n");          if (ARG_USE_ASSEMBLER)
1969          fprintf(stderr, " -turbo                         : use turbo presets for higher encoding speed\n");                  fprintf(stderr, " -noasm                       : do not use assembly optimized code (use)\n");
1970          fprintf(stderr, " -quality integer               : quality ([0..%d]) (6)\n", ME_ELEMENTS - 1);          else
1971          fprintf(stderr, " -vhqmode integer               : level of R-D optimizations ([0..4]) (1)\n");                  fprintf(stderr, " -asm                         : use assembly optimized code (don't use)\n");
1972          fprintf(stderr, " -bvhq                          : use R-D optimizations for B-frames\n");          if (ARG_TURBO)
1973          fprintf(stderr, " -metric integer                : distortion metric for R-D opt (PSNR:0, PSNRHVSM: 1)\n");                  fprintf(stderr, " -noturbo                     : do not use turbo presets for higher encoding speed (use)\n");
1974          fprintf(stderr, " -qpel                          : use quarter pixel ME\n");          else
1975          fprintf(stderr, " -gmc                           : use global motion compensation\n");                  fprintf(stderr, " -turbo                       : use turbo presets for higher encoding speed (don't use)\n");
1976          fprintf(stderr, " -qtype   integer               : quantization type (H263:0, MPEG4:1) (0)\n");          fprintf(stderr, " -quality          integer    : quality ([0..%d]) (%d)\n", ME_ELEMENTS - 1, ARG_QUALITY);
1977            fprintf(stderr, " -vhqmode          integer    : level of R-D optimizations ([0..4]) (%d)\n", ARG_VHQMODE);
1978            if (ARG_BVHQ)
1979                    fprintf(stderr, " -nobvhq                      : do not use R-D optimizations for B-frames (use)\n");
1980            else
1981                    fprintf(stderr, " -bvhq                        : use R-D optimizations for B-frames (don't use)\n");
1982            fprintf(stderr, " -metric           integer    : distortion metric for R-D opt (PSNR:0, PSNRHVSM:1) (%d)\n", ARG_QMETRIC);
1983            if (ARG_QPEL)
1984                    fprintf(stderr, " -noqpel                      : do not use quarter pixel ME (use)\n");
1985            else
1986                    fprintf(stderr, " -qpel                        : use quarter pixel ME (don't use)\n");
1987            if (ARG_GMC)
1988                    fprintf(stderr, " -nogmc                       : do not use global motion compensation (use)\n");
1989            else
1990                    fprintf(stderr, " -gmc                         : use global motion compensation (don't use)\n");
1991            fprintf(stderr, " -qtype            integer    : quantization type (H263:0, MPEG4:1) (%d)\n", ARG_QTYPE);
1992          fprintf(stderr, " -qmatrix filename              : use custom MPEG4 quantization matrix\n");          fprintf(stderr, " -qmatrix filename              : use custom MPEG4 quantization matrix\n");
1993          fprintf(stderr, " -interlaced [integer]          : interlaced encoding (BFF:1, TFF:2) (1)\n");          fprintf(stderr, " -interlaced       [integer]  : interlaced encoding (BFF:1, TFF:2) (%d)\n", DEFAULT_INTERLACING);
1994          fprintf(stderr, " -nopacked                      : Disable packed mode\n");          if (ARG_PACKED)
1995          fprintf(stderr, " -noclosed_gop                  : Disable closed GOP mode\n");                  fprintf(stderr, " -nopacked                    : disable packed B-frames mode (enabled)\n");
1996          fprintf(stderr, " -masking [integer]             : HVS masking mode (None:0, Lumi:1, Variance:2) (0)\n");          else
1997          fprintf(stderr, " -stats                         : print stats about encoded frames\n");                  fprintf(stderr, " -packed                      : enable packed B-frames mode (disabled)\n");
1998          fprintf(stderr, " -ssim [integer]                : prints ssim for every frame (accurate: 0 fast: 4) (2)\n");          if (ARG_CLOSED_GOP)
1999          fprintf(stderr, " -ssim_file filename            : outputs the ssim stats into a file\n");                  fprintf(stderr, " -noclosed_gop                : disable closed GOP mode (enabled)\n");
2000          fprintf(stderr, " -psnrhvsm                      : prints PSNRHVSM metric for every frame\n");          else
2001          fprintf(stderr, " -debug                         : activates xvidcore internal debugging output\n");                  fprintf(stderr, " -closed_gop                  : enable closed GOP mode (disabled)\n");
2002          fprintf(stderr, " -vop_debug                     : print some info directly into encoded frames\n");          fprintf(stderr, " -masking          [integer]  : HVS masking mode (None:0, Lumi:1, Variance:2) (%d)\n", ARG_LUMIMASKING);
2003          fprintf(stderr, " -nochromame                    : Disable chroma motion estimation\n");          if (ARG_STATS)
2004          fprintf(stderr, " -notrellis                     : Disable trellis quantization\n");                  fprintf(stderr, " -nostats                     : do not print stats about encoded frames (print)\n");
2005          fprintf(stderr, " -imin    integer               : Minimum I Quantizer (1..31) (2)\n");          else
2006          fprintf(stderr, " -imax    integer               : Maximum I quantizer (1..31) (31)\n");                  fprintf(stderr, " -stats                       : print stats about encoded frames (don't print)\n");
2007          fprintf(stderr, " -bmin    integer               : Minimum B Quantizer (1..31) (2)\n");          fprintf(stderr, " -ssim             [integer]  : print ssim for every frame (accurate: 0 fast: 4) (%d)\n", DEFAULT_SSIM);
2008          fprintf(stderr, " -bmax    integer               : Maximum B quantizer (1..31) (31)\n");          fprintf(stderr, " -ssim_file        filename   : output the ssim stats into a file\n");
2009          fprintf(stderr, " -pmin    integer               : Minimum P Quantizer (1..31) (2)\n");          if (ARG_PSNRHVSM)
2010          fprintf(stderr, " -pmax    integer               : Maximum P quantizer (1..31) (31)\n");                  fprintf(stderr, " -nopsnrhvsm                  : do not print PSNRHVSM metric for every frame (print)\n");
2011          fprintf(stderr, " -drop    integer               : Frame Drop Ratio (0..100) (0)\n");          else
2012          fprintf(stderr, " -start   integer               : Starting frame number\n");                  fprintf(stderr, " -psnrhvsm                    : print PSNRHVSM metric for every frame (don't print)\n");
2013          fprintf(stderr, " -threads integer               : Number of threads\n");          fprintf(stderr, " -debug            integer    : activate xvidcore internal debugging output (don't activate)\n");
2014          fprintf(stderr, " -slices  integer               : Number of slices\n");          if (ARG_VOPDEBUG)
2015          fprintf(stderr, " -progress [integer]            : Show progress updates every n frames (10)\n");                  fprintf(stderr, " -novop_debug                 : do not print debug info directly into encoded frames (print)\n");
2016          fprintf(stderr, " -par     integer[:integer]     : Set Pixel Aspect Ratio.\n");          else
2017                    fprintf(stderr, " -vop_debug                   : print some info directly into encoded frames (don't print)\n");
2018            if (ARG_CHROMAME)
2019                    fprintf(stderr, " -nochromame                  : disable chroma motion estimation (enabled)\n");
2020            else
2021                    fprintf(stderr, " -chromame                    : enable chroma motion estimation (disabled)\n");
2022            if (ARG_TRELLIS)
2023                    fprintf(stderr, " -notrellis                   : disable trellis quantization (enabled)\n");
2024            else
2025                    fprintf(stderr, " -trellis                     : enable trellis quantization (disabled)\n");
2026            fprintf(stderr, " -imin             integer    : minimum I Quantizer (1..31) (%d)\n", ARG_QUANTS[0]);
2027            fprintf(stderr, " -imax             integer    : maximum I quantizer (1..31) (%d)\n", ARG_QUANTS[1]);
2028            fprintf(stderr, " -bmin             integer    : minimum B Quantizer (1..31) (%d)\n", ARG_QUANTS[4]);
2029            fprintf(stderr, " -bmax             integer    : maximum B quantizer (1..31) (%d)\n", ARG_QUANTS[5]);
2030            fprintf(stderr, " -pmin             integer    : minimum P Quantizer (1..31) (%d)\n", ARG_QUANTS[2]);
2031            fprintf(stderr, " -pmax             integer    : maximum P quantizer (1..31) (%d)\n", ARG_QUANTS[3]);
2032            fprintf(stderr, " -drop             integer    : frame Drop Ratio (0..100) (%d)\n", ARG_FRAMEDROP);
2033            fprintf(stderr, " -start            integer    : starting frame number (%d)\n", ARG_STARTFRAMENR);
2034            fprintf(stderr, " -threads          integer    : number of threads (auto)\n");
2035            fprintf(stderr, " -slices           integer    : number of slices (%d)\n", ARG_SLICES);
2036            fprintf(stderr, " -progress         [integer]  : show progress updates every n frames (%d)\n", DEFAULT_PROGRESS);
2037            fprintf(stderr, " -par       integer[:integer] : set Pixel Aspect Ratio (%d)\n", ARG_PAR);
2038          fprintf(stderr, "                                  1 = 1:1\n");          fprintf(stderr, "                                  1 = 1:1\n");
2039          fprintf(stderr, "                                  2 = 12:11 (4:3 PAL)\n");          fprintf(stderr, "                                  2 = 12:11 (4:3 PAL)\n");
2040          fprintf(stderr, "                                  3 = 10:11 (4:3 NTSC)\n");          fprintf(stderr, "                                  3 = 10:11 (4:3 NTSC)\n");
2041          fprintf(stderr, "                                  4 = 16:11 (16:9 PAL)\n");          fprintf(stderr, "                                  4 = 16:11 (16:9 PAL)\n");
2042          fprintf(stderr, "                                  5 = 40:33 (16:9 NTSC)\n");          fprintf(stderr, "                                  5 = 40:33 (16:9 NTSC)\n");
2043          fprintf(stderr, "                              other = custom (width:height)\n");          fprintf(stderr, "                              other = custom (width:height)\n");
2044          fprintf(stderr, " -help                          : prints this help message\n");          fprintf(stderr, " -help                        : print this help message\n");
2045          fprintf(stderr, "\n");          fprintf(stderr, "\n");
2046          fprintf(stderr, "NB: You can define %d zones repeating the -z[qw] option as needed.\n", MAX_ZONES);          fprintf(stderr, "NB: You can define up to %d zones via both the -zones and the -z[qw] options as needed.\n", MAX_ZONES);
2047  }  }
2048    
2049  /*****************************************************************************  /*****************************************************************************
# Line 1931  Line 2061 
2061          int bytes, xsize, ysize, depth;          int bytes, xsize, ysize, depth;
2062          char dummy[2];          char dummy[2];
2063    
2064          bytes = fread(dummy, 1, 2, handle);          bytes = (int) fread(dummy, 1, 2, handle);
2065    
2066          if ((bytes < 2) || (dummy[0] != 'P') || (dummy[1] != '5'))          if ((bytes < 2) || (dummy[0] != 'P') || (dummy[1] != '5'))
2067                  return (1);                  return (1);
2068    
2069          fscanf(handle, "%d %d %d", &xsize, &ysize, &depth);          fscanf(handle, "%d %d %d", &xsize, &ysize, &depth);
2070            fread(&dummy, 1, 1, handle);
2071          if ((xsize > 4096) || (ysize > 4096*3/2) || (depth != 255)) {          if ((xsize > 4096) || (ysize > 4096*3/2) || (depth != 255)) {
2072                  fprintf(stderr, "%d %d %d\n", xsize, ysize, depth);                  fprintf(stderr, "%d %d %d\n", xsize, ysize, depth);
2073                  return (2);                  return (2);
# Line 1954  Line 2085 
2085                           unsigned char *image)                           unsigned char *image)
2086  {  {
2087          int i;          int i;
         char dummy;  
2088    
2089          unsigned char *y = image;          unsigned char *y = image;
2090          unsigned char *u = image + XDIM * YDIM;          unsigned char *u = image + XDIM * YDIM;
# Line 1975  Line 2105 
2105                  v += XDIM / 2;                  v += XDIM / 2;
2106          }          }
2107    
         /*  I don't know why, but this seems needed */  
         fread(&dummy, 1, 1, handle);  
   
2108          return (0);          return (0);
2109  }  }
2110  #else  #else
# Line 2039  Line 2166 
2166    
2167  /* sample plugin */  /* sample plugin */
2168    
2169    #if 0
2170  int  int
2171  rawenc_debug(void *handle,  rawenc_debug(void *handle,
2172                           int opt,                           int opt,
# Line 2078  Line 2206 
2206    
2207          return XVID_ERR_FAIL;          return XVID_ERR_FAIL;
2208  }  }
2209    #endif
2210    
2211  #define FRAMERATE_INCR 1001  #define FRAMERATE_INCR 1001
2212    
# Line 2591  Line 2719 
2719    
2720                  ZONES[NUM_ZONES].frame = 0;                  ZONES[NUM_ZONES].frame = 0;
2721                  ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;                  ZONES[NUM_ZONES].mode = XVID_ZONE_QUANT;
2722                  ZONES[NUM_ZONES].modifier = ARG_CQ;                  ZONES[NUM_ZONES].modifier = (int) ARG_CQ;
2723                  ZONES[NUM_ZONES].type = XVID_TYPE_AUTO;                  ZONES[NUM_ZONES].type = XVID_TYPE_AUTO;
2724                  ZONES[NUM_ZONES].greyscale = 0;                  ZONES[NUM_ZONES].greyscale = 0;
2725                  ZONES[NUM_ZONES].chroma_opt = 0;                  ZONES[NUM_ZONES].chroma_opt = 0;
# Line 2607  Line 2735 
2735          for(i = 0; i < NUM_ZONES; i++)          for(i = 0; i < NUM_ZONES; i++)
2736                  if (ZONES[i].mode == XVID_ZONE_WEIGHT) {                  if (ZONES[i].mode == XVID_ZONE_WEIGHT) {
2737                          ZONES[i].mode = XVID_ZONE_QUANT;                          ZONES[i].mode = XVID_ZONE_QUANT;
2738                          ZONES[i].modifier = (100*ARG_CQ) / ZONES[i].modifier;                          ZONES[i].modifier = (int) ((100*ARG_CQ) / ZONES[i].modifier);
2739                  }                  }
2740  }  }
2741    
# Line 2676  Line 2804 
2804          int i;          int i;
2805          char* userdata;          char* userdata;
2806    
2807          for (i=0; i <= (bufsize-sizeof(userdata_start_code)); i++) {          for (i=0; i <= (int)(bufsize-sizeof(userdata_start_code)); i++) {
2808                  if (memcmp((void*)userdata_start_code, (void*)(buf+i), strlen(userdata_start_code))==0) {                  if (memcmp((void*)userdata_start_code, (void*)(buf+i), strlen(userdata_start_code))==0) {
2809                          if ((userdata = strstr(buf+i+4, "DivX"))!=NULL) {                          if ((userdata = strstr(buf+i+4, "DivX"))!=NULL) {
2810                                  userdata[strlen(userdata)-1] = '\0';                                  userdata[strlen(userdata)-1] = '\0';

Legend:
Removed from v.1913  
changed lines
  Added in v.2129

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4