summaryrefslogtreecommitdiffstats
path: root/libavcodec/snow.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-07-27 13:40:16 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-07-27 13:40:16 +0000
commit78486403561c1389045229ee1137415d5e2eb3ae (patch)
tree4061706892e4bc9f509754b9d21fca2e5b7351d7 /libavcodec/snow.c
parentc07a22fb9fc5cfa24b5b80f83e8f08b17937ca97 (diff)
downloadffmpeg-streaming-78486403561c1389045229ee1137415d5e2eb3ae.zip
ffmpeg-streaming-78486403561c1389045229ee1137415d5e2eb3ae.tar.gz
use parent sample to predict significance & magnitude
1% bitrate reduction (foreman@352x288 qscale 1 & 8) Originally committed as revision 3352 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/snow.c')
-rw-r--r--libavcodec/snow.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 744d554..4dc3392 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -1419,7 +1419,7 @@ static void encode_subband(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *pa
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- int v, p;
+ int v, p=0;
int /*ll=0, */l=0, lt=0, t=0, rt=0;
if(orientation==1) v= src[y + x*stride];
else v= src[x + y*stride];
@@ -1444,7 +1444,13 @@ static void encode_subband(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *pa
else ll= src[x - 2 + y*stride];
}*/
}
- if(!(/*ll|*/l|lt|t|rt)){
+ if(parent){
+ int px= (orientation==1 ? y : x)>>1;
+ int py= (orientation==1 ? x : y)>>1;
+ if(px<b->parent->width && py<b->parent->height)
+ p= parent[px + py*2*stride];
+ }
+ if(!(/*ll|*/l|lt|t|rt|p)){
if(v){
runs[run_index++]= run;
run=0;
@@ -1462,7 +1468,7 @@ static void encode_subband(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *pa
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- int v, p;
+ int v, p=0;
int /*ll=0, */l=0, lt=0, t=0, rt=0;
if(orientation==1) v= src[y + x*stride];
else v= src[x + y*stride];
@@ -1487,8 +1493,14 @@ static void encode_subband(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *pa
else ll= src[x - 2 + y*stride];
}*/
}
- if(/*ll|*/l|lt|t|rt){
- int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt));
+ if(parent){
+ int px= (orientation==1 ? y : x)>>1;
+ int py= (orientation==1 ? x : y)>>1;
+ if(px<b->parent->width && py<b->parent->height)
+ p= parent[px + py*2*stride];
+ }
+ 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));
put_cabac(&s->c, &b->state[0][context], !!v);
}else{
@@ -1502,7 +1514,7 @@ static void encode_subband(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *pa
}
}
if(v){
- int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt));
+ int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
put_symbol(&s->c, b->state[context + 2], ABS(v)-1, 0);
put_cabac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]], v<0);
@@ -1642,7 +1654,7 @@ static inline void decode_subbandX(SnowContext *s, SubBand *b, DWTELEM *src, DWT
run= get_symbol(&s->c, b->state[1], 0);
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- int v, p;
+ int v, p=0;
int /*ll=0, */l=0, lt=0, t=0, rt=0;
if(y){
@@ -1665,8 +1677,14 @@ static inline void decode_subbandX(SnowContext *s, SubBand *b, DWTELEM *src, DWT
else ll= src[x - 2 + y*stride];
}*/
}
- if(/*ll|*/l|lt|t|rt){
- int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt));
+ if(parent){
+ int px= (orientation==1 ? y : x)>>1;
+ int py= (orientation==1 ? x : y)>>1;
+ if(px<b->parent->width && py<b->parent->height)
+ p= parent[px + py*2*stride];
+ }
+ 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));
v=get_cabac(&s->c, &b->state[0][context]);
}else{
@@ -1681,7 +1699,7 @@ static inline void decode_subbandX(SnowContext *s, SubBand *b, DWTELEM *src, DWT
}
}
if(v){
- int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt));
+ int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
v= get_symbol(&s->c, b->state[context + 2], 0) + 1;
if(get_cabac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]]))
v= -v;
OpenPOWER on IntegriCloud