[FFmpeg-soc] [soc]: r493 - in rv40: rv40.c rv40data.h rv40vlc2.h

kostya subversion at mplayerhq.hu
Fri Jul 20 13:51:21 CEST 2007


Author: kostya
Date: Fri Jul 20 13:51:21 2007
New Revision: 493

Log:
Some code for future intraframe decoding

Modified:
   rv40/rv40.c
   rv40/rv40data.h
   rv40/rv40vlc2.h

Modified: rv40/rv40.c
==============================================================================
--- rv40/rv40.c	(original)
+++ rv40/rv40.c	Fri Jul 20 13:51:21 2007
@@ -79,11 +79,13 @@ typedef struct RV40DecContext{
     SliceInfo prev_si;       ///< info for the saved slice
     uint8_t *slice_data;     ///< saved slice data
     int has_slice;           ///< has previously saved slice
+    int skip_blocks;         ///< blocks to skip (interframe slice only)
 }RV40DecContext;
 
 static RV40VLC intra_vlcs[NUM_INTRA_TABLES], inter_vlcs[NUM_INTER_TABLES];
 static VLC aic_top_vlc;
 static VLC aic_mode1_vlc[AIC_MODE1_NUM], aic_mode2_vlc[AIC_MODE2_NUM];
+static VLC mbinfo_vlc;
 
 /**
  * @defgroup vlc RV40 VLC generating functions
@@ -190,6 +192,10 @@ static void rv40_init_tables()
                  aic_mode2_vlc_bits[i],  1, 1,
                  aic_mode2_vlc_codes[i], 2, 2, INIT_VLC_USE_STATIC);
     }
+    init_vlc_sparse(&mbinfo_vlc, MBINFO_BITS, NUM_MBINFO,
+                    mbinfo_vlc_bits,  1, 1,
+                    mbinfo_vlc_codes, 1, 1,
+                    mbinfo_vlc_syms,  1, 1, INIT_VLC_USE_STATIC);
 }
 
 /** @} */ // vlc group
@@ -509,7 +515,10 @@ static int rv40_parse_slice_header(RV40D
     if(get_bits1(gb))
         return -1;
     t = get_bits(gb, 13); /// ???
-    rv40_parse_picture_size(gb, &w, &h);
+    if(!si->type)
+        rv40_parse_picture_size(gb, &w, &h);
+    else
+        get_bits1(gb);
 //    r->s.avctx->coded_width  = w;
 //    r->s.avctx->coded_height = h;
     mb_bits = av_log2((w + 7) >> 3) + av_log2((h + 7) >> 3);
@@ -582,6 +591,62 @@ static int rv40_decode_intra_types(RV40D
     return 0;
 }
 
+/**
+ * Decode quantizer difference and return modified quantizer
+ */
+static inline int rv40_decode_dquant(GetBitContext *gb, int quant)
+{
+    if(get_bits1(gb))
+        return av_clip(quant + rv40_dquant_tab[quant * 2 + get_bits1(gb)], 0, 31);
+    else
+        return get_bits(gb, 5);
+}
+
+/**
+ * Decode variable-length code constructed from variable-length codes
+ * similar to Even-Rodeh and Elias Omega codes
+ *
+ * Code is constructed from bit chunks of even length (odd length means end of code)
+ * and chunks are coded with variable-length codes too
+ */
+static inline int get_omega(GetBitContext *gb)
+{
+    int bits = 0, code = 0, t, tb;
+
+    for(;;){
+        t = get_vlc2(gb, mbinfo_vlc.table, MBINFO_BITS, 1);
+        tb = t >> 4;
+        code = (code << tb) | (t & 0xF);
+        bits += tb;
+        if(bits & 1) break;
+    }
+    return (code >> 1) | (1 << (bits - 1));
+}
+
+/**
+ * Decode macroblock information
+ */
+static int rv40_decode_mb_info(RV40DecContext *r, int *skip, int *mv_bits)
+{
+    MpegEncContext *s = &r->s;
+    GetBitContext *gb = &s->gb;
+
+    if(r->skip_blocks){
+         r->skip_blocks--;
+    }else{
+        r->skip_blocks = get_omega(gb);
+    }
+    if(r->skip_blocks){
+         *skip = 0;
+         r->skip_blocks--;
+         return 0;
+    }
+
+    //TODO: get size of mv from near blocks and select maximum value
+    //      then get size for the current MB and optional dquant
+    return 0;
+}
+
 /** Mapping of RV40 intra prediction types to standard H.264 types */
 static const int ittrans[9] = {
  DC_PRED, VERT_PRED, HOR_PRED, DIAG_DOWN_RIGHT_PRED, DIAG_DOWN_LEFT_PRED,

Modified: rv40/rv40data.h
==============================================================================
--- rv40/rv40data.h	(original)
+++ rv40/rv40data.h	Fri Jul 20 13:51:21 2007
@@ -157,4 +157,14 @@ static const uint8_t rv40_quant_to_vlc_s
  { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3,
    3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6 },
 };
+
+/**
+ * Table for obtaining quantizer difference
+ */
+static const int8_t rv40_dquant_tab[] = {
+  0,  0,  2,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1,  1,
+ -1,  1, -1,  1, -1,  1, -2,  2, -2,  2, -2,  2, -2,  2, -2,  2,
+ -2,  2, -2,  2, -2,  2, -2,  2, -2,  2, -3,  3, -3,  3, -3,  3,
+ -3,  3, -3,  3, -3,  3, -3,  3, -3,  3, -3,  2, -3,  1, -3, -5
+};
 #endif /* RV40DATA_H */

Modified: rv40/rv40vlc2.h
==============================================================================
--- rv40/rv40vlc2.h	(original)
+++ rv40/rv40vlc2.h	Fri Jul 20 13:51:21 2007
@@ -632,4 +632,31 @@ static const uint8_t aic_mode1_vlc_bits[
 
 //@}
 
+/** Tables used in macroblock information decoding */
+//@{
+#define NUM_MBINFO 31
+#define MBINFO_BITS 8
+
+static const uint8_t mbinfo_vlc_codes[NUM_MBINFO] = {
+ 0x00, 0x01, 0x01, 0x04, 0x05, 0x03, 0x01,
+ 0x10, 0x11, 0x09, 0x14, 0x15, 0x0B, 0x03, 0x01,
+ 0x40, 0x41, 0x21, 0x44, 0x45, 0x23, 0x09,
+ 0x50, 0x51, 0x29, 0x54, 0x55, 0x2B, 0x0B, 0x03, 0x01
+};
+
+static const uint8_t mbinfo_vlc_bits[NUM_MBINFO] = {
+ 8, 8, 7, 8, 8, 7, 5,
+ 8, 8, 7, 8, 8, 7, 5, 3,
+ 8, 8, 7, 8, 8, 7, 5,
+ 8, 8, 7, 8, 8, 7, 5, 3, 1
+};
+
+static const uint8_t mbinfo_vlc_syms[NUM_MBINFO] = {
+ 0x40, 0x41, 0x30, 0x42, 0x43, 0x31, 0x20,
+ 0x44, 0x45, 0x32, 0x46, 0x47, 0x33, 0x21, 0x10,
+ 0x48, 0x49, 0x34, 0x4A, 0x4B, 0x35, 0x22,
+ 0x4C, 0x4D, 0x36, 0x4E, 0x4F, 0x37, 0x23, 0x11, 0x00
+};
+//@}
+
 #endif /* RV40VLC2_H */



More information about the FFmpeg-soc mailing list