* [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata
@ 2024-02-05 14:29 Niklas Haas
2024-02-05 14:29 ` [FFmpeg-devel] [PATCH 2/2] avfilter/buffersrc: allow promoting color range to MPEG Niklas Haas
2024-02-11 20:53 ` [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata Niklas Haas
0 siblings, 2 replies; 3+ messages in thread
From: Niklas Haas @ 2024-02-05 14:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
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(-)
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
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avfilter/buffersrc: allow promoting color range to MPEG
2024-02-05 14:29 [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata Niklas Haas
@ 2024-02-05 14:29 ` Niklas Haas
2024-02-11 20:53 ` [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata Niklas Haas
1 sibling, 0 replies; 3+ messages in thread
From: Niklas Haas @ 2024-02-05 14:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
From: Niklas Haas <git@haasn.dev>
Otherwise, passing an UNSPECIFIED frame to am MPEG-only filter graph
would trigger insertion of an unnecessary vf_scale filter, which would
perform a memcpy to convert between the two.
This is safe to do because unspecified YUV frames are already
universally assumed to be MPEG range, in particular by swscale.
---
libavfilter/buffersrc.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 93fadab65f..a6a000df1e 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -506,8 +506,14 @@ static int query_formats(AVFilterContext *ctx)
if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 ||
(ret = ff_set_common_color_spaces(ctx, color_spaces)) < 0)
return ret;
- if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0 ||
- (ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0)
+ if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0)
+ return ret;
+ if (c->color_range == AVCOL_RANGE_UNSPECIFIED) {
+ /* allow implicitly promoting unspecified to mpeg */
+ if ((ret = ff_add_format(&color_ranges, AVCOL_RANGE_MPEG)) < 0)
+ return ret;
+ }
+ if ((ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0)
return ret;
}
break;
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata
2024-02-05 14:29 [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata Niklas Haas
2024-02-05 14:29 ` [FFmpeg-devel] [PATCH 2/2] avfilter/buffersrc: allow promoting color range to MPEG Niklas Haas
@ 2024-02-11 20:53 ` Niklas Haas
1 sibling, 0 replies; 3+ messages in thread
From: Niklas Haas @ 2024-02-11 20:53 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
Ping, last call for objections.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-11 20:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 14:29 [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata Niklas Haas
2024-02-05 14:29 ` [FFmpeg-devel] [PATCH 2/2] avfilter/buffersrc: allow promoting color range to MPEG Niklas Haas
2024-02-11 20:53 ` [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: promote unspecified color metadata Niklas Haas
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git