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

Alexandra Hájková git at videolan.org
Tue Sep 26 21:08:45 EEST 2017


ffmpeg | branch: master | Alexandra Hájková <alexandra at khirnov.net> | Sat Mar 19 17:32:04 2016 +0100| [ab2539bd374fe7ddbc6e2f058b62645cd5076192] | committer: Diego Biurrun

ffv1: Convert to the new bitstream reader

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

 libavcodec/ffv1.h    |  4 ++--
 libavcodec/ffv1dec.c | 24 ++++++++++++------------
 libavcodec/ffv1enc.c |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 34370fa143..7e0465abaa 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -26,7 +26,7 @@
 #include <stdint.h>
 
 #include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
 #include "put_bits.h"
 #include "rangecoder.h"
 
@@ -70,7 +70,7 @@ typedef struct FFV1Context {
     AVClass *class;
     AVCodecContext *avctx;
     RangeCoder c;
-    GetBitContext gb;
+    BitstreamContext bc;
     PutBitContext pb;
     uint64_t rc_stat[256][2];
     uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2];
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 2ebd6864a1..07e66b9dbb 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -33,9 +33,9 @@
 #include "libavutil/timer.h"
 
 #include "avcodec.h"
-#include "golomb_legacy.h"
+#include "bitstream.h"
+#include "golomb.h"
 #include "internal.h"
-#include "get_bits.h"
 #include "put_bits.h"
 #include "rangecoder.h"
 #include "mathops.h"
@@ -66,7 +66,7 @@ static av_noinline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
     return get_symbol_inline(c, state, is_signed);
 }
 
-static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state,
+static inline int get_vlc_symbol(BitstreamContext *bc, VlcState *const state,
                                  int bits)
 {
     int k, i, v, ret;
@@ -80,7 +80,7 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state,
 
     assert(k <= 8);
 
-    v = get_sr_golomb(gb, k, 12, bits);
+    v = get_sr_golomb(bc, k, 12, bits);
     ff_dlog(NULL, "v:%d bias:%d error:%d drift:%d count:%d k:%d",
             v, state->bias, state->error_sum, state->drift, state->count, k);
 
@@ -124,13 +124,13 @@ static av_always_inline void decode_line(FFV1Context *s, int w,
 
             if (run_mode) {
                 if (run_count == 0 && run_mode == 1) {
-                    if (get_bits1(&s->gb)) {
+                    if (bitstream_read_bit(&s->bc)) {
                         run_count = 1 << ff_log2_run[run_index];
                         if (x + run_count <= w)
                             run_index++;
                     } else {
                         if (ff_log2_run[run_index])
-                            run_count = get_bits(&s->gb, ff_log2_run[run_index]);
+                            run_count = bitstream_read(&s->bc, ff_log2_run[run_index]);
                         else
                             run_count = 0;
                         if (run_index)
@@ -142,17 +142,17 @@ static av_always_inline void decode_line(FFV1Context *s, int w,
                 if (run_count < 0) {
                     run_mode  = 0;
                     run_count = 0;
-                    diff      = get_vlc_symbol(&s->gb, &p->vlc_state[context],
+                    diff      = get_vlc_symbol(&s->bc, &p->vlc_state[context],
                                                bits);
                     if (diff >= 0)
                         diff++;
                 } else
                     diff = 0;
             } else
-                diff = get_vlc_symbol(&s->gb, &p->vlc_state[context], bits);
+                diff = get_vlc_symbol(&s->bc, &p->vlc_state[context], bits);
 
             ff_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n",
-                    run_count, run_index, run_mode, x, get_bits_count(&s->gb));
+                    run_count, run_index, run_mode, x, bitstream_tell(&s->bc));
         }
 
         if (sign)
@@ -364,9 +364,9 @@ static int decode_slice(AVCodecContext *c, void *arg)
         if (f->version == 3 && f->minor_version > 1 || f->version > 3)
             get_rac(&fs->c, (uint8_t[]) { 129 });
         fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0;
-        init_get_bits(&fs->gb, fs->c.bytestream_start + fs->ac_byte_count,
-                      (fs->c.bytestream_end - fs->c.bytestream_start -
-                       fs->ac_byte_count) * 8);
+        bitstream_init8(&fs->bc, fs->c.bytestream_start + fs->ac_byte_count,
+                        (fs->c.bytestream_end - fs->c.bytestream_start -
+                         fs->ac_byte_count));
     }
 
     av_assert1(width && height);
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index adf70d8a6b..c5088bb545 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -33,7 +33,7 @@
 #include "libavutil/imgutils.h"
 
 #include "avcodec.h"
-#include "golomb_legacy.h"
+#include "golomb.h"
 #include "internal.h"
 #include "put_bits.h"
 #include "rangecoder.h"



More information about the ffmpeg-cvslog mailing list