Message ID | 084180be-b440-4071-b118-c6b26a71c483@jkqxz.net |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] avfilter: Temporary hack to fix format negotiation for hw formats | expand |
Context | Check | Description |
---|---|---|
yinshiyou/configure_loongarch64 | warning | Failed to apply patch |
andriy/configure_x86 | warning | Failed to apply patch |
On Wo, 2024-01-03 at 20:46 +0000, Mark Thompson wrote: > 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. > --- > Suggested full fix is to carry sw_format through the format negotiation > separately so that we don't need hw_frames_ctx to be set (which also has other > benefits like hwdownload being able to set its output format). > > This hack is needed until that is ready because all hw formats are broken > right now. > > > libavfilter/avfiltergraph.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c > index 727eff81ee..bc503f6ebe 100644 > --- a/libavfilter/avfiltergraph.c > +++ b/libavfilter/avfiltergraph.c > @@ -667,8 +667,11 @@ 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 to work around hw_frames_ctx not yet > + // being available to return the real sw_format. Once that is > + // fixed, this should instead be: > + // swfmt = ((AVHWFramesContext *) link->hw_frames_ctx->data)- > >sw_format; > + swfmt = AV_PIX_FMT_YUV420P; > } > > if (!ff_fmt_is_regular_yuv(swfmt)) { It works for me, the issue I mentioned in https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/319235.html disappears after applying your patch. BRs Haihao
On 03/01/2024 20:46, Mark Thompson wrote: > 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. > --- > Suggested full fix is to carry sw_format through the format negotiation separately so that we don't need hw_frames_ctx to be set (which also has other benefits like hwdownload being able to set its output format). > > This hack is needed until that is ready because all hw formats are broken right now. > > > libavfilter/avfiltergraph.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c > index 727eff81ee..bc503f6ebe 100644 > --- a/libavfilter/avfiltergraph.c > +++ b/libavfilter/avfiltergraph.c > @@ -667,8 +667,11 @@ 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 to work around hw_frames_ctx not yet > + // being available to return the real sw_format. Once that is > + // fixed, this should instead be: > + // swfmt = ((AVHWFramesContext *) link->hw_frames_ctx->data)->sw_format; > + swfmt = AV_PIX_FMT_YUV420P; > } > > if (!ff_fmt_is_regular_yuv(swfmt)) { This was broken on git master and a better fix is not immediately available, so applied to make it work for now. Thanks, - Mark
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 727eff81ee..bc503f6ebe 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -667,8 +667,11 @@ 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 to work around hw_frames_ctx not yet + // being available to return the real sw_format. Once that is + // fixed, this should instead be: + // swfmt = ((AVHWFramesContext *) link->hw_frames_ctx->data)->sw_format; + swfmt = AV_PIX_FMT_YUV420P; } if (!ff_fmt_is_regular_yuv(swfmt)) {