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

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

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

trunk/xvidcore/examples/xvid_decraw.c revision 376, Sat Aug 17 20:03:36 2002 UTC branches/dev-api-4/xvidcore/examples/xvid_decraw.c revision 1116, Sat Aug 9 09:52:02 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 decoding test application  -
5     *
6     *  Copyright(C) 2002-2003 Christoph Lampert
7     *               2002-2003 Edouard Gomez <ed.gomez@free.fr>
8   *   *
9   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
10   *      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 18 
18   *   *
19   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
20   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
21   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22     *
23     * $Id: xvid_decraw.c,v 1.7.2.4 2003-08-09 09:52:02 chl Exp $
24   *   *
25   *************************************************************************/   ****************************************************************************/
26    
27  /************************************************************************  /*****************************************************************************
28   *   *
29   *  Test routine for XviD decoding   *  Application notes :
  *  (C) Christoph Lampert, 2002/08/17  
30   *   *
31   *  An MPEG-4 bitstream is read from stdin and decoded,   *  An MPEG-4 bitstream is read from an input file (or stdin) and decoded,
32   *  the speed for this is measured   *  the speed for this is measured.
33   *   *
34   *  The program is plain C and needs no libraries except for libxvidcore,   *  The program is plain C and needs no libraries except for libxvidcore,
35   *  and maths-lib, so with UN*X you simply compile by   *  and maths-lib.
  *  
  *   gcc xvid_decraw.c -lxvidcore -lm -o xvid_decraw  
36   *   *
37   *  You have to specify the image dimensions (until the add the feature   *  Use ./xvid_decraw -help for a list of options
  *  to read this from the bitstream)  
38   *   *
39   *  Parameters are: xvid_stat XDIM YDIM   ****************************************************************************/
  *  
  *  output and indivual m4v-files are saved, if corresponding flags are set  
  *  
  ************************************************************************/  
40    
41  #include <stdio.h>  #include <stdio.h>
42  #include <stdlib.h>  #include <stdlib.h>
43  #include <math.h>               // needed for log10  #include <string.h>
44  #include <sys/time.h>           // only needed for gettimeofday  #include <math.h>
45    #ifndef WIN32
46    #include <sys/time.h>
47    #else
48    #include <time.h>
49    #endif
50    
51  #include "../src/xvid.h"                /* comes with XviD */  #include "xvid.h"
52    
53  #define ABS_MAXFRAMENR 9999               // max number of frames  /*****************************************************************************
54     *               Global vars in module and constants
55     ****************************************************************************/
56    
57  int XDIM=720;  /* max number of frames */
58  int YDIM=576;  #define ABS_MAXFRAMENR 9999
 int i,filenr = 0;  
59    
60  int save_dec_flag = 1;          // save decompressed bytestream?  static int XDIM = 0;
61  int save_m4v_flag = 0;          // save bytestream itself?  static int YDIM = 0;
62    static int ARG_SAVEDECOUTPUT = 0;
63    static int ARG_SAVEMPEGSTREAM = 0;
64    static char *ARG_INPUTFILE = NULL;
65    
 char filepath[256] = "./";      // the path where to save output  
66    
67  void *dec_handle = NULL;                // handle for decoding  static char filepath[256] = "./";
68    static void *dec_handle = NULL;
69    
70  /*********************************************************************/  # define BUFFER_SIZE (2*1024*1024)
 /*                     "statistical" functions                               */  
 /*                                                                   */  
 /*  these are not needed for decoding itself, but for measuring      */  
 /*  time (and maybe later quality), there in nothing specific to     */  
 /*  XviD in these                                                    */  
 /*                                                                   */  
 /*********************************************************************/  
71    
72  double msecond()  /*****************************************************************************
73  /* return the current time in seconds(!)  */   *               Local prototypes
74  {   ****************************************************************************/
         struct timeval  tv;  
         gettimeofday(&tv, 0);  
         return tv.tv_sec + tv.tv_usec * 1.0e-6;  
 }  
75    
76    static double msecond();
77    static int write_pgm(char *filename,
78                                             unsigned char *image);
79    static int dec_init(int use_assembler);
80    static int dec_main(unsigned char *istream,
81                                            unsigned char *ostream,
82                                            int istream_size,
83                                            xvid_dec_stats_t *xvid_dec_stats);
84    static int dec_stop();
85    static void usage();
86    
 /*********************************************************************/  
 /*                    input and output functions                         */  
 /*                                                                   */  
 /* the are small and simple routines for writing image               */  
 /* image. It's just for convenience, again nothing specific to XviD  */  
 /*                                                                   */  
 /*********************************************************************/  
