[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

revision 918, Tue Mar 11 23:39:47 2003 UTC revision 1116, Sat Aug 9 09:52:02 2003 UTC
# Line 4  Line 4 
4   *  - Console based decoding test application  -   *  - Console based decoding test application  -
5   *   *
6   *  Copyright(C) 2002-2003 Christoph Lampert   *  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 19  Line 20 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   *   *
23   * $Id: xvid_decraw.c,v 1.7.2.1 2003-03-11 23:39:47 edgomez Exp $   * $Id: xvid_decraw.c,v 1.7.2.4 2003-08-09 09:52:02 chl Exp $
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 31  Line 32 
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.
36   *   *
37   *   gcc xvid_decraw.c -lxvidcore -lm -o xvid_decraw   *  Use ./xvid_decraw -help for a list of options
  *  
  *  You have to specify the image dimensions (until the add the feature  
  *  to read this from the bitstream)  
  *  
  * Usage : xvid_decraw <-w width> <-h height> [OPTIONS]  
  * Options :  
  *  -asm           : use assembly optimizations (default=disabled)  
  *  -i string      : input filename (default=stdin)  
  *  -t integer     : input data type (raw=0, mp4u=1)  
  *  -d             : save decoder output (0 False*, !=0 True)  
  *  -m             : save mpeg4 raw stream to single files (0 False*, !=0 True)  
  *  -help          : This help message  
  * (* means default)  
38   *   *
39   ****************************************************************************/   ****************************************************************************/
40    
# Line 96  Line 84 
84  static int dec_stop();  static int dec_stop();
85  static void usage();  static void usage();
86    
87    
88    const char * type2str(int type)
89    {
90        if (type==XVID_TYPE_IVOP)
91            return "I";
92        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   *        Main program
101   ****************************************************************************/   ****************************************************************************/
# Line 105  Line 105 
105          unsigned char *mp4_buffer = NULL;          unsigned char *mp4_buffer = NULL;
106          unsigned char *mp4_ptr    = NULL;          unsigned char *mp4_ptr    = NULL;
107          unsigned char *out_buffer = NULL;          unsigned char *out_buffer = NULL;
         unsigned char *type       = NULL;  
108          int still_left_in_buffer;          int still_left_in_buffer;
         int delayed_frames;  
109          xvid_dec_stats_t xvid_dec_stats;          xvid_dec_stats_t xvid_dec_stats;
110    
111          double totaldectime;          double totaldectime;
# Line 145  Line 143 
143                  else if (strcmp("-m", argv[i]) == 0) {                  else if (strcmp("-m", argv[i]) == 0) {
144                          ARG_SAVEMPEGSTREAM = 1;                          ARG_SAVEMPEGSTREAM = 1;
145                  }                  }
146                  else if (strcmp("-help", argv[i])) {                  else if (strcmp("-help", argv[i]) == 0) {
147                          usage();                          usage();
148                          return(0);                          return(0);
149                  }                  }
# Line 204  Line 202 
202          totaldectime = 0;          totaldectime = 0;
203          totalsize = 0;          totalsize = 0;
204          filenr = 0;          filenr = 0;
         delayed_frames = 0;  
205          mp4_ptr = mp4_buffer;          mp4_ptr = mp4_buffer;
206    
207          do {          do {
# Line 272  Line 269 
269                                  totalsize += used_bytes;                                  totalsize += used_bytes;
270                          }                          }
271    
272                  }while(xvid_dec_stats.type != XVID_TYPE_IVOP &&                  }while(xvid_dec_stats.type <= 0 && still_left_in_buffer > 0);
                            xvid_dec_stats.type != XVID_TYPE_PVOP &&  
                            xvid_dec_stats.type != XVID_TYPE_BVOP &&  
                            xvid_dec_stats.type != XVID_TYPE_SVOP &&  
                            still_left_in_buffer > 0);  
273    
274                  /* Negative buffer would mean we went too far */                  /* Negative buffer would mean we went too far */
275                  if(still_left_in_buffer < 0) break;          if(still_left_in_buffer <= 0)
276                break;
                 /* Skip when decoder is buffering images because of bframes */  
                 if(xvid_dec_stats.type == XVID_TYPE_NOTHING) {  
                         delayed_frames++;  
                         continue;  
                 }  
277    
278                  /* Updated data - Count only usefull decode time */                  /* Updated data - Count only usefull decode time */
279                  totaldectime += dectime;                  totaldectime += dectime;
280    
                 /* Prints some decoding stats */  
                 switch(xvid_dec_stats.type) {  
                 case XVID_TYPE_IVOP:  
                         type = "I";  
                         break;  
                 case XVID_TYPE_PVOP:  
                         type = "P";  
                         break;  
                 case XVID_TYPE_BVOP:  
                         type = "B";  
                         break;  
                 case XVID_TYPE_SVOP:  
                         type = "S";  
                         break;  
                 }  
281    
282                  printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",                  printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",
283                             filenr, type, dectime, used_bytes);                             filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
284    
285                  /* Save individual mpeg4 stream if required */                  /* Save individual mpeg4 stream if required */
286                  if(ARG_SAVEMPEGSTREAM) {                  if(ARG_SAVEMPEGSTREAM) {
# Line 344  Line 317 
317   *     Flush decoder buffers   *     Flush decoder buffers
318   ****************************************************************************/   ****************************************************************************/
319    
320          while(delayed_frames--) {          do {
321    
322                  /* Fake vars */                  /* Fake vars */
323                  int used_bytes;                  int used_bytes;
324                  double dectime;                  double dectime;
325    
326                  /* Decode frame */          do {
327                  dectime = msecond();                  dectime = msecond();
328                  used_bytes = dec_main(NULL, out_buffer, -1, &xvid_dec_stats);                  used_bytes = dec_main(NULL, out_buffer, -1, &xvid_dec_stats);
329                  dectime = msecond() - dectime;                  dectime = msecond() - dectime;
330            }while(used_bytes>=0 && xvid_dec_stats.type <= 0);
331    
332            if (used_bytes < 0) {   /* XVID_ERR_END */
333                break;
334            }
335    
336                  /* Updated data - Count only usefull decode time */                  /* Updated data - Count only usefull decode time */
337                  totaldectime += dectime;                  totaldectime += dectime;
338    
339                  /* Prints some decoding stats */                  /* Prints some decoding stats */
340                  printf("Frame %5d: dectime(ms) =%6.1f, length(bytes) =%7d\n",          printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",
341                             filenr, dectime, used_bytes);                             filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
342    
343                  /* Save output frame if required */                  /* Save output frame if required */
344                  if (ARG_SAVEDECOUTPUT) {                  if (ARG_SAVEDECOUTPUT) {
# Line 374  Line 352 
352    
353                  filenr++;                  filenr++;
354    
355          }          }while(1);
356    
357  /*****************************************************************************  /*****************************************************************************
358   *     Calculate totals and averages for output, print results   *     Calculate totals and averages for output, print results
# Line 411  Line 389 
389  static void usage()  static void usage()
390  {  {
391    
392          fprintf(stderr, "Usage : xvid_decraw <-w width> <-h height> [OPTIONS]\n");          fprintf(stderr, "Usage : xvid_decraw [OPTIONS]\n");
393          fprintf(stderr, "Options :\n");          fprintf(stderr, "Options :\n");
394          fprintf(stderr, " -asm           : use assembly optimizations (default=disabled)\n");          fprintf(stderr, " -asm           : use assembly optimizations (default=disabled)\n");
395          fprintf(stderr, " -i string      : input filename (default=stdin)\n");          fprintf(stderr, " -i string      : input filename (default=stdin)\n");

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

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