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 F03744A422 for ; Thu, 28 Mar 2024 02:17:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E14C268D6FE; Thu, 28 Mar 2024 04:17:39 +0200 (EET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 80E8D68ADF1 for ; Thu, 28 Mar 2024 04:17:32 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711592258; x=1743128258; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gf+LjjYkfhm8KDovFlpjb6bMK0XPbiAV4VhyrQs7FGY=; b=m/Lwb01wOz/G1opwZ19PTQTh3g4AAJwWsBK3HJjCy3aQvQtcwggcNjaD gqOMEJamStuxrE60kGTUVn3zu/zu9xjKTaJOOrRnenLyTQ9+rLdpy/Arp qGFEPKSjymi4R+U4nurgofBQEsoGS3ReWSbtsIMfHjzIEymAaBI5/2iYa CUZ+p75woBUvhXIClXwDl5ydQUJjSWybVSrcoyzgvfxVgPr9guaUrM8wg f1l9G/Tv3n2peXw5kMTOnCAwHV1QlxNcHsjSK1ji5erBJBYfqKtLcIPdl n6ClfNi9UR3D2GitIgaNYcy+2w3IPKJM4/XxKUeh7cSFw+NzVzVmrsiZD g==; X-CSE-ConnectionGUID: Kxb8g1eoRMuGP77qgB7zfw== X-CSE-MsgGUID: SeLfwg1QSn+OTnY6ZRWP+A== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="6664785" X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="6664785" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 19:17:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="16890300" Received: from xhh-dg264.sh.intel.com ([10.238.2.76]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 19:17:28 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Mar 2024 10:17:16 +0800 Message-Id: <20240328021717.4116418-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328021717.4116418-1-haihao.xiang@intel.com> References: <20240328021717.4116418-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavc/vaapi_decode: Use dynamic frame pool if possible 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 Cc: Haihao Xiang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Haihao Xiang This allows a downstream element stores more frames from VAAPI decoders and fixes the broke cases for the driver/hardware combination which doesn't rely on fixed surface-array. For example: $ ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi \ -i input.mp4 -c:v hevc_vaapi -f null - ... [h264 @ 0x557a075a1400] get_buffer() failed [h264 @ 0x557a075a1400] thread_get_buffer() failed [h264 @ 0x557a075a1400] decode_slice_header error [h264 @ 0x557a075a1400] no frame! Signed-off-by: Haihao Xiang --- libavcodec/vaapi_decode.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index cca94b5336..c690e25342 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -598,22 +598,26 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, if (err < 0) goto fail; - frames->initial_pool_size = 1; - // Add per-codec number of surfaces used for storing reference frames. - switch (avctx->codec_id) { - case AV_CODEC_ID_H264: - case AV_CODEC_ID_HEVC: - case AV_CODEC_ID_AV1: - frames->initial_pool_size += 16; - break; - case AV_CODEC_ID_VP9: - frames->initial_pool_size += 8; - break; - case AV_CODEC_ID_VP8: - frames->initial_pool_size += 3; - break; - default: - frames->initial_pool_size += 2; + if (hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_DYNAMIC_SURFACE_POOL) + frames->initial_pool_size = 0; + else { + frames->initial_pool_size = 1; + // Add per-codec number of surfaces used for storing reference frames. + switch (avctx->codec_id) { + case AV_CODEC_ID_H264: + case AV_CODEC_ID_HEVC: + case AV_CODEC_ID_AV1: + frames->initial_pool_size += 16; + break; + case AV_CODEC_ID_VP9: + frames->initial_pool_size += 8; + break; + case AV_CODEC_ID_VP8: + frames->initial_pool_size += 3; + break; + default: + frames->initial_pool_size += 2; + } } } -- 2.34.1 _______________________________________________ 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".