[svn] / branches / dev-api-4 / xvidcore / examples / xvid_encraw.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/examples/xvid_encraw.c

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

trunk/xvidcore/examples/xvid_encraw.c revision 376, Sat Aug 17 20:03:36 2002 UTC branches/dev-api-4/xvidcore/examples/xvid_encraw.c revision 926, Sun Mar 16 12:05:09 2003 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID MPEG-4 VIDEO CODEC - Example for encoding and decoding   *  XVID MPEG-4 VIDEO CODEC
4     *  - Console based test application  -
5     *
6     *  Copyright(C) 2002-2003 Christoph Lampert
7   *   *
8   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
9   *      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 14  Line 17 
17   *   *
18   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
19   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
20   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   *************************************************************************/   * $Id: xvid_encraw.c,v 1.11.2.8 2003-03-16 12:04:13 suxen_drol Exp $
   
 /************************************************************************  
23   *   *
24   *  Speed test routine for XviD using the XviD-API   ****************************************************************************/
25   *  (C) Christoph Lampert, 2002/08/17  
26    /*****************************************************************************
27     *  Application notes :
28   *   *
29   *  A sequence of YUV pics in PGM or RAW file format is encoded and the   *  A sequence of raw YUV I420 pics or YUV I420 PGM file format is encoded
30   *  raw MPEG-4 stream is written to stdout.   *  The speed is measured and frames' PSNR are taken from core.
  *  The encoding speed of this is measured, too.  
31   *   *
32   *  The program is plain C and needs no libraries except for libxvidcore,   *  The program is plain C and needs no libraries except for libxvidcore,
33   *  and maths-lib, so with UN*X you simply compile by   *  and maths-lib.
  *  
  *   gcc xvid_encraw.c -lxvidcore -lm -o xvid_encraw  
  *  
  *  Run without or with illegal parameters, then PGM input input is read  
  *  from stdin.  
  *  
  *  Parameters are: xvid_stat XDIM YDIM QUALITY BITRATE/QUANTIZER FRAMERATE  
  *  
  *  if XDIM or YDIM are illegal (e.g. 0), they are ignored and input is  
  *  considered to be PGM. Otherwise (X and Y both greater than 0) raw YUV  
  *  is expected, as e.g. the standard MPEG test-files, like "foreman"  
  *  
  *  0 <= QUALITY <= 6  (default 5)  
  *  
  *  BITRATE is in kbps (default 900),  
  *      if BITRATE<32, then value is taken is fixed QUANTIZER  
  *  
  *  FRAMERATE is a float (with or without decimal dot), default is 25.00  
  *  
  *  input/output and m4v-output is saved, if corresponding flags are set  
  *  
  *  PGM input must in a very specific format, see read_pgmheader  
  *  it can be generated e.g. from MPEG2 by    mpeg2dec -o pgmpipe  
  *  
  ************************************************************************/  
   
 /************************************************************************  
  *  
  *  For EXAMPLES how to use this, see the seperate file xvid_stat.examples  
34   *   *
35   ************************************************************************/   ************************************************************************/
36    
37  #include <stdio.h>  #include <stdio.h>
38  #include <stdlib.h>  #include <stdlib.h>
39  #include <math.h>               // needed for log10  #include <string.h>
40  #include <sys/time.h>           // only needed for gettimeofday  #include <math.h>
41    #ifndef WIN32
42    #include <sys/time.h>
43    #else
44    #include <time.h>
45    #endif
46    
47    #include "xvid.h"
48    
49    
50  #include "../src/xvid.h"                /* comes with XviD */  /*****************************************************************************
51     *                            Quality presets
52     ****************************************************************************/
53    
54    static xvid_motion_t const motion_presets[] = {
55            0,
56            PMV_HALFPELREFINE16,
57            PMV_HALFPELREFINE16,
58            PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8,
59            PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8 | PMV_EXTSEARCH16 | PMV_USESQUARES16,
60            PMV_HALFPELREFINE16 | PMV_HALFPELREFINE8 | PMV_EXTSEARCH16 | PMV_USESQUARES16 | PMV_CHROMA16 | PMV_CHROMA8,
61    };
62    
63  int motion_presets[7] = {  static xvid_vol_t const vol_presets[] = {
64          0,                                                              // Q 0          XVID_MPEGQUANT,
65          PMV_EARLYSTOP16,                                                // Q 1          0,
66          PMV_EARLYSTOP16,                                                // Q 2          0,
67          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16,                          // Q 3          XVID_QUARTERPEL,
68          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16,                          // Q 4          XVID_QUARTERPEL | XVID_GMC,
69          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8          // Q 5          XVID_QUARTERPEL | XVID_GMC
                         | PMV_HALFPELREFINE8,  
         PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16         // Q 6  
                         | PMV_USESQUARES16 | PMV_EARLYSTOP8 | PMV_HALFPELREFINE8  
70          };          };
71    
72  int general_presets[7] = {  static xvid_vop_t const vop_presets[] = {
73          XVID_H263QUANT, /* or use XVID_MPEGQUANT */             // Q 0          XVID_DYNAMIC_BFRAMES,
74          XVID_MPEGQUANT,                                         // Q 1          XVID_DYNAMIC_BFRAMES,
75          XVID_H263QUANT,                                // Q 2          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL,
76          XVID_H263QUANT | XVID_HALFPEL,                          // Q 3          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_INTER4V,
77          XVID_H263QUANT | XVID_HALFPEL | XVID_INTER4V,           // Q 4          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_INTER4V | XVID_HQACPRED,
78          XVID_H263QUANT | XVID_HALFPEL | XVID_INTER4V,           // Q 5          XVID_DYNAMIC_BFRAMES | XVID_HALFPEL | XVID_INTER4V | XVID_HQACPRED | XVID_MODEDECISION_BITS
79          XVID_H263QUANT | XVID_HALFPEL | XVID_INTER4V };         // Q 6  };
80    
81    /*****************************************************************************
82     *                     Command line global variables
83     ****************************************************************************/
84    
85    /* Maximum number of frames to encode */
86    #define ABS_MAXFRAMENR 9999
87    
88    static int   ARG_STATS = 0;
89    static int   ARG_DUMP = 0;
90    static int   ARG_LUMIMASKING = 0;
91    static int   ARG_BITRATE = 900;
92    static int   ARG_QUANTI = 0;
93    static int   ARG_QUALITY = 5;
94    static int   ARG_MINQUANT = 1;
95    static int   ARG_MAXQUANT = 31;
96    static float ARG_FRAMERATE = 25.00f;
97    static int   ARG_MAXFRAMENR = ABS_MAXFRAMENR;
98    static char *ARG_INPUTFILE = NULL;
99    static int   ARG_INPUTTYPE = 0;
100    static int   ARG_SAVEMPEGSTREAM = 0;
101    static char *ARG_OUTPUTFILE = NULL;
102    static int   XDIM = 0;
103    static int   YDIM = 0;
104    static int   ARG_BQRATIO = 150;
105    static int   ARG_BQOFFSET = 100;
106    static int   ARG_MAXBFRAMES = 0;
107    static int   ARG_PACKED = 0;
108    #define IMAGE_SIZE(x,y) ((x)*(y)*3/2)
109    
110  /* my default values for encoding */  #define MAX(A,B) ( ((A)>(B)) ? (A) : (B) )
111    #define SMALL_EPS (1e-10)
112    
113  #define ABS_MAXFRAMENR 9999               // max number of frames  #define SWAP(a) ( (((a)&0x000000ff)<<24) | (((a)&0x0000ff00)<<8) | \
114                      (((a)&0x00ff0000)>>8)  | (((a)&0xff000000)>>24) )
115    
116  int ARG_BITRATE=900;  /****************************************************************************
117  int ARG_QUANTI=0;   *                     Nasty global vars ;-)
118     ***************************************************************************/
119    
120    static int i;
121    
122    /* the path where to save output */
123    static char filepath[256] = "./";
124    
125    /* Internal structures (handles) for encoding and decoding */
126    static void *enc_handle = NULL;
127    
128    /*****************************************************************************
129     *               Local prototypes
130     ****************************************************************************/
131    
132    /* Prints program usage message */
133    static void usage();
134    
135    /* Statistical functions */
136    static double msecond();
137    
138    /* PGM related functions */
139    static int read_pgmheader(FILE* handle);
140    static int read_pgmdata(FILE* handle, unsigned char *image);
141    static int read_yuvdata(FILE* handle, unsigned char *image);
142    
143    /* Encoder related functions */
144    static int enc_init(int use_assembler);
145    static int enc_stop();
146    static int enc_main(unsigned char* image,
147                                            unsigned char* bitstream,
148                        int *key,
149                                            int *stats_type,
150                        int *stats_quant,
151                        int *stats_length,
152                                            int stats[3]);
153    
154    /*****************************************************************************
155     *               Main function
156     ****************************************************************************/
157    
158  int ARG_QUALITY =6;  int main(int argc, char *argv[])
159  int ARG_MINQUANT=1;  {
 int ARG_MAXQUANT=31;  
 float ARG_FRAMERATE=25.00;  
160    
161  int ARG_MAXFRAMENR=ABS_MAXFRAMENR;          unsigned char *mp4_buffer = NULL;
162            unsigned char *in_buffer = NULL;
163            unsigned char *out_buffer = NULL;
164    
165  #ifdef BFRAMES          double enctime;
166            double totalenctime=0.;
167    
168  int ARG_MAXBFRAMES=1;          int totalsize;
169  int ARG_BQUANTRATIO=200;          int result;
170            int m4v_size;
171        int key;
172            int stats_type;
173        int stats_quant;
174        int stats_length;
175            int use_assembler=0;
176    
177  #endif      int input_num;
178        int output_num;
179    
180  #define MAX(A,B) ( ((A)>(B)) ? (A) : (B) )          char filename[256];
 #define SMALL_EPS 1e-10  
181    
182  /* these are global variables. Not very elegant, but easy, and this is an easy program */          FILE *in_file = stdin;
183            FILE *out_file = NULL;
184    
185  int XDIM=0;          printf("xvid_encraw - raw mpeg4 bitstream encoder ");
186  int YDIM=0;     // will be set when reading first image          printf("written by Christoph Lampert 2002-2003\n\n");
 int i,filenr = 0;  
187    
188  int save_m4v_flag = 1;          // output MPEG4-bytestream?  /*****************************************************************************
189  int save_ref_flag = 0;          // save input image   *                            Command line parsing
190     ****************************************************************************/
191    
192  int pgmflag = 0;                // a flag, if input is in PGM format, overwritten in init-phase          for (i=1; i< argc; i++) {
 char filepath[256] = "./";      // the path where to save output  
193    
194  void *enc_handle = NULL;                // internal structures (handles) for encoding                  if (strcmp("-asm", argv[i]) == 0 ) {
195                            use_assembler = 1;
196                    }
197                    else if (strcmp("-w", argv[i]) == 0 && i < argc - 1 ) {
198                            i++;
199                            XDIM = atoi(argv[i]);
200                    }
201                    else if (strcmp("-h", argv[i]) == 0 && i < argc - 1 ) {
202                            i++;
203                            YDIM = atoi(argv[i]);
204                    }
205                    else if (strcmp("-b", argv[i]) == 0 && i < argc - 1 ) {
206                            i++;
207                            ARG_BITRATE = atoi(argv[i]);
208                    }
209                    else if (strcmp("-bn", argv[i]) == 0 && i < argc - 1 ) {
210                            i++;
211                            ARG_MAXBFRAMES = atoi(argv[i]);
212                    }
213                    else if (strcmp("-p", argv[i]) == 0) {
214                ARG_PACKED = 1;
215                    }
216                    else if (strcmp("-bqr", argv[i]) == 0 && i < argc - 1 ) {
217                            i++;
218                            ARG_BQRATIO = atoi(argv[i]);
219                    }
220                    else if (strcmp("-bqo", argv[i]) == 0 && i < argc - 1 ) {
221                            i++;
222                            ARG_BQOFFSET = atoi(argv[i]);
223                    }
224                    else if (strcmp("-q", argv[i]) == 0 && i < argc - 1 ) {
225                            i++;
226                            ARG_QUALITY = atoi(argv[i]);
227                    }
228                    else if (strcmp("-f", argv[i]) == 0 && i < argc - 1 ) {
229                            i++;
230                            ARG_FRAMERATE = (float)atof(argv[i]);
231                    }
232                    else if (strcmp("-i", argv[i]) == 0 && i < argc - 1 ) {
233                            i++;
234                            ARG_INPUTFILE = argv[i];
235                    }
236                    else if (strcmp("-s", argv[i]) == 0) {
237                            ARG_STATS = 1;
238                    }
239                    else if (strcmp("-dump", argv[i]) == 0) {
240                            ARG_DUMP = 1;
241                    }
242                    else if (strcmp("-lumimasking", argv[i]) == 0) {
243                            ARG_LUMIMASKING = 1;
244                    }
245                    else if (strcmp("-t", argv[i]) == 0 && i < argc - 1 ) {
246                            i++;
247                            ARG_INPUTTYPE = atoi(argv[i]);
248                    }
249                    else if(strcmp("-n", argv[i]) == 0 && i < argc - 1 ) {
250                            i++;
251                            ARG_MAXFRAMENR  = atoi(argv[i]);
252                    }
253                    else if (strcmp("-quant", argv[i]) == 0 && i < argc - 1 ) {
254                            i++;
255                            ARG_QUANTI = atoi(argv[i]);
256                    }
257                    else if (strcmp("-m", argv[i]) == 0) {
258                            ARG_SAVEMPEGSTREAM = 1;
259                    }
260                    else if (strcmp("-o", argv[i]) == 0 && i < argc - 1 ) {
261                            i++;
262                            ARG_OUTPUTFILE = argv[i];
263                    }
264                    else if (strcmp("-help", argv[i])) {
265                            usage();
266                            return(0);
267                    }
268                    else {
269                            usage();
270                            exit(-1);
271                    }
272    
273            }
274    
275  /*********************************************************************/  /*****************************************************************************
276  /*                     "statistical" functions                       */   *                            Arguments checking
277  /*                                                                   */   ****************************************************************************/
 /*  these are not needed for encoding or decoding, but for measuring */  
 /*  time and quality, there in nothing specific to XviD in these     */  
 /*                                                                   */  
 /*********************************************************************/  
