From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8732649687 for ; Sun, 17 Mar 2024 20:51:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F67168D1C4; Sun, 17 Mar 2024 22:51:03 +0200 (EET) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3D6B868CBCB for ; Sun, 17 Mar 2024 22:50:57 +0200 (EET) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-41412411672so389335e9.3 for ; Sun, 17 Mar 2024 13:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20230601.gappssmtp.com; s=20230601; t=1710708656; x=1711313456; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XlkVtxOLHSkb2i5tKmzBWWvbni23ILVIh11pNz5GL5g=; b=HCKDublBW4YXGR/uQCiEnQ0ecZOxjcgbp8icNr3RIJuce8wDU/+b8oBqTGhw2XKxy7 bdSsDAsBB2IehL2BSQGzEYbs84lySk6VV08GS+Zi0r5AQOIEQvKr2k/7mu4GDf/W/g9i aas1wfXhHGa6vHG8JIEehE3V36cNSA2AB3EQVHL9sW/QeWBaJCJg5dfc3z9qaCjoG7FB typtSONNBK9AKhMyu3JKHNWN3GpSLNWq7L9c73KgnXssYIwjA5tX/bA0AdBBGemVt1JO OlntQlckygeqXfwG7WxfXpN+HQIwOw1JxnAXis/jBGeqMnJjA6IgREtx5jVaANEqbCQU 0yvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710708656; x=1711313456; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XlkVtxOLHSkb2i5tKmzBWWvbni23ILVIh11pNz5GL5g=; b=oUYzF/78P9E1As8Yd/hXfUmHep2HCZTurRT7OF6m8bmR9h6/gCnIsEDrPL/X6Qrt4y faeB2iLhA6AIYJ250pR9uIu46zESL/SLstV2RJOZylAb6OY1Tywcu/nGomOki4x9oXt3 hcfmLOg50/beePbuouUc7CZtmfGtv1zbLXDNoNF6jPXMCBtZFvHlzCSavikZ8s3apwaZ XlRxqETzxnk6XPX7ATbxE7r8xKv4CVsBRBFSUeqEGC7lMMjMWGhPAo7UYP3X6Pgs/rEQ ZiVRYGGsuNQm4i+rFhr6rgBlMh2rxNjdP/o/KOr01zRc2o1cmEpUvAA5BGRX7k3vIsKy ay8Q== X-Gm-Message-State: AOJu0Yy1LEGtaRcYkkLLVxPAuCiTgZh+DkfOjIox58RWO/VQjxrJDOVj +rUsElqSSNIUjLGnuGXcc0JF22sFdf/2M7EknrBk8tth5XrQdgEA8RJmi4yS0XpD2yew7cQr0ea k X-Google-Smtp-Source: AGHT+IHw2x/tcQFAzlELOjQsHvNighvEbjCKgqssAW9OwR3RKV4JXFcJ62zf3nkieeJcgn3fuWHggg== X-Received: by 2002:a05:6000:245:b0:33e:bdea:629a with SMTP id m5-20020a056000024500b0033ebdea629amr6568377wrz.67.1710708656395; Sun, 17 Mar 2024 13:50:56 -0700 (PDT) Received: from [192.168.0.15] (cpc92302-cmbg19-2-0-cust1183.5-4.cable.virginm.net. [82.1.212.160]) by smtp.gmail.com with ESMTPSA id bj25-20020a0560001e1900b0033e68338fbasm118890wrb.81.2024.03.17.13.50.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 17 Mar 2024 13:50:56 -0700 (PDT) Message-ID: Date: Sun, 17 Mar 2024 20:51:29 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Mark Thompson To: FFmpeg development discussions and patches References: In-Reply-To: Subject: [FFmpeg-devel] [PATCH v3 2/2] lavc/get_buffer: Add a warning on failed allocation from a fixed pool X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 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; /** -- 2.43.0 _______________________________________________ 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".