comparison dsputil.c @ 1729:a4a5e7521339 libavcodec

interlaced dct decision cleanup function moved to dspcontext mmx&mmx2 optimized change SSE -> SAD as default (better quality) vbv buffer size command line option in kbyte
author michael
date Mon, 05 Jan 2004 22:57:07 +0000
parents dea5b2946999
children 07a484280a82
comparison
equal deleted inserted replaced
1728:73a3699b8375 1729:a4a5e7521339
2558 const int perm_j= permutation[j]; 2558 const int perm_j= permutation[j];
2559 block[perm_j]= temp[j]; 2559 block[perm_j]= temp[j];
2560 } 2560 }
2561 } 2561 }
2562 2562
2563 static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
2564 return 0;
2565 }
2566
2567 void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
2568 int i;
2569
2570 memset(cmp, 0, sizeof(void*)*5);
2571
2572 for(i=0; i<5; i++){
2573 switch(type&0xFF){
2574 case FF_CMP_SAD:
2575 cmp[i]= c->sad[i];
2576 break;
2577 case FF_CMP_SATD:
2578 cmp[i]= c->hadamard8_diff[i];
2579 break;
2580 case FF_CMP_SSE:
2581 cmp[i]= c->sse[i];
2582 break;
2583 case FF_CMP_DCT:
2584 cmp[i]= c->dct_sad[i];
2585 break;
2586 case FF_CMP_PSNR:
2587 cmp[i]= c->quant_psnr[i];
2588 break;
2589 case FF_CMP_BIT:
2590 cmp[i]= c->bit[i];
2591 break;
2592 case FF_CMP_RD:
2593 cmp[i]= c->rd[i];
2594 break;
2595 case FF_CMP_VSAD:
2596 cmp[i]= c->vsad[i];
2597 break;
2598 case FF_CMP_VSSE:
2599 cmp[i]= c->vsse[i];
2600 break;
2601 case FF_CMP_ZERO:
2602 cmp[i]= zero_cmp;
2603 break;
2604 default:
2605 av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n");
2606 }
2607 }
2608 }
2609
2563 /** 2610 /**
2564 * memset(blocks, 0, sizeof(DCTELEM)*6*64) 2611 * memset(blocks, 0, sizeof(DCTELEM)*6*64)
2565 */ 2612 */
2566 static void clear_blocks_c(DCTELEM *blocks) 2613 static void clear_blocks_c(DCTELEM *blocks)
2567 { 2614 {
2683 } 2730 }
2684 #endif 2731 #endif
2685 return sum; 2732 return sum;
2686 } 2733 }
2687 2734
2688 static int hadamard8_abs_c(uint8_t *src, int stride, int mean){ 2735 static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){
2689 int i; 2736 int i;
2690 int temp[64]; 2737 int temp[64];
2691 int sum=0; 2738 int sum=0;
2692 //FIXME OOOPS ignore 0 term instead of mean mess 2739
2740 assert(h==8);
2741
2693 for(i=0; i<8; i++){ 2742 for(i=0; i<8; i++){
2694 //FIXME try pointer walks 2743 //FIXME try pointer walks
2695 BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-mean,src[stride*i+1]-mean); 2744 BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]);
2696 BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-mean,src[stride*i+3]-mean); 2745 BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]);
2697 BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-mean,src[stride*i+5]-mean); 2746 BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]);
2698 BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-mean,src[stride*i+7]-mean); 2747 BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]);
2699 2748
2700 BUTTERFLY1(temp[8*i+0], temp[8*i+2]); 2749 BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
2701 BUTTERFLY1(temp[8*i+1], temp[8*i+3]); 2750 BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
2702 BUTTERFLY1(temp[8*i+4], temp[8*i+6]); 2751 BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
2703 BUTTERFLY1(temp[8*i+5], temp[8*i+7]); 2752 BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
2723 BUTTERFLYA(temp[8*0+i], temp[8*4+i]) 2772 BUTTERFLYA(temp[8*0+i], temp[8*4+i])
2724 +BUTTERFLYA(temp[8*1+i], temp[8*5+i]) 2773 +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
2725 +BUTTERFLYA(temp[8*2+i], temp[8*6+i]) 2774 +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
2726 +BUTTERFLYA(temp[8*3+i], temp[8*7+i]); 2775 +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
2727 } 2776 }
2777
2778 sum -= ABS(temp[8*0] + temp[8*4]); // -mean
2728 2779
2729 return sum; 2780 return sum;
2730 } 2781 }
2731 2782
2732 static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ 2783 static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
2909 } 2960 }
2910 2961
2911 return bits; 2962 return bits;
2912 } 2963 }
2913 2964
2965 static int vsad_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){
2966 int score=0;
2967 int x,y;
2968
2969 for(y=1; y<h; y++){
2970 for(x=0; x<16; x+=4){
2971 score+= ABS(s[x ] - s[x +stride]) + ABS(s[x+1] - s[x+1+stride])
2972 +ABS(s[x+2] - s[x+2+stride]) + ABS(s[x+3] - s[x+3+stride]);
2973 }
2974 s+= stride;
2975 }
2976
2977 return score;
2978 }
2979
2980 static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
2981 int score=0;
2982 int x,y;
2983
2984 for(y=1; y<h; y++){
2985 for(x=0; x<16; x++){
2986 score+= ABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
2987 }
2988 s1+= stride;
2989 s2+= stride;
2990 }
2991
2992 return score;
2993 }
2994
2995 #define SQ(a) ((a)*(a))
2996 static int vsse_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){
2997 int score=0;
2998 int x,y;
2999
3000 for(y=1; y<h; y++){
3001 for(x=0; x<16; x+=4){
3002 score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride])
3003 +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]);
3004 }
3005 s+= stride;
3006 }
3007
3008 return score;
3009 }
3010
3011 static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
3012 int score=0;
3013 int x,y;
3014
3015 for(y=1; y<h; y++){
3016 for(x=0; x<16; x++){
3017 score+= SQ(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
3018 }
3019 s1+= stride;
3020 s2+= stride;
3021 }
3022
3023 return score;
3024 }
3025
2914 WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c) 3026 WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
3027 WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
2915 WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c) 3028 WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
2916 WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) 3029 WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
2917 WARPER8_16_SQ(rd8x8_c, rd16_c) 3030 WARPER8_16_SQ(rd8x8_c, rd16_c)
2918 WARPER8_16_SQ(bit8x8_c, bit16_c) 3031 WARPER8_16_SQ(bit8x8_c, bit16_c)
2919 3032
3093 c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c; 3206 c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
3094 c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c; 3207 c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
3095 c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c; 3208 c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
3096 c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c; 3209 c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
3097 3210
3098 c->hadamard8_abs = hadamard8_abs_c;
3099
3100 #define SET_CMP_FUNC(name) \ 3211 #define SET_CMP_FUNC(name) \
3101 c->name[0]= name ## 16_c;\ 3212 c->name[0]= name ## 16_c;\
3102 c->name[1]= name ## 8x8_c; 3213 c->name[1]= name ## 8x8_c;
3103 3214
3104 SET_CMP_FUNC(hadamard8_diff) 3215 SET_CMP_FUNC(hadamard8_diff)
3216 c->hadamard8_diff[4]= hadamard8_intra16_c;
3105 SET_CMP_FUNC(dct_sad) 3217 SET_CMP_FUNC(dct_sad)
3106 c->sad[0]= pix_abs16_c; 3218 c->sad[0]= pix_abs16_c;
3107 c->sad[1]= pix_abs8_c; 3219 c->sad[1]= pix_abs8_c;
3108 c->sse[0]= sse16_c; 3220 c->sse[0]= sse16_c;
3109 c->sse[1]= sse8_c; 3221 c->sse[1]= sse8_c;
3110 SET_CMP_FUNC(quant_psnr) 3222 SET_CMP_FUNC(quant_psnr)
3111 SET_CMP_FUNC(rd) 3223 SET_CMP_FUNC(rd)
3112 SET_CMP_FUNC(bit) 3224 SET_CMP_FUNC(bit)
3225 c->vsad[0]= vsad16_c;
3226 c->vsad[4]= vsad_intra16_c;
3227 c->vsse[0]= vsse16_c;
3228 c->vsse[4]= vsse_intra16_c;
3113 3229
3114 c->add_bytes= add_bytes_c; 3230 c->add_bytes= add_bytes_c;
3115 c->diff_bytes= diff_bytes_c; 3231 c->diff_bytes= diff_bytes_c;
3116 c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; 3232 c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
3117 c->bswap_buf= bswap_buf; 3233 c->bswap_buf= bswap_buf;