comparison dsputil.c @ 3010:533c6386eca9 libavcodec

8x8 integer dct from x264 as cmp function (under CONFIG_GPL) if this gives better quality then SATD then someone should port the x86 code too or maybe we could even just call it from libx264 the 4x4 one could be tried too ...
author michael
date Wed, 04 Jan 2006 16:31:23 +0000
parents bfabfdf9ce55
children b6a90fabaa76
comparison
equal deleted inserted replaced
3009:f5898b9b8a8a 3010:533c6386eca9
3113 cmp[i]= c->sse[i]; 3113 cmp[i]= c->sse[i];
3114 break; 3114 break;
3115 case FF_CMP_DCT: 3115 case FF_CMP_DCT:
3116 cmp[i]= c->dct_sad[i]; 3116 cmp[i]= c->dct_sad[i];
3117 break; 3117 break;
3118 case FF_CMP_DCT264:
3119 cmp[i]= c->dct264_sad[i];
3120 break;
3118 case FF_CMP_DCTMAX: 3121 case FF_CMP_DCTMAX:
3119 cmp[i]= c->dct_max[i]; 3122 cmp[i]= c->dct_max[i];
3120 break; 3123 break;
3121 case FF_CMP_PSNR: 3124 case FF_CMP_PSNR:
3122 cmp[i]= c->quant_psnr[i]; 3125 cmp[i]= c->quant_psnr[i];
3339 sum+= ABS(temp[i]); 3342 sum+= ABS(temp[i]);
3340 3343
3341 return sum; 3344 return sum;
3342 } 3345 }
3343 3346
3347 #ifdef CONFIG_GPL
3348 #define DCT8_1D {\
3349 const int s07 = SRC(0) + SRC(7);\
3350 const int s16 = SRC(1) + SRC(6);\
3351 const int s25 = SRC(2) + SRC(5);\
3352 const int s34 = SRC(3) + SRC(4);\
3353 const int a0 = s07 + s34;\
3354 const int a1 = s16 + s25;\
3355 const int a2 = s07 - s34;\
3356 const int a3 = s16 - s25;\
3357 const int d07 = SRC(0) - SRC(7);\
3358 const int d16 = SRC(1) - SRC(6);\
3359 const int d25 = SRC(2) - SRC(5);\
3360 const int d34 = SRC(3) - SRC(4);\
3361 const int a4 = d16 + d25 + (d07 + (d07>>1));\
3362 const int a5 = d07 - d34 - (d25 + (d25>>1));\
3363 const int a6 = d07 + d34 - (d16 + (d16>>1));\
3364 const int a7 = d16 - d25 + (d34 + (d34>>1));\
3365 DST(0, a0 + a1 ) ;\
3366 DST(1, a4 + (a7>>2)) ;\
3367 DST(2, a2 + (a3>>1)) ;\
3368 DST(3, a5 + (a6>>2)) ;\
3369 DST(4, a0 - a1 ) ;\
3370 DST(5, a6 - (a5>>2)) ;\
3371 DST(6, (a2>>1) - a3 ) ;\
3372 DST(7, (a4>>2) - a7 ) ;\
3373 }
3374
3375 static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3376 MpegEncContext * const s= (MpegEncContext *)c;
3377 int16_t dct[8][8];
3378 int i;
3379 int sum=0;
3380
3381 s->dsp.diff_pixels(dct, src1, src2, stride);
3382
3383 #define SRC(x) dct[i][x]
3384 #define DST(x,v) dct[i][x]= v
3385 for( i = 0; i < 8; i++ )
3386 DCT8_1D
3387 #undef SRC
3388 #undef DST
3389
3390 #define SRC(x) dct[x][i]
3391 #define DST(x,v) sum += ABS(v)
3392 for( i = 0; i < 8; i++ )
3393 DCT8_1D
3394 #undef SRC
3395 #undef DST
3396 return sum;
3397 }
3398 #endif
3399
3344 static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ 3400 static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3345 MpegEncContext * const s= (MpegEncContext *)c; 3401 MpegEncContext * const s= (MpegEncContext *)c;
3346 uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8]; 3402 uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
3347 DCTELEM * const temp= (DCTELEM*)aligned_temp; 3403 DCTELEM * const temp= (DCTELEM*)aligned_temp;
3348 int sum=0, i; 3404 int sum=0, i;
3585 } 3641 }
3586 3642
3587 WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c) 3643 WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
3588 WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c) 3644 WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
3589 WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c) 3645 WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
3646 WARPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
3590 WARPER8_16_SQ(dct_max8x8_c, dct_max16_c) 3647 WARPER8_16_SQ(dct_max8x8_c, dct_max16_c)
3591 WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) 3648 WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
3592 WARPER8_16_SQ(rd8x8_c, rd16_c) 3649 WARPER8_16_SQ(rd8x8_c, rd16_c)
3593 WARPER8_16_SQ(bit8x8_c, bit16_c) 3650 WARPER8_16_SQ(bit8x8_c, bit16_c)
3594 3651
3868 3925
3869 SET_CMP_FUNC(hadamard8_diff) 3926 SET_CMP_FUNC(hadamard8_diff)
3870 c->hadamard8_diff[4]= hadamard8_intra16_c; 3927 c->hadamard8_diff[4]= hadamard8_intra16_c;
3871 SET_CMP_FUNC(dct_sad) 3928 SET_CMP_FUNC(dct_sad)
3872 SET_CMP_FUNC(dct_max) 3929 SET_CMP_FUNC(dct_max)
3930 SET_CMP_FUNC(dct264_sad)
3873 c->sad[0]= pix_abs16_c; 3931 c->sad[0]= pix_abs16_c;
3874 c->sad[1]= pix_abs8_c; 3932 c->sad[1]= pix_abs8_c;
3875 c->sse[0]= sse16_c; 3933 c->sse[0]= sse16_c;
3876 c->sse[1]= sse8_c; 3934 c->sse[1]= sse8_c;
3877 c->sse[2]= sse4_c; 3935 c->sse[2]= sse4_c;