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

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

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

revision 484, Sun Sep 15 20:22:01 2002 UTC revision 561, Sat Sep 28 14:53:40 2002 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_stat.c,v 1.7 2002-09-15 20:22:01 edgomez Exp $   * $Id: xvid_stat.c,v 1.15 2002-09-28 14:53:40 edgomez Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 44  Line 44 
44   *  -q integer     : quality ([0..5])   *  -q integer     : quality ([0..5])
45   *  -d boolean     : save decoder output (0 False*, !=0 True)   *  -d boolean     : save decoder output (0 False*, !=0 True)
46   *  -m boolean     : save mpeg4 raw stream (0 False*, !=0 True)   *  -m boolean     : save mpeg4 raw stream (0 False*, !=0 True)
47   *  -h, -help      : prints this help message   *  -help          : prints this help message
48   *  -quant integer : fixed quantizer (disables -b setting)   *  -quant integer : fixed quantizer (disables -b setting)
49   *  (* means default)   *  (* means default)
50   *   *
# Line 65  Line 65 
65  #include <stdlib.h>  #include <stdlib.h>
66  #include <string.h>  #include <string.h>
67  #include <math.h>  #include <math.h>
68    #ifndef _MSC_VER
69    #include <sys/time.h>
70    #else
71  #include <time.h>  #include <time.h>
72    #endif
73    
74  #include "../src/xvid.h"  #include "xvid.h"
75    
76  /****************************************************************************  /****************************************************************************
77   *                               Prototypes   *                               Prototypes
# Line 194  Line 198 
198    
199          double Ipsnr=0.,Imaxpsnr=0.,Iminpsnr=999.,Ivarpsnr=0.;          double Ipsnr=0.,Imaxpsnr=0.,Iminpsnr=999.,Ivarpsnr=0.;
200          double Ppsnr=0.,Pmaxpsnr=0.,Pminpsnr=999.,Pvarpsnr=0.;          double Ppsnr=0.,Pmaxpsnr=0.,Pminpsnr=999.,Pvarpsnr=0.;
         double Bpsnr=0.,Bmaxpsnr=0.,Bminpsnr=999.,Bvarpsnr=0.;  
201    
202          char filename[256];          char filename[256];
203    
# Line 257  Line 260 
260                          i++;                          i++;
261                          ARG_SAVEMPEGSTREAM = atoi(argv[i]);                          ARG_SAVEMPEGSTREAM = atoi(argv[i]);
262                  }                  }
263                  else if (strcmp("-h", argv[i]) == 0 || strcmp("-help", argv[i])) {                  else if (strcmp("-help", argv[i])) {
264                          usage();                          usage();
265                          return(0);                          return(0);
266                  }                  }
# Line 273  Line 276 
276   ****************************************************************************/   ****************************************************************************/
277    
278          if (XDIM <= 0 || XDIM >= 2048 || YDIM <=0 || YDIM >= 2048 ) {          if (XDIM <= 0 || XDIM >= 2048 || YDIM <=0 || YDIM >= 2048 ) {
279                  fprintf(stderr,                  fprintf(stderr, "Trying to retreive width and height from PGM header\n");
                                 "Trying to retreive width and height from PGM header\n",  
                                 XDIM,  
                                 YDIM);  
280                  ARG_INPUTTYPE = 1; /* pgm */                  ARG_INPUTTYPE = 1; /* pgm */
281          }          }
282    
# Line 291  Line 291 
291          }          }
292    
293          if ( ARG_FRAMERATE <= 0) {          if ( ARG_FRAMERATE <= 0) {
294                  fprintf(stderr,"Wrong Fraterate %s \n",argv[5]);                  fprintf(stderr,"Wrong Framerate %s \n",argv[5]);
295                  return -1;                  return -1;
296          }          }
297    
# Line 422  Line 422 
422   *             Analyse the decoded frame and compare to original   *             Analyse the decoded frame and compare to original
423   ****************************************************************************/   ****************************************************************************/
424    
425                  framepsnr[filenr] = PSNR(XDIM,YDIM, in_buffer, XDIM, out_buffer, XDIM);                  framepsnr[filenr] = PSNR(XDIM,YDIM*3/2, in_buffer, XDIM, out_buffer, XDIM);
426    
427                  printf("dectime =%6.1f ms PSNR %5.2f\n",dectime, framepsnr[filenr]);                  printf("dectime =%6.1f ms PSNR %5.2f\n",dectime, framepsnr[filenr]);
428    
# Line 497  Line 497 
497    
498          /* Print all statistics */          /* Print all statistics */
499          printf("Avg. Q%1d %2s ",ARG_QUALITY, (ARG_QUANTI ? " q" : "br"));          printf("Avg. Q%1d %2s ",ARG_QUALITY, (ARG_QUANTI ? " q" : "br"));
500          printf("%04d ",MAX(ARG_QUANTI,ARG_BITRATE));          printf("%04d ",(ARG_QUANTI)?ARG_QUANTI:ARG_BITRATE);
501          printf("( %.2f bpp) ", (double)ARG_BITRATE*1000/XDIM/YDIM/ARG_FRAMERATE);          printf("( %.2f bpp) ", (double)ARG_BITRATE*1000/XDIM/YDIM/ARG_FRAMERATE);
502          printf("size %6d ",totalsize);          printf("size %6d ", (int)totalsize);
503          printf("( %4d kbps ",(int)(totalsize*8*ARG_FRAMERATE/1000));          printf("( %4d kbps ",(int)(totalsize*8*ARG_FRAMERATE/1000));
504          printf("/ %.2f bpp) ",(double)totalsize*8/XDIM/YDIM);          printf("/ %.2f bpp) ",(double)totalsize*8/XDIM/YDIM);
505          printf("enc: %6.1f fps, dec: %6.1f fps \n",1/totalenctime, 1/totaldectime);          printf("enc: %6.1f fps, dec: %6.1f fps \n",1000/totalenctime, 1000/totaldectime);
506          printf("PSNR P(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Pframes,Ppsnr,Pminpsnr,Pmaxpsnr,sqrt(Pvarpsnr/filenr));          printf("PSNR P(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Pframes,Ppsnr,Pminpsnr,Pmaxpsnr,sqrt(Pvarpsnr/filenr));
507          printf("I(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Iframes,Ipsnr,Iminpsnr,Imaxpsnr,sqrt(Ivarpsnr/filenr));          printf("I(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Iframes,Ipsnr,Iminpsnr,Imaxpsnr,sqrt(Ivarpsnr/filenr));
508          printf("\n");          printf("\n");
# Line 551  Line 551 
551  /* Return time elapsed time in miliseconds since the program started */  /* Return time elapsed time in miliseconds since the program started */
552  static double msecond()  static double msecond()
553  {  {
554    #ifndef _MSC_VER
555            struct timeval  tv;
556            gettimeofday(&tv, 0);
557            return tv.tv_sec*1.0e3 + tv.tv_usec * 1.0e-3;
558    #else
559          clock_t clk;          clock_t clk;
   
560          clk = clock();          clk = clock();
   
561          return clk * 1000 / CLOCKS_PER_SEC;          return clk * 1000 / CLOCKS_PER_SEC;
562    #endif
563  }  }
564    
565    
# Line 628  Line 631 
631          fprintf(stderr, " -q integer     : quality ([0..5])\n");          fprintf(stderr, " -q integer     : quality ([0..5])\n");
632          fprintf(stderr, " -d boolean     : save decoder output (0 False*, !=0 True)\n");          fprintf(stderr, " -d boolean     : save decoder output (0 False*, !=0 True)\n");
633          fprintf(stderr, " -m boolean     : save mpeg4 raw stream (0 False*, !=0 True)\n");          fprintf(stderr, " -m boolean     : save mpeg4 raw stream (0 False*, !=0 True)\n");
634          fprintf(stderr, " -h, -help      : prints this help message\n");          fprintf(stderr, " -help          : prints this help message\n");
635          fprintf(stderr, " -quant integer : fixed quantizer (disables -b setting)\n");          fprintf(stderr, " -quant integer : fixed quantizer (disables -b setting)\n");
636          fprintf(stderr, " (* means default)\n");          fprintf(stderr, " (* means default)\n");
637    
# Line 701  Line 704 
704  static int read_yuvdata(FILE* handle, unsigned char *image)  static int read_yuvdata(FILE* handle, unsigned char *image)
705  {  {
706    
707          if (fread(image, 1, IMAGE_SIZE(XDIM, YDIM), handle) != IMAGE_SIZE(XDIM, YDIM))          if (fread(image, 1, IMAGE_SIZE(XDIM, YDIM), handle) != (unsigned int)IMAGE_SIZE(XDIM, YDIM))
708                  return 1;                  return 1;
709          else          else
710                  return 0;                  return 0;

Legend:
Removed from v.484  
changed lines
  Added in v.561

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