comparison dsputil.c @ 8978:a49197cd37ce libavcodec

Adding 2 intra 8x8 cmp functions: vsad, vsse
author romansh
date Thu, 19 Feb 2009 00:30:24 +0000
parents e7d87561b42b
children a031926f7d6b
comparison
equal deleted inserted replaced
8977:82ab0b77695b 8978:a49197cd37ce
3935 } 3935 }
3936 3936
3937 return bits; 3937 return bits;
3938 } 3938 }
3939 3939
3940 static int vsad_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ 3940 #define VSAD_INTRA(size) \
3941 int score=0; 3941 static int vsad_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
3942 int x,y; 3942 int score=0; \
3943 3943 int x,y; \
3944 for(y=1; y<h; y++){ 3944 \
3945 for(x=0; x<16; x+=4){ 3945 for(y=1; y<h; y++){ \
3946 score+= FFABS(s[x ] - s[x +stride]) + FFABS(s[x+1] - s[x+1+stride]) 3946 for(x=0; x<size; x+=4){ \
3947 +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]); 3947 score+= FFABS(s[x ] - s[x +stride]) + FFABS(s[x+1] - s[x+1+stride]) \
3948 } 3948 +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]); \
3949 s+= stride; 3949 } \
3950 } 3950 s+= stride; \
3951 3951 } \
3952 return score; 3952 \
3953 } 3953 return score; \
3954 }
3955 VSAD_INTRA(8)
3956 VSAD_INTRA(16)
3954 3957
3955 static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){ 3958 static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
3956 int score=0; 3959 int score=0;
3957 int x,y; 3960 int x,y;
3958 3961
3966 3969
3967 return score; 3970 return score;
3968 } 3971 }
3969 3972
3970 #define SQ(a) ((a)*(a)) 3973 #define SQ(a) ((a)*(a))
3971 static int vsse_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ 3974 #define VSSE_INTRA(size) \
3972 int score=0; 3975 static int vsse_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
3973 int x,y; 3976 int score=0; \
3974 3977 int x,y; \
3975 for(y=1; y<h; y++){ 3978 \
3976 for(x=0; x<16; x+=4){ 3979 for(y=1; y<h; y++){ \
3977 score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) 3980 for(x=0; x<size; x+=4){ \
3978 +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); 3981 score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) \
3979 } 3982 +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); \
3980 s+= stride; 3983 } \
3981 } 3984 s+= stride; \
3982 3985 } \
3983 return score; 3986 \
3984 } 3987 return score; \
3988 }
3989 VSSE_INTRA(8)
3990 VSSE_INTRA(16)
3985 3991
3986 static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){ 3992 static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
3987 int score=0; 3993 int score=0;
3988 int x,y; 3994 int x,y;
3989 3995
4538 c->name[0]= name ## 16_c;\ 4544 c->name[0]= name ## 16_c;\
4539 c->name[1]= name ## 8x8_c; 4545 c->name[1]= name ## 8x8_c;
4540 4546
4541 SET_CMP_FUNC(hadamard8_diff) 4547 SET_CMP_FUNC(hadamard8_diff)
4542 c->hadamard8_diff[4]= hadamard8_intra16_c; 4548 c->hadamard8_diff[4]= hadamard8_intra16_c;
4549 c->hadamard8_diff[5]= hadamard8_intra8x8_c;
4543 SET_CMP_FUNC(dct_sad) 4550 SET_CMP_FUNC(dct_sad)
4544 SET_CMP_FUNC(dct_max) 4551 SET_CMP_FUNC(dct_max)
4545 #if CONFIG_GPL 4552 #if CONFIG_GPL
4546 SET_CMP_FUNC(dct264_sad) 4553 SET_CMP_FUNC(dct264_sad)
4547 #endif 4554 #endif
4553 SET_CMP_FUNC(quant_psnr) 4560 SET_CMP_FUNC(quant_psnr)
4554 SET_CMP_FUNC(rd) 4561 SET_CMP_FUNC(rd)
4555 SET_CMP_FUNC(bit) 4562 SET_CMP_FUNC(bit)
4556 c->vsad[0]= vsad16_c; 4563 c->vsad[0]= vsad16_c;
4557 c->vsad[4]= vsad_intra16_c; 4564 c->vsad[4]= vsad_intra16_c;
4565 c->vsad[5]= vsad_intra8_c;
4558 c->vsse[0]= vsse16_c; 4566 c->vsse[0]= vsse16_c;
4559 c->vsse[4]= vsse_intra16_c; 4567 c->vsse[4]= vsse_intra16_c;
4568 c->vsse[5]= vsse_intra8_c;
4560 c->nsse[0]= nsse16_c; 4569 c->nsse[0]= nsse16_c;
4561 c->nsse[1]= nsse8_c; 4570 c->nsse[1]= nsse8_c;
4562 #if CONFIG_SNOW_ENCODER 4571 #if CONFIG_SNOW_ENCODER
4563 c->w53[0]= w53_16_c; 4572 c->w53[0]= w53_16_c;
4564 c->w53[1]= w53_8_c; 4573 c->w53[1]= w53_8_c;