278    
279  double msecond()          if (XDIM <= 0 || XDIM >= 2048 || YDIM <=0 || YDIM >= 2048 ) {
280  /* return the current time in seconds(!)  */                  fprintf(stderr, "Trying to retreive width and height from PGM header\n");
281  {                  ARG_INPUTTYPE = 1; /* pgm */
         struct timeval  tv;  
         gettimeofday(&tv, 0);  
         return tv.tv_sec + tv.tv_usec * 1.0e-6;  
282  }  }
283    
284  /*********************************************************************/          if ( ARG_QUALITY < 0 || ARG_QUALITY > 5) {
285  /*                    input and output functions                     */                  fprintf(stderr,"Wrong Quality\n");
286  /*                                                                   */                  return(-1);
287  /* the are small and simple routines to read and write PGM and YUV   */          }
 /* image. It's just for convenience, again nothing specific to XviD  */  
 /*                                                                   */  
 /*********************************************************************/  
288    
289  int read_pgmheader(FILE* handle)          if ( ARG_BITRATE <= 0 && ARG_QUANTI == 0) {
290  {                  fprintf(stderr,"Wrong Bitrate\n");
291          int bytes,xsize,ysize,depth;                  return(-1);
292          char dummy[2];          }
293    
294          bytes = fread(dummy,1,2,handle);          if ( ARG_FRAMERATE <= 0) {
295                    fprintf(stderr,"Wrong Framerate %s \n",argv[5]);
296                    return(-1);
297            }
298    
299          if ( (bytes < 2) || (dummy[0] != 'P') || (dummy[1] != '5' ))          if ( ARG_MAXFRAMENR <= 0) {
300                  return 1;                  fprintf(stderr,"Wrong number of frames\n");
301          fscanf(handle,"%d %d %d",&xsize,&ysize,&depth);                  return(-1);
         if ( (xsize > 1440) || (ysize > 2880 ) || (depth != 255) )  
         {  
                 return 2;  
302          }          }
303          if ( (XDIM==0) || (YDIM==0) )  
304          {       XDIM=xsize;          if ( ARG_INPUTFILE == NULL || strcmp(ARG_INPUTFILE, "stdin") == 0) {
305                  YDIM=ysize;                  in_file = stdin;
306          }          }
307            else {
308    
309          return 0;                  in_file = fopen(ARG_INPUTFILE, "rb");
310                    if (in_file == NULL) {
311                            fprintf(stderr, "Error opening input file %s\n", ARG_INPUTFILE);
312                            return(-1);
313                    }
314  }  }
315    
316  int read_pgmdata(FILE* handle, unsigned char *image)          if (ARG_INPUTTYPE) {
317  {                  if (read_pgmheader(in_file)) {
318          int i,status;                          fprintf(stderr, "Wrong input format, I want YUV encapsulated in PGM\n");
319          char dummy;                          return(-1);
320                    }
321            }
322    
323            /* now we know the sizes, so allocate memory */
324            in_buffer = (unsigned char *) malloc(IMAGE_SIZE(XDIM,YDIM));
325            if (!in_buffer)
326                    goto free_all_memory;
327    
328            /* this should really be enough memory ! */
329            mp4_buffer = (unsigned char *) malloc(IMAGE_SIZE(XDIM,YDIM)*2);
330            if (!mp4_buffer)
331                    goto free_all_memory;
332    
333          unsigned char* buff1_ptr2 = image + XDIM*YDIM;  /*****************************************************************************
334          unsigned char* buff1_ptr3 = image + XDIM*YDIM + XDIM/2*YDIM/2;   *                            XviD PART  Start
335     ****************************************************************************/
336    
         fread(image,XDIM*YDIM,1,stdin); // read Y component of picture  
337    
338          for (i=0;i<YDIM/2;i++)          result = enc_init(use_assembler);
339            if (result)
340          {          {
341                  fread(buff1_ptr2,XDIM/2,1,stdin);        // read U                  fprintf(stderr, "Encore INIT problem, return value %d\n", result);
342                  buff1_ptr2 += XDIM/2;                  goto release_all;
                 fread(buff1_ptr3,XDIM/2,1,stdin);        // read V  
                 buff1_ptr3 += XDIM/2;  
343          }          }
344          fread(&dummy,1,1,handle);       //  I don't know why, but this seems needed  
345          return 0;  /*****************************************************************************
346     *                            Main loop
347     ****************************************************************************/
348    
349            if (ARG_SAVEMPEGSTREAM && ARG_OUTPUTFILE) {
350    
351                    if((out_file = fopen(ARG_OUTPUTFILE, "w+b")) == NULL) {
352                            fprintf(stderr, "Error opening output file %s\n", ARG_OUTPUTFILE);
353                            goto release_all;
354  }  }
355    
356  int read_yuvdata(FILE* handle, unsigned char *image)          }
357  {       int i;          else {
358          char dummy;                  out_file = NULL;
359            }
360    
361          unsigned char* buff1_ptr2 = image + XDIM*YDIM;  /*****************************************************************************
362          unsigned char* buff1_ptr3 = image + XDIM*YDIM + XDIM/2*YDIM/2;   *                       Encoding loop
363     ****************************************************************************/
364    
365          if (fread(image,XDIM,YDIM*3/2,stdin) != YDIM*3/2)          totalsize = 0;
366                  return 1;  
367          else      result = 0;
368                  return 0;  
369        input_num = 0;  /* input frame counter */
370        output_num = 0; /* output frame counter */
371    
372            do {
373    
374                    char *type;
375                    int stats[3];
376    
377            if (input_num >= ARG_MAXFRAMENR)
378            {
379                result = 1;
380  }  }
381    
382  int write_pgm(char *filename, unsigned char *image)          if (!result)
383  {  {
384          FILE *filehandle;                      if(ARG_INPUTTYPE) {
385          filehandle=fopen(filename,"wb");                              /* read PGM data (YUV-format) */
386          if (filehandle)                              result = read_pgmdata(in_file, in_buffer);
387          {                      } else {
388                  fprintf(filehandle,"P5\n\n");           //                              /* read raw data (YUV-format) */
389                  fprintf(filehandle,"%d %d 255\n",XDIM,YDIM*3/2);                              result = read_yuvdata(in_file, in_buffer);
                 fwrite(image,XDIM,YDIM*3/2,filehandle);  
                 fclose(filehandle);  
                 return 0;  
390          }          }
         else  
                 return 1;  
391  }  }
392    
393  /*********************************************************************/  /*****************************************************************************
394  /* Routines for encoding: init encoder, frame step, release encoder  */   *                       Encode and decode this frame
395  /*********************************************************************/   ****************************************************************************/
   
 #define FRAMERATE_INCR 1001  
396    
397                    enctime = msecond();
398            m4v_size = enc_main(!result?in_buffer:0, mp4_buffer, &key, &stats_type, &stats_quant, &stats_length, stats);
399                    enctime = msecond() - enctime;
400    
401  int enc_init(int use_assembler)                  /* Write the Frame statistics */
 {       /* initialize encoder for first use, pass all needed parameters to the codec */  
         int xerr;  
402    
403          XVID_INIT_PARAM xinit;                  printf("%5d: key=%i, time(ms)=%6.1f, length=%7d",
404          XVID_ENC_PARAM xparam;              !result?input_num:-1,
405                               key,
406                               (float)enctime,
407                               (int)m4v_size);
408    
409          if(use_assembler)          if (stats_type > 0) {   /* !XVID_TYPE_NOTHING */
410    
411  #ifdef ARCH_IA64                  switch(stats_type) {
412                  xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64;                  case XVID_TYPE_IVOP:
413  #else                          type = "I";
414                  xinit.cpu_flags = 0;                          break;
415  #endif                  case XVID_TYPE_PVOP:
416                            type = "P";
417                            break;
418                    case XVID_TYPE_BVOP:
419                            type = "B";
420                            break;
421                    case XVID_TYPE_SVOP:
422                            type = "S";
423                            break;
424                    default:
425                            type = "U";
426                            break;
427                    }
428    
429          else              printf(" | type=%s quant=%2d, length=%7d", type, stats_quant, stats_length);
                 xinit.cpu_flags = XVID_CPU_FORCE;  
430    
431          xvid_init(NULL, 0, &xinit, NULL);               if(ARG_STATS) {
432                            printf(", psnr y = %2.2f, psnr u = %2.2f, psnr v = %2.2f",
433                                       (stats[0] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[0]/((float)(XDIM)*(YDIM))),
434                                       (stats[1] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[1]/((float)(XDIM)*(YDIM)/4)),
435                                       (stats[2] == 0)? 0.0f: 48.131f - 10*(float)log10((float)stats[2]/((float)(XDIM)*(YDIM)/4)));
436                 }
437    
         xparam.width = XDIM;  
         xparam.height = YDIM;  
         if ((ARG_FRAMERATE - (int)ARG_FRAMERATE) < SMALL_EPS)  
         {  
                 xparam.fincr = 1;  
                 xparam.fbase = (int)ARG_FRAMERATE;  
438          }          }
439          else  
440          {                  printf("\n");
441                  xparam.fincr = FRAMERATE_INCR;  
442                  xparam.fbase = (int)(FRAMERATE_INCR * ARG_FRAMERATE);          if (m4v_size < 0) {
443                break;
444          }          }
         xparam.rc_reaction_delay_factor = 16;  
         xparam.rc_averaging_period = 100;  
         xparam.rc_buffer = 10;  
         xparam.rc_bitrate = ARG_BITRATE*1000;  
         xparam.min_quantizer = 1;  
         xparam.max_quantizer = 31;  
         xparam.max_key_interval = (int)ARG_FRAMERATE*10;  
   
 #ifdef BFRAMES  
         xparam.global = XVID_GLOBAL_DX50BVOP;  
         xparam.max_bframes = ARG_MAXBFRAMES;  
         xparam.bquant_ratio = ARG_BQUANTRATIO;  
         xparam.frame_drop_ratio=0;  
 #endif  
445    
446          /* I use a small value here, since will not encode whole movies,                  /* Update encoding time stats */
447                  but short clips */                  totalenctime += enctime;
448                    totalsize += m4v_size;
449    
450          xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xparam, NULL);  /*****************************************************************************
451          enc_handle=xparam.handle;   *                       Save stream to file
452     ****************************************************************************/
453    
454          return xerr;                  if (m4v_size>0 && ARG_SAVEMPEGSTREAM)
455                    {
456                            /* Save single files */
457                            if (out_file == NULL) {
458                                    sprintf(filename, "%sframe%05d.m4v", filepath, output_num);
459                                    out_file = fopen(filename, "wb");
460                                    fwrite(mp4_buffer, m4v_size, 1, out_file);
461                                    fclose(out_file);
462                                    out_file = NULL;
463                    output_num++;
464  }  }
465                            else {
466    
467  int  enc_stop()                                  /* Write mp4 data */
468  {       int xerr;                                  fwrite(mp4_buffer, 1, m4v_size, out_file);
469    
470          xerr = xvid_encore(enc_handle, XVID_ENC_DESTROY, NULL, NULL);                          }
         return xerr;  
471  }  }
472    
473  int  enc_main(unsigned char* image, unsigned char* bitstream, int *streamlength, int* frametype)                  input_num++;
 {       int xerr;  
474    
475          XVID_ENC_FRAME xframe;                  /* Read the header if it's pgm stream */
476          XVID_ENC_STATS xstats;          if (!result && ARG_INPUTTYPE)
477                            result = read_pgmheader(in_file);
478    
479          xframe.bitstream = bitstream;          } while (1);
         xframe.length = -1;     // this is written by the routine  
