[FFmpeg-devel] [PATCH v3] avcodec/libkvazaar: Respect codec context color settings.

John Mather johnmather at sidefx.com
Mon Oct 2 20:20:49 EEST 2023


This patch makes the libkvazaar encoder respect color settings that are
present on the codec context, including color range, primaries, transfer
function and colorspace.
---
This addresses the issues raised in v2.
 * The unspecified conditions have been removed as they were
   unnecessary.
 * Added the ability to specify the chroma sample location. The
   unspecified check is required here as without it, if
   avctx->chroma_sample_location was AVCHROMA_LOC_UNSPECIFIED,
   cfg->vui.chroma_loc would receive -1, which is outside of the
   expected range.

 libavcodec/libkvazaar.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 2ef34dd82e..4855d5649d 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -101,6 +101,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
         cfg->rc_algorithm = KVZ_LAMBDA;
     }
 
+    cfg->vui.fullrange = avctx->color_range == AVCOL_RANGE_JPEG;
+    cfg->vui.colorprim = avctx->color_primaries;
+    cfg->vui.transfer = avctx->color_trc;
+    cfg->vui.colormatrix = avctx->colorspace;
+    if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED)
+        cfg->vui.chroma_loc = avctx->chroma_sample_location - 1;
+
     if (ctx->kvz_params) {
         AVDictionary *dict = NULL;
         if (!av_dict_parse_string(&dict, ctx->kvz_params, "=", ",", 0)) {
-- 
2.39.3



More information about the ffmpeg-devel mailing list