diff mbox series

[FFmpeg-devel,1/2] avfilter/buffersrc: promote unspecified color metadata

Message ID 20240205142926.12050-1-ffmpeg@haasn.xyz
State New
Headers show
Series [FFmpeg-devel,1/2] avfilter/buffersrc: promote unspecified color metadata | 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

Niklas Haas Feb. 5, 2024, 2:29 p.m. UTC
From: Niklas Haas <git@haasn.dev>

Currently, this only affects untagged RGB/XYZ/Gray, which get forced to
their corresponding metadata before entering the filter graph. The main
justification for this change, however, is the planned ability to add
automatic promotion of unspecified yuv to mpeg range yuv.

Notably, this change will never allow accidentally cross-promoting
unspecified to jpeg or to a specific YUV matrix, since that is still
bound by the constraints of YUV range negotiation as set up by
query_formats.
---
 libavfilter/buffersrc.c  | 5 +++++
 tests/ref/fate/rgb24-mkv | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Niklas Haas Feb. 11, 2024, 8:53 p.m. UTC | #1
Ping, last call for objections.
diff mbox series

Patch

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 6e450ff6b7..93fadab65f 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -291,6 +291,11 @@  FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+    if (copy->colorspace == AVCOL_SPC_UNSPECIFIED)
+        copy->colorspace = ctx->outputs[0]->colorspace;
+    if (copy->color_range == AVCOL_RANGE_UNSPECIFIED)
+        copy->color_range = ctx->outputs[0]->color_range;
+
     ret = ff_filter_frame(ctx->outputs[0], copy);
     if (ret < 0)
         return ret;
diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
index 99234f1052..1cbed136dd 100644
--- a/tests/ref/fate/rgb24-mkv
+++ b/tests/ref/fate/rgb24-mkv
@@ -1,5 +1,5 @@ 
-e181dc84058c3584598333dabd110123 *tests/data/fate/rgb24-mkv.matroska
-58225 tests/data/fate/rgb24-mkv.matroska
+7d767e8238c674ecfa80458cb281c09e *tests/data/fate/rgb24-mkv.matroska
+58236 tests/data/fate/rgb24-mkv.matroska
 #tb 0: 1/10
 #media_type 0: video
 #codec_id 0: rawvideo