summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/alpha/dsputil_alpha.c2
-rw-r--r--libavcodec/arm/dsputil_init_arm.c2
-rw-r--r--libavcodec/arm/dsputil_init_armv5te.c5
-rw-r--r--libavcodec/arm/dsputil_init_armv6.c5
-rw-r--r--libavcodec/arm/dsputil_init_neon.c2
-rw-r--r--libavcodec/bfin/dsputil_bfin.c22
-rw-r--r--libavcodec/dct-test.c2
-rw-r--r--libavcodec/dsputil.c15
-rw-r--r--libavcodec/ppc/dsputil_ppc.c2
-rw-r--r--libavcodec/ps2/dsputil_mmi.c3
-rw-r--r--libavcodec/sh4/dsputil_sh4.c3
-rw-r--r--libavcodec/simple_idct.c338
-rw-r--r--libavcodec/simple_idct.h11
-rw-r--r--libavcodec/simple_idct_template.c401
-rw-r--r--libavcodec/sparc/dsputil_vis.c3
-rw-r--r--libavcodec/vc1.c4
-rw-r--r--libavcodec/x86/dsputil_mmx.c2
17 files changed, 461 insertions, 361 deletions
diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c
index 32bb0fc932..039608b9ed 100644
--- a/libavcodec/alpha/dsputil_alpha.c
+++ b/libavcodec/alpha/dsputil_alpha.c
@@ -335,7 +335,7 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
put_pixels_clamped_axp_p = c->put_pixels_clamped;
add_pixels_clamped_axp_p = c->add_pixels_clamped;
- if (!avctx->lowres &&
+ if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) {
c->idct_put = ff_simple_idct_put_axp;
diff --git a/libavcodec/arm/dsputil_init_arm.c b/libavcodec/arm/dsputil_init_arm.c
index 777a2f954e..5b4b24a43e 100644
--- a/libavcodec/arm/dsputil_init_arm.c
+++ b/libavcodec/arm/dsputil_init_arm.c
@@ -80,7 +80,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
ff_put_pixels_clamped = c->put_pixels_clamped;
ff_add_pixels_clamped = c->add_pixels_clamped;
- if (!avctx->lowres) {
+ if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) {
if(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_ARM){
c->idct_put = j_rev_dct_arm_put;
diff --git a/libavcodec/arm/dsputil_init_armv5te.c b/libavcodec/arm/dsputil_init_armv5te.c
index 572e06cf36..e0224dabfb 100644
--- a/libavcodec/arm/dsputil_init_armv5te.c
+++ b/libavcodec/arm/dsputil_init_armv5te.c
@@ -29,8 +29,9 @@ void ff_prefetch_arm(void *mem, int stride, int h);
void av_cold ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx)
{
- if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) {
+ if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
+ (avctx->idct_algo == FF_IDCT_AUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) {
c->idct_put = ff_simple_idct_put_armv5te;
c->idct_add = ff_simple_idct_add_armv5te;
c->idct = ff_simple_idct_armv5te;
diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c
index 7584aeefc6..d442415aec 100644
--- a/libavcodec/arm/dsputil_init_armv6.c
+++ b/libavcodec/arm/dsputil_init_armv6.c
@@ -74,8 +74,9 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)
{
const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
- if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
+ if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
+ (avctx->idct_algo == FF_IDCT_AUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
c->idct_put = ff_simple_idct_put_armv6;
c->idct_add = ff_simple_idct_add_armv6;
c->idct = ff_simple_idct_armv6;
diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c
index 3f58dea9cd..ce45caf53e 100644
--- a/libavcodec/arm/dsputil_init_neon.c
+++ b/libavcodec/arm/dsputil_init_neon.c
@@ -177,7 +177,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
{
const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
- if (!avctx->lowres) {
+ if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) {
if (avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLENEON) {
c->idct_put = ff_simple_idct_put_neon;
diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c
index 0db2d8baf8..d06bd8e4fd 100644
--- a/libavcodec/bfin/dsputil_bfin.c
+++ b/libavcodec/bfin/dsputil_bfin.c
@@ -256,16 +256,18 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
if (avctx->dct_algo == FF_DCT_AUTO)
c->fdct = ff_bfin_fdct;
- if (avctx->idct_algo==FF_IDCT_VP3) {
- c->idct_permutation_type = FF_NO_IDCT_PERM;
- c->idct = ff_bfin_vp3_idct;
- c->idct_add = ff_bfin_vp3_idct_add;
- c->idct_put = ff_bfin_vp3_idct_put;
- } else if (avctx->idct_algo == FF_IDCT_AUTO) {
- c->idct_permutation_type = FF_NO_IDCT_PERM;
- c->idct = ff_bfin_idct;
- c->idct_add = bfin_idct_add;
- c->idct_put = bfin_idct_put;
+ if (avctx->bits_per_raw_sample <= 8) {
+ if (avctx->idct_algo == FF_IDCT_VP3) {
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ c->idct = ff_bfin_vp3_idct;
+ c->idct_add = ff_bfin_vp3_idct_add;
+ c->idct_put = ff_bfin_vp3_idct_put;
+ } else if (avctx->idct_algo == FF_IDCT_AUTO) {
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ c->idct = ff_bfin_idct;
+ c->idct_add = bfin_idct_add;
+ c->idct_put = bfin_idct_put;
+ }
}
}
diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c
index dbf9639c1e..136f5c4742 100644
--- a/libavcodec/dct-test.c
+++ b/libavcodec/dct-test.c
@@ -111,7 +111,7 @@ static const struct algo idct_tab[] = {
{ "FAANI", ff_faanidct, NO_PERM },
{ "REF-DBL", ff_ref_idct, NO_PERM },
{ "INT", j_rev_dct, MMX_PERM },
- { "SIMPLE-C", ff_simple_idct, NO_PERM },
+ { "SIMPLE-C", ff_simple_idct_8, NO_PERM },
#if HAVE_MMX
#if CONFIG_GPL
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index e2cf708940..4b26f68387 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -2237,7 +2237,7 @@ static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *s
s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
s->dct_unquantize_inter(s, temp, 0, s->qscale);
- ff_simple_idct(temp); //FIXME
+ ff_simple_idct_8(temp); //FIXME
for(i=0; i<64; i++)
sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
@@ -2878,6 +2878,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct = j_rev_dct1;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else{
+ if (avctx->bits_per_raw_sample == 10) {
+ c->idct_put = ff_simple_idct_put_10;
+ c->idct_add = ff_simple_idct_add_10;
+ c->idct = ff_simple_idct_10;
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ } else {
if(avctx->idct_algo==FF_IDCT_INT){
c->idct_put= ff_jref_idct_put;
c->idct_add= ff_jref_idct_add;
@@ -2908,11 +2914,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct_put = ff_bink_idct_put_c;
c->idct_permutation_type = FF_NO_IDCT_PERM;
}else{ //accurate/default
- c->idct_put= ff_simple_idct_put;
- c->idct_add= ff_simple_idct_add;
- c->idct = ff_simple_idct;
+ c->idct_put = ff_simple_idct_put_8;
+ c->idct_add = ff_simple_idct_add_8;
+ c->idct = ff_simple_idct_8;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}
+ }
}
c->get_pixels = get_pixels_c;
diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c
index 3bf410c2ca..c1f68fc5f7 100644
--- a/libavcodec/ppc/dsputil_ppc.c
+++ b/libavcodec/ppc/dsputil_ppc.c
@@ -178,7 +178,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
}
#endif //CONFIG_ENCODERS
- if (avctx->lowres==0) {
+ if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
if ((avctx->idct_algo == FF_IDCT_AUTO) ||
(avctx->idct_algo == FF_IDCT_ALTIVEC)) {
c->idct_put = idct_put_altivec;
diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c
index f4503a9030..585709679b 100644
--- a/libavcodec/ps2/dsputil_mmi.c
+++ b/libavcodec/ps2/dsputil_mmi.c
@@ -156,7 +156,8 @@ void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
c->get_pixels = get_pixels_mmi;
- if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2){
+ if (avctx->bits_per_raw_sample <= 8 &&
+ (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2)) {
c->idct_put= ff_mmi_idct_put;
c->idct_add= ff_mmi_idct_add;
c->idct = ff_mmi_idct;
diff --git a/libavcodec/sh4/dsputil_sh4.c b/libavcodec/sh4/dsputil_sh4.c
index 9ea48ad4a1..bf58a9cbbd 100644
--- a/libavcodec/sh4/dsputil_sh4.c
+++ b/libavcodec/sh4/dsputil_sh4.c
@@ -97,7 +97,8 @@ void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
if (!high_bit_depth)
c->clear_blocks = clear_blocks_sh4;
- if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){
+ if (avctx->bits_per_raw_sample <= 8 &&
+ (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) {
c->idct_put = idct_put;
c->idct_add = idct_add;
c->idct = idct_sh4;
diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c
index 0ffbfcaf33..b62658bdb3 100644
--- a/libavcodec/simple_idct.c
+++ b/libavcodec/simple_idct.c
@@ -25,339 +25,19 @@
* simpleidct in C.
*/
-/*
- based upon some outcommented c code from mpeg2dec (idct_mmx.c
- written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
- */
-
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mathops.h"
#include "simple_idct.h"
-#define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define ROW_SHIFT 11
-#define COL_SHIFT 20 // 6
-
-static inline void idctRowCondDC (DCTELEM * row)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
-
-#if HAVE_FAST_64BIT
-#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
- if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
- uint64_t temp = (row[0] << 3) & 0xffff;
- temp += temp << 16;
- temp += temp << 32;
- ((uint64_t *)row)[0] = temp;
- ((uint64_t *)row)[1] = temp;
- return;
- }
-#else
- if (!(((uint32_t*)row)[1] |
- ((uint32_t*)row)[2] |
- ((uint32_t*)row)[3] |
- row[1])) {
- uint32_t temp = (row[0] << 3) & 0xffff;
- temp += temp << 16;
- ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
- ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
- return;
- }
-#endif
-
- a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
- a1 = a0;
- a2 = a0;
- a3 = a0;
-
- /* no need to optimize : gcc does it */
- a0 += W2 * row[2];
- a1 += W6 * row[2];
- a2 -= W6 * row[2];
- a3 -= W2 * row[2];
-
- b0 = MUL16(W1, row[1]);
- MAC16(b0, W3, row[3]);
- b1 = MUL16(W3, row[1]);
- MAC16(b1, -W7, row[3]);
- b2 = MUL16(W5, row[1]);
- MAC16(b2, -W1, row[3]);
- b3 = MUL16(W7, row[1]);
- MAC16(b3, -W5, row[3]);
-
- if (AV_RN64A(row + 4)) {
- a0 += W4*row[4] + W6*row[6];
- a1 += - W4*row[4] - W2*row[6];
- a2 += - W4*row[4] + W2*row[6];
- a3 += W4*row[4] - W6*row[6];
-
- MAC16(b0, W5, row[5]);
- MAC16(b0, W7, row[7]);
-
- MAC16(b1, -W1, row[5]);
- MAC16(b1, -W5, row[7]);
-
- MAC16(b2, W7, row[5]);
- MAC16(b2, W3, row[7]);
-
- MAC16(b3, W3, row[5]);
- MAC16(b3, -W1, row[7]);
- }
-
- row[0] = (a0 + b0) >> ROW_SHIFT;
- row[7] = (a0 - b0) >> ROW_SHIFT;
- row[1] = (a1 + b1) >> ROW_SHIFT;
- row[6] = (a1 - b1) >> ROW_SHIFT;
- row[2] = (a2 + b2) >> ROW_SHIFT;
- row[5] = (a2 - b2) >> ROW_SHIFT;
- row[3] = (a3 + b3) >> ROW_SHIFT;
- row[4] = (a3 - b3) >> ROW_SHIFT;
-}
-
-static inline void idctSparseColPut (uint8_t *dest, int line_size,
- DCTELEM * col)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-
- /* XXX: I did that only to give same values as previous code */
- a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
- a1 = a0;
- a2 = a0;
- a3 = a0;
-
- a0 += + W2*col[8*2];
- a1 += + W6*col[8*2];
- a2 += - W6*col[8*2];
- a3 += - W2*col[8*2];
-
- b0 = MUL16(W1, col[8*1]);
- b1 = MUL16(W3, col[8*1]);
- b2 = MUL16(W5, col[8*1]);
- b3 = MUL16(W7, col[8*1]);
-
- MAC16(b0, + W3, col[8*3]);
- MAC16(b1, - W7, col[8*3]);
- MAC16(b2, - W1, col[8*3]);
- MAC16(b3, - W5, col[8*3]);
-
- if(col[8*4]){
- a0 += + W4*col[8*4];
- a1 += - W4*col[8*4];
- a2 += - W4*col[8*4];
- a3 += + W4*col[8*4];
- }
-
- if (col[8*5]) {
- MAC16(b0, + W5, col[8*5]);
- MAC16(b1, - W1, col[8*5]);
- MAC16(b2, + W7, col[8*5]);
- MAC16(b3, + W3, col[8*5]);
- }
-
- if(col[8*6]){
- a0 += + W6*col[8*6];
- a1 += - W2*col[8*6];
- a2 += + W2*col[8*6];
- a3 += - W6*col[8*6];
- }
-
- if (col[8*7]) {
- MAC16(b0, + W7, col[8*7]);
- MAC16(b1, - W5, col[8*7]);
- MAC16(b2, + W3, col[8*7]);
- MAC16(b3, - W1, col[8*7]);
- }
-
- dest[0] = cm[(a0 + b0) >> COL_SHIFT];
- dest += line_size;
- dest[0] = cm[(a1 + b1) >> COL_SHIFT];
- dest += line_size;
- dest[0] = cm[(a2 + b2) >> COL_SHIFT];
- dest += line_size;
- dest[0] = cm[(a3 + b3) >> COL_SHIFT];
- dest += line_size;
- dest[0] = cm[(a3 - b3) >> COL_SHIFT];
- dest += line_size;
- dest[0] = cm[(a2 - b2) >> COL_SHIFT];
- dest += line_size;
- dest[0] = cm[(a1 - b1) >> COL_SHIFT];
- dest += line_size;
- dest[0] = cm[(a0 - b0) >> COL_SHIFT];
-}
-
-static inline void idctSparseColAdd (uint8_t *dest, int line_size,
- DCTELEM * col)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-
- /* XXX: I did that only to give same values as previous code */
- a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
- a1 = a0;
- a2 = a0;
- a3 = a0;
-
- a0 += + W2*col[8*2];
- a1 += + W6*col[8*2];
- a2 += - W6*col[8*2];
- a3 += - W2*col[8*2];
-
- b0 = MUL16(W1, col[8*1]);
- b1 = MUL16(W3, col[8*1]);
- b2 = MUL16(W5, col[8*1]);
- b3 = MUL16(W7, col[8*1]);
+#define BIT_DEPTH 8
+#include "simple_idct_template.c"
+#undef BIT_DEPTH
- MAC16(b0, + W3, col[8*3]);
- MAC16(b1, - W7, col[8*3]);
- MAC16(b2, - W1, col[8*3]);
- MAC16(b3, - W5, col[8*3]);
-
- if(col[8*4]){
- a0 += + W4*col[8*4];
- a1 += - W4*col[8*4];
- a2 += - W4*col[8*4];
- a3 += + W4*col[8*4];
- }
-
- if (col[8*5]) {
- MAC16(b0, + W5, col[8*5]);
- MAC16(b1, - W1, col[8*5]);
- MAC16(b2, + W7, col[8*5]);
- MAC16(b3, + W3, col[8*5]);
- }
-
- if(col[8*6]){
- a0 += + W6*col[8*6];
- a1 += - W2*col[8*6];
- a2 += + W2*col[8*6];
- a3 += - W6*col[8*6];
- }
-
- if (col[8*7]) {
- MAC16(b0, + W7, col[8*7]);
- MAC16(b1, - W5, col[8*7]);
- MAC16(b2, + W3, col[8*7]);
- MAC16(b3, - W1, col[8*7]);
- }
-
- dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)];
- dest += line_size;
- dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)];
- dest += line_size;
- dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)];
- dest += line_size;
- dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)];
- dest += line_size;
- dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)];
- dest += line_size;
- dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)];
- dest += line_size;
- dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)];
- dest += line_size;
- dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
-}
-
-static inline void idctSparseCol (DCTELEM * col)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
-
- /* XXX: I did that only to give same values as previous code */
- a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
- a1 = a0;
- a2 = a0;
- a3 = a0;
-
- a0 += + W2*col[8*2];
- a1 += + W6*col[8*2];
- a2 += - W6*col[8*2];
- a3 += - W2*col[8*2];
-
- b0 = MUL16(W1, col[8*1]);
- b1 = MUL16(W3, col[8*1]);
- b2 = MUL16(W5, col[8*1]);
- b3 = MUL16(W7, col[8*1]);
-
- MAC16(b0, + W3, col[8*3]);
- MAC16(b1, - W7, col[8*3]);
- MAC16(b2, - W1, col[8*3]);
- MAC16(b3, - W5, col[8*3]);
-
- if(col[8*4]){
- a0 += + W4*col[8*4];
- a1 += - W4*col[8*4];
- a2 += - W4*col[8*4];
- a3 += + W4*col[8*4];
- }
-
- if (col[8*5]) {
- MAC16(b0, + W5, col[8*5]);
- MAC16(b1, - W1, col[8*5]);
- MAC16(b2, + W7, col[8*5]);
- MAC16(b3, + W3, col[8*5]);
- }
-
- if(col[8*6]){
- a0 += + W6*col[8*6];
- a1 += - W2*col[8*6];
- a2 += + W2*col[8*6];
- a3 += - W6*col[8*6];
- }
-
- if (col[8*7]) {
- MAC16(b0, + W7, col[8*7]);
- MAC16(b1, - W5, col[8*7]);
- MAC16(b2, + W3, col[8*7]);
- MAC16(b3, - W1, col[8*7]);
- }
-
- col[0 ] = ((a0 + b0) >> COL_SHIFT);
- col[8 ] = ((a1 + b1) >> COL_SHIFT);
- col[16] = ((a2 + b2) >> COL_SHIFT);
- col[24] = ((a3 + b3) >> COL_SHIFT);
- col[32] = ((a3 - b3) >> COL_SHIFT);
- col[40] = ((a2 - b2) >> COL_SHIFT);
- col[48] = ((a1 - b1) >> COL_SHIFT);
- col[56] = ((a0 - b0) >> COL_SHIFT);
-}
-
-void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
- int i;
- for(i=0; i<8; i++)
- idctRowCondDC(block + i*8);
-
- for(i=0; i<8; i++)
- idctSparseColPut(dest + i, line_size, block + i);
-}
-
-void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
- int i;
- for(i=0; i<8; i++)
- idctRowCondDC(block + i*8);
-
- for(i=0; i<8; i++)
- idctSparseColAdd(dest + i, line_size, block + i);
-}
-
-void ff_simple_idct(DCTELEM *block)
-{
- int i;
- for(i=0; i<8; i++)
- idctRowCondDC(block + i*8);
-
- for(i=0; i<8; i++)
- idctSparseCol(block + i);
-}
+#define BIT_DEPTH 10
+#include "simple_idct_template.c"
+#undef BIT_DEPTH
/* 2x4x8 idct */
@@ -428,7 +108,7 @@ void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
/* IDCT8 on each line */
for(i=0; i<8; i++) {
- idctRowCondDC(block + i*8);
+ idctRowCondDC_8(block + i*8);
}
/* IDCT4 and store */
@@ -503,7 +183,7 @@ void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
/* IDCT8 on each line */
for(i=0; i<4; i++) {
- idctRowCondDC(block + i*8);
+ idctRowCondDC_8(block + i*8);
}
/* IDCT4 and store */
@@ -523,7 +203,7 @@ void ff_simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
/* IDCT8 and store */
for(i=0; i<4; i++){
- idctSparseColAdd(dest + i, line_size, block + i);
+ idctSparseColAdd_8(dest + i, line_size, block + i);
}
}
diff --git a/libavcodec/simple_idct.h b/libavcodec/simple_idct.h
index 23bae9c2fe..a33eb964ce 100644
--- a/libavcodec/simple_idct.h
+++ b/libavcodec/simple_idct.h
@@ -31,12 +31,17 @@
#include <stdint.h>
#include "dsputil.h"
-void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
+void ff_simple_idct_put_8(uint8_t *dest, int line_size, DCTELEM *block);
+void ff_simple_idct_add_8(uint8_t *dest, int line_size, DCTELEM *block);
+void ff_simple_idct_8(DCTELEM *block);
+
+void ff_simple_idct_put_10(uint8_t *dest, int line_size, DCTELEM *block);
+void ff_simple_idct_add_10(uint8_t *dest, int line_size, DCTELEM *block);
+void ff_simple_idct_10(DCTELEM *block);
+
void ff_simple_idct_mmx(int16_t *block);
void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct(DCTELEM *block);
void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block);
diff --git a/libavcodec/simple_idct_template.c b/libavcodec/simple_idct_template.c
new file mode 100644
index 0000000000..be49cb9570
--- /dev/null
+++ b/libavcodec/simple_idct_template.c
@@ -0,0 +1,401 @@
+/*
+ * Simple IDCT
+ *
+ * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * simpleidct in C.
+ */
+
+/*
+ based upon some outcommented c code from mpeg2dec (idct_mmx.c
+ written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
+ */
+
+#include "bit_depth_template.c"
+
+#undef W1
+#undef W2
+#undef W3
+#undef W4
+#undef W5
+#undef W6
+#undef W7
+#undef ROW_SHIFT
+#undef COL_SHIFT
+#undef DC_SHIFT
+#undef MUL
+#undef MAC
+
+#if BIT_DEPTH == 8
+
+#define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+#define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+#define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+#define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+#define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+#define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+#define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
+
+#define ROW_SHIFT 11
+#define COL_SHIFT 20
+#define DC_SHIFT 3
+
+#define MUL(a, b) MUL16(a, b)
+#define MAC(a, b, c) MAC16(a, b, c)
+
+#elif BIT_DEPTH == 10
+
+#define W1 90901
+#define W2 85627
+#define W3 77062
+#define W4 65535
+#define W5 51491
+#define W6 35468
+#define W7 18081
+
+#define ROW_SHIFT 15
+#define COL_SHIFT 20
+#define DC_SHIFT 1
+
+#define MUL(a, b) ((a) * (b))
+#define MAC(a, b, c) ((a) += (b) * (c))
+
+#else
+
+#error "Unsupported bitdepth"
+
+#endif
+
+static inline void FUNC(idctRowCondDC)(DCTELEM *row)
+{
+ int a0, a1, a2, a3, b0, b1, b2, b3;
+
+#if HAVE_FAST_64BIT
+#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
+ if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
+ uint64_t temp = (row[0] << DC_SHIFT) & 0xffff;
+ temp += temp << 16;
+ temp += temp << 32;
+ ((uint64_t *)row)[0] = temp;
+ ((uint64_t *)row)[1] = temp;
+ return;
+ }
+#else
+ if (!(((uint32_t*)row)[1] |
+ ((uint32_t*)row)[2] |
+ ((uint32_t*)row)[3] |
+ row[1])) {
+ uint32_t temp = (row[0] << DC_SHIFT) & 0xffff;
+ temp += temp << 16;
+ ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
+ ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
+ return;
+ }
+#endif
+
+ a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
+ a1 = a0;
+ a2 = a0;
+ a3 = a0;
+
+ /* no need to optimize : gcc does it */
+ a0 += W2 * row[2];
+ a1 += W6 * row[2];
+ a2 -= W6 * row[2];
+ a3 -= W2 * row[2];
+
+ b0 = MUL(W1, row[1]);
+ MAC(b0, W3, row[3]);
+ b1 = MUL(W3, row[1]);
+ MAC(b1, -W7, row[3]);
+ b2 = MUL(W5, row[1]);
+ MAC(b2, -W1, row[3]);
+ b3 = MUL(W7, row[1]);
+ MAC(b3, -W5, row[3]);
+
+ if (AV_RN64A(row + 4)) {
+ a0 += W4*row[4] + W6*row[6];
+ a1 += - W4*row[4] - W2*row[6];
+ a2 += - W4*row[4] + W2*row[6];
+ a3 += W4*row[4] - W6*row[6];
+
+ MAC(b0, W5, row[5]);
+ MAC(b0, W7, row[7]);
+
+ MAC(b1, -W1, row[5]);
+ MAC(b1, -W5, row[7]);
+
+ MAC(b2, W7, row[5]);
+ MAC(b2, W3, row[7]);
+
+ MAC(b3, W3, row[5]);
+ MAC(b3, -W1, row[7]);
+ }
+
+ row[0] = (a0 + b0) >> ROW_SHIFT;
+ row[7] = (a0 - b0) >> ROW_SHIFT;
+ row[1] = (a1 + b1) >> ROW_SHIFT;
+ row[6] = (a1 - b1) >> ROW_SHIFT;
+ row[2] = (a2 + b2) >> ROW_SHIFT;
+ row[5] = (a2 - b2) >> ROW_SHIFT;
+ row[3] = (a3 + b3) >> ROW_SHIFT;
+ row[4] = (a3 - b3) >> ROW_SHIFT;
+}
+
+static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size,
+ DCTELEM *col)
+{
+ int a0, a1, a2, a3, b0, b1, b2, b3;
+ INIT_CLIP;
+
+ /* XXX: I did that only to give same values as previous code */
+ a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
+ a1 = a0;
+ a2 = a0;
+ a3 = a0;
+
+ a0 += + W2*col[8*2];
+ a1 += + W6*col[8*2];
+ a2 += - W6*col[8*2];
+ a3 += - W2*col[8*2];
+
+ b0 = MUL(W1, col[8*1]);
+ b1 = MUL(W3, col[8*1]);
+ b2 = MUL(W5, col[8*1]);
+ b3 = MUL(W7, col[8*1]);
+
+ MAC(b0, + W3, col[8*3]);
+ MAC(b1, - W7, col[8*3]);
+ MAC(b2, - W1, col[8*3]);
+ MAC(b3, - W5, col[8*3]);
+
+ if(col[8*4]){
+ a0 += + W4*col[8*4];
+ a1 += - W4*col[8*4];
+ a2 += - W4*col[8*4];
+ a3 += + W4*col[8*4];
+ }
+
+ if (col[8*5]) {
+ MAC(b0, + W5, col[8*5]);
+ MAC(b1, - W1, col[8*5]);
+ MAC(b2, + W7, col[8*5]);
+ MAC(b3, + W3, col[8*5]);
+ }
+
+ if(col[8*6]){
+ a0 += + W6*col[8*6];
+ a1 += - W2*col[8*6];
+ a2 += + W2*col[8*6];
+ a3 += - W6*col[8*6];
+ }
+
+ if (col[8*7]) {
+ MAC(b0, + W7, col[8*7]);
+ MAC(b1, - W5, col[8*7]);
+ MAC(b2, + W3, col[8*7]);
+ MAC(b3, - W1, col[8*7]);
+ }
+
+ dest[0] = CLIP((a0 + b0) >> COL_SHIFT);
+ dest += line_size;
+ dest[0] = CLIP((a1 + b1) >> COL_SHIFT);
+ dest += line_size;
+ dest[0] = CLIP((a2 + b2) >> COL_SHIFT);
+ dest += line_size;
+ dest[0] = CLIP((a3 + b3) >> COL_SHIFT);
+ dest += line_size;
+ dest[0] = CLIP((a3 - b3) >> COL_SHIFT);
+ dest += line_size;
+ dest[0] = CLIP((a2 - b2) >> COL_SHIFT);
+ dest += line_size;
+ dest[0] = CLIP((a1 - b1) >> COL_SHIFT);
+ dest += line_size;
+ dest[0] = CLIP((a0 - b0) >> COL_SHIFT);
+}
+
+static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size,
+ DCTELEM *col)
+{
+ int a0, a1, a2, a3, b0, b1, b2, b3;
+ INIT_CLIP;
+
+ /* XXX: I did that only to give same values as previous code */
+ a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
+ a1 = a0;
+ a2 = a0;
+ a3 = a0;
+
+ a0 += + W2*col[8*2];
+ a1 += + W6*col[8*2];
+ a2 += - W6*col[8*2];
+ a3 += - W2*col[8*2];
+
+ b0 = MUL(W1, col[8*1]);
+ b1 = MUL(W3, col[8*1]);
+ b2 = MUL(W5, col[8*1]);
+ b3 = MUL(W7, col[8*1]);
+
+ MAC(b0, + W3, col[8*3]);
+ MAC(b1, - W7, col[8*3]);
+ MAC(b2, - W1, col[8*3]);
+ MAC(b3, - W5, col[8*3]);
+
+ if(col[8*4]){
+ a0 += + W4*col[8*4];
+ a1 += - W4*col[8*4];
+ a2 += - W4*col[8*4];
+ a3 += + W4*col[8*4];
+ }
+
+ if (col[8*5]) {
+ MAC(b0, + W5, col[8*5]);
+ MAC(b1, - W1, col[8*5]);
+ MAC(b2, + W7, col[8*5]);
+ MAC(b3, + W3, col[8*5]);
+ }
+
+ if(col[8*6]){
+ a0 += + W6*col[8*6];
+ a1 += - W2*col[8*6];
+ a2 += + W2*col[8*6];
+ a3 += - W6*col[8*6];
+ }
+
+ if (col[8*7]) {
+ MAC(b0, + W7, col[8*7]);
+ MAC(b1, - W5, col[8*7]);
+ MAC(b2, + W3, col[8*7]);
+ MAC(b3, - W1, col[8*7]);
+ }
+
+ dest[0] = CLIP(dest[0] + ((a0 + b0) >> COL_SHIFT));
+ dest += line_size;
+ dest[0] = CLIP(dest[0] + ((a1 + b1) >> COL_SHIFT));
+ dest += line_size;
+ dest[0] = CLIP(dest[0] + ((a2 + b2) >> COL_SHIFT));
+ dest += line_size;
+ dest[0] = CLIP(dest[0] + ((a3 + b3) >> COL_SHIFT));
+ dest += line_size;
+ dest[0] = CLIP(dest[0] + ((a3 - b3) >> COL_SHIFT));
+ dest += line_size;
+ dest[0] = CLIP(dest[0] + ((a2 - b2) >> COL_SHIFT));
+ dest += line_size;
+ dest[0] = CLIP(dest[0] + ((a1 - b1) >> COL_SHIFT));
+ dest += line_size;
+ dest[0] = CLIP(dest[0] + ((a0 - b0) >> COL_SHIFT));
+}
+
+static inline void FUNC(idctSparseCol)(DCTELEM *col)
+{
+ int a0, a1, a2, a3, b0, b1, b2, b3;
+
+ /* XXX: I did that only to give same values as previous code */
+ a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
+ a1 = a0;
+ a2 = a0;
+ a3 = a0;
+
+ a0 += + W2*col[8*2];
+ a1 += + W6*col[8*2];
+ a2 += - W6*col[8*2];
+ a3 += - W2*col[8*2];
+
+ b0 = MUL(W1, col[8*1]);
+ b1 = MUL(W3, col[8*1]);
+ b2 = MUL(W5, col[8*1]);
+ b3 = MUL(W7, col[8*1]);
+
+ MAC(b0, + W3, col[8*3]);
+ MAC(b1, - W7, col[8*3]);
+ MAC(b2, - W1, col[8*3]);
+ MAC(b3, - W5, col[8*3]);
+
+ if(col[8*4]){
+ a0 += + W4*col[8*4];
+ a1 += - W4*col[8*4];
+ a2 += - W4*col[8*4];
+ a3 += + W4*col[8*4];
+ }
+
+ if (col[8*5]) {
+ MAC(b0, + W5, col[8*5]);
+ MAC(b1, - W1, col[8*5]);
+ MAC(b2, + W7, col[8*5]);
+ MAC(b3, + W3, col[8*5]);
+ }
+
+ if(col[8*6]){
+ a0 += + W6*col[8*6];
+ a1 += - W2*col[8*6];
+ a2 += + W2*col[8*6];
+ a3 += - W6*col[8*6];
+ }
+
+ if (col[8*7]) {
+ MAC(b0, + W7, col[8*7]);
+ MAC(b1, - W5, col[8*7]);
+ MAC(b2, + W3, col[8*7]);
+ MAC(b3, - W1, col[8*7]);
+ }
+
+ col[0 ] = ((a0 + b0) >> COL_SHIFT);
+ col[8 ] = ((a1 + b1) >> COL_SHIFT);
+ col[16] = ((a2 + b2) >> COL_SHIFT);
+ col[24] = ((a3 + b3) >> COL_SHIFT);
+ col[32] = ((a3 - b3) >> COL_SHIFT);
+ col[40] = ((a2 - b2) >> COL_SHIFT);
+ col[48] = ((a1 - b1) >> COL_SHIFT);
+ col[56] = ((a0 - b0) >> COL_SHIFT);
+}
+
+void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block)
+{
+ pixel *dest = (pixel *)dest_;
+ int i;
+ for(i=0; i<8; i++)
+ FUNC(idctRowCondDC)(block + i*8);
+
+ for(i=0; i<8; i++)
+ FUNC(idctSparseColPut)(dest + i, line_size, block + i);
+}
+
+void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block)
+{
+ pixel *dest = (pixel *)dest_;
+ int i;
+ for(i=0; i<8; i++)
+ FUNC(idctRowCondDC)(block + i*8);
+
+ for(i=0; i<8; i++)
+ FUNC(idctSparseColAdd)(dest + i, line_size, block + i);
+}
+
+void FUNC(ff_simple_idct)(DCTELEM *block)
+{
+ int i;
+ for(i=0; i<8; i++)
+ FUNC(idctRowCondDC)(block + i*8);
+
+ for(i=0; i<8; i++)
+ FUNC(idctSparseCol)(block + i);
+}
diff --git a/libavcodec/sparc/dsputil_vis.c b/libavcodec/sparc/dsputil_vis.c
index ab9258b2b9..9811b2622e 100644
--- a/libavcodec/sparc/dsputil_vis.c
+++ b/libavcodec/sparc/dsputil_vis.c
@@ -3956,7 +3956,8 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx)
const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
if (accel & ACCEL_SPARC_VIS) {
- if(avctx->idct_algo==FF_IDCT_SIMPLEVIS){
+ if (avctx->bits_per_raw_sample <= 8 &&
+ avctx->idct_algo == FF_IDCT_SIMPLEVIS) {
c->idct_put = ff_simple_idct_put_vis;
c->idct_add = ff_simple_idct_add_vis;
c->idct = ff_simple_idct_vis;
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 32869b97d1..1f83dd27b8 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -337,11 +337,11 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte
v->res_fasttx = get_bits1(gb);
if (!v->res_fasttx)
{
- v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct;
+ v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct_8;
v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
- v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add;
+ v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add_8;
v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c
index 29fff276ad..84ae47b04d 100644
--- a/libavcodec/x86/dsputil_mmx.c
+++ b/libavcodec/x86/dsputil_mmx.c
@@ -2465,7 +2465,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
if (mm_flags & AV_CPU_FLAG_MMX) {
const int idct_algo= avctx->idct_algo;
- if(avctx->lowres==0){
+ if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx;
c->idct_add= ff_simple_idct_add_mmx;