diff mbox series

[FFmpeg-devel,23/39] lavc/ffv1dec: move slice_reset_contexts to per-slice context

Message ID 20240716171155.31838-23-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/39] tests/fate/vcodec: add vsynth tests for FFV1 version 2 | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov July 16, 2024, 5:11 p.m. UTC
---
 libavcodec/ffv1.h    | 16 +++++++++++++---
 libavcodec/ffv1dec.c |  4 ++--
 2 files changed, 15 insertions(+), 5 deletions(-)

Comments

Michael Niedermayer July 24, 2024, 7:44 p.m. UTC | #1
On Tue, Jul 16, 2024 at 07:11:38PM +0200, Anton Khirnov wrote:
> ---
>  libavcodec/ffv1.h    | 16 +++++++++++++---
>  libavcodec/ffv1dec.c |  4 ++--
>  2 files changed, 15 insertions(+), 5 deletions(-)

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index ae81940073..cef61f38ec 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -86,8 +86,19 @@  typedef struct FFV1SliceContext {
     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];
+
+    union {
+        // decoder-only
+        struct {
+            int slice_reset_contexts;
+        };
+
+        // encoder-only
+        struct {
+            uint64_t rc_stat[256][2];
+            uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2];
+        };
+    };
 } FFV1SliceContext;
 
 typedef struct FFV1Context {
@@ -135,7 +146,6 @@  typedef struct FFV1Context {
     int max_slice_count;
     int num_v_slices;
     int num_h_slices;
-    int slice_reset_contexts;
 
     FFV1SliceContext *slices;
 } FFV1Context;
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 4dc1f4b1cf..92e5b2a80b 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -238,7 +238,7 @@  static int decode_slice_header(const FFV1Context *f, FFV1Context *fs,
     }
 
     if (fs->version > 3) {
-        fs->slice_reset_contexts = get_rac(c, state);
+        sc->slice_reset_contexts = get_rac(c, state);
         sc->slice_coding_mode = get_symbol(c, state, 0);
         if (sc->slice_coding_mode != 1) {
             sc->slice_rct_by_coef = get_symbol(c, state, 0);
@@ -308,7 +308,7 @@  static int decode_slice(AVCodecContext *c, void *arg)
     }
     if ((ret = ff_ffv1_init_slice_state(f, sc)) < 0)
         return ret;
-    if ((p->flags & AV_FRAME_FLAG_KEY) || fs->slice_reset_contexts) {
+    if ((p->flags & AV_FRAME_FLAG_KEY) || sc->slice_reset_contexts) {
         ff_ffv1_clear_slice_state(f, sc);
     } else if (fs->slice_damaged) {
         return AVERROR_INVALIDDATA;