diff mbox series

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

Message ID 20231002172049.69615-1-johnmather@sidefx.com
State New
Headers show
Series [FFmpeg-devel,v3] avcodec/libkvazaar: Respect codec context color settings. | 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

John Mather Oct. 2, 2023, 5:20 p.m. UTC
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(+)

Comments

Jan Ekström Oct. 11, 2023, 6:59 p.m. UTC | #1
On Mon, Oct 2, 2023 at 8:21 PM John Mather via ffmpeg-devel
<ffmpeg-devel@ffmpeg.org> wrote:
>
> This patch makes the libkvazaar encoder respect color settings that are
> present on the codec context, including color range, primaries, transfer
> function and colorspace.
> ---

LGTM.

Verified that this indeed builds with libkvazaar v2.0.0 and that the
color information gets properly passed.

Adjusted the equality signs to be on the same level and applied as
a2175ca8615d09418564fcff63c85e18dd993ad1 to master. And then same
thing with regards to the description starting with lowercase.

Jan
diff mbox series

Patch

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)) {