summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-01-04 16:31:23 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-01-04 16:31:23 +0000
commit27c61ac53df2876b80633ec5b69229d06f466131 (patch)
tree101f0b40585121ad3c4b120f68b5ee05b66c8051
parent702200358197a0ea5ea82d1d6540c785bb04fae4 (diff)
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 ... Originally committed as revision 4811 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/avcodec.h1
-rw-r--r--libavcodec/dsputil.c58
-rw-r--r--libavcodec/dsputil.h2
3 files changed, 61 insertions, 0 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a9ab7962d3..0aafb03f4c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1402,6 +1402,7 @@ typedef struct AVCodecContext {
#define FF_CMP_W53 11
#define FF_CMP_W97 12
#define FF_CMP_DCTMAX 13
+#define FF_CMP_DCT264 14
#define FF_CMP_CHROMA 256
/**
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index 49bd1c4ca1..1bee9b969e 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -3115,6 +3115,9 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
case FF_CMP_DCT:
cmp[i]= c->dct_sad[i];
break;
+ case FF_CMP_DCT264:
+ cmp[i]= c->dct264_sad[i];
+ break;
case FF_CMP_DCTMAX:
cmp[i]= c->dct_max[i];
break;
@@ -3341,6 +3344,59 @@ static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2
return sum;
}
+#ifdef CONFIG_GPL
+#define DCT8_1D {\
+ const int s07 = SRC(0) + SRC(7);\
+ const int s16 = SRC(1) + SRC(6);\
+ const int s25 = SRC(2) + SRC(5);\
+ const int s34 = SRC(3) + SRC(4);\
+ const int a0 = s07 + s34;\
+ const int a1 = s16 + s25;\
+ const int a2 = s07 - s34;\
+ const int a3 = s16 - s25;\
+ const int d07 = SRC(0) - SRC(7);\
+ const int d16 = SRC(1) - SRC(6);\
+ const int d25 = SRC(2) - SRC(5);\
+ const int d34 = SRC(3) - SRC(4);\
+ const int a4 = d16 + d25 + (d07 + (d07>>1));\
+ const int a5 = d07 - d34 - (d25 + (d25>>1));\
+ const int a6 = d07 + d34 - (d16 + (d16>>1));\
+ const int a7 = d16 - d25 + (d34 + (d34>>1));\
+ DST(0, a0 + a1 ) ;\
+ DST(1, a4 + (a7>>2)) ;\
+ DST(2, a2 + (a3>>1)) ;\
+ DST(3, a5 + (a6>>2)) ;\
+ DST(4, a0 - a1 ) ;\
+ DST(5, a6 - (a5>>2)) ;\
+ DST(6, (a2>>1) - a3 ) ;\
+ DST(7, (a4>>2) - a7 ) ;\
+}
+
+static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
+ MpegEncContext * const s= (MpegEncContext *)c;
+ int16_t dct[8][8];
+ int i;
+ int sum=0;
+
+ s->dsp.diff_pixels(dct, src1, src2, stride);
+
+#define SRC(x) dct[i][x]
+#define DST(x,v) dct[i][x]= v
+ for( i = 0; i < 8; i++ )
+ DCT8_1D
+#undef SRC
+#undef DST
+
+#define SRC(x) dct[x][i]
+#define DST(x,v) sum += ABS(v)
+ for( i = 0; i < 8; i++ )
+ DCT8_1D
+#undef SRC
+#undef DST
+ return sum;
+}
+#endif
+
static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
MpegEncContext * const s= (MpegEncContext *)c;
uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
@@ -3587,6 +3643,7 @@ static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int st
WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
+WARPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
WARPER8_16_SQ(dct_max8x8_c, dct_max16_c)
WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
WARPER8_16_SQ(rd8x8_c, rd16_c)
@@ -3870,6 +3927,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->hadamard8_diff[4]= hadamard8_intra16_c;
SET_CMP_FUNC(dct_sad)
SET_CMP_FUNC(dct_max)
+ SET_CMP_FUNC(dct264_sad)
c->sad[0]= pix_abs16_c;
c->sad[1]= pix_abs8_c;
c->sse[0]= sse16_c;
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index f9c6dff612..969fdbcb69 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -170,6 +170,7 @@ typedef struct DSPContext {
me_cmp_func w53[5];
me_cmp_func w97[5];
me_cmp_func dct_max[5];
+ me_cmp_func dct264_sad[5];
me_cmp_func me_pre_cmp[5];
me_cmp_func me_cmp[5];
@@ -366,6 +367,7 @@ static inline int get_penalty_factor(int lambda, int lambda2, int type){
case FF_CMP_W97:
return (2*lambda)>>(FF_LAMBDA_SHIFT);
case FF_CMP_SATD:
+ case FF_CMP_DCT264:
return (2*lambda)>>FF_LAMBDA_SHIFT;
case FF_CMP_RD:
case FF_CMP_PSNR: