From 8b76bae8961c3045fa73aa2da47345c70a93d599 Mon Sep 17 00:00:00 2001 From: Mark Thompson Date: Wed, 3 Jan 2024 20:40:19 +0000 Subject: [PATCH] avfilter: Temporary hack to fix format negotiation for hw formats hw_frames_ctx on the input link is only set when the input link is configured, which hasn't happened yet. This temporarily hacks around the problem (in a way no worse than before the format negotiation changes) until a proper fix can be applied. --- libavfilter/avfiltergraph.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 727eff81ee..96aa137e6d 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -667,8 +667,12 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) if (link->type == AVMEDIA_TYPE_VIDEO) { enum AVPixelFormat swfmt = link->format; if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_HWACCEL) { - av_assert1(link->hw_frames_ctx); - swfmt = ((AVHWFramesContext *) link->hw_frames_ctx->data)->sw_format; + // FIXME: this is a hack - we'd like to use the sw_format of + // link->hw_frames_ctx here, but it is not yet available. + // To make this work properly we will need to either reorder + // things so that it is available here or somehow negotiate + // sw_format separately. + swfmt = AV_PIX_FMT_YUV420P; } if (!ff_fmt_is_regular_yuv(swfmt)) {