From patchwork Sun Mar 17 20:51:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 47145 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp670489pzb; Sun, 17 Mar 2024 13:51:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU02e9oMHNLsK9BHoLXzUhKKz8gZnAkpOgdsj2UOF9emSnZN/kpE9KjxVlsjtS6aoUfT+cjn6KenK04NEhs6C+mHdOBXAGpRh8cJw== X-Google-Smtp-Source: AGHT+IFCndsAtEj2PFgtA19gipIv2osAoEVXM0JnPVZSzGjstXBEU0KVcF8bKMCmMyYogB4xS+9f X-Received: by 2002:a05:6402:3899:b0:568:9564:7836 with SMTP id fd25-20020a056402389900b0056895647836mr5297080edb.32.1710708665980; Sun, 17 Mar 2024 13:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710708665; cv=none; d=google.com; s=arc-20160816; b=cIdFmah//x28iEOWe9iBfCIeRR/qsvkBwU+X7C/w7ez7h3uk3xcO2QoAP5szE4enlW DWENrihOjH9a6fY1KJHLlo+ltjI1MwI/RfJctqc70+kmuOtvWpUiZro6cj2bAspD+QWa FMM9R9CW6nAPrrjb5AUZeYnip7s7vDvFrXlmO9PSJ4qCg+N0TM0zxZQsuQsjpO8Dg3Yo F27tOd4ksBXfWwaBFSzOPATMNhE50feIgFvveq7b0H6atTeczJrQzL2PXtHkgmMf2NyK iCTMgKKHktO9O8Zf6R/E73uMSaIySvh9pwdpk/+k9I4hBE7d3tYoco3UJI6FsJUe7lQj M8Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:in-reply-to:references:to:from:content-language :user-agent:mime-version:date:message-id:dkim-signature:delivered-to; bh=jkd5Wts0JkR9s1RpM0nlOPULJ7/HMKe/U0evj4AYJdc=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=Dzrkc23aeQGdQL37uiWLVGkQD6iZ2Eqh2DywfTtd0gP8P3rSThwDOFELoZnDq0suvB LbWo68eATZwPrk+RIPbtKC0hJcws1BEsvOHBF68SIbb3jNkI0lv+wZkL4jMenWxPpvOV WesQxM9Ld9qlTYoZHswHyuRs4l5bgFDe7XUBL1SrOYSF99ZNCAJPGAXg3iKPlxc5/jYM MYy48RGK3OS47xOrsDW3b923/BnvmPi2Q21yZZK2njQfGZFoLhBlgsOmpc4wzGbITcet I6ogJECAipttOrdOJ97mENXmVH9k4ISW8FTCOnck/7/9vgeRehIrSqFMvIPKwJgZC1br ygDQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20230601.gappssmtp.com header.s=20230601 header.b=HCKDublB; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dz19-20020a0564021d5300b0056b0af6450asi6189edb.160.2024.03.17.13.51.05; Sun, 17 Mar 2024 13:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20230601.gappssmtp.com header.s=20230601 header.b=HCKDublB; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43E6A68D1C6; Sun, 17 Mar 2024 22:51:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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-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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dsii0Vutj+3l 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; /**