[FFmpeg-devel] [PATCH 1/3] lavfi/tonemap_vaapi: By default use bt709 for output frame

Xiang, Haihao haihao.xiang at intel.com
Mon Mar 18 10:12:44 EET 2024


From: Haihao Xiang <haihao.xiang at intel.com>

By default don't use the color properties from input frame as output
frame properties when performing HDR to SDR conversion

Signed-off-by: Haihao Xiang <haihao.xiang at intel.com>
---
 doc/filters.texi               | 4 ++--
 libavfilter/vf_tonemap_vaapi.c | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 913365671d..2cb84c1476 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -27839,7 +27839,7 @@ Default is nv12.
 @item primaries, p
 Set the output color primaries.
 
-Default is same as input.
+Default is bt709.
 
 @item transfer, t
 Set the output transfer characteristics.
@@ -27849,7 +27849,7 @@ Default is bt709.
 @item matrix, m
 Set the output colorspace matrix.
 
-Default is same as input.
+Default is bt709.
 
 @end table
 
diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c
index 0b767202d2..a21f565e3a 100644
--- a/libavfilter/vf_tonemap_vaapi.c
+++ b/libavfilter/vf_tonemap_vaapi.c
@@ -278,13 +278,16 @@ static int tonemap_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame
     if (err < 0)
         goto fail;
 
+    /* Use BT709 by default for HDR to SDR output frame */
+    output_frame->color_primaries = AVCOL_PRI_BT709;
+    output_frame->color_trc = AVCOL_TRC_BT709;
+    output_frame->colorspace = AVCOL_SPC_BT709;
+
     if (ctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
         output_frame->color_primaries = ctx->color_primaries;
 
     if (ctx->color_transfer != AVCOL_TRC_UNSPECIFIED)
         output_frame->color_trc = ctx->color_transfer;
-    else
-        output_frame->color_trc = AVCOL_TRC_BT709;
 
     if (ctx->color_matrix != AVCOL_SPC_UNSPECIFIED)
         output_frame->colorspace = ctx->color_matrix;
-- 
2.34.1



More information about the ffmpeg-devel mailing list