1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

simple_idct: add 10-bit version

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Mans Rullgard 2011-07-20 16:05:05 +01:00
parent 7b4ee3a21d
commit e7a972e113
17 changed files with 461 additions and 361 deletions

View File

@ -335,7 +335,7 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
put_pixels_clamped_axp_p = c->put_pixels_clamped; put_pixels_clamped_axp_p = c->put_pixels_clamped;
add_pixels_clamped_axp_p = c->add_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_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) { avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) {
c->idct_put = ff_simple_idct_put_axp; c->idct_put = ff_simple_idct_put_axp;

View File

@ -80,7 +80,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
ff_put_pixels_clamped = c->put_pixels_clamped; ff_put_pixels_clamped = c->put_pixels_clamped;
ff_add_pixels_clamped = c->add_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 || if(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_ARM){ avctx->idct_algo == FF_IDCT_ARM){
c->idct_put = j_rev_dct_arm_put; c->idct_put = j_rev_dct_arm_put;

View File

@ -29,7 +29,8 @@ void ff_prefetch_arm(void *mem, int stride, int h);
void av_cold ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx) void av_cold ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx)
{ {
if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO || if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) { avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) {
c->idct_put = ff_simple_idct_put_armv5te; c->idct_put = ff_simple_idct_put_armv5te;
c->idct_add = ff_simple_idct_add_armv5te; c->idct_add = ff_simple_idct_add_armv5te;

View File

@ -74,7 +74,8 @@ 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; 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 || if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) { avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
c->idct_put = ff_simple_idct_put_armv6; c->idct_put = ff_simple_idct_put_armv6;
c->idct_add = ff_simple_idct_add_armv6; c->idct_add = ff_simple_idct_add_armv6;

View File

@ -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; 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 || if (avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLENEON) { avctx->idct_algo == FF_IDCT_SIMPLENEON) {
c->idct_put = ff_simple_idct_put_neon; c->idct_put = ff_simple_idct_put_neon;

View File

@ -256,6 +256,7 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
if (avctx->dct_algo == FF_DCT_AUTO) if (avctx->dct_algo == FF_DCT_AUTO)
c->fdct = ff_bfin_fdct; c->fdct = ff_bfin_fdct;
if (avctx->bits_per_raw_sample <= 8) {
if (avctx->idct_algo == FF_IDCT_VP3) { if (avctx->idct_algo == FF_IDCT_VP3) {
c->idct_permutation_type = FF_NO_IDCT_PERM; c->idct_permutation_type = FF_NO_IDCT_PERM;
c->idct = ff_bfin_vp3_idct; c->idct = ff_bfin_vp3_idct;
@ -268,6 +269,7 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
c->idct_put = bfin_idct_put; c->idct_put = bfin_idct_put;
} }
} }
}

View File

@ -111,7 +111,7 @@ static const struct algo idct_tab[] = {
{ "FAANI", ff_faanidct, NO_PERM }, { "FAANI", ff_faanidct, NO_PERM },
{ "REF-DBL", ff_ref_idct, NO_PERM }, { "REF-DBL", ff_ref_idct, NO_PERM },
{ "INT", j_rev_dct, MMX_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 HAVE_MMX
#if CONFIG_GPL #if CONFIG_GPL

View File

@ -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->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); 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++) for(i=0; i<64; i++)
sum+= (temp[i]-bak[i])*(temp[i]-bak[i]); sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
@ -2877,6 +2877,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct_add= ff_jref_idct1_add; c->idct_add= ff_jref_idct1_add;
c->idct = j_rev_dct1; c->idct = j_rev_dct1;
c->idct_permutation_type= FF_NO_IDCT_PERM; 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 { } else {
if(avctx->idct_algo==FF_IDCT_INT){ if(avctx->idct_algo==FF_IDCT_INT){
c->idct_put= ff_jref_idct_put; c->idct_put= ff_jref_idct_put;
@ -2908,12 +2914,13 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct_put = ff_bink_idct_put_c; c->idct_put = ff_bink_idct_put_c;
c->idct_permutation_type = FF_NO_IDCT_PERM; c->idct_permutation_type = FF_NO_IDCT_PERM;
}else{ //accurate/default }else{ //accurate/default
c->idct_put= ff_simple_idct_put; c->idct_put = ff_simple_idct_put_8;
c->idct_add= ff_simple_idct_add; c->idct_add = ff_simple_idct_add_8;
c->idct = ff_simple_idct; c->idct = ff_simple_idct_8;
c->idct_permutation_type= FF_NO_IDCT_PERM; c->idct_permutation_type= FF_NO_IDCT_PERM;
} }
} }
}
c->get_pixels = get_pixels_c; c->get_pixels = get_pixels_c;
c->diff_pixels = diff_pixels_c; c->diff_pixels = diff_pixels_c;

