[FFmpeg-cvslog] r21962 - in trunk/libavcodec: indeo5.c ivi_common.c ivi_common.h

kostya subversion
Mon Feb 22 14:51:32 CET 2010


Author: kostya
Date: Mon Feb 22 14:51:32 2010
New Revision: 21962

Log:
Macroblock and block Huffman code sets are to be used by both Indeo 4 and
Indeo 5, so make them global and move their initialization to the common place
as well. And fix static VLC initialization, as ff_ivi_create_huff_from_desc()
used old way to do so.

Modified:
   trunk/libavcodec/indeo5.c
   trunk/libavcodec/ivi_common.c
   trunk/libavcodec/ivi_common.h

Modified: trunk/libavcodec/indeo5.c
==============================================================================
--- trunk/libavcodec/indeo5.c	Mon Feb 22 13:35:12 2010	(r21961)
+++ trunk/libavcodec/indeo5.c	Mon Feb 22 14:51:32 2010	(r21962)
@@ -79,10 +79,6 @@ typedef struct {
     IVIPicConfig    pic_conf;
 } IVI5DecContext;
 
-//! static vlc tables (initialized at startup)
-static VLC mb_vlc_tabs [8];
-static VLC blk_vlc_tabs[8];
-
 
 /**
  *  Decodes Indeo5 GOP (Group of pictures) header.
@@ -346,7 +342,7 @@ static int decode_pic_hdr(IVI5DecContext
         if (ctx->frame_flags & 0x40) {
             ctx->mb_huff_sel = ff_ivi_dec_huff_desc(&ctx->gb, &new_huff);
             if (ctx->mb_huff_sel != 7) {
-                ctx->mb_vlc = &mb_vlc_tabs[ctx->mb_huff_sel];
+                ctx->mb_vlc = &ff_ivi_mb_vlc_tabs[ctx->mb_huff_sel];
             } else {
                 if (ff_ivi_huff_desc_cmp(&new_huff, &ctx->mb_huff_desc)) {
                     ff_ivi_huff_desc_copy(&ctx->mb_huff_desc, &new_huff);
@@ -363,7 +359,7 @@ static int decode_pic_hdr(IVI5DecContext
                 ctx->mb_vlc = &ctx->mb_vlc_cust;
             }
         } else {
-            ctx->mb_vlc = &mb_vlc_tabs[7]; /* select the default macroblock huffman table */
+            ctx->mb_vlc = &ff_ivi_mb_vlc_tabs[7]; /* select the default macroblock huffman table */
         }
 
         skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
@@ -426,7 +422,7 @@ static int decode_band_hdr(IVI5DecContex
     if (band_flags & 0x80) {
         band->huff_sel = ff_ivi_dec_huff_desc(&ctx->gb, &new_huff);
         if (band->huff_sel != 7) {
-            band->blk_vlc = &blk_vlc_tabs[band->huff_sel];
+            band->blk_vlc = &ff_ivi_blk_vlc_tabs[band->huff_sel];
         } else {
             if (ff_ivi_huff_desc_cmp(&new_huff, &band->huff_desc)) {
                 ff_ivi_huff_desc_copy(&band->huff_desc, &new_huff);
@@ -443,7 +439,7 @@ static int decode_band_hdr(IVI5DecContex
             band->blk_vlc = &band->blk_vlc_cust;
         }
     } else {
-        band->blk_vlc = &blk_vlc_tabs[7]; /* select the default macroblock huffman table */
+        band->blk_vlc = &ff_ivi_blk_vlc_tabs[7]; /* select the default macroblock huffman table */
     }
 
     band->checksum_present = get_bits1(&ctx->gb);
@@ -752,13 +748,9 @@ static void switch_buffers(IVI5DecContex
 static av_cold int decode_init(AVCodecContext *avctx)
 {
     IVI5DecContext  *ctx = avctx->priv_data;
-    int             i, result;
+    int             result;
 
-    /* initialize static vlc tables for macroblock/block signals */
-    for (i = 0; i < 8; i++) {
-        ff_ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i],  &mb_vlc_tabs[i],  1);
-        ff_ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &blk_vlc_tabs[i], 1);
-    }
+    ff_ivi_init_static_vlc();
 
     /* copy rvmap tables in our context so we can apply changes to them */
     memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));

