diff mbox series

[FFmpeg-devel,15/39] lavc/ffv1: always use the main context values of plane_count/transparency

Message ID 20240716171155.31838-15-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
They cannot change between slices.
---
 libavcodec/ffv1.c             | 2 --
 libavcodec/ffv1dec.c          | 5 ++---
 libavcodec/ffv1dec_template.c | 2 +-
 libavcodec/ffv1enc.c          | 2 +-
 libavcodec/ffv1enc_template.c | 2 +-
 5 files changed, 5 insertions(+), 8 deletions(-)

Comments

Michael Niedermayer July 24, 2024, 7:15 p.m. UTC | #1
On Tue, Jul 16, 2024 at 07:11:30PM +0200, Anton Khirnov wrote:
> They cannot change between slices.
> ---
>  libavcodec/ffv1.c             | 2 --
>  libavcodec/ffv1dec.c          | 5 ++---
>  libavcodec/ffv1dec_template.c | 2 +-
>  libavcodec/ffv1enc.c          | 2 +-
>  libavcodec/ffv1enc_template.c | 2 +-
>  5 files changed, 5 insertions(+), 8 deletions(-)

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 6a0aca6429..06a77c3a26 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -56,8 +56,6 @@  av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs)
 {
     int j, i;
 
-    fs->plane_count  = f->plane_count;
-    fs->transparency = f->transparency;
     for (j = 0; j < f->plane_count; j++) {
         PlaneContext *const p = &fs->plane[j];
 
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 618020d10f..6d3db25279 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -270,7 +270,6 @@  static int decode_slice(AVCodecContext *c, void *arg)
 
     if(f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY)) {
         FFV1Context *fssrc = f->fsrc->slice_context[si];
-        av_assert1(fs->plane_count == fssrc->plane_count);
 
         if (!(p->flags & AV_FRAME_FLAG_KEY))
             fs->slice_damaged |= fssrc->slice_damaged;
@@ -330,7 +329,7 @@  static int decode_slice(AVCodecContext *c, void *arg)
     }
 
     av_assert1(width && height);
-    if (f->colorspace == 0 && (f->chroma_planes || !fs->transparency)) {
+    if (f->colorspace == 0 && (f->chroma_planes || !f->transparency)) {
         const int chroma_width  = AV_CEIL_RSHIFT(width,  f->chroma_h_shift);
         const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift);
         const int cx            = x >> f->chroma_h_shift;
@@ -341,7 +340,7 @@  static int decode_slice(AVCodecContext *c, void *arg)
             decode_plane(f, fs, sc, &gb, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1);
             decode_plane(f, fs, sc, &gb, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1);
         }
-        if (fs->transparency)
+        if (f->transparency)
             decode_plane(f, fs, sc, &gb, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], (f->version >= 4 && !f->chroma_planes) ? 1 : 2, 1);
     } else if (f->colorspace == 0) {
          decode_plane(f, fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0]    , width, height, p->linesize[0], 0, 2);
diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
index 97a28b085a..d868617de9 100644
--- a/libavcodec/ffv1dec_template.c
+++ b/libavcodec/ffv1dec_template.c
@@ -140,7 +140,7 @@  static int RENAME(decode_rgb_frame)(FFV1Context *f,
     int lbd    = s->avctx->bits_per_raw_sample <= 8;
     int bits   = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8;
     int offset = 1 << bits;
-    int transparency = s->transparency;
+    int transparency = f->transparency;
 
     for (x = 0; x < 4; x++) {
         sample[x][0] = RENAME(sc->sample_buffer) +  x * 2      * (w + 6) + 3;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 714e007659..d334220e13 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1072,7 +1072,7 @@  retry:
             ret |= encode_plane(f, fs, sc, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1);
             ret |= encode_plane(f, fs, sc, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1);
         }
-        if (fs->transparency)
+        if (f->transparency)
             ret |= encode_plane(f, fs, sc, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2, 1);
     } else if (c->pix_fmt == AV_PIX_FMT_YA8) {
         ret  = encode_plane(f, fs, sc, p->data[0] +     ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 2);
diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c
index 4a5580e1a5..0f47a0b424 100644
--- a/libavcodec/ffv1enc_template.c
+++ b/libavcodec/ffv1enc_template.c
@@ -138,7 +138,7 @@  static int RENAME(encode_rgb_frame)(FFV1Context *f,
     int packed = !src[1];
     int bits   = s->bits_per_raw_sample > 0 ? s->bits_per_raw_sample : 8;
     int offset = 1 << bits;
-    int transparency = s->transparency;
+    int transparency = f->transparency;
     int packed_size = (3 + transparency)*2;
 
     sc->run_index = 0;