480    
         xframe.image = image;  
         xframe.colorspace = XVID_CSP_YV12;      // defined in <xvid.h>  
481    
         xframe.intra = -1; // let the codec decide between I-frame (1) and P-frame (0)  
482    
483          xframe.quant = ARG_QUANTI;      // is quant != 0, use a fixed quant (and ignore bitrate)  /*****************************************************************************
484     *         Calculate totals and averages for output, print results
485     ****************************************************************************/
486    
487          xframe.motion = motion_presets[ARG_QUALITY];          printf("Tot: enctime(ms) =%7.2f,               length(bytes) = %7d\n",
488          xframe.general = general_presets[ARG_QUALITY];                     totalenctime, (int)totalsize);
         xframe.quant_intra_matrix = xframe.quant_inter_matrix = NULL;  
489    
490  #ifdef BFRAMES      if (input_num > 0) {
491          xframe.bquant = 0;              totalsize    /= input_num;
492  #endif              totalenctime /= input_num;
493        }else{
494            totalsize = -1;
495            totalenctime = -1;
496        }
497    
498          xerr = xvid_encore(enc_handle, XVID_ENC_ENCODE, &xframe, &xstats);          printf("Avg: enctime(ms) =%7.2f, fps =%7.2f, length(bytes) = %7d\n",
499                       totalenctime, 1000/totalenctime, (int)totalsize);
500    
 /*              enc_result->is_key_frame = xframe.intra;  
                 enc_result->quantizer = xframe.quant;  
                 enc_result->total_bits = xframe.length * 8;  
                 enc_result->motion_bits = xstats.hlength * 8;  
                 enc_result->texture_bits = enc_result->total_bits - enc_result->motion_bits;  
 */  
   
 /*  This is statictical data, e.g. for 2-pass.  
     If you are not interested in any of this, you can use  
         NULL instead of &xstats  
 */  
         *frametype = xframe.intra;  
         *streamlength = xframe.length;  
   
         return xerr;  
 }  
   
 /*********************************************************************/  
 /*                          Main program                             */  
 /*********************************************************************/  
501    
502  int main(int argc, char *argv[])  /*****************************************************************************
503     *                            XviD PART  Stop
504     ****************************************************************************/
505    
506     release_all:
507    
508            if (enc_handle)
509  {  {
510    unsigned char *divx_buffer = NULL;                  result = enc_stop();
511    unsigned char *in_buffer = NULL;                  if (result)
512                            fprintf(stderr, "Encore RELEASE problem return value %d\n", result);
513            }
514    
515    double enctime;          if(in_file)
516    double totalenctime=0.;                  fclose(in_file);
517            if(out_file)
518                    fclose(out_file);
519    
520    long totalsize=0;   free_all_memory:
521    int status;          free(out_buffer);
522            free(mp4_buffer);
523            free(in_buffer);
524    
525    int m4v_size;          return(0);
526    int frame_type[ABS_MAXFRAMENR];  
527    int Iframes=0, Pframes=0, Bframes=0;  }
   int use_assembler=1;  
528    
   char filename[256];  
529    
530    FILE *filehandle;  /*****************************************************************************
531     *                        "statistical" functions
532     *
533     *  these are not needed for encoding or decoding, but for measuring
534     *  time and quality, there in nothing specific to XviD in these
535     *
536     *****************************************************************************/
537    
538  /* read YUV in pgm format from stdin */  /* Return time elapsed time in miliseconds since the program started */
539    if (!pgmflag)  static double msecond()
540    {    {
541          pgmflag = 1;  #ifndef WIN32
542            struct timeval  tv;
543            gettimeofday(&tv, 0);
544            return(tv.tv_sec*1.0e3 + tv.tv_usec * 1.0e-3);
545    #else
546            clock_t clk;
547            clk = clock();
548            return(clk * 1000 / CLOCKS_PER_SEC);
549    #endif
550    }
551    
552  //      if (argc==2 && !strcmp(argv[1],"-noasm"))  /*****************************************************************************
553  //        use_assembler = 0;   *                             Usage message
554     *****************************************************************************/
555    
556    static void usage()
557    {
558    
559            fprintf(stderr, "Usage : xvid_stat [OPTIONS]\n");
560            fprintf(stderr, "Options :\n");
561            fprintf(stderr, " -w integer     : frame width ([1.2048])\n");
562            fprintf(stderr, " -h integer     : frame height ([1.2048])\n");
563            fprintf(stderr, " -b integer     : target bitrate (>0 | default=900kbit)\n");
564            fprintf(stderr, " -bn integer    : max bframes (default=0)\n");
565        fprintf(stderr, " -p             : packed mode\n");
566            fprintf(stderr, " -bqr integer   : bframe quantizer ratio (default=150)\n");
567            fprintf(stderr, " -bqo integer   : bframe quantizer offset (default=100)\n");
568            fprintf(stderr, " -f float       : target framerate (>0)\n");
569            fprintf(stderr, " -i string      : input filename (default=stdin)\n");
570            fprintf(stderr, " -s             : print stats about encoded frames\n");
571            fprintf(stderr, " -t integer     : input data type (yuv=0, pgm=1)\n");
572            fprintf(stderr, " -n integer     : number of frames to encode\n");
573            fprintf(stderr, " -q integer     : quality ([0..5])\n");
574            fprintf(stderr, " -dump          : save decoder output\n");
575            fprintf(stderr, " -m             : save mpeg4 raw stream\n");
576            fprintf(stderr, " -o string      : output container filename (only usefull when -m 1 is used) :\n");
577            fprintf(stderr, "                  When this option is not used : one file per encoded frame\n");
578            fprintf(stderr, "                  When this option is used : save to 'string' file\n");
579            fprintf(stderr, " -help          : prints this help message\n");
580            fprintf(stderr, " -quant integer : fixed quantizer (disables -b setting)\n");
581            fprintf(stderr, " (* means default)\n");
582    
         if (argc>=3)  
         {       XDIM = atoi(argv[1]);  
                 YDIM = atoi(argv[2]);  
                 if ( (XDIM <= 0) || (XDIM >= 2048) || (YDIM <=0) || (YDIM >= 2048) )  
                 {       fprintf(stderr,"Wrong frames size %d %d, trying PGM \n",XDIM, YDIM);  
583                  }                  }
584                  else  
585    /*****************************************************************************
586     *                       Input and output functions
587     *
588     *      the are small and simple routines to read and write PGM and YUV
589     *      image. It's just for convenience, again nothing specific to XviD
590     *
591     *****************************************************************************/
592    
593    static int read_pgmheader(FILE* handle)
594                  {                  {
595                          YDIM = YDIM*3/2; /* for YUV */          int bytes,xsize,ysize,depth;
596                          pgmflag = 0;          char dummy[2];
597                  }  
598          }          bytes = fread(dummy,1,2,handle);
599    }  
600            if ( (bytes < 2) || (dummy[0] != 'P') || (dummy[1] != '5' ))
601                    return(1);
602    
603    if (pgmflag)          fscanf(handle,"%d %d %d",&xsize,&ysize,&depth);
604    {     if (read_pgmheader(stdin))          if ( (xsize > 1440) || (ysize > 2880 ) || (depth != 255) )
605              {              {
606                fprintf(stderr,"Wrong input format, I want YUV encapsulated in PGM\n");                  fprintf(stderr,"%d %d %d\n",xsize,ysize,depth);
607                return 1;                  return(2);
             }  
   }  
   if (argc>=4)  
   {     ARG_QUALITY = atoi(argv[3]);  
         if ( (ARG_QUALITY < 0) || (ARG_QUALITY > 6) )  
                 { fprintf(stderr,"Wrong Quality\n"); return -1; }  
         else  
                   fprintf(stderr,"Quality %d\n",ARG_QUALITY);  
   }  
   if (argc>=5)  
   {     ARG_BITRATE = atoi(argv[4]);  
         if ( (ARG_BITRATE <= 0) )  
                 { fprintf(stderr,"Wrong Bitrate\n"); return -1; }  
         if ( (ARG_BITRATE < 32) )  
                 { ARG_QUANTI = ARG_BITRATE;  
                   ARG_BITRATE=0;  
                   fprintf(stderr,"Quantizer %d\n",ARG_QUANTI);  
608                  }                  }
609          else          if ( (XDIM==0) || (YDIM==0) )
610                    fprintf(stderr,"Bitrate %d kbps\n",ARG_BITRATE);          {
611                    XDIM=xsize;
612                    YDIM=ysize*2/3;
613    }    }
614    if (argc>=6)  
615    {     ARG_FRAMERATE = (float)atof(argv[5]);          return(0);
         if ( (ARG_FRAMERATE <= 0) )  
                 { fprintf(stderr,"Wrong Fraterate %s \n",argv[5]); return -1; }  
         fprintf(stderr,"Framerate %6.3f fps\n",ARG_FRAMERATE);  
   }  
   
   if (argc>=7)  
   {     ARG_MAXFRAMENR = atoi(argv[6]);  
         if ( (ARG_MAXFRAMENR <= 0) )  
          { fprintf(stderr,"Wrong number of frames\n"); return -1; }  
         fprintf(stderr,"max. Framenr. %d\n",ARG_MAXFRAMENR);  
   }  
   
 #ifdef BFRAMES  
   if (argc>=8)  
   {     ARG_MAXBFRAMES = atoi(argv[7]);  
         if ( (ARG_MAXBFRAMES < -1) || ( ARG_MAXBFRAMES > ARG_FRAMERATE) )  
          { fprintf(stderr,"Wrong maximumnumber of bframes\n"); return -1; }  
         fprintf(stderr,"max. B-frames %d\n",ARG_MAXBFRAMES);  
   }  
   
   if (argc>=9)  
   {     ARG_MAXFRAMENR = atoi(argv[8]);  
         if ( (ARG_BQUANTRATIO <= 0) )  
          { fprintf(stderr,"Wrong B-frames Quantizer ratio \n"); return -1; }  
         fprintf(stderr,"B-frames quant-ratio %d\n",ARG_BQUANTRATIO);  
616    }    }
 #endif  
