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.
This commit is contained in:
Mark Thompson 2024-01-03 20:40:19 +00:00
parent d178539532
commit 8b76bae896
1 changed files with 6 additions and 2 deletions

View File

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