[Ffmpeg-devel] [RFC] VC-1 I-frames decoder

Michael Niedermayer michaelni
Sun Jun 18 13:14:17 CEST 2006


Hi

On Sun, Jun 18, 2006 at 06:21:46AM +0300, Kostya wrote:
> On Sat, Jun 17, 2006 at 12:52:34PM +0200, Michael Niedermayer wrote:
> > Hi
> > 
> > On Sat, Jun 17, 2006 at 07:43:18AM +0300, Kostya wrote:
> > > Here is my VC-1 decoder which decodes I-frames only. And not all of them are decoded properly too.
> > > Nevertheless I want to get opinions on this implementation before moving to P-frames support.
> > > P.S. If somebody will find and fix bugs in AC prediction it would be incredibly great.
> > 
> > hmm, are ac predicted coeffs dequantized in non-coded blocks?
> 
> If AC prediction is present then some AC coeffs are copied from previous block and dequantized
> no matter was block coded or not.

i can see that part in your latest patch but i dont see where that would
have been done in your previous patch which was the latest when i wrote my
reply ...

previous patch:
+        /* scale AC coeffs */
+        for(k = 1; k < 64; k++)
+            if(block[k]) {
+                block[k] *= scale;
+                if(v->quantizer_mode != QUANT_UNIFORM)
+                    block[k] += (block[k] < 0) ? -mquant : mquant;
+            }
+
+        if(s->ac_pred) i = 63;
+    }
+
+not_coded:
+    if(!coded) {
+        int k;
+        ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
+        ac_val2 = ac_val;
+        if(dc_pred_dir) //left
+            ac_val -= 16;
+        else //top
+            ac_val -= 16 * s->block_wrap[n];
+        /* apply AC prediction if needed */
+        if(s->ac_pred) {
+            if(dc_pred_dir) { //left
+                for(k = 1; k < 8; k++)
+                    block[k << 3] += ac_val[k];
+            } else { //top
+                for(k = 1; k < 8; k++)
+                    block[k] += ac_val[k + 8];
+            }
+        }
+        /* save AC coeffs for further prediction */
+        for(k = 1; k < 8; k++) {
+            ac_val2[k] = block[k << 3];
+            ac_val2[k + 8] = block[k];
+        }
+        i = 63;
+    }
+    s->block_last_index[n] = i;
+
+    return 0;
+}


latest patch:
+not_coded:
+    if(!coded) {
+        int k, scale;
+        ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
+        ac_val2 = ac_val;
+        scale = mquant * 2 + v->halfpq;
+        if(dc_pred_dir) {//left
+            ac_val -= 16;
+            memcpy(ac_val2, ac_val, 8 * sizeof(ac_val[0]));
+            memset(ac_val2 + 8, 0, 8 * sizeof(ac_val[0]));
+        } else {//top
+            ac_val -= 16 * s->block_wrap[n];
+            memcpy(ac_val2 + 8, ac_val, 8 * sizeof(ac_val[0]));
+            memset(ac_val2, 0, 8 * sizeof(ac_val[0]));
+        }
+
+        /* apply AC prediction if needed */
+        if(s->ac_pred) {
+            if(dc_pred_dir) { //left
+                for(k = 1; k < 8; k++) {
+                    block[k << 3] = ac_val[k] * scale;
+                    if(v->quantizer_mode != QUANT_UNIFORM)
+                        block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
+                }
+            } else { //top
+                for(k = 1; k < 8; k++) {
+                    block[k] = ac_val[k + 8] * scale;
+                    if(v->quantizer_mode != QUANT_UNIFORM)
+                        block[k] += (block[k] < 0) ? -mquant : mquant;
+                }
+            }
+        }
+        i = 63;
+    }
+    s->block_last_index[n] = i;
+
+    return 0;
+}


your latest patch also copies the ac prediction around even if ac_pred=0
i dont think thats correct ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list