617    
618  /* now we know the sizes, so allocate memory */  static int read_pgmdata(FILE* handle, unsigned char *image)
619    {
620            int i;
621            char dummy;
622    
623    in_buffer = (unsigned char *) malloc(XDIM*YDIM);          unsigned char *y = image;
624    if (!in_buffer)          unsigned char *u = image + XDIM*YDIM;
625      goto free_all_memory;          unsigned char *v = image + XDIM*YDIM + XDIM/2*YDIM/2;
626    
627    divx_buffer = (unsigned char *) malloc(XDIM*YDIM*2);          /* read Y component of picture */
628    if (!divx_buffer)          fread(y, 1, XDIM*YDIM, handle);
     goto free_all_memory;  
629    
630    YDIM = YDIM*2/3; // PGM is YUV 4:2:0 format, so real image height is *2/3 of PGM picture          for (i=0;i<YDIM/2;i++)
631            {
632                    /* read U */
633                    fread(u, 1, XDIM/2, handle);
634    
635  /*********************************************************************/                  /* read V */
636  /*                         XviD PART  Start                          */                  fread(v, 1, XDIM/2, handle);
 /*********************************************************************/  
637    
638    status = enc_init(use_assembler);                  /* Update pointers */
639          if (status)                  u += XDIM/2;
640          {                  v += XDIM/2;
                 fprintf(stderr,"Encore INIT problem, return value %d\n", status);  
                 goto release_all;  
641          }          }
642    
643  /*********************************************************************/      /*  I don't know why, but this seems needed */
644  /*                               Main loop                           */          fread(&dummy, 1, 1, handle);
645  /*********************************************************************/  
646            return(0);
647    }
648    
649    do  static int read_yuvdata(FILE* handle, unsigned char *image)
650      {      {
651          if (pgmflag)  
652                status = read_pgmdata(stdin, in_buffer);  // read PGM data (YUV-format)          if (fread(image, 1, IMAGE_SIZE(XDIM, YDIM), handle) != (unsigned int)IMAGE_SIZE(XDIM, YDIM))
653                    return(1);
654          else          else
655                status = read_yuvdata(stdin, in_buffer);  // read raw data (YUV-format)                  return(0);
656    }
657    
658    /*****************************************************************************
659     *     Routines for encoding: init encoder, frame step, release encoder
660     ****************************************************************************/
661    
662      if (status)  /* sample plugin */
663    
664    int rawenc_debug(void * handle, int opt, void * param1, void * param2)
665    {
666        switch(opt)
667          {          {
668            // Couldn't read image, most likely end-of-file      case XVID_PLG_INFO :
669            continue;          {
670            xvid_plg_info_t * info = (xvid_plg_info_t*)param1;
671            info->flags = XVID_REQDQUANTS;
672            return 0;
673          }          }
674    
675        case XVID_PLG_CREATE :
676        case XVID_PLG_DESTROY :
677        case XVID_PLG_BEFORE :
678            return 0;
679    
680      if (save_ref_flag)      case XVID_PLG_AFTER :
681          {          {
682                  sprintf(filename, "%s%05d.pgm", filepath, filenr);          xvid_plg_data_t * data = (xvid_plg_data_t*)param1;
683                  write_pgm(filename,in_buffer);          int i,j;
684    
685            printf("---[ frame: %5i   quant: %2i   length: %6i ]---\n", data->frame_num, data->quant, data->length);
686            for (j=0; j<data->mb_height; j++) {
687                for (i = 0; i<data->mb_width; i++)
688                    printf("%2i ",  data->dquant[j*data->dquant_stride + i]);
689                printf("\n");
690          }          }
691    
692            return 0;
693            }
694        }
695    
696  /*********************************************************************/      return XVID_ERR_FAIL;
697  /*               analyse this frame before encoding                  */  }
 /*********************************************************************/  
698    
 //      nothing is done here at the moment, but you could e.g. create  
 //      histograms or measure entropy or apply preprocessing filters...  
699    
700  /*********************************************************************/  #define FRAMERATE_INCR 1001
 /*               encode and decode this frame                        */  
 /*********************************************************************/  
701    
702          enctime = -msecond();  /* Initialize encoder for first use, pass all needed parameters to the codec */
703          status = enc_main(in_buffer, divx_buffer, &m4v_size, &frame_type[filenr]);  static int enc_init(int use_assembler)
704          enctime += msecond();  {
705            int xerr;
706    
707          totalenctime += enctime;      xvid_enc_plugin_t plugins[2];
         totalsize += m4v_size;  
708    
709          fprintf(stderr,"Frame %5d: intra %d, enctime =%6.1f ms length=%7d bytes\n",          xvid_gbl_init_t   xvid_gbl_init;
710                   filenr, frame_type[filenr], enctime*1000, m4v_size);          xvid_enc_create_t xvid_enc_create;
711    
712          if (save_m4v_flag)          /*------------------------------------------------------------------------
713          {           * XviD core initialization
714                  fwrite(divx_buffer, m4v_size, 1, stdout);           *----------------------------------------------------------------------*/
715    
716            /* Set version -- version checking will done by xvidcore*/
717        memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init));
718            xvid_gbl_init.version = XVID_VERSION;
719    
720    
721            /* Do we have to enable ASM optimizations ? */
722            if(use_assembler) {
723    
724    #ifdef ARCH_IS_IA64
725                    xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64;
726    #else
727                    xvid_gbl_init.cpu_flags = 0;
728    #endif
729            }
730            else {
731                    xvid_gbl_init.cpu_flags = XVID_CPU_FORCE;
732          }          }
733    
734          if (pgmflag)          /* Initialize XviD core -- Should be done once per __process__ */
735                  status = read_pgmheader(stdin);          xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);
                                 // because if this was the last PGM, stop now  
