Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/get_buffer: Add a warning on failed allocation from a fixed pool
Date: Mon, 18 Mar 2024 05:53:41 +0000
Message-ID: <a061213aa1655bf9d0421492b36c999142ca0d13.camel@intel.com> (raw)
In-Reply-To: <c99fd41b-c55a-44ce-819e-ec9df1b49b03@jkqxz.net>

On So, 2024-03-17 at 20:51 +0000, Mark Thompson wrote:
> For hardware cases where we are forced to have a fixed pool of frames
> allocated up-front (such as array textures on decoder output), suggest
> a possible workaround to the user if an allocation fails because the
> pool is exhausted.
> ---
> Perhaps helpful; any thoughts?
> 
> The warning comes out before any errors, looking like:
> 
> [mpeg2video @ 0x560ff51b4600] Failed to allocate a vaapi/nv12 frame from a
> fixed pool of hardware frames.
> [mpeg2video @ 0x560ff51b4600] Consider setting extra_hw_frames to a larger
> value (currently set to 8, giving a pool size of 14).
> [mpeg2video @ 0x560ff51b4600] get_buffer() failed
> [vist#0:0/mpeg2video @ 0x560ff5199840] [dec:mpeg2video @ 0x560ff51b3b40] Error
> submitting packet to decoder: Operation not permitted

I'm OK to print such warning so user may know how to work around it. But now
many cases are impacted by this error (e.g. https://trac.ffmpeg.org/ticket/10856
), I think it is a regression to user. I still prefer to use a dynamic buffer
pool instead fixed frame pool to avoid such error when the dynamic buffer pool
can work.

Thanks
Haihao

> 
>   libavcodec/get_buffer.c | 16 ++++++++++++++++
>   libavcodec/internal.h   |  6 ++++++
>   2 files changed, 22 insertions(+)
> 
> diff --git a/libavcodec/get_buffer.c b/libavcodec/get_buffer.c
> index 46c20781af..9b35fde7c6 100644
> --- a/libavcodec/get_buffer.c
> +++ b/libavcodec/get_buffer.c
> @@ -257,6 +257,22 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx,
> AVFrame *frame, int flags
> 
>       if (avctx->hw_frames_ctx) {
>           ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
> +        if (ret == AVERROR(ENOMEM)) {
> +            AVHWFramesContext *frames_ctx =
> +                (AVHWFramesContext*)avctx->hw_frames_ctx->data;
> +            if (frames_ctx->initial_pool_size > 0 &&
> +                !avctx->internal-
> >warned_on_failed_allocation_from_fixed_pool) {
> +                av_log(avctx, AV_LOG_WARNING, "Failed to allocate a %s/%s "
> +                       "frame from a fixed pool of hardware frames.\n",
> +                       av_get_pix_fmt_name(frames_ctx->format),
> +                       av_get_pix_fmt_name(frames_ctx->sw_format));
> +                av_log(avctx, AV_LOG_WARNING, "Consider setting "
> +                       "extra_hw_frames to a larger value "
> +                       "(currently set to %d, giving a pool size of %d).\n",
> +                       avctx->extra_hw_frames, frames_ctx-
> >initial_pool_size);
> +                avctx->internal->warned_on_failed_allocation_from_fixed_pool
> = 1;
> +            }
> +        }
>           frame->width  = avctx->coded_width;
>           frame->height = avctx->coded_height;
>           return ret;
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index 04f7cebdcb..64fe0122c8 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -144,6 +144,12 @@ typedef struct AVCodecInternal {
>   #if CONFIG_LCMS2
>       FFIccContext icc; /* used to read and write embedded ICC profiles */
>   #endif
> +
> +    /**
> +     * Set when the user has been warned about a failed allocation from
> +     * a fixed frame pool.
> +     */
> +    int warned_on_failed_allocation_from_fixed_pool;
>   } AVCodecInternal;
> 
>   /**

_______________________________________________
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".

  reply	other threads:[~2024-03-18  5:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-17 20:49 [FFmpeg-devel] [PATCH v3 1/2] ffmpeg: set extra_hw_frames to account for frames held in queues Mark Thompson
2024-03-17 20:51 ` [FFmpeg-devel] [PATCH v3 2/2] lavc/get_buffer: Add a warning on failed allocation from a fixed pool Mark Thompson
2024-03-18  5:53   ` Xiang, Haihao [this message]
2024-03-18 21:33     ` Mark Thompson
2024-03-19  4:16       ` Xiang, Haihao
2024-03-19 22:52         ` Mark Thompson
2024-03-25  7:35           ` Xiang, Haihao
2024-03-25 21:12             ` Mark Thompson
2024-03-18  5:35 ` [FFmpeg-devel] [PATCH v3 1/2] ffmpeg: set extra_hw_frames to account for frames held in queues Xiang, Haihao
2024-03-19 23:18   ` Mark Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a061213aa1655bf9d0421492b36c999142ca0d13.camel@intel.com \
    --to=haihao.xiang-at-intel.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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