diff mbox series

[FFmpeg-devel] avcodec/ffv1: RCT is only possible with RGB

Message ID 20241003143527.2645752-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel] avcodec/ffv1: RCT is only possible with RGB | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Oct. 3, 2024, 2:35 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ffv1dec.c | 2 +-
 libavcodec/ffv1enc.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index da31b863da5..932b2de0ff7 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -241,7 +241,7 @@  static int decode_slice_header(const FFV1Context *f,
     if (f->version > 3) {
         sc->slice_reset_contexts = get_rac(c, state);
         sc->slice_coding_mode = get_symbol(c, state, 0);
-        if (sc->slice_coding_mode != 1) {
+        if (sc->slice_coding_mode != 1 && f->colorspace == 1) {
             sc->slice_rct_by_coef = get_symbol(c, state, 0);
             sc->slice_rct_ry_coef = get_symbol(c, state, 0);
             if ((uint64_t)sc->slice_rct_by_coef + (uint64_t)sc->slice_rct_ry_coef > 4) {
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 8b23e73c841..4e3ae304cfb 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -946,7 +946,7 @@  static void encode_slice_header(FFV1Context *f, FFV1SliceContext *sc)
         if (sc->slice_coding_mode == 1)
             ff_ffv1_clear_slice_state(f, sc);
         put_symbol(c, state, sc->slice_coding_mode, 0);
-        if (sc->slice_coding_mode != 1) {
+        if (sc->slice_coding_mode != 1 && f->colorspace == 1) {
             put_symbol(c, state, sc->slice_rct_by_coef, 0);
             put_symbol(c, state, sc->slice_rct_ry_coef, 0);
         }
@@ -1054,7 +1054,7 @@  static int encode_slice(AVCodecContext *c, void *arg)
                                 p->data[3] ? p->data[3] + ps*x + y*p->linesize[3] : NULL};
 
     sc->slice_coding_mode = 0;
-    if (f->version > 3) {
+    if (f->version > 3 && f->colorspace == 1) {
         choose_rct_params(f, sc, planes, p->linesize, width, height);
     } else {
         sc->slice_rct_by_coef = 1;