736    
737          filenr++;          /*------------------------------------------------------------------------
738             * XviD encoder initialization
739             *----------------------------------------------------------------------*/
740    
741     } while ( (!status) && (filenr<ARG_MAXFRAMENR) );          /* Version again */
742        memset(&xvid_enc_create, 0, sizeof(xvid_enc_create));
743            xvid_enc_create.version = XVID_VERSION;
744    
745            /* Width and Height of input frames */
746            xvid_enc_create.width = XDIM;
747            xvid_enc_create.height = YDIM;
748    
749        /* init plugins  */
750    
751  /*********************************************************************/      xvid_enc_create.plugins = plugins;
752  /*     calculate totals and averages for output, print results       */      xvid_enc_create.num_plugins = 0;
 /*********************************************************************/  
753    
754          totalsize    /= filenr;      if (ARG_LUMIMASKING) {
755          totalenctime /= filenr;          plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
756            plugins[xvid_enc_create.num_plugins].param = NULL;
757            xvid_enc_create.num_plugins++;
758        }
759    
760          for (i=0;i<filenr;i++)      if (ARG_DUMP) {
761          {          plugins[xvid_enc_create.num_plugins].func = xvid_plugin_dump;
762                  switch (frame_type[i])          plugins[xvid_enc_create.num_plugins].param = NULL;
763                  {          xvid_enc_create.num_plugins++;
                 case 0:  
                         Pframes++;  
                         break;  
                 case 1:  
                         Iframes++;  
                         break;  
                 case 2:  
                 default:  
                         Bframes++;  
                         break;  
764                  }                  }
765    
766    /*   plugins[xvid_enc_create.num_plugins].func = rawenc_debug;
767         plugins[xvid_enc_create.num_plugins].param = NULL;
768         xvid_enc_create.num_plugins++; */
769    
770            /* No fancy thread tests */
771            xvid_enc_create.num_threads = 0;
772    
773            /* Frame rate - Do some quick float fps = fincr/fbase hack */
774            if ((ARG_FRAMERATE - (int)ARG_FRAMERATE) < SMALL_EPS) {
775                    xvid_enc_create.fincr = 1;
776                    xvid_enc_create.fbase = (int)ARG_FRAMERATE;
777            } else {
778                    xvid_enc_create.fincr = FRAMERATE_INCR;
779                    xvid_enc_create.fbase = (int)(FRAMERATE_INCR * ARG_FRAMERATE);
780          }          }
781    
782          fprintf(stderr,"Avg: enctime %5.2f ms, %5.2f fps, filesize =%d\n",          /* Maximum key frame interval */
783                  1000*totalenctime, 1./totalenctime, totalsize);          xvid_enc_create.max_key_interval = (int)ARG_FRAMERATE*10;
784    
785  /*********************************************************************/          /* Bframes settings */
786  /*                         XviD PART  Stop                           */          xvid_enc_create.max_bframes = ARG_MAXBFRAMES;
787  /*********************************************************************/          xvid_enc_create.bquant_ratio = ARG_BQRATIO;
788            xvid_enc_create.bquant_offset = ARG_BQOFFSET;
789    
790  release_all:          /* Dropping ratio frame -- we don't need that */
791            xvid_enc_create.frame_drop_ratio = 0;
792    
793          if (enc_handle)          /* Global encoder options */
794            xvid_enc_create.global = 0;
795        if (ARG_PACKED) xvid_enc_create.global |= XVID_PACKED;
796        if (ARG_STATS) xvid_enc_create.global |= XVID_EXTRASTATS_ENABLE;
797    
798            /* I use a small value here, since will not encode whole movies, but short clips */
799            xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
800    
801            /* Retrieve the encoder instance from the structure */
802            enc_handle = xvid_enc_create.handle;
803    
804            return(xerr);
805    }
806    
807    static int enc_stop()
808          {          {
809                  status = enc_stop();          int xerr;
810                  if (status)  
811                          fprintf(stderr,"Encore RELEASE problem return value %d\n", status);          /* Destroy the encoder instance */
812            xerr = xvid_encore(enc_handle, XVID_ENC_DESTROY, NULL, NULL);
813    
814            return(xerr);
815          }          }
816    
817  free_all_memory:  static int enc_main(unsigned char* image,
818          free(divx_buffer);                                          unsigned char* bitstream,
819          free(in_buffer);                      int * key,
820                                            int *stats_type,
821                        int *stats_quant,
822                        int *stats_length,
823                                            int stats[3])
824    {
825            int ret;
826    
827    return 0;          xvid_enc_frame_t xvid_enc_frame;
828            xvid_enc_stats_t xvid_enc_stats;
829    
830            /* Version for the frame and the stats */
831        memset(&xvid_enc_frame, 0, sizeof(xvid_enc_frame));
832            xvid_enc_frame.version = XVID_VERSION;
833    
834        memset(&xvid_enc_stats, 0, sizeof(xvid_enc_stats));
835            xvid_enc_stats.version = XVID_VERSION;
836    
837            /* Bind output buffer */
838            xvid_enc_frame.bitstream = bitstream;
839            xvid_enc_frame.length = -1;
840    
841            /* Initialize input image fields */
842        if (image) {
843                xvid_enc_frame.input.plane[0]  = image;
844                xvid_enc_frame.input.csp       = XVID_CSP_I420;
845                xvid_enc_frame.input.stride[0] = XDIM;
846        }else{
847            xvid_enc_frame.input.csp       = XVID_CSP_NULL;
848        }
849    
850            /* Set up core's general features */
851            xvid_enc_frame.vol_flags = vol_presets[ARG_QUALITY];
852        if (ARG_STATS) xvid_enc_frame.vol_flags |= XVID_EXTRASTATS;
853    
854            /* Set up core's general features */
855            xvid_enc_frame.vop_flags = vop_presets[ARG_QUALITY];
856    
857            /* Frame type -- let core decide for us */
858            xvid_enc_frame.type   = XVID_TYPE_AUTO;
859    
860            /* Force the right quantizer */
861            xvid_enc_frame.quant  = ARG_QUANTI;
862    
863            /* Set up motion estimation flags */
864            xvid_enc_frame.motion = motion_presets[ARG_QUALITY];
865    
866            /* We don't use special matrices */
867            xvid_enc_frame.quant_intra_matrix = NULL;
868            xvid_enc_frame.quant_inter_matrix = NULL;
869    
870            /* Encode the frame */
871            ret = xvid_encore(enc_handle, XVID_ENC_ENCODE, &xvid_enc_frame, &xvid_enc_stats);
872    
873        *key = (xvid_enc_frame.out_flags & XVID_KEYFRAME);
874            *stats_type = xvid_enc_stats.type;
875        *stats_quant = xvid_enc_stats.quant;
876        *stats_length = xvid_enc_stats.length;
877            stats[0]   = xvid_enc_stats.sse_y;
878            stats[1]   = xvid_enc_stats.sse_u;
879            stats[2]   = xvid_enc_stats.sse_v;
880    
881            return(ret);
882  }  }

Legend:
Removed from v.376  
changed lines
  Added in v.926

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