Revision 622348f9 libavcodec/dsputil.c

View differences:

libavcodec/dsputil.c
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 2611
 * memset(blocks, 0, sizeof(DCTELEM)*6*64)
2565 2612
 */
......
2685 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 2736
    int i;
2690 2737
    int temp[64];
2691 2738
    int sum=0;
2692
//FIXME OOOPS ignore 0 term instead of mean mess
2739
    
2740
    assert(h==8);
2741
    
2693 2742
    for(i=0; i<8; i++){
2694 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);
2696
        BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-mean,src[stride*i+3]-mean);
2697
        BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-mean,src[stride*i+5]-mean);
2698
        BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-mean,src[stride*i+7]-mean);
2744
        BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]);
2745
        BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]);
2746
        BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]);
2747
        BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]);
2699 2748
        
2700 2749
        BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
2701 2750
        BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
......
2726 2775
            +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
2727 2776
    }
2728 2777
    
2778
    sum -= ABS(temp[8*0] + temp[8*4]); // -mean
2779
    
2729 2780
    return sum;
2730 2781
}
2731 2782

  
......
2911 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 3026
WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
3027
WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
2915 3028
WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
2916 3029
WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
2917 3030
WARPER8_16_SQ(rd8x8_c, rd16_c)
......
3095 3208
    c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
3096 3209
    c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
3097 3210
        
3098
    c->hadamard8_abs = hadamard8_abs_c;
3099

  
3100 3211
#define SET_CMP_FUNC(name) \
3101 3212
    c->name[0]= name ## 16_c;\
3102 3213
    c->name[1]= name ## 8x8_c;
3103 3214
    
3104 3215
    SET_CMP_FUNC(hadamard8_diff)
3216
    c->hadamard8_diff[4]= hadamard8_intra16_c;
3105 3217
    SET_CMP_FUNC(dct_sad)
3106 3218
    c->sad[0]= pix_abs16_c;
3107 3219
    c->sad[1]= pix_abs8_c;
......
3110 3222
    SET_CMP_FUNC(quant_psnr)
3111 3223
    SET_CMP_FUNC(rd)
3112 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 3230
    c->add_bytes= add_bytes_c;
3115 3231
    c->diff_bytes= diff_bytes_c;

Also available in: Unified diff