[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 945, Wed Mar 26 10:29:51 2003 UTC
# Line 19  Line 19 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   * $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.2 2003-03-26 10:29:10 suxen_drol Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 96  Line 96 
96  static int dec_stop();  static int dec_stop();
97  static void usage();  static void usage();
98    
99    
100    const char * type2str(int type)
101    {
102        if (type==XVID_TYPE_IVOP)
103            return "I";
104        if (type==XVID_TYPE_PVOP)
105            return "P";
106        if (type==XVID_TYPE_BVOP)
107            return "B";
108        return "S";
109    }
110    
111  /*****************************************************************************  /*****************************************************************************
112   *        Main program   *        Main program
113   ****************************************************************************/   ****************************************************************************/
# Line 105  Line 117 
117          unsigned char *mp4_buffer = NULL;          unsigned char *mp4_buffer = NULL;
118          unsigned char *mp4_ptr    = NULL;          unsigned char *mp4_ptr    = NULL;
119          unsigned char *out_buffer = NULL;          unsigned char *out_buffer = NULL;
         unsigned char *type       = NULL;  
120          int still_left_in_buffer;          int still_left_in_buffer;
         int delayed_frames;  
121          xvid_dec_stats_t xvid_dec_stats;          xvid_dec_stats_t xvid_dec_stats;
122    
123          double totaldectime;          double totaldectime;
# Line 204  Line 214 
214          totaldectime = 0;          totaldectime = 0;
215          totalsize = 0;          totalsize = 0;
216          filenr = 0;          filenr = 0;
         delayed_frames = 0;  
217          mp4_ptr = mp4_buffer;          mp4_ptr = mp4_buffer;
218    
219          do {          do {
# Line 272  Line 281 
281                                  totalsize += used_bytes;                                  totalsize += used_bytes;
282                          }                          }
283    
284                  }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);  
285    
286                  /* Negative buffer would mean we went too far */                  /* Negative buffer would mean we went too far */
287                  if(still_left_in_buffer < 0) break;          if(still_left_in_buffer <= 0)
288                break;
                 /* Skip when decoder is buffering images because of bframes */  
                 if(xvid_dec_stats.type == XVID_TYPE_NOTHING) {  
                         delayed_frames++;  
                         continue;  
                 }  
289    
290                  /* Updated data - Count only usefull decode time */                  /* Updated data - Count only usefull decode time */
291                  totaldectime += dectime;                  totaldectime += dectime;
292    
                 /* 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;  
                 }  
293    
294                  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",
295                             filenr, type, dectime, used_bytes);                             filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
296    
297                  /* Save individual mpeg4 stream if required */                  /* Save individual mpeg4 stream if required */
298                  if(ARG_SAVEMPEGSTREAM) {                  if(ARG_SAVEMPEGSTREAM) {
# Line 344  Line 329 
329   *     Flush decoder buffers   *     Flush decoder buffers
330   ****************************************************************************/   ****************************************************************************/
331    
332          while(delayed_frames--) {          do {
333    
334                  /* Fake vars */                  /* Fake vars */
335                  int used_bytes;                  int used_bytes;
336                  double dectime;                  double dectime;
337    
338                  /* Decode frame */          do {
339                  dectime = msecond();                  dectime = msecond();
340                  used_bytes = dec_main(NULL, out_buffer, -1, &xvid_dec_stats);                  used_bytes = dec_main(NULL, out_buffer, -1, &xvid_dec_stats);
341                  dectime = msecond() - dectime;                  dectime = msecond() - dectime;
342            }while(used_bytes>=0 && xvid_dec_stats.type <= 0);
343    
344            if (used_bytes < 0) {   /* XVID_ERR_END */
345                break;
346            }
347    
348                  /* Updated data - Count only usefull decode time */                  /* Updated data - Count only usefull decode time */
349                  totaldectime += dectime;                  totaldectime += dectime;
350    
351                  /* Prints some decoding stats */                  /* Prints some decoding stats */
352                  printf("Frame %5d: dectime(ms) =%6.1f, length(bytes) =%7d\n",          printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",
353                             filenr, dectime, used_bytes);                             filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
354    
355                  /* Save output frame if required */                  /* Save output frame if required */
356                  if (ARG_SAVEDECOUTPUT) {                  if (ARG_SAVEDECOUTPUT) {
# Line 374  Line 364 
364    
365                  filenr++;                  filenr++;
366    
367          }          }while(1);
368    
369  /*****************************************************************************  /*****************************************************************************
370   *     Calculate totals and averages for output, print results   *     Calculate totals and averages for output, print results

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

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