87    
88  int write_pgm(char *filename, unsigned char *image)  const char * type2str(int type)
89  {  {
90          FILE *filehandle;      if (type==XVID_TYPE_IVOP)
91          filehandle=fopen(filename,"wb");          return "I";
92          if (filehandle)      if (type==XVID_TYPE_PVOP)
93            return "P";
94        if (type==XVID_TYPE_BVOP)
95            return "B";
96        return "S";
97    }
98    
99    /*****************************************************************************
100     *        Main program
101     ****************************************************************************/
102    
103    int main(int argc, char *argv[])
104          {          {
105                  fprintf(filehandle,"P5\n\n");           //          unsigned char *mp4_buffer = NULL;
106                  fprintf(filehandle,"%d %d 255\n",XDIM,YDIM*3/2);          unsigned char *mp4_ptr    = NULL;
107                  fwrite(image,XDIM,YDIM*3/2,filehandle);          unsigned char *out_buffer = NULL;
108            int still_left_in_buffer;
109            xvid_dec_stats_t xvid_dec_stats;
110    
111                  fclose(filehandle);          double totaldectime;
112                  return 0;  
113            long totalsize;
114            int status;
115    
116            int use_assembler = 0;
117    
118            char filename[256];
119    
120            FILE *in_file;
121            int filenr;
122            int i;
123    
124            printf("xvid_decraw - raw mpeg4 bitstream decoder ");
125            printf("written by Christoph Lampert 2002-2003\n\n");
126    
127    /*****************************************************************************
128     * Command line parsing
129     ****************************************************************************/
130    
131            for (i=1; i< argc; i++) {
132    
133                    if (strcmp("-asm", argv[i]) == 0 ) {
134                            use_assembler = 1;
135          }          }
136          else                  else if (strcmp("-d", argv[i]) == 0) {
137                  return 1;                          ARG_SAVEDECOUTPUT = 1;
138                    }
139                    else if (strcmp("-i", argv[i]) == 0 && i < argc - 1 ) {
140                            i++;
141                            ARG_INPUTFILE = argv[i];
142                    }
143                    else if (strcmp("-m", argv[i]) == 0) {
144                            ARG_SAVEMPEGSTREAM = 1;
145                    }
146                    else if (strcmp("-help", argv[i]) == 0) {
147                            usage();
148                            return(0);
149                    }
150                    else {
151                            usage();
152                            exit(-1);
153  }  }
154    
155            }
156    
157  int write_ppm(char *filename, unsigned char *image)  /*****************************************************************************
158  {   * Values checking
159          FILE *filehandle;   ****************************************************************************/
         filehandle=fopen(filename,"wb");  
         if (filehandle)  
         {  
                 fprintf(filehandle,"P6\n\n");           //  
                 fprintf(filehandle,"%d %d 255\n",XDIM,YDIM);  
                 fwrite(image,XDIM,YDIM*3,filehandle);  
160    
161                  fclose(filehandle);          if ( ARG_INPUTFILE == NULL || strcmp(ARG_INPUTFILE, "stdin") == 0) {
162                  return 0;                  in_file = stdin;
163            }
164            else {
165    
166                    in_file = fopen(ARG_INPUTFILE, "rb");
167                    if (in_file == NULL) {
168                            fprintf(stderr, "Error opening input file %s\n", ARG_INPUTFILE);
169                            return(-1);
170          }          }
         else  
                 return 1;  
171  }  }
172    
173  /*********************************************************************/  /*****************************************************************************
174  /* Routines for decoding: init encoder, frame step, release encoder  */   *        Memory allocation
175  /*********************************************************************/   ****************************************************************************/
176    
177  int dec_init(int use_assembler) /* init decoder before first run */          /* Memory for encoded mp4 stream */
178  {          mp4_buffer = (unsigned char *) malloc(BUFFER_SIZE);
179          int xerr;          mp4_ptr = mp4_buffer;
180            if (!mp4_buffer)
181                    goto free_all_memory;
182    
183          XVID_INIT_PARAM xinit;  /*****************************************************************************
184          XVID_DEC_PARAM xparam;   *        XviD PART  Start
185     ****************************************************************************/
186    
187                  if(use_assembler)          status = dec_init(use_assembler);
188  #ifdef ARCH_IA64          if (status) {
189                          xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64;                  fprintf(stderr,
190  #else                                  "Decore INIT problem, return value %d\n", status);
191                          xinit.cpu_flags = 0;                  goto release_all;
192  #endif          }
                 else  
                         xinit.cpu_flags = XVID_CPU_FORCE;  
193    
         xvid_init(NULL, 0, &xinit, NULL);  
         xparam.width = XDIM;  
         xparam.height = YDIM;  
194    
195          xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL);  /*****************************************************************************
196          dec_handle = xparam.handle;   *                               Main loop
197     ****************************************************************************/
198    
199            /* Fill the buffer */
200            still_left_in_buffer = fread(mp4_buffer, 1, BUFFER_SIZE, in_file);
201    
202            totaldectime = 0;
203            totalsize = 0;
204            filenr = 0;
205            mp4_ptr = mp4_buffer;
206    
207          return xerr;          do {
208  }  
209                    int mp4_size = (mp4_buffer + BUFFER_SIZE - mp4_ptr);
210                    int used_bytes = 0;
211                    double dectime;
212    
213                    /*
214                     * If the buffer is half empty or there are no more bytes in it
215                     * then fill it.
216                     */
217                    if (mp4_ptr > mp4_buffer + BUFFER_SIZE/2 ||
218                            still_left_in_buffer <= 0) {
219                            int rest = (mp4_buffer + BUFFER_SIZE - mp4_ptr);
220    
221  int dec_main(unsigned char *m4v_buffer, unsigned char *out_buffer,int *m4v_size)                          /* Move data if needed */
222  {       /* decode one frame  */                          if (rest)
223                                    memcpy(mp4_buffer, mp4_ptr, rest);
224    
225                            /* Update mp4_ptr */
226                            mp4_ptr = mp4_buffer;
227    
228          int xerr;                          /* read new data */
229          XVID_DEC_FRAME xframe;              if(feof(in_file))
230                                    break;
231    
232          xframe.bitstream = m4v_buffer;                          still_left_in_buffer = fread(mp4_buffer + rest,
233          xframe.length = 9999;                                                                                   1,
234              xframe.image = out_buffer;                                                                                   BUFFER_SIZE - rest,
235          xframe.stride = XDIM;                                                                                   in_file);
236              xframe.colorspace = XVID_CSP_YV12;  
237                    }
238    
239    
240                    /* This loop is needed to handle VOL/NVOP reading */
241                  do {                  do {
                 xerr = xvid_decore(dec_handle, XVID_DEC_DECODE, &xframe, NULL);  
242    
243                          *m4v_size = xframe.length;                          /* Decode frame */
244                  xframe.bitstream += *m4v_size;                          dectime = msecond();
245                            used_bytes = dec_main(mp4_ptr, out_buffer, mp4_size, &xvid_dec_stats);
246                            dectime = msecond() - dectime;
247    
248                            /* Resize image buffer if needed */
249                            if(xvid_dec_stats.type == XVID_TYPE_VOL) {
250    
251                                    /* Free old output buffer*/
252                                    if(out_buffer) free(out_buffer);
253    
254                                    /* Copy witdh and height from the vol structure */
255                                    XDIM = xvid_dec_stats.data.vol.width;
256                                    YDIM = xvid_dec_stats.data.vol.height;
257    
258                  } while (*m4v_size<7);  /* this skips N-VOPs */                                  /* Allocate the new buffer */
259                                    if((out_buffer = (unsigned char*)malloc(XDIM*YDIM*4)) == NULL)
260                                            goto free_all_memory;
261                            }
262    
263          return xerr;                          /* Update buffer pointers */
264                            if(used_bytes > 0) {
265                                    mp4_ptr += used_bytes;
266                                    still_left_in_buffer -= used_bytes;
267    
268                                    /* Total size */
269                                    totalsize += used_bytes;
270  }  }
271    
272  int dec_stop()  /* close decoder to release resources */                  }while(xvid_dec_stats.type <= 0 && still_left_in_buffer > 0);
273  {  
274          int xerr;                  /* Negative buffer would mean we went too far */
275          xerr = xvid_decore(dec_handle, XVID_DEC_DESTROY, NULL, NULL);          if(still_left_in_buffer <= 0)
276                break;
277    
278            /* Updated data - Count only usefull decode time */
279                    totaldectime += dectime;
280    
281    
282          return xerr;          printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",
283                               filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
284    
285                    /* Save individual mpeg4 stream if required */
286                    if(ARG_SAVEMPEGSTREAM) {
287                            FILE *filehandle = NULL;
288    
289                            sprintf(filename, "%sframe%05d.m4v", filepath, filenr);
290                            filehandle = fopen(filename, "wb");
291                            if(!filehandle) {
292                                    fprintf(stderr,
293                                                    "Error writing single mpeg4 stream to file %s\n",
294                                                    filename);
295                            }
296                            else {
297                                    fwrite(mp4_buffer, 1, used_bytes, filehandle);
298                                    fclose(filehandle);
299                            }
300                    }
301    
302                    /* Save output frame if required */
303                    if (ARG_SAVEDECOUTPUT) {
304                            sprintf(filename, "%sdec%05d.pgm", filepath, filenr);
305                            if(write_pgm(filename,out_buffer)) {
306                                    fprintf(stderr,
307                                                    "Error writing decoded PGM frame %s\n",
308                                                    filename);
309                            }
310  }  }
311    
312                    filenr++;
313    
314  /*********************************************************************/          } while ( (status>=0) && (filenr<ABS_MAXFRAMENR));
 /*                          Main program                             */  
 /*********************************************************************/  
