[SCM] libav/experimental: Allow clean initialization of lut_status array by changing type to signed int.

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 17:18:50 UTC 2013


The following commit has been merged in the experimental branch:
commit 4051ae7617f450e604ee951eb8e362bbf9f05211
Author: Thilo Borgmann <thilo.borgmann at googlemail.com>
Date:   Mon Nov 8 15:22:15 2010 +0000

    Allow clean initialization of lut_status array by changing type to signed int.
    
    Originally committed as revision 25710 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 6993bb9..20dbe43 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -203,7 +203,7 @@ typedef struct {
     unsigned int num_blocks;        ///< number of blocks used in the current frame
     unsigned int s_max;             ///< maximum Rice parameter allowed in entropy coding
     uint8_t *bgmc_lut;              ///< pointer at lookup tables used for BGMC
-    unsigned int *bgmc_lut_status;  ///< pointer at lookup table status flags used for BGMC
+    int *bgmc_lut_status;  ///< pointer at lookup table status flags used for BGMC
     int ltp_lag_length;             ///< number of bits used for ltp lag value
     int *use_ltp;                   ///< contains use_ltp flags for all channels
     int *ltp_lag;                   ///< contains ltp lag values for all channels
@@ -749,7 +749,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
 
     // read all residuals
     if (sconf->bgmc) {
-        unsigned int delta[8];
+        int delta[8];
         unsigned int k    [8];
         unsigned int b = av_clip((av_ceil_log2(bd->block_length) - 3) >> 1, 0, 5);
         unsigned int i = start;
diff --git a/libavcodec/bgmc.c b/libavcodec/bgmc.c
index ffe3cea..b9041d0 100644
--- a/libavcodec/bgmc.c
+++ b/libavcodec/bgmc.c
@@ -426,8 +426,8 @@ static const uint16_t * const cf_table[16] = {
 
 /** Initialize a given lookup table using a given delta
  */
-static void bgmc_lut_fillp(uint8_t *lut, unsigned int *lut_status,
-                           unsigned int delta)
+static void bgmc_lut_fillp(uint8_t *lut, int *lut_status,
+                           int delta)
 {
     unsigned int sx, i;
 
@@ -448,8 +448,8 @@ static void bgmc_lut_fillp(uint8_t *lut, unsigned int *lut_status,
 
 /** Retune the index of a suitable lookup table for a given delta
  */
-static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status,
-                              unsigned int delta)
+static uint8_t* bgmc_lut_getp(uint8_t *lut, int *lut_status,
+                              int delta)
 {
     unsigned int i = av_clip(delta, 0, LUT_BUFF - 1);
 
@@ -464,7 +464,7 @@ static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status,
 
 /** Initialize the lookup table arrays
  */
-int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status)
+int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
 {
     *cf_lut        = av_malloc(sizeof(*cf_lut       ) * LUT_BUFF * 16 * LUT_SIZE);
     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
@@ -473,6 +473,9 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_
         ff_bgmc_end(cf_lut, cf_lut_status);
         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
         return AVERROR(ENOMEM);
+    } else {
+        // initialize lut_status buffer to a value never used to compare against
+        memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF);
     }
 
     return 0;
@@ -481,7 +484,7 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_
 
 /** Release the lookup table arrays
  */
-void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status)
+void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
 {
     av_freep(cf_lut);
     av_freep(cf_lut_status);
@@ -510,9 +513,9 @@ void ff_bgmc_decode_end(GetBitContext *gb)
 /** Read and decode a block Gilbert-Moore coded symbol
  */
 void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
-                 unsigned int delta, unsigned int sx,
+                 int delta, unsigned int sx,
                  unsigned int *h, unsigned int *l, unsigned int *v,
-                 uint8_t *cf_lut, unsigned int *cf_lut_status)
+                 uint8_t *cf_lut, int *cf_lut_status)
 {
     unsigned int i;
     uint8_t *lut = bgmc_lut_getp(cf_lut, cf_lut_status, delta);
diff --git a/libavcodec/bgmc.h b/libavcodec/bgmc.h
index eab413b..9e386fd 100644
--- a/libavcodec/bgmc.h
+++ b/libavcodec/bgmc.h
@@ -34,10 +34,10 @@
 #include "get_bits.h"
 
 
-int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status);
+int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status);
 
 
-void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status);
+void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status);
 
 
 void ff_bgmc_decode_init(GetBitContext *gb,
@@ -48,9 +48,9 @@ void ff_bgmc_decode_end(GetBitContext *gb);
 
 
 void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
-                 unsigned int delta, unsigned int sx,
+                 int delta, unsigned int sx,
                  unsigned int *h, unsigned int *l, unsigned int *v,
-                 uint8_t *cf_lut, unsigned int *cf_lut_status);
+                 uint8_t *cf_lut, int *cf_lut_status);
 
 
 #endif /* AVCODEC_BGMC_H */

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list