[cvs] / xvidcore / src / xvid.c Repository:
ViewVC logotype

Diff of /xvidcore/src/xvid.c

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

revision 1.33.2.15, Sun Dec 8 05:38:56 2002 UTC revision 1.33.2.19, Mon Dec 30 10:49:17 2002 UTC
# Line 237  Line 237 
237    
238          /* reduced resoltuion */          /* reduced resoltuion */
239    
240            copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C;
241            add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C;
242  #ifdef ARCH_X86  #ifdef ARCH_X86
243          vfilter_31 = xvid_VFilter_31_x86;          vfilter_31 = xvid_VFilter_31_x86;
244          hfilter_31 = xvid_HFilter_31_x86;          hfilter_31 = xvid_HFilter_31_x86;
245  #else  #else
         copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C;  
         add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C;  
246          vfilter_31 = xvid_VFilter_31_C;          vfilter_31 = xvid_VFilter_31_C;
247          hfilter_31 = xvid_HFilter_31_C;          hfilter_31 = xvid_HFilter_31_C;
248  #endif  #endif
249            filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C;
250            filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C;
251    
252          /* Initialize internal colorspace transformation tables */          /* Initialize internal colorspace transformation tables */
253          colorspace_init();          colorspace_init();
# Line 354  Line 356 
356                  copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx;                  copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx;
357                  add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx;                  add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx;
358                  hfilter_31 = xvid_HFilter_31_mmx;                  hfilter_31 = xvid_HFilter_31_mmx;
359                    filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx;
360                    filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx;
361    
362                  /* image input xxx_to_yv12 related functions */                  /* image input xxx_to_yv12 related functions */
363                  yv12_to_yv12  = yv12_to_yv12_mmx;                  yv12_to_yv12  = yv12_to_yv12_mmx;
# Line 409  Line 413 
413                  add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm;                  add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm;
414    
415                  /* Quantization */                  /* Quantization */
416                    quant4_intra = quant4_intra_xmm;
417                    quant4_inter = quant4_inter_xmm;
418    
419                  dequant_intra = dequant_intra_xmm;                  dequant_intra = dequant_intra_xmm;
420                  dequant_inter = dequant_inter_xmm;                  dequant_inter = dequant_inter_xmm;
421    
# Line 437  Line 444 
444                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn;                  interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn;
445          }          }
446    
447            if ((cpu_flags & XVID_CPU_3DNOWEXT) > 0) {
448    
449                    /* Inverse DCT */
450                    idct =  idct_3dne;
451    
452                    /* Buffer transfer */
453                    transfer_8to16copy =  transfer_8to16copy_3dne;
454                    transfer_16to8copy = transfer_16to8copy_3dne;
455                    transfer_8to16sub =  transfer_8to16sub_3dne;
456                    transfer_8to16sub2 =  transfer_8to16sub2_3dne;
457                    transfer_16to8add = transfer_16to8add_3dne;
458                    transfer8x8_copy = transfer8x8_copy_3dne;
459    
460                    /* Quantization */
461                    dequant4_intra = dequant4_intra_3dne;
462                    dequant4_inter = dequant4_inter_3dne;
463                    quant_intra = quant_intra_3dne;
464                    quant_inter = quant_inter_3dne;
465                    dequant_intra = dequant_intra_3dne;
466                    dequant_inter = dequant_inter_3dne;
467    
468                    /* ME functions */
469                    calc_cbp = calc_cbp_3dne;
470                    sad16 = sad16_3dne;
471                    sad8 = sad8_3dne;
472                    sad16bi = sad16bi_3dne;
473                    sad8bi = sad8bi_3dne;
474                    dev16 = dev16_3dne;
475    
476                    /* Interpolation */
477                    interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dne;
478                    interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dne;
479                    interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne;
480            }
481    
482    
483          if ((cpu_flags & XVID_CPU_SSE2) > 0) {          if ((cpu_flags & XVID_CPU_SSE2) > 0) {
484  #ifdef EXPERIMENTAL_SSE2_CODE  #ifdef EXPERIMENTAL_SSE2_CODE
485    
# Line 509  Line 552 
552  static int  static int
553  xvid_init_convert(XVID_INIT_CONVERTINFO* convert)  xvid_init_convert(XVID_INIT_CONVERTINFO* convert)
554  {  {
555          const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);          // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP);
556          const int width = convert->width;          const int width = convert->width;
557          const int height = convert->height;          const int height = convert->height;
558          const int width2 = convert->width/2;          const int width2 = convert->width/2;
# Line 537  Line 580 
580  }  }
581    
582    
583    
584    void fill8(uint8_t * block, int size, int value)
585    {
586            int i;
587            for (i = 0; i < size; i++)
588                    block[i] = value;
589    }
590    
591    void fill16(int16_t * block, int size, int value)
592    {
593            int i;
594            for (i = 0; i < size; i++)
595                    block[i] = value;
596    }
597    
598    #define RANDOM(min,max) min + (rand() % (max-min))
599    
600    void random8(uint8_t * block, int size, int min, int max)
601    {
602            int i;
603            for (i = 0; i < size; i++)
604                    block[i] = RANDOM(min,max);
605    }
606    
607    void random16(int16_t * block, int size, int min, int max)
608    {
609            int i;
610            for (i = 0; i < size; i++)
611                    block[i] = RANDOM(min,max);
612    }
613    
614    int compare16(const int16_t * blockA, const int16_t * blockB, int size)
615    {
616            int i;
617            for (i = 0; i < size; i++)
618                    if (blockA[i] != blockB[i])
619                            return 1;
620    
621            return 0;
622    }
623    
624    
625    
626    int test_h263_intra(quanth263_intraFunc * funcA, quanth263_intraFunc * funcB,
627                                                    const char * nameA, const char * nameB,
628                                                    int min, int max)
629    {
630            int q,i;
631            int64_t timeSTART;
632            int64_t timeA = 0;
633            int64_t timeB = 0;
634            DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE);
635            DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE);
636            DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE);
637    
638            for (q = 1; q <= 31; q++)       /* quantizer */
639            {
640                    for (i = min; i < max; i++)     /* input coeff */
641                    {
642                            fill16(arrayX, 64, i);
643    
644                            timeSTART = read_counter();
645                            funcA(arrayA, arrayX, q, q);
646                            timeA += read_counter() - timeSTART;
647    
648                            timeSTART = read_counter();
649                            funcB(arrayB, arrayX, q, q);
650                            timeB += read_counter() - timeSTART;
651    
652                            if (compare16(arrayA, arrayB, 64))
653                            {
654                                    printf("%s/%s error: q=%i, i=%i\n", nameA?nameA:"?", nameB?nameB:"?", q, i);
655                                    return 0;
656                            }
657                    }
658            }
659    
660            if (nameA) printf("%s:\t%I64i\n", nameA, timeA);
661            if (nameB) printf("%s:\t%I64i\n", nameB, timeB);
662    
663            return 0;
664    }
665    
666    int test_h263_inter(quanth263_interFunc * funcA, quanth263_interFunc * funcB,
667                                                    const char * nameA, const char * nameB,
668                                                    int min, int max)
669    {
670            int q,i;
671            int64_t timeSTART;
672            int64_t timeA = 0;
673            int64_t timeB = 0;
674            DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE);
675            DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE);
676            DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE);
677    
678            for (q = 1; q <= 31; q++)       /* quantizer */
679            {
680                    for (i = min; i < max; i++)     /* input coeff */
681                    {
682                            fill16(arrayX, 64, i);
683    
684                            timeSTART = read_counter();
685                            funcA(arrayA, arrayX, q);
686                            timeA += read_counter() - timeSTART;
687    
688                            timeSTART = read_counter();
689                            funcB(arrayB, arrayX, q);
690                            timeB += read_counter() - timeSTART;
691    
692                            if (compare16(arrayA, arrayB, 64))
693                            {
694                                    printf("%s/%s error: q=%i, i=%i\n", nameA?nameA:"?", nameB?nameB:"?", q, i);
695                                    return 0;
696                            }
697                    }
698            }
699    
700            if (nameA) printf("%s:\t%I64i\n", nameA, timeA);
701            if (nameB) printf("%s:\t%I64i\n", nameB, timeB);
702    
703            return 0;
704    }
705    
706    
707    
708    int xvid_init_test()
709    {
710            int cpu_flags;
711    
712            printf("xvid_init_test\n");
713    
714    #if defined(ARCH_X86)
715            cpu_flags = check_cpu_features();
716    
717            emms_mmx();
718    
719            printf("--- quant intra ---\n");
720            if (cpu_flags & XVID_CPU_MMX)
721                    test_h263_intra(quant_intra_c, quant_intra_mmx, "c", "mmx", -2048, 2047);
722            if (cpu_flags & XVID_CPU_3DNOWEXT)
723                    test_h263_intra(quant_intra_c, quant_intra_3dne, NULL, "3dne", -2048, 2047);
724            if (cpu_flags & XVID_CPU_SSE2)
725                    test_h263_intra(quant_intra_c, quant_intra_sse2, NULL, "sse2", -2048, 2047);
726    
727            printf("\n--- quant inter ---\n");
728            if (cpu_flags & XVID_CPU_MMX)
729                    test_h263_inter(quant_inter_c, quant_inter_mmx, "c", "mmx", -2048, 2047);
730            if (cpu_flags & XVID_CPU_3DNOWEXT)
731                    test_h263_inter(quant_inter_c, quant_inter_3dne, NULL, "3dne", -2048, 2047);
732            if (cpu_flags & XVID_CPU_SSE2)
733                    test_h263_inter(quant_inter_c, quant_inter_sse2, NULL, "sse2", -2048, 2047);
734    
735            printf("\n--- dequan intra ---\n");
736            if (cpu_flags & XVID_CPU_MMX)
737                    test_h263_intra(dequant_intra_c, dequant_intra_mmx, "c", "mmx", -256, 255);
738            if (cpu_flags & XVID_CPU_MMXEXT)
739                    test_h263_intra(dequant_intra_c, dequant_intra_xmm, NULL, "xmm", -256, 255);
740            if (cpu_flags & XVID_CPU_3DNOWEXT)
741                    test_h263_intra(dequant_intra_c, dequant_intra_3dne, NULL, "3dne", -256, 255);
742            if (cpu_flags & XVID_CPU_SSE2)
743                    test_h263_intra(dequant_intra_c, dequant_intra_sse2, NULL, "sse2", -256, 255);
744    
745            printf("\n--- dequant inter ---\n");
746            if (cpu_flags & XVID_CPU_MMX)
747                    test_h263_inter((quanth263_interFunc*)dequant_inter_c,
748                                                    (quanth263_interFunc*)dequant_inter_mmx, "c", "mmx", -256, 255);
749    
750            if (cpu_flags & XVID_CPU_MMXEXT)
751                    test_h263_inter((quanth263_interFunc*)dequant_inter_c,
752                                                    (quanth263_interFunc*)dequant_inter_xmm, NULL, "xmm", -256, 255);
753            if (cpu_flags & XVID_CPU_3DNOWEXT)
754                    test_h263_inter((quanth263_interFunc*)dequant_inter_c,
755                                                    (quanth263_interFunc*)dequant_inter_3dne, NULL, "3dne", -256, 255);
756            if (cpu_flags & XVID_CPU_SSE2)
757                    test_h263_inter((quanth263_interFunc*)dequant_inter_c,
758                                                    (quanth263_interFunc*)dequant_inter_sse2, NULL, "sse2", -256, 255);
759    
760            printf("\n--- quant4_intra ---\n");
761            if (cpu_flags & XVID_CPU_MMX)
762                    test_h263_intra((quanth263_intraFunc*)quant4_intra_c,
763                                                    (quanth263_intraFunc*)quant4_intra_mmx, "c", "mmx", -2048, 2047);
764            if (cpu_flags & XVID_CPU_MMXEXT)
765                    test_h263_intra((quanth263_intraFunc*)quant4_intra_c,
766                                                    (quanth263_intraFunc*)quant4_intra_xmm, NULL, "xmm", -2048, 2047);
767    
768            printf("\n--- quant4_inter ---\n");
769            if (cpu_flags & XVID_CPU_MMX)
770                    test_h263_inter((quanth263_interFunc*)quant4_inter_c,
771                                                    (quanth263_interFunc*)quant4_inter_mmx, "c", "mmx", -2048, 2047);
772            if (cpu_flags & XVID_CPU_MMXEXT)
773                    test_h263_inter((quanth263_interFunc*)quant4_inter_c,
774                                                    (quanth263_interFunc*)quant4_inter_xmm, NULL, "xmm", -2048, 2047);
775    
776    
777            printf("\n--- dequant4_intra ---\n");
778            if (cpu_flags & XVID_CPU_MMX)
779                    test_h263_intra((quanth263_intraFunc*)dequant4_intra_c,
780                                                    (quanth263_intraFunc*)dequant4_intra_mmx, "c", "mmx", -256, 255);
781            if (cpu_flags & XVID_CPU_3DNOWEXT)
782                    test_h263_intra((quanth263_intraFunc*)dequant4_intra_c,
783                                                    (quanth263_intraFunc*)dequant4_intra_3dne, NULL, "sse2", -256, 255);
784    
785            printf("\n--- dequant4_inter ---\n");
786            if (cpu_flags & XVID_CPU_MMX)
787                    test_h263_inter((quanth263_interFunc*)dequant4_inter_c,
788                                                    (quanth263_interFunc*)dequant4_inter_mmx, "c", "mmx", -256, 255);
789            if (cpu_flags & XVID_CPU_3DNOWEXT)
790                    test_h263_inter((quanth263_interFunc*)dequant4_inter_c,
791                                                    (quanth263_interFunc*)dequant4_inter_3dne, NULL, "sse2", -256, 255);
792    
793            emms_mmx();
794    
795    #endif
796    
797            return XVID_ERR_OK;
798    }
799    
800    
801  int  int
802  xvid_init(void *handle,  xvid_init(void *handle,
803                    int opt,                    int opt,
# Line 551  Line 812 
812                  case XVID_INIT_CONVERT :                  case XVID_INIT_CONVERT :
813                          return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);                          return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);
814    
815                    case XVID_INIT_TEST :
816                            return xvid_init_test();
817    
818                  default :                  default :
819                          return XVID_ERR_FAIL;                          return XVID_ERR_FAIL;
820          }          }

Legend:
Removed from v.1.33.2.15  
changed lines
  Added in v.1.33.2.19

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