Modified: trunk/libavcodec/ivi_common.c
==============================================================================
--- trunk/libavcodec/ivi_common.c	Mon Feb 22 13:35:12 2010	(r21961)
+++ trunk/libavcodec/ivi_common.c	Mon Feb 22 14:51:32 2010	(r21962)
@@ -33,6 +33,12 @@
 #include "libavutil/common.h"
 #include "ivi_dsp.h"
 
+extern const IVIHuffDesc ff_ivi_mb_huff_desc[8];  ///< static macroblock huffman tables
+extern const IVIHuffDesc ff_ivi_blk_huff_desc[8]; ///< static block huffman tables
+
+VLC ff_ivi_mb_vlc_tabs [8];
+VLC ff_ivi_blk_vlc_tabs[8];
+
 /**
  *  Reverses "nbits" bits of the value "val" and returns the result
  *  in the least significant bits.
@@ -80,7 +86,26 @@ int ff_ivi_create_huff_from_desc(const I
 
     /* number of codewords = pos */
     return init_vlc(vlc, IVI_VLC_BITS, pos, bits, 1, 1, codewords, 2, 2,
-                    (flag & 1) | INIT_VLC_LE);
+                    (flag ? INIT_VLC_USE_NEW_STATIC : 0) | INIT_VLC_LE);
+}
+
+void ff_ivi_init_static_vlc()
+{
+    int i;
+    static VLC table_data[8192 * 16][2];
+    static int initialized_vlcs = 0;
+
+    if (initialized_vlcs)
+        return;
+    for (i = 0; i < 8; i++) {
+        ff_ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192;
+        ff_ivi_mb_vlc_tabs[i].table_allocated = 8192;
+        ff_ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i],  &ff_ivi_mb_vlc_tabs[i],  1);
+        ff_ivi_blk_vlc_tabs[i].table = table_data + (i * 2 + 1) * 8192;
+        ff_ivi_blk_vlc_tabs[i].table_allocated = 8192;
+        ff_ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &ff_ivi_blk_vlc_tabs[i], 1);
+    }
+    initialized_vlcs = 1;
 }
 
 int ff_ivi_dec_huff_desc(GetBitContext *gb, IVIHuffDesc *desc)

Modified: trunk/libavcodec/ivi_common.h
==============================================================================
--- trunk/libavcodec/ivi_common.h	Mon Feb 22 13:35:12 2010	(r21961)
+++ trunk/libavcodec/ivi_common.h	Mon Feb 22 14:51:32 2010	(r21962)
@@ -45,8 +45,8 @@ typedef struct {
     uint8_t     xbits[16];
 } IVIHuffDesc;
 
-extern const IVIHuffDesc ff_ivi_mb_huff_desc[8];  ///< static macroblock huffman tables
-extern const IVIHuffDesc ff_ivi_blk_huff_desc[8]; ///< static block huffman tables
+extern VLC ff_ivi_mb_vlc_tabs [8]; ///< static macroblock Huffman tables
+extern VLC ff_ivi_blk_vlc_tabs[8]; ///< static block Huffman tables
 
 
 /**
@@ -203,6 +203,11 @@ static inline int ivi_scale_mv(int mv, i
 int  ff_ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag);
 
 /**
+ * Initializes static codes used for macroblock and block decoding.
+ */
+void ff_ivi_init_static_vlc();
+
+/**
  *  Decodes a huffman codebook descriptor from the bitstream.
  *
  *  @param gb   [in,out] the GetBit context



More information about the ffmpeg-cvslog mailing list