[FFmpeg-cvslog] ea: Convert to the new bitstream reader

Alexandra Hájková git at videolan.org
Mon Apr 3 21:38:35 EEST 2017


ffmpeg | branch: master | Alexandra Hájková <alexandra at khirnov.net> | Sat Apr  9 20:31:47 2016 +0200| [7d957b3f477a8cb333f8ef2697c9aa5363ad0c9f] | committer: Anton Khirnov

ea: Convert to the new bitstream reader

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7d957b3f477a8cb333f8ef2697c9aa5363ad0c9f
---

 libavcodec/eatgq.c | 34 +++++++++++++++++-----------------
 libavcodec/eatgv.c | 22 +++++++++++-----------
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index 8355471..9abedcc 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -31,9 +31,9 @@
 #define BITSTREAM_READER_LE
 #include "aandcttab.h"
 #include "avcodec.h"
+#include "bitstream.h"
 #include "bytestream.h"
 #include "eaidct.h"
-#include "get_bits.h"
 #include "idctdsp.h"
 #include "internal.h"
 
@@ -58,44 +58,44 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx)
     return 0;
 }
 
-static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb)
+static void tgq_decode_block(TgqContext *s, int16_t block[64], BitstreamContext *bc)
 {
     uint8_t *perm = s->scantable.permutated;
     int i, j, value;
-    block[0] = get_sbits(gb, 8) * s->qtable[0];
+    block[0] = bitstream_read_signed(bc, 8) * s->qtable[0];
     for (i = 1; i < 64;) {
-        switch (show_bits(gb, 3)) {
+        switch (bitstream_peek(bc, 3)) {
         case 4:
             block[perm[i++]] = 0;
         case 0:
             block[perm[i++]] = 0;
-            skip_bits(gb, 3);
+            bitstream_skip(bc, 3);
             break;
         case 5:
         case 1:
-            skip_bits(gb, 2);
-            value = get_bits(gb, 6);
+            bitstream_skip(bc, 2);
+            value = bitstream_read(bc, 6);
             for (j = 0; j < value; j++)
                 block[perm[i++]] = 0;
             break;
         case 6:
-            skip_bits(gb, 3);
+            bitstream_skip(bc, 3);
             block[perm[i]] = -s->qtable[perm[i]];
             i++;
             break;
         case 2:
-            skip_bits(gb, 3);
+            bitstream_skip(bc, 3);
             block[perm[i]] = s->qtable[perm[i]];
             i++;
             break;
         case 7: // 111b
         case 3: // 011b
-            skip_bits(gb, 2);
-            if (show_bits(gb, 6) == 0x3F) {
-                skip_bits(gb, 6);
-                block[perm[i]] = get_sbits(gb, 8) * s->qtable[perm[i]];
+            bitstream_skip(bc, 2);
+            if (bitstream_peek(bc, 6) == 0x3F) {
+                bitstream_skip(bc, 6);
+                block[perm[i]] = bitstream_read_signed(bc, 8) * s->qtable[perm[i]];
             } else {
-                block[perm[i]] = get_sbits(gb, 6) * s->qtable[perm[i]];
+                block[perm[i]] = bitstream_read_signed(bc, 6) * s->qtable[perm[i]];
             }
             i++;
             break;
@@ -156,10 +156,10 @@ static void tgq_decode_mb(TgqContext *s, AVFrame *frame, int mb_y, int mb_x)
 
     mode = bytestream2_get_byte(&s->gb);
     if (mode > 12) {
-        GetBitContext gb;
-        init_get_bits(&gb, s->gb.buffer, FFMIN(s->gb.buffer_end - s->gb.buffer, mode) * 8);
+        BitstreamContext bc;
+        bitstream_init(&bc, s->gb.buffer, FFMIN(s->gb.buffer_end - s->gb.buffer, mode) * 8);
         for (i = 0; i < 6; i++)
-            tgq_decode_block(s, s->block[i], &gb);
+            tgq_decode_block(s, s->block[i], &bc);
         tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);
         bytestream2_skip(&s->gb, mode);
     } else {
diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
index 7a50d01..549b5b6 100644
--- a/libavcodec/eatgv.c
+++ b/libavcodec/eatgv.c
@@ -33,7 +33,7 @@
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
 #include "internal.h"
 
 #define EA_PREAMBLE_SIZE    8
@@ -153,7 +153,7 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
     int num_blocks_packed;
     int vector_bits;
     int i,j,x,y;
-    GetBitContext gb;
+    BitstreamContext bc;
     int mvbits;
     const uint8_t *blocks_raw;
 
@@ -166,7 +166,7 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
     vector_bits       = AV_RL16(&buf[6]);
     buf += 12;
 
-    if (vector_bits > MIN_CACHE_BITS || !vector_bits) {
+    if (vector_bits > 32 || !vector_bits) {
         av_log(s->avctx, AV_LOG_ERROR,
                "Invalid value for motion vector bits: %d\n", vector_bits);
         return AVERROR_INVALIDDATA;
@@ -195,10 +195,10 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
     if (buf + (mvbits >> 3) + 16 * num_blocks_raw + 8 * num_blocks_packed > buf_end)
         return AVERROR_INVALIDDATA;
 
-    init_get_bits(&gb, buf, mvbits);
+    bitstream_init(&bc, buf, mvbits);
     for (i = 0; i < num_mvs; i++) {
-        s->mv_codebook[i][0] = get_sbits(&gb, 10);
-        s->mv_codebook[i][1] = get_sbits(&gb, 10);
+        s->mv_codebook[i][0] = bitstream_read_signed(&bc, 10);
+        s->mv_codebook[i][1] = bitstream_read_signed(&bc, 10);
     }
     buf += mvbits >> 3;
 
@@ -207,23 +207,23 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
     buf       += num_blocks_raw * 16;
 
     /* read compressed blocks */
-    init_get_bits(&gb, buf, (buf_end - buf) << 3);
+    bitstream_init(&bc, buf, (buf_end - buf) << 3);
     for (i = 0; i < num_blocks_packed; i++) {
         int tmp[4];
         for (j = 0; j < 4; j++)
-            tmp[j] = get_bits(&gb, 8);
+            tmp[j] = bitstream_read(&bc, 8);
         for (j = 0; j < 16; j++)
-            s->block_codebook[i][15-j] = tmp[get_bits(&gb, 2)];
+            s->block_codebook[i][15-j] = tmp[bitstream_read(&bc, 2)];
     }
 
-    if (get_bits_left(&gb) < vector_bits *
+    if (bitstream_bits_left(&bc) < vector_bits *
         (s->avctx->height / 4) * (s->avctx->width / 4))
         return AVERROR_INVALIDDATA;
 
     /* read vectors and build frame */
     for (y = 0; y < s->avctx->height / 4; y++)
         for (x = 0; x < s->avctx->width / 4; x++) {
-            unsigned int vector = get_bits(&gb, vector_bits);
+            unsigned int vector = bitstream_read(&bc, vector_bits);
             const uint8_t *src;
             ptrdiff_t src_stride;
 



More information about the ffmpeg-cvslog mailing list