315    
316  int main(int argc, char *argv[])  /*****************************************************************************
317  {   *     Flush decoder buffers
318    unsigned char *divx_buffer = NULL;   ****************************************************************************/
   unsigned char *divx_ptr = NULL;  
   unsigned char *out_buffer = NULL;  
319    
320            do {
321    
322                    /* Fake vars */
323                    int used_bytes;
324    double dectime;    double dectime;
   double totaldectime=0.;  
325    
326    long totalsize=0;          do {
327    int status;                      dectime = msecond();
328                        used_bytes = dec_main(NULL, out_buffer, -1, &xvid_dec_stats);
329                        dectime = msecond() - dectime;
330            }while(used_bytes>=0 && xvid_dec_stats.type <= 0);
331    
332    int m4v_size;          if (used_bytes < 0) {   /* XVID_ERR_END */
333    int frame_type[ABS_MAXFRAMENR];              break;
334    int use_assembler=1;          }
335    
336    char filename[256];                  /* Updated data - Count only usefull decode time */
337                    totaldectime += dectime;
338    
339    FILE *filehandle;                  /* Prints some decoding stats */
340            printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",
341                               filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
342    
343          if (argc>=3)                  /* Save output frame if required */
344          {       XDIM = atoi(argv[1]);                  if (ARG_SAVEDECOUTPUT) {
345                  YDIM = atoi(argv[2]);                          sprintf(filename, "%sdec%05d.pgm", filepath, filenr);
346                  if ( (XDIM <= 0) || (XDIM >= 2048) || (YDIM <=0) || (YDIM >= 2048) )                          if(write_pgm(filename, out_buffer)) {
347                  {       fprintf(stderr,"Wrong frames size %d %d, trying PGM \n",XDIM, YDIM);                                  fprintf(stderr,
348                                                    "Error writing decoded PGM frame %s\n",
349                                                    filename);
350                  }                  }
351          }          }
         if (argc>=4 && !strcmp(argv[3],"noasm"))  
           use_assembler = 0;  
352    
353                    filenr++;
354    
355  /* allocate memory */          }while(1);
356    
357    divx_buffer = (unsigned char *) malloc(10*XDIM*YDIM);  /*****************************************************************************
358    // this should really be enough memory!   *     Calculate totals and averages for output, print results
359    if (!divx_buffer)   ****************************************************************************/
     goto free_all_memory;  
   divx_ptr = divx_buffer+10*XDIM*YDIM;  
