changeset 2148:678be5a8f282 libavcodec

use parent sample to predict significance & magnitude 1% bitrate reduction (foreman@352x288 qscale 1 & 8)
author michael
date Tue, 27 Jul 2004 13:40:16 +0000
parents f980082baeaa
children 48dc4ec06e88
files snow.c
diffstat 1 files changed, 28 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/snow.c	Tue Jul 27 11:09:41 2004 +0000
+++ b/snow.c	Tue Jul 27 13:40:16 2004 +0000
@@ -1419,7 +1419,7 @@
 
         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 @@
                         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 @@
         
         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 @@
                         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 @@
                     }
                 }
                 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 @@
         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 @@
                         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 @@
                     }
                 }
                 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;