[svn] / trunk / xvidcore / examples / xvid_stat.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/examples/xvid_stat.c

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

revision 478, Thu Sep 12 19:06:37 2002 UTC revision 479, Thu Sep 12 19:18:12 2002 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 Christoph Lampert
7     *
8     *  This program is an implementation of a part of one or more MPEG-4
9     *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
10     *  to use this software module in hardware or software products are
11     *  advised that its use may infringe existing patents or copyrights, and
12     *  any such use would be at such party's own risk.  The original
13     *  developer of this software module and his/her company, and subsequent
14     *  editors and their companies, will have no liability for use of this
15     *  software or modifications or derivatives thereof.
16   *   *
17   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
18   *      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 26 
26   *   *
27   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
28   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
29   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
30     *
31     * $Id: xvid_stat.c,v 1.5 2002-09-12 19:18:12 chl Exp $
32   *   *
33   *************************************************************************/   ****************************************************************************/
34    
35  /************************************************************************  /************************************************************************
36   *   *
# Line 107  Line 121 
121  #define MAX(A,B) ( ((A)>(B)) ? (A) : (B) )  #define MAX(A,B) ( ((A)>(B)) ? (A) : (B) )
122  #define SMALL_EPS 1e-10  #define SMALL_EPS 1e-10
123    
   
124  /* these are global variables. Not very elegant, but easy, and this is an easy program */  /* these are global variables. Not very elegant, but easy, and this is an easy program */
125    
126  int XDIM=0;  int XDIM=0;
# Line 142  Line 155 
155  }  }
156    
157    
   
158  double absdistq(int x,int y, unsigned char* buf1, int stride1, unsigned char* buf2, int stride2)  double absdistq(int x,int y, unsigned char* buf1, int stride1, unsigned char* buf2, int stride2)
159  /* returns the sum of squared distances (SSD) between two images of dimensions x times y */  /* returns the sum of squared distances (SSD) between two images of dimensions x times y */
160  {  {
# Line 433  Line 445 
445    
446    int m4v_size;    int m4v_size;
447    int frame_type[ABS_MAXFRAMENR];    int frame_type[ABS_MAXFRAMENR];
448    int Iframes=0, Pframes=0, Bframes=0, use_assembler=0;    int Iframes=0, Pframes=0, use_assembler=0;
449    double framepsnr[ABS_MAXFRAMENR];    double framepsnr[ABS_MAXFRAMENR];
450    
451    double Ipsnr=0.,Imaxpsnr=0.,Iminpsnr=999.,Ivarpsnr=0.;    double Ipsnr=0.,Imaxpsnr=0.,Iminpsnr=999.,Ivarpsnr=0.;
# Line 646  Line 658 
658                          Iframes++;                          Iframes++;
659                          Ipsnr += framepsnr[i];                          Ipsnr += framepsnr[i];
660                          break;                          break;
                 case 2:  
661                  default:                  default:
                         Bframes++;  
                         Bpsnr += framepsnr[i];  
662                          break;                          break;
663                  }                  }
664          }          }
# Line 658  Line 667 
667                  Ppsnr /= Pframes;                  Ppsnr /= Pframes;
668          if (Iframes)          if (Iframes)
669                  Ipsnr /= Iframes;                  Ipsnr /= Iframes;
         if (Bframes)  
                 Bpsnr /= Bframes;  
   
670    
671          for (i=0;i<filenr;i++)  // calculate statistics for every frametype: P,I (and B)          for (i=0;i<filenr;i++)  // calculate statistics for every frametype: P,I (and B)
672          {          {
# Line 679  Line 685 
685                          if (framepsnr[i] < Pminpsnr)                          if (framepsnr[i] < Pminpsnr)
686                                  Iminpsnr = framepsnr[i];                                  Iminpsnr = framepsnr[i];
687                          Ivarpsnr += (framepsnr[i] - Ipsnr)*(framepsnr[i] - Ipsnr) /Iframes;                          Ivarpsnr += (framepsnr[i] - Ipsnr)*(framepsnr[i] - Ipsnr) /Iframes;
688                          break;                  default:
                 case 2:  
                         if (framepsnr[i] > Bmaxpsnr)  
                                 Bmaxpsnr = framepsnr[i];  
                         if (framepsnr[i] < Pminpsnr)  
                                 Bminpsnr = framepsnr[i];  
                         Bvarpsnr += (framepsnr[i] - Bpsnr)*(framepsnr[i] - Bpsnr) /Bframes;  
689                          break;                          break;
690                  }                  }
691          }          }
# Line 699  Line 699 
699          printf("enc: %6.1f fps, dec: %6.1f fps \n",1/totalenctime, 1/totaldectime);          printf("enc: %6.1f fps, dec: %6.1f fps \n",1/totalenctime, 1/totaldectime);
700          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));
701          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));
         if (Bframes)  
                 printf("B(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Bframes,Bpsnr,Bminpsnr,Bmaxpsnr,sqrt(Bvarpsnr/filenr));  
702          printf("\n");          printf("\n");
703    
704  /*********************************************************************/  /*********************************************************************/

Legend:
Removed from v.478  
changed lines
  Added in v.479

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