Commit ab2539bd authored by Alexandra Hájková's avatar Alexandra Hájková Committed by Diego Biurrun

ffv1: Convert to the new bitstream reader

parent 2d722195
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <stdint.h> #include <stdint.h>
#include "avcodec.h" #include "avcodec.h"
#include "get_bits.h" #include "bitstream.h"
#include "put_bits.h" #include "put_bits.h"
#include "rangecoder.h" #include "rangecoder.h"
...@@ -70,7 +70,7 @@ typedef struct FFV1Context { ...@@ -70,7 +70,7 @@ typedef struct FFV1Context {
AVClass *class; AVClass *class;
AVCodecContext *avctx; AVCodecContext *avctx;
RangeCoder c; RangeCoder c;
GetBitContext gb; BitstreamContext bc;
PutBitContext pb; PutBitContext pb;
uint64_t rc_stat[256][2]; uint64_t rc_stat[256][2];
uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2];
......
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
#include "libavutil/timer.h" #include "libavutil/timer.h"
#include "avcodec.h" #include "avcodec.h"
#include "golomb_legacy.h" #include "bitstream.h"
#include "golomb.h"
#include "internal.h" #include "internal.h"
#include "get_bits.h"
#include "put_bits.h" #include "put_bits.h"
#include "rangecoder.h" #include "rangecoder.h"
#include "mathops.h" #include "mathops.h"
...@@ -66,7 +66,7 @@ static av_noinline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed) ...@@ -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); 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 bits)
{ {
int k, i, v, ret; int k, i, v, ret;
...@@ -80,7 +80,7 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state, ...@@ -80,7 +80,7 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state,
assert(k <= 8); 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", 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); 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, ...@@ -124,13 +124,13 @@ static av_always_inline void decode_line(FFV1Context *s, int w,
if (run_mode) { if (run_mode) {
if (run_count == 0 && run_mode == 1) { 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]; run_count = 1 << ff_log2_run[run_index];
if (x + run_count <= w) if (x + run_count <= w)
run_index++; run_index++;
} else { } else {
if (ff_log2_run[run_index]) 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 else
run_count = 0; run_count = 0;
if (run_index) if (run_index)
...@@ -142,17 +142,17 @@ static av_always_inline void decode_line(FFV1Context *s, int w, ...@@ -142,17 +142,17 @@ static av_always_inline void decode_line(FFV1Context *s, int w,
if (run_count < 0) { if (run_count < 0) {
run_mode = 0; run_mode = 0;
run_count = 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); bits);
if (diff >= 0) if (diff >= 0)
diff++; diff++;
} else } else
diff = 0; diff = 0;
} else } 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", 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) if (sign)
...@@ -364,9 +364,9 @@ static int decode_slice(AVCodecContext *c, void *arg) ...@@ -364,9 +364,9 @@ static int decode_slice(AVCodecContext *c, void *arg)
if (f->version == 3 && f->minor_version > 1 || f->version > 3) if (f->version == 3 && f->minor_version > 1 || f->version > 3)
get_rac(&fs->c, (uint8_t[]) { 129 }); 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; 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, bitstream_init8(&fs->bc, fs->c.bytestream_start + fs->ac_byte_count,
(fs->c.bytestream_end - fs->c.bytestream_start - (fs->c.bytestream_end - fs->c.bytestream_start -
fs->ac_byte_count) * 8); fs->ac_byte_count));
} }
av_assert1(width && height); av_assert1(width && height);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "avcodec.h" #include "avcodec.h"
#include "golomb_legacy.h" #include "golomb.h"
#include "internal.h" #include "internal.h"
#include "put_bits.h" #include "put_bits.h"
#include "rangecoder.h" #include "rangecoder.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment