diff options
author | Gnattu OC <gnattuoc@me.com> | 2024-08-16 10:06:37 +0800 |
---|---|---|
committer | Zhao Zhili <zhilizhao@tencent.com> | 2024-08-24 00:24:06 +0800 |
commit | 30f090b4f8f73a05917cec914d3f7340f749bf9e (patch) | |
tree | 9c8ebaea2b54dc91350202c5787a29dddc6ad171 | |
parent | cfe0a36352f5439668fc9b5b9e5b985d2958b906 (diff) | |
download | ffmpeg-30f090b4f8f73a05917cec914d3f7340f749bf9e.tar.gz |
avfilter: inherit input color range for videotoolbox filters
The color range should be set to match the input when creating
the VideoToolbox context. Otherwise, the new context will default
to limited range, creates inconsistencies with full range inputs.
Signed-off-by: Gnattu OC <gnattuoc@me.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r-- | libavfilter/vf_scale_vt.c | 1 | ||||
-rw-r--r-- | libavfilter/vf_transpose_vt.c | 1 | ||||
-rw-r--r-- | libavfilter/vf_yadif_videotoolbox.m | 6 |
3 files changed, 7 insertions, 1 deletions
diff --git a/libavfilter/vf_scale_vt.c b/libavfilter/vf_scale_vt.c index 527e3ca72a..05f4e7b797 100644 --- a/libavfilter/vf_scale_vt.c +++ b/libavfilter/vf_scale_vt.c @@ -208,6 +208,7 @@ static int scale_vt_config_output(AVFilterLink *outlink) hw_frame_ctx_out->sw_format = hw_frame_ctx_in->sw_format; hw_frame_ctx_out->width = outlink->w; hw_frame_ctx_out->height = outlink->h; + ((AVVTFramesContext *)hw_frame_ctx_out->hwctx)->color_range = ((AVVTFramesContext *)hw_frame_ctx_in->hwctx)->color_range; err = ff_filter_init_hw_frames(avctx, outlink, 1); if (err < 0) diff --git a/libavfilter/vf_transpose_vt.c b/libavfilter/vf_transpose_vt.c index 86024c4ad3..8193340865 100644 --- a/libavfilter/vf_transpose_vt.c +++ b/libavfilter/vf_transpose_vt.c @@ -123,6 +123,7 @@ static int transpose_vt_recreate_hw_ctx(AVFilterLink *outlink) hw_frame_ctx_out->sw_format = hw_frame_ctx_in->sw_format; hw_frame_ctx_out->width = outlink->w; hw_frame_ctx_out->height = outlink->h; + ((AVVTFramesContext *)hw_frame_ctx_out->hwctx)->color_range = ((AVVTFramesContext *)hw_frame_ctx_in->hwctx)->color_range; err = ff_filter_init_hw_frames(avctx, outlink, 1); if (err < 0) diff --git a/libavfilter/vf_yadif_videotoolbox.m b/libavfilter/vf_yadif_videotoolbox.m index 85942e8321..09520db35d 100644 --- a/libavfilter/vf_yadif_videotoolbox.m +++ b/libavfilter/vf_yadif_videotoolbox.m @@ -24,6 +24,7 @@ #include "yadif.h" #include "libavutil/avassert.h" #include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_videotoolbox.h" #include "libavutil/objc.h" #include <assert.h> @@ -323,7 +324,8 @@ static int config_input(AVFilterLink *inlink) static int do_config_output(AVFilterLink *link) API_AVAILABLE(macos(10.11), ios(8.0)) { FilterLink *l = ff_filter_link(link); - AVHWFramesContext *output_frames; + FilterLink *il = ff_filter_link(link->src->inputs[0]); + AVHWFramesContext *output_frames, *input_frames; AVFilterContext *ctx = link->src; YADIFVTContext *s = ctx->priv; YADIFContext *y = &s->yadif; @@ -345,12 +347,14 @@ static int do_config_output(AVFilterLink *link) API_AVAILABLE(macos(10.11), ios( goto exit; } + input_frames = (AVHWFramesContext*)il->hw_frames_ctx->data; output_frames = (AVHWFramesContext*)l->hw_frames_ctx->data; output_frames->format = AV_PIX_FMT_VIDEOTOOLBOX; output_frames->sw_format = s->input_frames->sw_format; output_frames->width = ctx->inputs[0]->w; output_frames->height = ctx->inputs[0]->h; + ((AVVTFramesContext *)output_frames->hwctx)->color_range = ((AVVTFramesContext *)input_frames->hwctx)->color_range; ret = ff_filter_init_hw_frames(ctx, link, 10); if (ret < 0) |