changeset 59:efd3c19f6d62 libavcodec

fixed mpeg2 non intra dequant - fixed MPEG1 and 2 matrix parsing
author glantau
date Sun, 12 Aug 2001 00:52:01 +0000
parents 0e0a24def67a
children 35c1141e23d9
files mpeg12.c
diffstat 1 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mpeg12.c	Sat Aug 11 22:08:23 2001 +0000
+++ b/mpeg12.c	Sun Aug 12 00:52:01 2001 +0000
@@ -554,6 +554,7 @@
             s->mv_dir = MV_DIR_FORWARD;
             s->mv[0][0][0] = s->mv[0][0][1] = 0;
             s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
+            s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
         } else {
             /* if B type, reuse previous vectors and directions */
             s->mv[0][0][0] = s->last_mv[0][0][0];
@@ -981,7 +982,13 @@
     add_coef:
 	j = scan_table[i];
         dprintf("%d: run=%d level=%d\n", n, run, level);
-        level = ((level * 2 + 1) * s->qscale * matrix[j]) / 32;
+        /* XXX: optimize */
+        if (level > 0) {
+            level = ((level * 2 + 1) * s->qscale * matrix[j]) >> 5;
+        } else {
+            level = ((-level * 2 + 1) * s->qscale * matrix[j]) >> 5;
+            level = -level;
+        }
         /* XXX: is it really necessary to saturate since the encoder
            knows whats going on ? */
         mismatch ^= level;
@@ -1029,7 +1036,7 @@
         matrix = s->intra_matrix;
     else
         matrix = s->chroma_intra_matrix;
-        
+
     /* now quantify & encode AC coefs */
     for(;;) {
         code = get_vlc(&s->gb, &rl->vlc);
@@ -1183,10 +1190,12 @@
 {
     int i, v, j;
 
+    dprintf("matrix extension\n");
+
     if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
-            j = block_permute_op(i);
+            j = zigzag_direct[i];
             s->intra_matrix[j] = v;
             s->chroma_intra_matrix[j] = v;
         }
@@ -1194,7 +1203,7 @@
     if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
-            j = block_permute_op(i);
+            j = zigzag_direct[i];
             s->non_intra_matrix[j] = v;
             s->chroma_non_intra_matrix[j] = v;
         }
@@ -1202,14 +1211,14 @@
     if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
-            j = block_permute_op(i);
+            j = zigzag_direct[i];
             s->chroma_intra_matrix[j] = v;
         }
     }
     if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
-            j = block_permute_op(i);
+            j = zigzag_direct[i];
             s->chroma_non_intra_matrix[j] = v;
         }
     }
@@ -1234,10 +1243,11 @@
     s->chroma_420_type = get_bits1(&s->gb);
     s->progressive_frame = get_bits1(&s->gb);
     /* composite display not parsed */
-    dprintf("dc_preci=%d\n", s->intra_dc_precision);
-    dprintf("pict_structure=%d\n", s->picture_structure);
+    dprintf("intra_dc_precion=%d\n", s->intra_dc_precision);
+    dprintf("picture_structure=%d\n", s->picture_structure);
     dprintf("conceal=%d\n", s->concealment_motion_vectors);
-    dprintf("intrafmt=%d\n", s->intra_vlc_format);
+    dprintf("intra_vlc_format=%d\n", s->intra_vlc_format);
+    dprintf("alternate_scan=%d\n", s->alternate_scan);
     dprintf("frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
 }
 
@@ -1402,10 +1412,16 @@
     if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
-            j = block_permute_op(i);
+            j = zigzag_direct[i];
             s->intra_matrix[j] = v;
             s->chroma_intra_matrix[j] = v;
         }
+#ifdef DEBUG
+        dprintf("intra matrix present\n");
+        for(i=0;i<64;i++)
+            dprintf(" %d", s->intra_matrix[zigzag_direct[i]]);
+        printf("\n");
+#endif
     } else {
         for(i=0;i<64;i++) {
             v = default_intra_matrix[i];
@@ -1416,10 +1432,16 @@
     if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
-            j = block_permute_op(i);
+            j = zigzag_direct[i];
             s->non_intra_matrix[j] = v;
             s->chroma_non_intra_matrix[j] = v;
         }
+#ifdef DEBUG
+        dprintf("non intra matrix present\n");
+        for(i=0;i<64;i++)
+            dprintf(" %d", s->non_intra_matrix[zigzag_direct[i]]);
+        printf("\n");
+#endif
     } else {
         for(i=0;i<64;i++) {
             v = default_non_intra_matrix[i];