]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bgmc.c
build: Set correct dependencies for rtmp* protocols implemented by librtmp.
[ffmpeg] / libavcodec / bgmc.c
index ffe3cea4a6b6277461a1b08a0a92da4910409b39..b17c3b1f7241f59c3e027c1353eacca34ba71406 100644 (file)
@@ -2,20 +2,20 @@
  * Block Gilbert-Moore decoder
  * Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -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,10 @@ 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 +485,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);
@@ -491,7 +495,7 @@ void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status)
 /** Initialize decoding and reads the first value
  */
 void ff_bgmc_decode_init(GetBitContext *gb,
-                      unsigned int *h, unsigned int *l, unsigned int *v)
+                         unsigned int *h, unsigned int *l, unsigned int *v)
 {
     *h = TOP_VALUE;
     *l = 0;
@@ -510,9 +514,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,
-                 unsigned int *h, unsigned int *l, unsigned int *v,
-                 uint8_t *cf_lut, unsigned int *cf_lut_status)
+                    int delta, unsigned int sx,
+                    unsigned int *h, unsigned int *l, unsigned int *v,
+                    uint8_t *cf_lut, int *cf_lut_status)
 {
     unsigned int i;
     uint8_t *lut = bgmc_lut_getp(cf_lut, cf_lut_status, delta);
@@ -564,4 +568,3 @@ void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
     *l = low;
     *v = value;
 }
-