From patchwork Tue Jan 11 06:55:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 33201 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3432743iog; Mon, 10 Jan 2022 22:57:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOnvT/lSrnPYahGbWgDWhQpiNzrniWzsDqPY0rsQ402CuKGytLHRj2lc602i9ZyH3XWgt3 X-Received: by 2002:a17:906:540f:: with SMTP id q15mr2550161ejo.641.1641884226974; Mon, 10 Jan 2022 22:57:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641884226; cv=none; d=google.com; s=arc-20160816; b=G+ptnV/74ufAiDVY3niOMail6o2CY0PH2gKhvPTYikbrejFLcg/NuCiRvkeflohrME RiCm8Q1HuLXaeCkjMnA53hwfHBFAmRJVqp3bVsHMLnclQmYCR8KavQRbZGlwBnsz8q0Z oyJqctG5Ik+PsEptgIoj+WU8YZr2R7RGS5SYH0JUjvB7hbHvfDg/29gxovKj6ZvKyYHA BVP9fC+F8sYsqFiPBDCBV0Z8qI5Ml5VjvfOpwwIJo46nyoTap3l26d6wKyXC+wuoullQ RRYTMDFKVZRMxkUGVrlpBT9WcJQaqGYAMv/QIv8uoSPDqFJHU1GO1F3BiBzqV2efvS00 ufKw== 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:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=Bg2o7pCCTtYm3WYaKb2IoCXTAFdbdRv90XQI2Jj7jfU=; b=TYW0ztTGQx2cFf8BLf1gOvVptnlvxDa0GxqVf8epJizAXp6hL1KGGhP9REGdv+KbVb nWXfBm/crvE51l48pBnmd5a7yX21IKxQafG2DVTBctbtpVpVbe9cjriTUhCBrxEWCJyz YwtHLUCvy0x83mcAWYO1IRc7vn5kDaAgQ2KxFLUTa9yte8jdhl1SKcwYebNJ3qjNebgE 1EvXY+900UPakjzhisdChbNROJr9aqi2/TDJ/5tJUKOGCa3jV0EOsysP5Ial3khvQqok NaBla1Jgk//yLSocrG5GEiuOHaMdlwwb5lD5ND/6hrUGtSx3Xxetc1z81fqI+Pqes9ND 4WNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=RgUGo0xA; 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 s1si5871175ejn.485.2022.01.10.22.57.06; Mon, 10 Jan 2022 22:57:06 -0800 (PST) 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=@intel.com header.s=Intel header.b=RgUGo0xA; 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 714BD68AECA; Tue, 11 Jan 2022 08:57:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57EBF68A8E6 for ; Tue, 11 Jan 2022 08:56:54 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641884220; x=1673420220; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=RzNg75RP5h4qCVvbQA5kGCoXWuoRaE+gBXWNlPmNQQU=; b=RgUGo0xA1eOy1++ASnFN2u4f8n2WIPRklCyHYcnCBMXsz4zxGGOIPRtk ToMdFU/6uWj61G/kBQ//Ffic5LIBRnTE5amWtE7JuyVhY5pMP7EtpAYM/ Z5t6AtPlniAbgHjMdmufob76OP08KGg1SzGVwWewtNSTpTnlO7FuoQmdm MpBNM9rQTl7h4+OgKBb5uw3IMY3zcSn/gbxW9PZkmK72uq14Sq6R/aF7k Fw8Gyng87cJIeQPlvCmjWr1QTaSEmumt+A/ibQbUEqFpFLJnTjkIS2jdn ZIsA3UdA6uJmcONLAqBjalqnciXr0ZOmijVNMIc+ihWqVPco6x/XGnyD2 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10223"; a="243214618" X-IronPort-AV: E=Sophos;i="5.88,279,1635231600"; d="scan'208";a="243214618" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2022 22:56:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,279,1635231600"; d="scan'208";a="474427063" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga006.jf.intel.com with ESMTP; 10 Jan 2022 22:56:52 -0800 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 14:55:37 +0800 Message-Id: <20220111065538.750653-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V5 1/2] libavcodec/vaapi_decode: fix the problem that init_pool_size < nb_surface 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: F8iLmB8Sn2rU For vaapi if the init_pool_size is not zero, the pool size is fixed. This means max surfaces is init_pool_size, but when mapping vaapi frame to qsv frame, the init_pool_size < nb_surface. The cause is that vaapi_decode_make_config() config the init_pool_size and it is called twice. The first time is to init frame_context and the second time is to init codec. On the second time the init_pool_size is changed to original value so the init_pool_size is lower than the reall size because pool_size used to initialize frame_context need to plus thread_count and 3 (guarantee 4 base work surfaces). Now add code to make sure init_pool_size is only set once. Now the following commandline works: ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \ -hwaccel_output_format vaapi -i input.264 \ -vf "hwmap=derive_device=qsv,format=qsv" \ -c:v h264_qsv output.264 Signed-off-by: Wenbin Chen --- libavcodec/vaapi_decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 665af370ed..da0e72b10b 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -650,7 +650,7 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) ctx->hwctx = ctx->device->hwctx; err = vaapi_decode_make_config(avctx, ctx->frames->device_ref, - &ctx->va_config, avctx->hw_frames_ctx); + &ctx->va_config, NULL); if (err) goto fail;