summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/snow.c42
-rw-r--r--tests/ffmpeg.regression.ref8
-rw-r--r--tests/rotozoom.regression.ref6
3 files changed, 38 insertions, 18 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 263918ed25..faed630ad4 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -71,6 +71,24 @@ static const int8_t quant3b[256]={
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
};
+static const int8_t quant3bA[256]={
+ 0, 0, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+ 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1,
+};
static const int8_t quant5[256]={
0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -373,7 +391,7 @@ typedef struct BlockNode{
typedef struct x_and_coeff{
int16_t x;
- int16_t coeff;
+ uint16_t coeff;
} x_and_coeff;
typedef struct SubBand{
@@ -1702,9 +1720,11 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELE
}
if(v){
int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
+ int l2= 2*ABS(l) + (l<0);
+ int t2= 2*ABS(t) + (t<0);
put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4);
- put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]], v<0);
+ put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l2&0xFF] + 3*quant3bA[t2&0xFF]], v<0);
}
}
}
@@ -1763,7 +1783,7 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i
}
}
if(/*ll|*/l|lt|t|rt|p){
- int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
+ int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
v=get_rac(&s->c, &b->state[0][context]);
}else{
@@ -1785,10 +1805,10 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i
}
}
if(v){
- int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
- v= get_symbol2(&s->c, b->state[context + 2], context-4) + 1;
- if(get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]]))
- v *= -1;
+ int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
+ v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1);
+ v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]);
+
b->x_coeff[index].x=x;
b->x_coeff[index++].coeff= v;
}
@@ -1842,10 +1862,10 @@ static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, sli
x = b->x_coeff[new_index++].x;
while(x < w)
{
- if (v < 0)
- line[x] = -(( -v*qmul + qadd)>>(QEXPSHIFT));
- else
- line[x] = (( v*qmul + qadd)>>(QEXPSHIFT));
+ register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT;
+ register int u= -(v&1);
+ line[x] = (t^u) - u;
+
v = b->x_coeff[new_index].coeff;
x = b->x_coeff[new_index++].x;
}
diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref
index 28dfa4da98..c5517d6b8a 100644
--- a/tests/ffmpeg.regression.ref
+++ b/tests/ffmpeg.regression.ref
@@ -119,12 +119,12 @@ a7ef4746f27be309138c188e327d3ebe *./data/a-ffv1.avi
2653642 ./data/a-ffv1.avi
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-ba3d08fe9c54acb58cb72e02476849d7 *./data/a-snow.avi
-1280600 ./data/a-snow.avi
+3e7738ae0429e48d3465d4f941eb7448 *./data/a-snow.avi
+1280602 ./data/a-snow.avi
e4b8c83278efee032a84569c25593937 *./data/out.yuv
stddev: 2.92 PSNR:38.79 bytes:7602176
-7acf773e701b92dbc15a6852aac329b6 *./data/a-snow53.avi
-3537412 ./data/a-snow53.avi
+45687368463932f08dbc74c973ad32dd *./data/a-snow53.avi
+3537042 ./data/a-snow53.avi
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
b5b6275f58f012de73644bbaa9080097 *./data/a-svq1.mov
diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref
index f0a053f609..352eb9a8ac 100644
--- a/tests/rotozoom.regression.ref
+++ b/tests/rotozoom.regression.ref
@@ -119,12 +119,12 @@ d0831a8339491fd680b650f05262e5d9 *./data/a-ffv1.avi
3524768 ./data/a-ffv1.avi
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-440794294cc44c4cb25e32b947ba3311 *./data/a-snow.avi
+6e0ea3a5128f54f42e5fdb81532d95fe *./data/a-snow.avi
332700 ./data/a-snow.avi
1f3439e1b3ff09492f196a024d7119e3 *./data/out.yuv
stddev: 2.37 PSNR:40.60 bytes:7602176
-eaea93acf339ad2a7349dc5d0872e870 *./data/a-snow53.avi
-2724574 ./data/a-snow53.avi
+92ab639886be86087942dd76cfd91bf3 *./data/a-snow53.avi
+2724572 ./data/a-snow53.avi
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
920c610ec324b772d882b0717e375943 *./data/a-svq1.mov