changeset 3429:fb2a69de8ded libavcodec

Enable coefficient scaling
author kostya
date Fri, 07 Jul 2006 04:51:50 +0000
parents 2b5c3f1bbbc4
children d0e85690841d
files vc1.c
diffstat 1 files changed, 21 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/vc1.c	Fri Jul 07 04:50:13 2006 +0000
+++ b/vc1.c	Fri Jul 07 04:51:50 2006 +0000
@@ -1731,7 +1731,7 @@
     int a, b, c, wrap, pred, scale;
     int16_t *dc_val;
     int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
-    int mb_pos2, q1, q2;
+    int q1, q2 = 0;
 
     /* find prediction - wmv3_dc_scale always used here in fact */
     if (n < 4)     scale = s->y_dc_scale;
@@ -1751,28 +1751,32 @@
         if(abs(a - b) <= abs(b - c)) {
             pred = c;
             *dir_ptr = 1;//left
+            q2 = s->current_picture.qscale_table[mb_pos - 1];
         } else {
             pred = a;
             *dir_ptr = 0;//top
+            q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
         }
     } else if(a_avail) {
         pred = a;
         *dir_ptr = 0;//top
+        q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
     } else if(c_avail) {
         pred = c;
         *dir_ptr = 1;//left
+        q2 = s->current_picture.qscale_table[mb_pos - 1];
     } else {
         pred = 0;
         *dir_ptr = 1;//left
     }
 
-    /* scale coeffs if needed
-    mb_pos2 = mb_pos - *dir_ptr - (1 - *dir_ptr) * s->mb_stride;
-    q1 = s->y_dc_scale_table[s->current_picture.qscale_table[mb_pos]];
-    q2 = s->y_dc_scale_table[s->current_picture.qscale_table[mb_pos2]];
-    if(q2 && q1!=q2 && ((*dir_ptr && c_avail) || (!*dir_ptr && a_avail))) {
-        pred = (pred * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
-    } */
+    /* scale coeffs if needed */
+    q1 = s->current_picture.qscale_table[mb_pos];
+    if(n && n<4) q2=q1;
+
+    if(q2 && q1!=q2) {
+        pred = (pred * s->y_dc_scale_table[q2] * vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
+    }
 
     /* update predictor */
     *dc_val_ptr = &dc_val[0];
@@ -2064,6 +2068,7 @@
     int a_avail = v->a_avail, c_avail = v->c_avail;
     int use_pred = s->ac_pred;
     int scale;
+    int q1, q2 = 0;
 
     /* XXX: Guard against dumb values of mquant */
     mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant );
@@ -2134,6 +2139,11 @@
     else //top
         ac_val -= 16 * s->block_wrap[n];
 
+    q1 = s->current_picture.qscale_table[mb_pos];
+    if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];
+    if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
+    if(n && n<4) q2 = q1;
+
     if(coded) {
         int last = 0, skip, value;
         const int8_t *zz_table;
@@ -2152,13 +2162,7 @@
         /* apply AC prediction if needed */
         if(use_pred) {
             /* scale predictors if needed*/
-            int mb_pos2, q1, q2;
-
-            mb_pos2 = mb_pos - dc_pred_dir - (1 - dc_pred_dir) * s->mb_stride;
-            q1 = s->current_picture.qscale_table[mb_pos];
-            q2 = s->current_picture.qscale_table[mb_pos2];
-
-            if(0 && q2 && q1!=q2 && ((dc_pred_dir && c_avail) || (!dc_pred_dir && a_avail))) {
+            if(q2 && q1!=q2) {
                 q1 = q1 * 2 - 1;
                 q2 = q2 * 2 - 1;
 
@@ -2196,17 +2200,12 @@
         if(use_pred) i = 63;
     } else { // no AC coeffs
         int k;
-        int mb_pos2, q1, q2;
-
-        mb_pos2 = mb_pos - dc_pred_dir - (1 - dc_pred_dir) * s->mb_stride;
-        q1 = s->current_picture.qscale_table[mb_pos];
-        q2 = s->current_picture.qscale_table[mb_pos2];
 
         memset(ac_val2, 0, 16 * 2);
         if(dc_pred_dir) {//left
             if(use_pred) {
                 memcpy(ac_val2, ac_val, 8 * 2);
-                if(0 && q2 && q1!=q2 && c_avail) {
+                if(q2 && q1!=q2) {
                     q1 = q1 * 2 - 1;
                     q2 = q2 * 2 - 1;
                     for(k = 1; k < 8; k++)
@@ -2216,7 +2215,7 @@
         } else {//top
             if(use_pred) {
                 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
-                if(0 && q2 && q1!=q2 && a_avail) {
+                if(q2 && q1!=q2) {
                     q1 = q1 * 2 - 1;
                     q2 = q2 * 2 - 1;
                     for(k = 1; k < 8; k++)