[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 1794, Fri Nov 14 15:43:28 2008 UTC revision 1804, Wed Nov 26 23:37:28 2008 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.36 2008-11-14 15:43:27 Isibaar Exp $   * $Id: xvid_bench.c,v 1.38 2008-11-26 23:37:28 Isibaar Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 115  Line 115 
115    
116  CPU cpu_list[] = {  CPU cpu_list[] = {
117          { "PLAINC ", 0 },          { "PLAINC ", 0 },
118  #ifdef ARCH_IS_IA32  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
119          { "MMX    ", XVID_CPU_MMX },          { "MMX    ", XVID_CPU_MMX },
120          { "MMXEXT ", XVID_CPU_MMXEXT | XVID_CPU_MMX },          { "MMXEXT ", XVID_CPU_MMXEXT | XVID_CPU_MMX },
121          { "SSE2   ", XVID_CPU_SSE2 | XVID_CPU_MMX },          { "SSE2   ", XVID_CPU_SSE2 | XVID_CPU_MMX },
# Line 127  Line 127 
127  #ifdef ARCH_IS_PPC  #ifdef ARCH_IS_PPC
128          { "ALTIVEC", XVID_CPU_ALTIVEC },          { "ALTIVEC", XVID_CPU_ALTIVEC },
129  #endif  #endif
 #ifdef ARCH_IS_X86_64  
         { "X86_64 ", XVID_CPU_ASM},  
 #endif  
130  #ifdef ARCH_IS_IA64  #ifdef ARCH_IS_IA64
131  //      { "IA64   ", XVID_CPU_IA64 },  //      { "IA64   ", XVID_CPU_IA64 },
132  #endif  #endif
# Line 416  Line 413 
413    
414                  t = gettime_usec();                  t = gettime_usec();
415                  emms();                  emms();
416                    for(tst=0; tst<nb_tests; ++tst) s = sad8bi(Cur, Ref1, Ref2, 8);
417                    emms();
418                    t = (gettime_usec() - t) / nb_tests;
419                    printf( "%s - sad8bi %.3f usec       sad=%d %s\n",
420                                    cpu->name, t, s,
421                                    (s!=4002)?"| ERROR": "" );
422    
423                    t = gettime_usec();
424                    emms();
425                  for(tst=0; tst<nb_tests; ++tst) s = dev16(Cur, 16);                  for(tst=0; tst<nb_tests; ++tst) s = dev16(Cur, 16);
426                  emms();                  emms();
427                  t = (gettime_usec() - t) / nb_tests;                  t = (gettime_usec() - t) / nb_tests;
# Line 733  Line 739 
739    set_intra_matrix( mpeg_quant_matrices, Quant );                \    set_intra_matrix( mpeg_quant_matrices, Quant );                \
740    emms();                                   \    emms();                                   \
741    for(q=1; q<=max_Q; ++q) {                 \    for(q=1; q<=max_Q; ++q) {                 \
742            init_intra_matrix( mpeg_quant_matrices, q ); \
743          for(tst=0; tst<nb_tests; ++tst)         \          for(tst=0; tst<nb_tests; ++tst)         \
744            (FUNC)((DST), (SRC), q, q, mpeg_quant_matrices);           \            (FUNC)((DST), (SRC), q, q, mpeg_quant_matrices);           \
745          byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0]));  \          byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0]));  \
# Line 743  Line 750 
750  t = (gettime_usec()-t-overhead)/nb_tests/qm  t = (gettime_usec()-t-overhead)/nb_tests/qm
751    
752  #define TEST_INTRA(REFFUNC, NEWFUNC, RANGE)              \  #define TEST_INTRA(REFFUNC, NEWFUNC, RANGE)              \
753  { int i,q,s;\  { int32_t i,q,s;\
754          DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \          DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \
755    DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \    DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \
756    DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \    DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \
# Line 775  Line 782 
782    
783  void test_quant()  void test_quant()
784  {  {
785          const int nb_tests = 1*speed_ref;          const int32_t nb_tests = 1*speed_ref;
786          const int max_Q = 31;          const int32_t max_Q = 31;
787          DECLARE_ALIGNED_MATRIX(mpeg_quant_matrices, 8, 64, uint16_t, 16);          DECLARE_ALIGNED_MATRIX(mpeg_quant_matrices, 8, 64, uint16_t, 16);
788    
789          int i, qm;          int32_t i, qm;
790          CPU *cpu;          CPU *cpu;
791          DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16);          DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16);
792          DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16);          DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16);
# Line 798  Line 805 
805          for(cpu = cpu_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
806          {          {
807                  double t, overhead;                  double t, overhead;
808                  int tst, q;                  int32_t tst, q;
809                  uint32_t s;                  uint32_t s;
810    
811                  if (!init_cpu(cpu))                  if (!init_cpu(cpu))
# Line 822  Line 829 
829                  TEST_QUANT2(quant_mpeg_intra, Dst, Src);                  TEST_QUANT2(quant_mpeg_intra, Dst, Src);
830                  printf("%s -   quant_mpeg_intra %.3f usec       crc32=0x%08x %s\n",                  printf("%s -   quant_mpeg_intra %.3f usec       crc32=0x%08x %s\n",
831                             cpu->name, t, s,                             cpu->name, t, s,
832                             (s!=0xfd6a21a4)? "| ERROR": "");                             (s!=0x3b999af6)? "| ERROR": "");
833    
834                  TEST_QUANT(quant_mpeg_inter, Dst, Src);                  TEST_QUANT(quant_mpeg_inter, Dst, Src);
835                  printf("%s -   quant_mpeg_inter %.3f usec       crc32=0x%08x %s\n",                  printf("%s -   quant_mpeg_inter %.3f usec       crc32=0x%08x %s\n",
# Line 1723  Line 1730 
1730  t = (gettime_usec() - t) / nb_tests;  \  t = (gettime_usec() - t) / nb_tests;  \
1731          iCrc = calc_crc((uint8_t*)Dst0, sizeof(Dst0), CRC32_INITIAL)          iCrc = calc_crc((uint8_t*)Dst0, sizeof(Dst0), CRC32_INITIAL)
1732    
1733  #define TEST_YUYV(FUNC, S)                \  #define TEST_YUYV(FUNC, S, FLIP)                \
1734  ENTER                               \  ENTER                               \
1735  for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], S*WIDTH, Src0[0], Src0[1], Src0[2], WIDTH, WIDTH/2, WIDTH, HEIGHT, 0); \  for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], S*WIDTH, Src0[0], Src0[1], Src0[2], WIDTH, WIDTH/2, WIDTH, HEIGHT, (FLIP)); \
1736  LEAVE  LEAVE
1737    
1738    static const int yuv_CRCs[6][2] = {
1739            {0x0f4fb96b,0x780b6a68}
1740    ,       {0xa986b289,0x65e49b76}
1741    ,       {0x7f19c152,0xd539b86e}
1742    ,       {0x0f4fb96b,0x780b6a68}
1743    ,       {0xa986b289,0x65e49b76}
1744    ,       {0x36ab8b57,0x1cd92fee}
1745    };
1746    
1747  #define WIDTH 128  #define WIDTH 128
1748  #define HEIGHT 32  #define HEIGHT 32
1749  void test_yuv()  void test_yuv()
# Line 1736  Line 1752 
1752          CPU *cpu;          CPU *cpu;
1753          uint8_t Src0[3][WIDTH*HEIGHT];          uint8_t Src0[3][WIDTH*HEIGHT];
1754          uint8_t Dst0[4][WIDTH*HEIGHT];          uint8_t Dst0[4][WIDTH*HEIGHT];
1755          int i, j;          int i, j, with_flip;
1756          double t;          double t;
1757          int tst, iCrc;          int tst, iCrc;
1758    
# Line 1747  Line 1763 
1763    
1764          printf( "\n ===  test YUV ===\n" );          printf( "\n ===  test YUV ===\n" );
1765    
1766            for(with_flip=0; with_flip<=1; ++with_flip) {
1767    
1768          init_cpu(&cpu_list[0]);          init_cpu(&cpu_list[0]);
1769          TEST_YUYV(yv12_to_yuyv_c, 4);                  TEST_YUYV(yv12_to_yuyv_c, 4, with_flip);
1770          printf(" yv12_to_yuyv_c %.3f usec       crc32=0x%08x %s\n",          printf(" yv12_to_yuyv_c %.3f usec       crc32=0x%08x %s\n",
1771                     t, iCrc, (iCrc!=0xeb1a0b0a)?"| ERROR": "" );                             t, iCrc, (iCrc!=yuv_CRCs[0][with_flip])?"| ERROR": "" );
1772          TEST_YUYV(yv12_to_uyvy_c, 4);                  TEST_YUYV(yv12_to_uyvy_c, 4, with_flip);
1773          printf(" yv12_to_uyvy_c %.3f usec       crc32=0x%08x %s\n",          printf(" yv12_to_uyvy_c %.3f usec       crc32=0x%08x %s\n",
1774                     t, iCrc, (iCrc!=0x6e82f55b)?"| ERROR": "" );                          t, iCrc, (iCrc!=yuv_CRCs[1][with_flip])?"| ERROR": "" );
1775    
1776                    TEST_YUYV(yv12_to_bgra_c, 4, with_flip);
1777                    printf(" yv12_to_bgra_c %.3f usec       crc32=0x%08x %s\n",
1778                            t, iCrc, (iCrc!=yuv_CRCs[2][with_flip])?"| ERROR": "" );
1779    
1780  #ifdef ARCH_IS_IA32  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
1781          init_cpu(&cpu_list[1]);          init_cpu(&cpu_list[1]);
1782          TEST_YUYV(yv12_to_yuyv_mmx, 4);                  TEST_YUYV(yv12_to_yuyv_mmx, 4, with_flip);
1783          printf(" yv12_to_yuyv_mmx %.3f usec       crc32=0x%08x %s\n",          printf(" yv12_to_yuyv_mmx %.3f usec       crc32=0x%08x %s\n",
1784                  t, iCrc, (iCrc!=0xeb1a0b0a)?"| ERROR": "" );                          t, iCrc, (iCrc!=yuv_CRCs[3][with_flip])?"| ERROR": "" );
1785    
1786          TEST_YUYV(yv12_to_uyvy_mmx, 4);                  TEST_YUYV(yv12_to_uyvy_mmx, 4, with_flip);
1787          printf(" yv12_to_uyvy_mmx %.3f usec       crc32=0x%08x %s\n",          printf(" yv12_to_uyvy_mmx %.3f usec       crc32=0x%08x %s\n",
1788                  t, iCrc, (iCrc!=0x6e82f55b)?"| ERROR": "" );                          t, iCrc, (iCrc!=yuv_CRCs[4][with_flip])?"| ERROR": "" );
1789    
1790                    TEST_YUYV(yv12_to_bgra_mmx, 4, with_flip);
1791                    printf(" yv12_to_bgra_mmx %.3f usec       crc32=0x%08x %s\n",
1792                            t, iCrc, (iCrc!=yuv_CRCs[5][with_flip])?"| ERROR": "" );
1793    
1794  #endif  #endif
1795    
1796  #ifdef ARCH_IS_PPC  #ifdef ARCH_IS_PPC
1797          init_cpu(&cpu_list[1]);          init_cpu(&cpu_list[1]);
1798          TEST_YUYV(yv12_to_yuyv_altivec_c, 4);                  TEST_YUYV(yv12_to_yuyv_altivec_c, 4, with_flip);
1799          printf(" yv12_to_yuyv_altivec_c %.3f usec       crc32=0x%08x %s\n",          printf(" yv12_to_yuyv_altivec_c %.3f usec       crc32=0x%08x %s\n",
1800                  t, iCrc, (iCrc!=0xeb1a0b0a)?"| ERROR": "" );                          t, iCrc, (iCrc!=yuv_CRCs[3][with_flip])?"| ERROR": "" );
1801    
1802          TEST_YUYV(yv12_to_uyvy_altivec_c, 4);                  TEST_YUYV(yv12_to_uyvy_altivec_c, 4, with_flip);
1803          printf(" yv12_to_uyvy_altivec_c %.3f usec       crc32=0x%08x %s\n",          printf(" yv12_to_uyvy_altivec_c %.3f usec       crc32=0x%08x %s\n",
1804                  t, iCrc, (iCrc!=0x6e82f55b)?"| ERROR": "" );                          t, iCrc, (iCrc!=yuv_CRCs[4][with_flip])?"| ERROR": "" );
1805    
1806                    TEST_YUYV(yv12_to_bgra_altivec_c, 4, with_flip);
1807                    printf(" yv12_to_bgra_altivec_c %.3f usec       crc32=0x%08x %s\n",
1808                            t, iCrc, (iCrc!=yuv_CRCs[5][with_flip])?"| ERROR": "" );
1809  #endif  #endif
1810            }
1811          printf( " --- \n" );          printf( " --- \n" );
1812  }  }
1813    
# Line 1824  Line 1856 
1856                                  t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" );                                  t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" );
1857                          /* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */                          /* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */
1858    
1859  #ifdef ARCH_IS_IA32  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
1860                          init_cpu(&cpu_list[1]);                          init_cpu(&cpu_list[1]);
1861                          TEST_YV2(yv12_to_yv12_mmx, with_uv, with_flip);                          TEST_YV2(yv12_to_yv12_mmx, with_uv, with_flip);
1862                          printf(" yv12_to_yv12_mmx %.3f usec     \tcrc32=0x%08x %s\n",                          printf(" yv12_to_yv12_mmx %.3f usec     \tcrc32=0x%08x %s\n",
# Line 2062  Line 2094 
2094                  lum8x8 = lum_8x8_c;                  lum8x8 = lum_8x8_c;
2095                  lum2x8 = lum_2x8_c;                  lum2x8 = lum_2x8_c;
2096                  csim   = consim_c;                  csim   = consim_c;
2097  #ifdef ARCH_IS_IA32  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
2098                  if (cpu->cpu & XVID_CPU_MMX){                  if (cpu->cpu & XVID_CPU_MMX){
2099                          lum8x8 = lum_8x8_mmx;                          lum8x8 = lum_8x8_mmx;
2100                          csim = consim_mmx;                          csim = consim_mmx;
# Line 2259  Line 2291 
2291                             "    may appear to be slow.\n");                             "    may appear to be slow.\n");
2292          }          }
2293    
2294  #ifdef ARCH_IS_IA32  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
2295          if (what == 0 || what == 5) {          if (what == 0 || what == 5) {
2296                  printf("\n"                  printf("\n"
2297                             "NB: MMX mpeg4 quantization is known to have very small errors (+/-1 magnitude)\n"                             "NB: MMX mpeg4 quantization is known to have very small errors (+/-1 magnitude)\n"

Legend:
Removed from v.1794  
changed lines
  Added in v.1804

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