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

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

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

revision 1743, Mon Oct 30 11:21:42 2006 UTC revision 1746, Wed Nov 1 07:12:26 2006 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_bench.c,v 1.33 2006-10-30 11:21:42 Skal Exp $   * $Id: xvid_bench.c,v 1.34 2006-11-01 07:12:26 Skal Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 58  Line 58 
58  #include "utils/timer.h"  #include "utils/timer.h"
59  #include "quant/quant_matrix.c"  #include "quant/quant_matrix.c"
60  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
61    #include "bitstream/bitstream.h"
62    
63  #include <math.h>  #include <math.h>
64    
# Line 2009  Line 2010 
2010      printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" );      printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" );
2011    }    }
2012  }  }
2013    
2014  /*********************************************************************  /*********************************************************************
2015   * test SSIM functions   * test SSIM functions
2016   *********************************************************************/   *********************************************************************/
# Line 2097  Line 2099 
2099  }  }
2100    
2101  /*********************************************************************  /*********************************************************************
2102     * test bitstream functions
2103     *********************************************************************/
2104    
2105    #define BIT_BUF_SIZE 2000
2106    
2107    static void test_bits()
2108    {
2109      const int nb_tests = 50*speed_ref;
2110      int tst;
2111      uint32_t Crc;
2112      uint8_t Buf[BIT_BUF_SIZE];
2113      uint32_t Extracted[BIT_BUF_SIZE*8]; /* worst case: bits read 1 by 1 */
2114      int Lens[BIT_BUF_SIZE*8];
2115      double t1;
2116    
2117    
2118      printf( "\n ===  test bitstream ===\n" );
2119      ieee_reseed(1);
2120      Crc = 0;
2121    
2122      t1 = gettime_usec();
2123      for(tst=0; tst<nb_tests; ++tst) {
2124            Bitstream bs;
2125            int m, m2, l, l2;
2126    
2127            for(l=0; l<BIT_BUF_SIZE; ++l)
2128                    Buf[l] = (uint8_t)ieee_rand(0,255);
2129    
2130            l = BIT_BUF_SIZE - ieee_rand(1,BIT_BUF_SIZE/10);
2131            BitstreamInit(&bs, (void*)(Buf+BIT_BUF_SIZE-l), l);
2132    
2133    
2134            BitstreamReset(&bs);
2135            for(l2=l*8, m=0; l2>0; m++) {
2136                    const int b = ieee_rand(1,32);
2137                    Lens[m] = b;
2138                    l2 -= b;
2139                    if (l2<0) break;
2140                    Extracted[m] = BitstreamShowBits(&bs, b);
2141                    BitstreamSkip(&bs, b);
2142    //              printf( "<= %d: %d 0x%x\n", m, b, Extracted[m]);
2143            }
2144    
2145            BitstreamReset(&bs);
2146            for(m2=0; m2<m; ++m2) {
2147                    const int b = Lens[m2];
2148                    const uint32_t v = BitstreamGetBits(&bs, b);
2149                    Crc |= (v!=Extracted[m2]);
2150    //              printf( "=> %d: %d 0x%x %c\n", m2, b, v, " *"[Crc]);
2151            }
2152      }
2153      t1 = (gettime_usec() - t1) / nb_tests;
2154      printf(" test_bits   %.3f usec   %s\n", t1, (Crc!=0)?"| ERROR": "" );
2155    }
2156    
2157    /*********************************************************************
2158   * main   * main
2159   *********************************************************************/   *********************************************************************/
2160    
# Line 2168  Line 2226 
2226          if (what==0 || what==14) test_yuv();          if (what==0 || what==14) test_yuv();
2227          if (what==0 || what==15) test_SSIM();          if (what==0 || what==15) test_SSIM();
2228          if (what==0 || what==16) test_yuv2();          if (what==0 || what==16) test_yuv2();
2229            if (what==0 || what==17) test_bits();
2230    
2231          if (what==7) {          if (what==7) {
2232                  test_IEEE1180_compliance(-256, 255, 1);                  test_IEEE1180_compliance(-256, 255, 1);

Legend:
Removed from v.1743  
changed lines
  Added in v.1746

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