PR #22494 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22494
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22494.patch

Shorter naming suggestions than "lavc_lcevc_enhancement_layer_decoding" welcome.


>From b3809b6a66031ede4eacb164f3043aa4971d43ce Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Fri, 13 Mar 2026 15:42:43 +0100
Subject: [PATCH 1/4] configure: Add separate lavc-generic lcevc decoding
 option

This allows to disable the lavc-generic lcevc decoding
and keeping the filter.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 configure           |  5 +++++
 libavcodec/Makefile |  2 +-
 libavcodec/decode.c | 12 ++++++------
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 2f6167fddb..471e4a31c0 100755
--- a/configure
+++ b/configure
@@ -138,6 +138,8 @@ Component options:
   --disable-network        disable network support [no]
   --disable-dwt            disable DWT code
   --disable-error-resilience disable error resilience code
+  --disable-lavc-lcevc-enhancement-layer-decoding disable generic lcevc 
enhancement layer
+                           decoding in libavcodec
   --disable-lsp            disable LSP code
   --disable-faan           disable floating point AAN (I)DCT code
   --disable-iamf           disable support for Immersive Audio Model
@@ -2217,6 +2219,7 @@ SUBSYSTEM_LIST="
     faan
     fast_unaligned
     iamf
+    lavc_lcevc_enhancement_layer_decoding
     lsp
     pixelutils
     network
@@ -3764,6 +3767,7 @@ hevc_videotoolbox_encoder_deps="pthreads"
 hevc_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder"
 prores_videotoolbox_encoder_deps="pthreads"
 prores_videotoolbox_encoder_select="videotoolbox_encoder"
+lavc_lcevc_enhancement_layer_decoding_deps="liblcevc_dec"
 libaom_av1_decoder_deps="libaom"
 libaom_av1_encoder_deps="libaom"
 libaom_av1_encoder_select="extract_extradata_bsf dovi_rpuenc"
@@ -4407,6 +4411,7 @@ enable doc
 enable faan faandct faanidct
 enable iamf
 enable large_tests
+enable lavc_lcevc_enhancement_layer_decoding
 enable optimizations
 enable shader_compression
 enable resource_compression
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1410bd8142..ecce6500fb 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -130,7 +130,7 @@ OBJS-$(CONFIG_IVIDSP)                  += ivi_dsp.o
 OBJS-$(CONFIG_JNI)                     += ffjni.o jni.o
 OBJS-$(CONFIG_JPEGTABLES)              += jpegtables.o
 OBJS-$(CONFIG_LCMS2)                   += fflcms2.o
