Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avfilter: Temporary hack to fix format negotiation for hw formats
@ 2024-01-03 20:46 Mark Thompson
  2024-01-04  4:01 ` Xiang, Haihao
  2024-01-04 21:54 ` Mark Thompson
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Thompson @ 2024-01-03 20:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

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)) {
-- 
2.39.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avfilter: Temporary hack to fix format negotiation for hw formats
  2024-01-03 20:46 [FFmpeg-devel] [PATCH] avfilter: Temporary hack to fix format negotiation for hw formats Mark Thompson
@ 2024-01-04  4:01 ` Xiang, Haihao
  2024-01-04 21:54 ` Mark Thompson
  1 sibling, 0 replies; 3+ messages in thread
From: Xiang, Haihao @ 2024-01-04  4:01 UTC (permalink / raw)
  To: ffmpeg-devel

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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avfilter: Temporary hack to fix format negotiation for hw formats
  2024-01-03 20:46 [FFmpeg-devel] [PATCH] avfilter: Temporary hack to fix format negotiation for hw formats Mark Thompson
  2024-01-04  4:01 ` Xiang, Haihao
@ 2024-01-04 21:54 ` Mark Thompson
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Thompson @ 2024-01-04 21:54 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-04 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03 20:46 [FFmpeg-devel] [PATCH] avfilter: Temporary hack to fix format negotiation for hw formats Mark Thompson
2024-01-04  4:01 ` Xiang, Haihao
2024-01-04 21:54 ` Mark Thompson

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git