360    
361    out_buffer = (unsigned char *) malloc(4*XDIM*YDIM);   /* YUV needs less */          totalsize    /= filenr;
362    if (!out_buffer)          totaldectime /= filenr;
     goto free_all_memory;  
363    
364            printf("Avg: dectime(ms) =%7.2f, fps =%7.2f, length(bytes) =%7d\n",
365                       totaldectime, 1000/totaldectime, (int)totalsize);
366    
367  /*********************************************************************/  /*****************************************************************************
368  /*                         XviD PART  Start                          */   *      XviD PART  Stop
369  /*********************************************************************/   ****************************************************************************/
370    
371          status = dec_init(use_assembler);   release_all:
372            if (dec_handle) {
373                    status = dec_stop();
374          if (status)          if (status)
375          {                          fprintf(stderr, "decore RELEASE problem return value %d\n", status);
                 printf("Decore INIT problem, return value %d\n", status);  
                 goto release_all;  
376          }          }
377    
378     free_all_memory:
379            free(out_buffer);
380            free(mp4_buffer);
381    
382  /*********************************************************************/          return(0);
383  /*                               Main loop                           */  }
 /*********************************************************************/  
384    
385    do  /*****************************************************************************
386     *               Usage function
387     ****************************************************************************/
388    
389    static void usage()
390      {      {
391    
392          if (divx_ptr > divx_buffer+5*XDIM*YDIM) /* buffer more than half empty */          fprintf(stderr, "Usage : xvid_decraw [OPTIONS]\n");
393          {       int rest=(divx_buffer+10*XDIM*YDIM-divx_ptr);          fprintf(stderr, "Options :\n");
394                  if (rest)          fprintf(stderr, " -asm           : use assembly optimizations (default=disabled)\n");
395                          memcpy(divx_buffer, divx_ptr, rest);          fprintf(stderr, " -i string      : input filename (default=stdin)\n");
396                  divx_ptr = divx_buffer;          fprintf(stderr, " -t integer     : input data type (raw=0, mp4u=1)\n");
397                  fread(divx_buffer+rest, 1, 5*XDIM*YDIM, stdin); /* read new data */          fprintf(stderr, " -d             : save decoder output\n");
398            fprintf(stderr, " -m             : save mpeg4 raw stream to individual files\n");
399            fprintf(stderr, " -help          : This help message\n");
400            fprintf(stderr, " (* means default)\n");
401    
402          }          }
403    
404          dectime = -msecond();  /*****************************************************************************
405          status = dec_main(divx_ptr, out_buffer, &m4v_size);   *               "helper" functions
406     ****************************************************************************/
407    
408          if (status)  /* return the current time in milli seconds */
409    static double
410    msecond()
411          {          {
412                  break;  #ifndef WIN32
413            struct timeval  tv;
414            gettimeofday(&tv, 0);
415            return((double)tv.tv_sec*1.0e3 + (double)tv.tv_usec*1.0e-3);
416    #else
417            clock_t clk;
418            clk = clock();
419            return(clk * 1000 / CLOCKS_PER_SEC);
420    #endif
421          }          }
         dectime += msecond();  
         divx_ptr += m4v_size;  
422    
423          totalsize += m4v_size;  /*****************************************************************************
424     *              output functions
425     ****************************************************************************/
426    
427    static int
428    write_pgm(char *filename,
429                      unsigned char *image)
430    {
431            int loop;
432    
433            unsigned char *y = image;
434            unsigned char *u = image + XDIM*YDIM;
435            unsigned char *v = image + XDIM*YDIM + XDIM/2*YDIM/2;
436    
437            FILE *filehandle;
438            filehandle=fopen(filename,"w+b");
439            if (filehandle) {
440    
441                    /* Write header */
442                    fprintf(filehandle,"P5\n\n%d %d 255\n", XDIM,YDIM*3/2);
443    
444          printf("Frame %5d: dectime =%6.1f ms length=%7d bytes \n",                  /* Write Y data */
445                          filenr, dectime*1000, m4v_size);                  fwrite(y, 1, XDIM*YDIM, filehandle);
446    
447          if (save_m4v_flag)                  for(loop=0; loop<YDIM/2; loop++)
448          {          {
449                  sprintf(filename, "%sframe%05d.m4v", filepath, filenr);                          /* Write U scanline */
450                  filehandle = fopen(filename, "wb");                          fwrite(u, 1, XDIM/2, filehandle);
451                  fwrite(divx_buffer, m4v_size, 1, filehandle);  
452                  fclose(filehandle);                          /* Write V scanline */
453                            fwrite(v, 1, XDIM/2, filehandle);
454    
455                            /* Update pointers */
456                            u += XDIM/2;
457                            v += XDIM/2;
458    
459          }          }
         totaldectime += dectime;  
460    
461                    /* Close file */
462                    fclose(filehandle);
463    
464  /*********************************************************************/                  return(0);
465  /*        analyse the decoded frame and compare to original          */          }
466  /*********************************************************************/          else
467                    return(1);
468    }
469    
470          if (save_dec_flag)  /*****************************************************************************
471     * Routines for decoding: init decoder, use, and stop decoder
472     ****************************************************************************/
473    
474    /* init decoder before first run */
475    static int
476    dec_init(int use_assembler)
477          {          {
478                  sprintf(filename, "%sdec%05d.pgm", filepath, filenr);          int ret;
                 write_pgm(filename,out_buffer);  
         }  
479    
480          filenr++;          xvid_gbl_init_t   xvid_gbl_init;
481            xvid_dec_create_t xvid_dec_create;
482    
483     } while ( (status>=0) && (filenr<ABS_MAXFRAMENR) );          /*------------------------------------------------------------------------
484             * XviD core initialization
485             *----------------------------------------------------------------------*/
486    
487            /* Version */
488            xvid_gbl_init.version = XVID_VERSION;
489    
490  /*********************************************************************/          /* Assembly setting */
491  /*     calculate totals and averages for output, print results       */          if(use_assembler)
492  /*********************************************************************/  #ifdef ARCH_IS_IA64
493                    xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64;
494    #else
495            xvid_gbl_init.cpu_flags = 0;
496    #endif
497            else
498                    xvid_gbl_init.cpu_flags = XVID_CPU_FORCE;
499    
500          totalsize    /= filenr;          xvid_global(NULL, 0, &xvid_gbl_init, NULL);
         totaldectime /= filenr;  
501    
502          fprintf(stderr,"Avg: dectime %5.2f ms, %5.2f fps, filesize =%d\n",          /*------------------------------------------------------------------------
503                  1000*totaldectime, 1./totaldectime, totalsize);           * XviD encoder initialization
504             *----------------------------------------------------------------------*/
505    
506  /*********************************************************************/          /* Version */
507  /*                         XviD PART  Stop                           */          xvid_dec_create.version = XVID_VERSION;
 /*********************************************************************/  
508    
509  release_all:          /*
510             * Image dimensions -- set to 0, xvidcore will resize when ever it is
511             * needed
512             */
513            xvid_dec_create.width = 0;
514            xvid_dec_create.height = 0;
515    
516            ret = xvid_decore(NULL, XVID_DEC_CREATE, &xvid_dec_create, NULL);
517    
518            dec_handle = xvid_dec_create.handle;
519    
520            return(ret);
521    }
522    
523          if (dec_handle)  /* decode one frame  */
524    static int
525    dec_main(unsigned char *istream,
526                     unsigned char *ostream,
527                     int istream_size,
528                     xvid_dec_stats_t *xvid_dec_stats)
529          {          {
530                  status = dec_stop();  
531                  if (status)          int ret;
532                          printf("Decore RELEASE problem return value %d\n", status);  
533            xvid_dec_frame_t xvid_dec_frame;
534    
535            /* Set version */
536            xvid_dec_frame.version = XVID_VERSION;
537            xvid_dec_stats->version = XVID_VERSION;
538    
539            /* No general flags to set */
540            xvid_dec_frame.general          = 0;
541    
542            /* Input stream */
543            xvid_dec_frame.bitstream        = istream;
544            xvid_dec_frame.length           = istream_size;
545    
546            /* Output frame structure */
547            xvid_dec_frame.output.plane[0]  = ostream;
548            xvid_dec_frame.output.stride[0] = XDIM;
549            xvid_dec_frame.output.csp       = XVID_CSP_I420;
550    
551            ret = xvid_decore(dec_handle, XVID_DEC_DECODE, &xvid_dec_frame, xvid_dec_stats);
552    
553            return(ret);
554          }          }
555    
556  free_all_memory:  /* close decoder to release resources */
557          free(out_buffer);  static int
558          free(divx_buffer);  dec_stop()
559    {
560            int ret;
561    
562            ret = xvid_decore(dec_handle, XVID_DEC_DESTROY, NULL, NULL);
563    
564    return 0;          return(ret);
565  }  }

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

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