]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bgmc.c
lavc: Drop deprecated way of setting codec dimensions
[ffmpeg] / libavcodec / bgmc.c
index ec8cf9bc0a8babd2d78a6eb0c607f8cf2450329c..1de67537af6462f4154a21bfe35f823a5087781d 100644 (file)
@@ -25,6 +25,9 @@
  * @author Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
  */
 
+#include "libavutil/attributes.h"
+
+#include "bitstream.h"
 #include "bgmc.h"
 
 #define FREQ_BITS  14                      // bits used by frequency counters
@@ -456,10 +459,11 @@ static uint8_t *bgmc_lut_getp(uint8_t *lut, int *lut_status, int delta)
 
 
 /** Initialize the lookup table arrays */
-int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
+av_cold 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);
+    *cf_lut        = av_malloc(sizeof(**cf_lut)        * LUT_BUFF * 16 * LUT_SIZE);
+    *cf_lut_status = av_malloc(sizeof(**cf_lut_status) * LUT_BUFF);
 
     if (!*cf_lut || !*cf_lut_status) {
         ff_bgmc_end(cf_lut, cf_lut_status);
@@ -467,7 +471,7 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
         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);
+        memset(*cf_lut_status, -1, sizeof(**cf_lut_status) * LUT_BUFF);
     }
 
     return 0;
@@ -475,7 +479,7 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
 
 
 /** Release the lookup table arrays */
-void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
+av_cold void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
 {
     av_freep(cf_lut);
     av_freep(cf_lut_status);
@@ -483,24 +487,26 @@ void ff_bgmc_end(uint8_t **cf_lut, 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)
+void ff_bgmc_decode_init(BitstreamContext *bc, unsigned int *h,
+                         unsigned int *l, unsigned int *v)
 {
     *h = TOP_VALUE;
     *l = 0;
-    *v = get_bits_long(gb, VALUE_BITS);
+    *v = bitstream_read(bc, VALUE_BITS);
 }
 
 
 /** Finish decoding */
-void ff_bgmc_decode_end(GetBitContext *gb)
+void ff_bgmc_decode_end(BitstreamContext *bc)
 {
-    skip_bits_long(gb, -(VALUE_BITS - 2));
+    unsigned pos = bitstream_tell(bc) - VALUE_BITS + 2;
+
+    bitstream_seek(bc, pos);
 }
 
 
 /** Read and decode a block Gilbert-Moore coded symbol */
-void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
+void ff_bgmc_decode(BitstreamContext *bc, unsigned int num, int32_t *dst,
                     int delta, unsigned int sx,
                     unsigned int *h, unsigned int *l, unsigned int *v,
                     uint8_t *cf_lut, int *cf_lut_status)
@@ -545,7 +551,7 @@ void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
 
             low  *= 2;
             high  = 2 * high + 1;
-            value = 2 * value + get_bits1(gb);
+            value = 2 * value + bitstream_read_bit(bc);
         }
 
         *dst++ = symbol;