-OBJS-$(CONFIG_LIBLCEVC_DEC)            += lcevcdec.o
+OBJS-$(CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING) += lcevcdec.o
 OBJS-$(CONFIG_LLAUDDSP)                += lossless_audiodsp.o
 OBJS-$(CONFIG_LLVIDDSP)                += lossless_videodsp.o
 OBJS-$(CONFIG_LLVIDENCDSP)             += lossless_videoencdsp.o
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 5de5a84038..d8bead6f29 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -94,7 +94,7 @@ typedef struct DecodeContext {
      */
     uint64_t side_data_pref_mask;
 
-#if CONFIG_LIBLCEVC_DEC
+#if CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING
     struct {
         FFLCEVCContext *ctx;
         int frame;
@@ -1665,7 +1665,7 @@ int ff_attach_decode_data(AVFrame *frame)
 
 static int update_frame_props(AVCodecContext *avctx, AVFrame *frame)
 {
-#if CONFIG_LIBLCEVC_DEC
+#if CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING
     AVCodecInternal    *avci = avctx->internal;
     DecodeContext        *dc = decode_ctx(avci);
 
@@ -1694,7 +1694,7 @@ static int update_frame_props(AVCodecContext *avctx, 
AVFrame *frame)
 
 static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
 {
-#if CONFIG_LIBLCEVC_DEC
+#if CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING
     AVCodecInternal    *avci = avctx->internal;
     DecodeContext        *dc = decode_ctx(avci);
 
@@ -2110,7 +2110,7 @@ av_cold int ff_decode_preinit(AVCodecContext *avctx)
 
     if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
         if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
-#if CONFIG_LIBLCEVC_DEC
+#if CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING
             ret = ff_lcevc_alloc(&dc->lcevc.ctx, avctx);
             if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
                 return ret;
@@ -2356,7 +2356,7 @@ av_cold void ff_decode_internal_sync(AVCodecContext *dst, 
const AVCodecContext *
     dst_dc->initial_pict_type = src_dc->initial_pict_type;
     dst_dc->intra_only_flag   = src_dc->intra_only_flag;
     dst_dc->side_data_pref_mask = src_dc->side_data_pref_mask;
-#if CONFIG_LIBLCEVC_DEC
+#if CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING
     av_refstruct_replace(&dst_dc->lcevc.ctx, src_dc->lcevc.ctx);
     dst_dc->lcevc.width = src_dc->lcevc.width;
     dst_dc->lcevc.height = src_dc->lcevc.height;
@@ -2365,7 +2365,7 @@ av_cold void ff_decode_internal_sync(AVCodecContext *dst, 
const AVCodecContext *
 
 av_cold void ff_decode_internal_uninit(AVCodecContext *avctx)
 {
-#if CONFIG_LIBLCEVC_DEC
+#if CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING
     AVCodecInternal *avci = avctx->internal;
     DecodeContext *dc = decode_ctx(avci);
 
-- 
2.52.0


>From 21b501657272e972a555dfadc9e4b5c052be2fc7 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Fri, 13 Mar 2026 15:44:13 +0100
Subject: [PATCH 2/4] configure: Add lcevc enhancement layer
 decoding->cbs_lcevc dependency

Forgotten in 49d75d81f6753623a3d1f5e8c5c6aa8bf669f744.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index 471e4a31c0..e3d8cc3759 100755
--- a/configure
+++ b/configure
@@ -3768,6 +3768,7 @@ hevc_videotoolbox_encoder_select="atsc_a53 
videotoolbox_encoder"
 prores_videotoolbox_encoder_deps="pthreads"
 prores_videotoolbox_encoder_select="videotoolbox_encoder"
 lavc_lcevc_enhancement_layer_decoding_deps="liblcevc_dec"
+lavc_lcevc_enhancement_layer_decoding_select="cbs_lcevc"
 libaom_av1_decoder_deps="libaom"
 libaom_av1_encoder_deps="libaom"
 libaom_av1_encoder_select="extract_extradata_bsf dovi_rpuenc"
-- 
2.52.0


>From b8ab9146e37d3f4e439efc59ad240b623ec52065 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Fri, 13 Mar 2026 15:46:28 +0100
Subject: [PATCH 3/4] avcodec/lcevctab: Properly deduplicate
 ff_lcevc_resolution_type

(Currently lcevctab.o does not export anything.)

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/Makefile   |  2 +-
 libavcodec/lcevctab.c | 16 ++++++++++++++++
 libavcodec/lcevctab.h | 20 ++++----------------
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ecce6500fb..ec988faeae 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -130,7 +130,7 @@ OBJS-$(CONFIG_IVIDSP)                  += ivi_dsp.o
 OBJS-$(CONFIG_JNI)                     += ffjni.o jni.o
 OBJS-$(CONFIG_JPEGTABLES)              += jpegtables.o
 OBJS-$(CONFIG_LCMS2)                   += fflcms2.o
-OBJS-$(CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING) += lcevcdec.o
+OBJS-$(CONFIG_LAVC_LCEVC_ENHANCEMENT_LAYER_DECODING) += lcevcdec.o lcevctab.o
 OBJS-$(CONFIG_LLAUDDSP)                += lossless_audiodsp.o
 OBJS-$(CONFIG_LLVIDDSP)                += lossless_videodsp.o
 OBJS-$(CONFIG_LLVIDENCDSP)             += lossless_videoencdsp.o
diff --git a/libavcodec/lcevctab.c b/libavcodec/lcevctab.c
index 76853b80e5..045fc718e4 100644
--- a/libavcodec/lcevctab.c
+++ b/libavcodec/lcevctab.c
@@ -17,3 +17,19 @@
  */
 
 #include "lcevctab.h"
+
+const struct FFLCEVCDim ff_lcevc_resolution_type[63] = {
+    { 0, 0},
+    { 360,  200 },  { 400,  240 },  { 480,  320 },  { 640,  360 },
+    { 640,  480 },  { 768,  480 },  { 800,  600 },  { 852,  480 },
+    { 854,  480 },  { 856,  480 },  { 960,  540 },  { 960,  640 },
+    { 1024, 576 },  { 1024, 600 },  { 1024, 768 },  { 1152, 864 },
+    { 1280, 720 },  { 1280, 800 },  { 1280, 1024 }, { 1360, 768 },
+    { 1366, 768 },  { 1920, 1200 }, { 2048, 1080 }, { 2048, 1152 },
+    { 2048, 1536 }, { 2160, 1440 }, { 2560, 1440 }, { 2560, 1600 },
+    { 2560, 2048 }, { 3200, 1800 }, { 3200, 2048 }, { 3200, 2400 },
+    { 3440, 1440 }, { 3840, 1600 }, { 3840, 2160 }, { 3840, 2400 },
+    { 4096, 2160 }, { 4096, 3072 }, { 5120, 2880 }, { 5120, 3200 },
+    { 5120, 4096 }, { 6400, 4096 }, { 6400, 4800 }, { 7680, 4320 },
+    { 7680, 4800 },
+};
diff --git a/libavcodec/lcevctab.h b/libavcodec/lcevctab.h
index 6803589531..89361cebe9 100644
--- a/libavcodec/lcevctab.h
+++ b/libavcodec/lcevctab.h
@@ -19,23 +19,11 @@
 #ifndef AVCODEC_LCEVCTAB_H
 #define AVCODEC_LCEVCTAB_H
 
-static const struct {
+#include "libavutil/attributes_internal.h"
+
+EXTERN const struct FFLCEVCDim {
     int width;
     int height;
-} ff_lcevc_resolution_type[63] = {
-    { 0, 0},
-    { 360,  200 },  { 400,  240 },  { 480,  320 },  { 640,  360 },
-    { 640,  480 },  { 768,  480 },  { 800,  600 },  { 852,  480 },
-    { 854,  480 },  { 856,  480 },  { 960,  540 },  { 960,  640 },
-    { 1024, 576 },  { 1024, 600 },  { 1024, 768 },  { 1152, 864 },
-    { 1280, 720 },  { 1280, 800 },  { 1280, 1024 }, { 1360, 768 },
-    { 1366, 768 },  { 1920, 1200 }, { 2048, 1080 }, { 2048, 1152 },
-    { 2048, 1536 }, { 2160, 1440 }, { 2560, 1440 }, { 2560, 1600 },
-    { 2560, 2048 }, { 3200, 1800 }, { 3200, 2048 }, { 3200, 2400 },
-    { 3440, 1440 }, { 3840, 1600 }, { 3840, 2160 }, { 3840, 2400 },
-    { 4096, 2160 }, { 4096, 3072 }, { 5120, 2880 }, { 5120, 3200 },
-    { 5120, 4096 }, { 6400, 4096 }, { 6400, 4800 }, { 7680, 4320 },
-    { 7680, 4800 },
-};
+} ff_lcevc_resolution_type[63];
 
 #endif /* AVCODEC_LCEVCTAB_H */
-- 
2.52.0


>From 52dfa1f90486651551195e3a320ff25e0f78a41e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Fri, 13 Mar 2026 15:48:30 +0100
Subject: [PATCH 4/4] avcodec/lcevctab: Use smaller types

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/lcevctab.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/lcevctab.h b/libavcodec/lcevctab.h
index 89361cebe9..3bbca2e52b 100644
--- a/libavcodec/lcevctab.h
+++ b/libavcodec/lcevctab.h
@@ -19,11 +19,13 @@
 #ifndef AVCODEC_LCEVCTAB_H
 #define AVCODEC_LCEVCTAB_H
 
+#include <stdint.h>
+
 #include "libavutil/attributes_internal.h"
 
 EXTERN const struct FFLCEVCDim {
-    int width;
-    int height;
+    uint16_t width;
+    uint16_t height;
 } ff_lcevc_resolution_type[63];
 
 #endif /* AVCODEC_LCEVCTAB_H */
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to