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>
This commit is contained in:
Gnattu OC 2024-08-16 10:06:37 +08:00 committed by Zhao Zhili
parent cfe0a36352
commit 30f090b4f8
3 changed files with 7 additions and 1 deletions

View File

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

View File

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

View File

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