[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 151, Mon Apr 29 07:23:16 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 65  Line 79 
79  #include <math.h>               // needed for log10  #include <math.h>               // needed for log10
80  #include <sys/time.h>           // only needed for gettimeofday  #include <sys/time.h>           // only needed for gettimeofday
81    
82  #include "xvid.h"               /* comes with XviD */  #include "../src/xvid.h"                /* comes with XviD */
83    
84  int motion_presets[7] = {  int motion_presets[7] = {
85          0,                                                              // Q 0          0,                                                              // Q 0
# 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 262  Line 274 
274  #define FRAMERATE_INCR 1001  #define FRAMERATE_INCR 1001
275    
276    
277  int enc_init()  int enc_init(int use_assembler)
278  {       /* initialize encoder for first use, pass all needed parameters to the codec */  {       /* initialize encoder for first use, pass all needed parameters to the codec */
279          int xerr;          int xerr;
280    
281          XVID_INIT_PARAM xinit;          XVID_INIT_PARAM xinit;
282          XVID_ENC_PARAM xparam;          XVID_ENC_PARAM xparam;
283    
284            if(use_assembler)
285    
286    #ifdef ARCH_IA64
287                    xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64;
288    #else
289                    xinit.cpu_flags = 0;
290    #endif
291    
292            else
293          xinit.cpu_flags = XVID_CPU_FORCE;          xinit.cpu_flags = XVID_CPU_FORCE;
294    
295          xvid_init(NULL, 0, &xinit, NULL);          xvid_init(NULL, 0, &xinit, NULL);
296    
297          xparam.width = XDIM;          xparam.width = XDIM;
# Line 350  Line 372 
372  /* Routines for decoding: init encoder, frame step, release encoder  */  /* Routines for decoding: init encoder, frame step, release encoder  */
373  /*********************************************************************/  /*********************************************************************/
374    
375  int dec_init()  /* init decoder before first run */  int dec_init(int use_assembler) /* init decoder before first run */
376  {  {
377          int xerr;          int xerr;
378    
379          XVID_INIT_PARAM xinit;          XVID_INIT_PARAM xinit;
380          XVID_DEC_PARAM xparam;          XVID_DEC_PARAM xparam;
381    
382                    if(use_assembler)
383    
384    #ifdef ARCH_IA64
385                            xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64;
386    #else
387          xinit.cpu_flags = 0;          xinit.cpu_flags = 0;
388    #endif
389    
390                    else
391                            xinit.cpu_flags = XVID_CPU_FORCE;
392    
393          xvid_init(NULL, 0, &xinit, NULL);          xvid_init(NULL, 0, &xinit, NULL);
394          xparam.width = XDIM;          xparam.width = XDIM;
395          xparam.height = YDIM;          xparam.height = YDIM;
# Line 413  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;    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 429  Line 461 
461    {    {
462          pgmflag = 1;          pgmflag = 1;
463    
464            if (argc==2 && !strcmp(argv[1],"-asm"))
465              use_assembler = 1;
466          if (argc>=3)          if (argc>=3)
467          {       XDIM = atoi(argv[1]);          {       XDIM = atoi(argv[1]);
468                  YDIM = atoi(argv[2]);                  YDIM = atoi(argv[2]);
# Line 505  Line 539 
539  /*********************************************************************/  /*********************************************************************/
540    
541    
542          status = enc_init();    status = enc_init(use_assembler);
543          if (status)          if (status)
544          {          {
545                  printf("Encore INIT problem, return value %d\n", status);                  printf("Encore INIT problem, return value %d\n", status);
546                  goto release_all;                  goto release_all;
547          }          }
548    
549          status = dec_init();          status = dec_init(use_assembler);
550          if (status)          if (status)
551          {          {
552                  printf("Decore INIT problem, return value %d\n", status);                  printf("Decore INIT problem, return value %d\n", status);
# Line 624  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 636  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 657  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 677  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.151  
changed lines
  Added in v.479

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