View File

@ -178,7 +178,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
} }
#endif //CONFIG_ENCODERS #endif //CONFIG_ENCODERS
if (avctx->lowres==0) { if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
if ((avctx->idct_algo == FF_IDCT_AUTO) || if ((avctx->idct_algo == FF_IDCT_AUTO) ||
(avctx->idct_algo == FF_IDCT_ALTIVEC)) { (avctx->idct_algo == FF_IDCT_ALTIVEC)) {
c->idct_put = idct_put_altivec; c->idct_put = idct_put_altivec;

View File

@ -156,7 +156,8 @@ void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
c->get_pixels = get_pixels_mmi; 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_put= ff_mmi_idct_put;
c->idct_add= ff_mmi_idct_add; c->idct_add= ff_mmi_idct_add;
c->idct = ff_mmi_idct; c->idct = ff_mmi_idct;

View File

@ -97,7 +97,8 @@ void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
if (!high_bit_depth) if (!high_bit_depth)
c->clear_blocks = clear_blocks_sh4; 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_put = idct_put;
c->idct_add = idct_add; c->idct_add = idct_add;
c->idct = idct_sh4; c->idct = idct_sh4;

View File

@ -25,339 +25,19 @@
* simpleidct in C. * 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 "libavutil/intreadwrite.h"
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "dsputil.h"
#include "mathops.h" #include "mathops.h"
#include "simple_idct.h" #include "simple_idct.h"
#define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #define BIT_DEPTH 8
#define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #include "simple_idct_template.c"
#define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 #undef BIT_DEPTH
#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) #define BIT_DEPTH 10
{ #include "simple_idct_template.c"
int a0, a1, a2, a3, b0, b1, b2, b3; #undef BIT_DEPTH
#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]);
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);
}
/* 2x4x8 idct */ /* 2x4x8 idct */
@ -428,7 +108,7 @@ void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
/* IDCT8 on each line */ /* IDCT8 on each line */
for(i=0; i<8; i++) { for(i=0; i<8; i++) {
idctRowCondDC(block + i*8); idctRowCondDC_8(block + i*8);
} }
/* IDCT4 and store */ /* IDCT4 and store */
@ -503,7 +183,7 @@ void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
/* IDCT8 on each line */ /* IDCT8 on each line */
for(i=0; i<4; i++) { for(i=0; i<4; i++) {
idctRowCondDC(block + i*8); idctRowCondDC_8(block + i*8);
} }
/* IDCT4 and store */ /* IDCT4 and store */
@ -523,7 +203,7 @@ void ff_simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
/* IDCT8 and store */ /* IDCT8 and store */
for(i=0; i<4; i++){ for(i=0; i<4; i++){
idctSparseColAdd(dest + i, line_size, block + i); idctSparseColAdd_8(dest + i, line_size, block + i);
} }
} }

View File

@ -31,12 +31,17 @@
#include <stdint.h> #include <stdint.h>
#include "dsputil.h" #include "dsputil.h"
void ff_simple_idct_put(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(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_mmx(int16_t *block);
void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, 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_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); void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block);

View File

@ -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);
}

View File

@ -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; const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
if (accel & ACCEL_SPARC_VIS) { 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_put = ff_simple_idct_put_vis;
c->idct_add = ff_simple_idct_add_vis; c->idct_add = ff_simple_idct_add_vis;
c->idct = ff_simple_idct_vis; c->idct = ff_simple_idct_vis;

View File

@ -337,11 +337,11 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte
v->res_fasttx = get_bits1(gb); v->res_fasttx = get_bits1(gb);
if (!v->res_fasttx) 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_8x4 = ff_simple_idct84_add;
v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_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_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_8x4_dc = ff_simple_idct84_add;
v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add; v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add; v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;

View File

@ -2465,7 +2465,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
const int idct_algo= avctx->idct_algo; 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){ if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx; c->idct_put= ff_simple_idct_put_mmx;
c->idct_add= ff_simple_idct_add_mmx; c->idct_add= ff_simple_idct_add_mmx;