[FFmpeg-devel] [PATCH 21/39] lavc/ffv1: move ac_byte_count to per-slice context
Anton Khirnov
anton at khirnov.net
Tue Jul 16 20:11:36 EEST 2024
---
libavcodec/ffv1.h | 2 +-
libavcodec/ffv1dec.c | 6 +++---
libavcodec/ffv1enc.c | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index bee7b75614..ae81940073 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -85,6 +85,7 @@ typedef struct FFV1SliceContext {
PutBitContext pb;
RangeCoder c;
+ int ac_byte_count; ///< number of bytes used for AC coding
uint64_t rc_stat[256][2];
uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2];
} FFV1SliceContext;
@@ -109,7 +110,6 @@ typedef struct FFV1Context {
const AVFrame *cur_enc_frame;
int plane_count;
int ac; ///< 1=range coder <-> 0=golomb rice
- int ac_byte_count; ///< number of bytes used for AC coding
int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256];
int context_count[MAX_QUANT_TABLES];
uint8_t state_transition[256];
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index e0344c996b..4dc1f4b1cf 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -322,10 +322,10 @@ static int decode_slice(AVCodecContext *c, void *arg)
if (f->ac == AC_GOLOMB_RICE) {
if (f->version == 3 && f->micro_version > 1 || f->version > 3)
get_rac(&sc->c, (uint8_t[]) { 129 });
- fs->ac_byte_count = f->version > 2 || (!x && !y) ? sc->c.bytestream - sc->c.bytestream_start - 1 : 0;
+ sc->ac_byte_count = f->version > 2 || (!x && !y) ? sc->c.bytestream - sc->c.bytestream_start - 1 : 0;
init_get_bits(&gb,
- sc->c.bytestream_start + fs->ac_byte_count,
- (sc->c.bytestream_end - sc->c.bytestream_start - fs->ac_byte_count) * 8);
+ sc->c.bytestream_start + sc->ac_byte_count,
+ (sc->c.bytestream_end - sc->c.bytestream_start - sc->ac_byte_count) * 8);
}
av_assert1(width && height);
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index e3d094141c..3a6a0e6d90 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1059,10 +1059,10 @@ retry:
encode_slice_header(f, fs, sc);
}
if (f->ac == AC_GOLOMB_RICE) {
- fs->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&sc->c, f->version > 2) : 0;
+ sc->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&sc->c, f->version > 2) : 0;
init_put_bits(&sc->pb,
- sc->c.bytestream_start + fs->ac_byte_count,
- sc->c.bytestream_end - sc->c.bytestream_start - fs->ac_byte_count);
+ sc->c.bytestream_start + sc->ac_byte_count,
+ sc->c.bytestream_end - sc->c.bytestream_start - sc->ac_byte_count);
}
if (f->colorspace == 0 && c->pix_fmt != AV_PIX_FMT_YA8) {
--
2.43.0
More information about the ffmpeg-devel
mailing list