rescale coefficients during IDWT, that way the lifting steps are much simpler and faster
Originally committed as revision 4119 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
6fbcfec0c8
commit
f5a719287d
@ -756,6 +756,29 @@ static always_inline void lift5(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int ds
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse){
|
||||||
|
const int mirror_left= !highpass;
|
||||||
|
const int mirror_right= (width&1) ^ highpass;
|
||||||
|
const int w= (width>>1) - 1 + (highpass & width);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
assert(shift == 4);
|
||||||
|
#define LIFTS(src, ref, inv) ((inv) ? (src) - (((ref) - 4*(src))>>shift): (16*4*(src) + 4*(ref) + 8 + (5<<27))/(5*16) - (1<<23))
|
||||||
|
if(mirror_left){
|
||||||
|
dst[0] = LIFTS(src[0], mul*2*ref[0]+add, inverse);
|
||||||
|
dst += dst_step;
|
||||||
|
src += src_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0; i<w; i++){
|
||||||
|
dst[i*dst_step] = LIFTS(src[i*src_step], mul*(ref[i*ref_step] + ref[(i+1)*ref_step])+add, inverse);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mirror_right){
|
||||||
|
dst[w*dst_step] = LIFTS(src[w*src_step], mul*2*ref[w*ref_step]+add, inverse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void inplace_lift(DWTELEM *dst, int width, int *coeffs, int n, int shift, int start, int inverse){
|
static void inplace_lift(DWTELEM *dst, int width, int *coeffs, int n, int shift, int start, int inverse){
|
||||||
int x, i;
|
int x, i;
|
||||||
@ -1070,24 +1093,25 @@ STOP_TIMER("vertical_decompose53i*")}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define liftS lift
|
||||||
#define lift5 lift
|
#define lift5 lift
|
||||||
#if 1
|
#if 1
|
||||||
#define W_AM 3
|
#define W_AM 3
|
||||||
#define W_AO 0
|
#define W_AO 0
|
||||||
#define W_AS 1
|
#define W_AS 1
|
||||||
|
|
||||||
|
#undef liftS
|
||||||
#define W_BM 1
|
#define W_BM 1
|
||||||
#define W_BO 8
|
#define W_BO 8
|
||||||
#define W_BS 4
|
#define W_BS 4
|
||||||
|
|
||||||
#undef lift5
|
#define W_CM 1
|
||||||
#define W_CM 9999
|
#define W_CO 0
|
||||||
#define W_CO 2
|
#define W_CS 0
|
||||||
#define W_CS 2
|
|
||||||
|
|
||||||
#define W_DM 15
|
#define W_DM 3
|
||||||
#define W_DO 16
|
#define W_DO 4
|
||||||
#define W_DS 5
|
#define W_DS 3
|
||||||
#elif 0
|
#elif 0
|
||||||
#define W_AM 55
|
#define W_AM 55
|
||||||
#define W_AO 16
|
#define W_AO 16
|
||||||
@ -1144,7 +1168,7 @@ static void horizontal_decompose97i(DWTELEM *b, int width){
|
|||||||
const int w2= (width+1)>>1;
|
const int w2= (width+1)>>1;
|
||||||
|
|
||||||
lift (temp+w2, b +1, b , 1, 2, 2, width, -W_AM, W_AO, W_AS, 1, 0);
|
lift (temp+w2, b +1, b , 1, 2, 2, width, -W_AM, W_AO, W_AS, 1, 0);
|
||||||
lift (temp , b , temp+w2, 1, 2, 1, width, -W_BM, W_BO, W_BS, 0, 0);
|
liftS(temp , b , temp+w2, 1, 2, 1, width, -W_BM, W_BO, W_BS, 0, 0);
|
||||||
lift5(b +w2, temp+w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 0);
|
lift5(b +w2, temp+w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 0);
|
||||||
lift (b , temp , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 0);
|
lift (b , temp , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 0);
|
||||||
}
|
}
|
||||||
@ -1177,7 +1201,11 @@ static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int w
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=0; i<width; i++){
|
for(i=0; i<width; i++){
|
||||||
|
#ifdef liftS
|
||||||
b1[i] -= (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS;
|
b1[i] -= (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS;
|
||||||
|
#else
|
||||||
|
b1[i] = (16*4*b1[i] - 4*(b0[i] + b2[i]) + 8*5 + (5<<27)) / (5*16) - (1<<23);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1373,7 +1401,7 @@ static void horizontal_compose97i(DWTELEM *b, int width){
|
|||||||
|
|
||||||
lift (temp , b , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 1);
|
lift (temp , b , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 1);
|
||||||
lift5(temp+w2, b +w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 1);
|
lift5(temp+w2, b +w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 1);
|
||||||
lift (b , temp , temp+w2, 2, 1, 1, width, -W_BM, W_BO, W_BS, 0, 1);
|
liftS(b , temp , temp+w2, 2, 1, 1, width, -W_BM, W_BO, W_BS, 0, 1);
|
||||||
lift (b+1 , temp+w2, b , 2, 1, 2, width, -W_AM, W_AO, W_AS, 1, 1);
|
lift (b+1 , temp+w2, b , 2, 1, 2, width, -W_AM, W_AO, W_AS, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1404,7 +1432,11 @@ static void vertical_compose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int wid
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=0; i<width; i++){
|
for(i=0; i<width; i++){
|
||||||
|
#ifdef liftS
|
||||||
b1[i] += (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS;
|
b1[i] += (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS;
|
||||||
|
#else
|
||||||
|
b1[i] += (W_BM*(b0[i] + b2[i])+4*b1[i]+W_BO)>>W_BS;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1430,7 +1462,11 @@ static void vertical_compose97i(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *
|
|||||||
r+= r>>8;
|
r+= r>>8;
|
||||||
b3[i] -= (r+W_CO)>>W_CS;
|
b3[i] -= (r+W_CO)>>W_CS;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef liftS
|
||||||
b2[i] += (W_BM*(b1[i] + b3[i])+W_BO)>>W_BS;
|
b2[i] += (W_BM*(b1[i] + b3[i])+W_BO)>>W_BS;
|
||||||
|
#else
|
||||||
|
b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
|
||||||
|
#endif
|
||||||
b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
|
b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ a7ef4746f27be309138c188e327d3ebe *./data/a-ffv1.avi
|
|||||||
2653642 ./data/a-ffv1.avi
|
2653642 ./data/a-ffv1.avi
|
||||||
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
|
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
|
||||||
stddev: 0.00 PSNR:99.99 bytes:7602176
|
stddev: 0.00 PSNR:99.99 bytes:7602176
|
||||||
15527997420c2ace9ab26e4504f7ca8d *./data/a-snow.avi
|
98f6913d98bccb4ba4829ccde7286e8f *./data/a-snow.avi
|
||||||
1269510 ./data/a-snow.avi
|
1266766 ./data/a-snow.avi
|
||||||
20e858677a35136bfa0765fafd3f9385 *./data/out.yuv
|
575fdd879119902a8289c825c2389dca *./data/out.yuv
|
||||||
stddev: 2.96 PSNR:38.67 bytes:7602176
|
stddev: 2.96 PSNR:38.67 bytes:7602176
|
||||||
28b6a82fdd8058e2df35778c9a5edbbf *./data/a-snow53.avi
|
28b6a82fdd8058e2df35778c9a5edbbf *./data/a-snow53.avi
|
||||||
3537074 ./data/a-snow53.avi
|
3537074 ./data/a-snow53.avi
|
||||||
|
@ -119,10 +119,10 @@ d0831a8339491fd680b650f05262e5d9 *./data/a-ffv1.avi
|
|||||||
3524768 ./data/a-ffv1.avi
|
3524768 ./data/a-ffv1.avi
|
||||||
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
|
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
|
||||||
stddev: 0.00 PSNR:99.99 bytes:7602176
|
stddev: 0.00 PSNR:99.99 bytes:7602176
|
||||||
7b3468914d99ff2803c35560a0a4a6f0 *./data/a-snow.avi
|
d1546d2176c4cd3913ccb0920e5e556f *./data/a-snow.avi
|
||||||
327494 ./data/a-snow.avi
|
326454 ./data/a-snow.avi
|
||||||
3c1e7765d9be2af73e992c2f6d769e7b *./data/out.yuv
|
c0b1b63dc45141c76d538edfd618ac19 *./data/out.yuv
|
||||||
stddev: 2.40 PSNR:40.52 bytes:7602176
|
stddev: 2.40 PSNR:40.51 bytes:7602176
|
||||||
8b510a8e4a26d6d469bd80b46922d5e6 *./data/a-snow53.avi
|
8b510a8e4a26d6d469bd80b46922d5e6 *./data/a-snow53.avi
|
||||||
2724602 ./data/a-snow53.avi
|
2724602 ./data/a-snow53.avi
|
||||||
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
|
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
|
||||||
|
Loading…
x
Reference in New Issue
Block a user