From patchwork Thu Mar 28 02:17:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 47565 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp1031000pzb; Wed, 27 Mar 2024 19:17:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVGZdjXn+9YucmwEQDn36PTJQ5T/tcoN7SdLkEOgkncJ0pR3exyjeAgSKCsyvgJGPqSccOIswNZ1jMFOGf9dHGzsEPxgMBGV1pjQg== X-Google-Smtp-Source: AGHT+IFkNc3Qd2lXRCaSRy0SOtQsLgB22Llkk6PJLrdwn+h78yfG4gVI0lcU576wcmFEHGNRh6KW X-Received: by 2002:ac2:499c:0:b0:515:a97d:6396 with SMTP id f28-20020ac2499c000000b00515a97d6396mr716545lfl.68.1711592259350; Wed, 27 Mar 2024 19:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711592259; cv=none; d=google.com; s=arc-20160816; b=LuPqAsqCREolnxCp51t126j71VCi2aNHB3XyglW1APX33sRRXIrYi8qcyum6Ih8ejS 8uiSSv0yIqjNdoAzVi7eB+ztjI8k6dRJIVFcK6YHPvlqiUIycZZZlmG1O2lAo8Ip0T/9 g7ZH3c+jEVlzVEAxSbmsW7CQsgdRAHMk8Yw4qENeQADb1k6nZnBrk1ruhJMLNXnMjniL eln/afITL0MTdDJvVtFb3RgpM/AYaZkTSUTtC6mlhRy7fZ+ND+cvEF0GmtQlLTf+KLBr GmExtYNDehQQmQgX5xjKo/+hiTX3EwGCI12BfZkkSowST5DyNakH4k9Vu06DZ05Rrtof 5yTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=y2Tx3DlDkVtEoTIBvE68SD/hFIU5NZx0ZgTYTIg+oBo=; fh=1kpmTRI1sW42eNCnNMby7VLIISQBX6KJuVYxOEG0t2A=; b=vrev68JKAW8CCm55gHKzQXbKSstSbMmhE/HFBll9BzmOr3qOFH7PAnTumQgTse5uxb TVAPbupfkwBynvs+d57JKseTB+i9Mh0dURF96wpd5hSIiPNRFTR/V4pDp/sNGXM+8O9W CS4FCL+ve57kYI/leTCYybPwmuhRTDSMBphJSO08Z4YL09UMfxPntZ8sNPvrGBvyVKAD PlGNq5rxbdIDBZYD7avQZaY6qIVW/zVjWFvFuTs+lwliAtsrTy8NwyQNOXH1ozgzjDKE 9UuMXoxseT4izRj4S7QtFmIFtfPzWrh5lJYqxM+oSE4nkeBlT6MXFBn9G9QTHdNtjAxY 7qag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=jd5MtSaE; 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 bj17-20020a170906b05100b00a475301bb92si182686ejb.920.2024.03.27.19.17.38; Wed, 27 Mar 2024 19:17:39 -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=@intel.com header.s=Intel header.b=jd5MtSaE; 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 012AC68D6FA; Thu, 28 Mar 2024 04:17:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0F14068ADF1 for ; Thu, 28 Mar 2024 04:17:29 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711592256; x=1743128256; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=TwzOtJbVrt3BmqhmFeMV4QPIYgPCkfsBLHKVnWFF4Mw=; b=jd5MtSaEIT0h3nxrJe9Mxms6h3pbV5STULCdqPtzjPoTHEaFHmd8zIXe dQLdQSzJRBr1e4SeRgfPUDyBWnKAMxjFkM33Jw1mNj/+6ePJsLgQ15hHG a2h6Uf9V1QqYm8X2ZrQI5R/HPz7FpIlB/CuJKPMwXJAmSk23UL6fEWSUa nG7H6pljqjekVL/rn7tKoRSx3caOAQ5sUEnKhPul68e8NFpyHLCiceSkk RAw9h9CyCLxxvdMGXpUgTBI5Cica7oDwBkRtZcBGiXLUtcCF10126J9Dy uBtYt3Cf61yXnw+uvjdPrfwAAe2v9zQmfy6K5KlBJETCRM5+UcSLGVDNd w==; X-CSE-ConnectionGUID: mzAXwkQVSXG/vlUB6RLL3Q== X-CSE-MsgGUID: dBVbidL6QgWVlpIdVqAUpg== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="6664783" X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="6664783" 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:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="16890294" 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:27 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Mar 2024 10:17:15 +0800 Message-Id: <20240328021717.4116418-1-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] lavu/hwcontext_vaapi: Add a new quirk 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BSSeYAGo2skV From: Haihao Xiang libva2 doesn't require a fixed surface-array any more, but some driver/hardware combinations which rely on this are still used. To reduce the impact to users, add a quirk for the driver/hardware combination which supports dynamic surface pool. Signed-off-by: Haihao Xiang --- libavutil/hwcontext_vaapi.c | 7 +++++++ libavutil/hwcontext_vaapi.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 56d03aa4cd..dae5dd4a11 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -390,6 +390,13 @@ static const struct { "Splitted-Desktop Systems VDPAU backend for VA-API", AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES, }, +#if CONFIG_VAAPI_1 + { + "New Intel iHD", + "Intel iHD driver for Intel(R) Gen Graphics", + AV_VAAPI_DRIVER_QUIRK_DYNAMIC_SURFACE_POOL, + }, +#endif }; static int vaapi_device_init(AVHWDeviceContext *hwdev) diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h index 0b2e071cb3..07014fd526 100644 --- a/libavutil/hwcontext_vaapi.h +++ b/libavutil/hwcontext_vaapi.h @@ -58,6 +58,12 @@ enum { * and the results of the vaQuerySurfaceAttributes() call will be faked. */ AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES = (1 << 3), + + /** + * The driver (and the underlying HW) supports dynamic surface pool. + * The vaCreateContext() call doesn't require a fixed surface-array. + */ + AV_VAAPI_DRIVER_QUIRK_DYNAMIC_SURFACE_POOL = (1 << 4), }; /** From patchwork Thu Mar 28 02:17:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 47566 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp1031036pzb; Wed, 27 Mar 2024 19:17:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXNyR40w2KIbcLRRoTsGt+Clfzzdt/CcJFcCZ7rtSLH0vuw9XHeHP7ZOX2Jt7dZqnuLP/hlHMOzLfnfhQ2Eh/z7cmN0DM6vBzjeow== X-Google-Smtp-Source: AGHT+IGw/u0YnN+l6qeZ6oAfxvctUVKWpVPpmGO3tJXzNL4CVoJ7pgoW6n6ZUf+S33XOVceRfPpC X-Received: by 2002:a19:4303:0:b0:515:c190:140f with SMTP id q3-20020a194303000000b00515c190140fmr689920lfa.14.1711592267181; Wed, 27 Mar 2024 19:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711592267; cv=none; d=google.com; s=arc-20160816; b=OfA8u3e3yfBw54XWh+tTd0ZFRaLKGwITty4IWh8+RXs+XrhtAZQczUQNPzlBdwY1ug eI2p7e3Z4jjmVp3HdaCqiwG4jxs9dQCiFYR2EoNdE33KuA0vi5h5FIrj5oszdWg5FWsl d7CBhd7b1ivIepSHkc7kSqQaM2TFDP5INk74mRcpd7kBpuEdJ+/um5A5AU3UsxzS2rzv toXYC0sqNB1wPrjD37NSxYApyOpDaS5KobgJ9iqqBYl83M7OnCha5C1hFOqqxE6Tckn5 dvUlfEXG06XAnKGT+mttq+eWXl6q4AI4B3PW3QgNkaPwrlAmsp/2F8LSDJ7KnBxaQUFL bdOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=7ucZUB0smPiPw/d34gdIo/TBJVzrDMSzPNJ5tBUCIIc=; fh=1kpmTRI1sW42eNCnNMby7VLIISQBX6KJuVYxOEG0t2A=; b=wk2TlBS0JgSJuTNOeloMKPb3PrXbtPTnIfgOCL/npAZPs42dHVb3JaR8wQ9YHFGjbj QUbX9GGftgeuvWGR3/YuT7KlNzRut/WvLirPwjqdKZiEGZ+JYSDAx/rH6+DdRwIq1LNl CtA5B02XEqemBLfJTnyHrtsg44v423o9fqxOs1+CeNQRqkR+AoIZXtYIHt+nIGm5zDzw 1NL0hD4KIcMT5vXrqM3iBhYKve4zDBnq3Gob8bdpZ9Wj5Hv8ftTcjaDuKLfIM7jdwWKE vOrJqkyE/4vGpPMzc3z2/iqV4XBzIbsL2+ra0memxA192AB5y8KN0mPznBni8rQBS6/O 0bqg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="m/Lwb01w"; 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 m19-20020a170906235300b00a4df7996a3esi180983eja.461.2024.03.27.19.17.46; Wed, 27 Mar 2024 19:17:47 -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=@intel.com header.s=Intel header.b="m/Lwb01w"; 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 2B29368D701; Thu, 28 Mar 2024 04:17:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 36G/pbQLv3My 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; + } } } From patchwork Thu Mar 28 02:17:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 47567 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp1031079pzb; Wed, 27 Mar 2024 19:17:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWmjr1SiMbFNVPo2qG0RKINVRxewJ2X+wMriZ/uoCIYwnslcv9H/4+9TX7IXOv4i6JtsWTOAHP+x/5TyrVsgCVDVkL6HBk2yM2NIg== X-Google-Smtp-Source: AGHT+IHjESWIzOBMlq4nIY+lA9xydFrGV+E5yLGJN+j11RyZOzli6qgLLGVctKuCA11ZHSmJS9NH X-Received: by 2002:a50:ccc3:0:b0:56c:2ee6:f452 with SMTP id b3-20020a50ccc3000000b0056c2ee6f452mr1277258edj.28.1711592275442; Wed, 27 Mar 2024 19:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711592275; cv=none; d=google.com; s=arc-20160816; b=ALxzPDSHAGpfgyXuXTrEMCzOxMJqxS2u+s2DBM9pvvpZKx3FToXzdl3r235t0xyOHU OryQVmUKvZ22dGVHoYu11LBXLYrM1/DuJYbgsZdQZ/9Rk+RpyE68eEg69oMDWtOa4OJf q/4j2F6tXTPbLwppZVerhcSF/rDYSXEh+sQPghqfJR8VsZ7fFT4tMXRa2o5JaqYygCQv Mu2k9xuAR3nL49nsM/JOLVtcXrHDaM8cVvJ18ro22t2sOodTKBkIVErxfe+XlQnprswJ 5ZLorm0LK6fQbKSXBi89vvS+UN1ELi0IALiZ9P+4e26+PEeCTPaUDIv145n9k9WADSQb yrHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=kep/4ZUEsyozsFgWrezP4/xoH2BjAD1WcCG2MHfCu9w=; fh=1kpmTRI1sW42eNCnNMby7VLIISQBX6KJuVYxOEG0t2A=; b=ofFy/ZuiXly22QVjJsWmZvlwTf/PKxh7EoeXh6hJntMC9diotU/Smg+JY+tYciGI7v +zLHljnnhyLgMHZZpJcm6eXU8dIhtYlfDJgepCUTqlINtpHrgUnaiWNhePiOLMeL59At ciS5YJ+nxzIclrZDt1KI3EJTeojLPwD84ceqQ2etS1F2zbZdrjn/AcbosljNUXpGv8+d K2emRJS7gt+1Y7KlUr1QGvLld7tx8Qh9s4lFp9lfr1M8kdVG+iC5e8RRril7/liGtu1B ezyidcdTYunqU0FdaDXvTuNa2j+7T9UrzRB+bLMs2fG0LWP/64pgu6yCKYUvALbSvKX2 WBRg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=SQSIUCVu; 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 z21-20020a056402275500b00568a519f45asi241973edd.310.2024.03.27.19.17.55; Wed, 27 Mar 2024 19:17:55 -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=@intel.com header.s=Intel header.b=SQSIUCVu; 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 3027168D582; Thu, 28 Mar 2024 04:17:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED97068D6EB for ; Thu, 28 Mar 2024 04:17:35 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711592262; x=1743128262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dimF0bmVjubApKBUH0BS26DIrpkZzlZs4c+4ilaW1V8=; b=SQSIUCVurnpjs3sSeGSbELl0sNUHwXrLS/MilCLJMeOZ/kz2NB+0taW3 sMBtoSGYTugpFBZJBmhpdKPajH62YiTQoyHt4zpstdPt3LA1K6p4B0QKe 8Av5pB/Bs4FJLUubyNF9RZEjx07KwKZ23IX/E1eAvvbX0d01QsXlY+gW1 gpeyVH1WXYleBiy4gT7bE0IFHewfJWv3hURqHm950M8z3Im2i5mNHR6C4 v+xsECBz999C6Bv+pgFS1bZAAh7EWvXylWwMU8iFXJcFiQuAHc87ndEji ZUVwt7xtZHPm/lkY1CHWKsyjTrT7izhWVk3qloPlmuAO9GrfugMTLsKuV Q==; X-CSE-ConnectionGUID: LLRfB6peRwOxWovCzmN8jA== X-CSE-MsgGUID: gUVSCvh+R5qBT8jc7HLpxw== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="6664788" X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="6664788" 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:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="16890306" 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:29 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Mar 2024 10:17:17 +0800 Message-Id: <20240328021717.4116418-3-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 3/3] lavfi/vaapi_vpp: Use dynamic frame pool in outlink 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: U2Tc0IU/5tJN From: Haihao Xiang This can fix the broken cases for the driver/hardware combination which doesn't rely on fixed surface-array. For example: $ ffmpeg -hwaccel_output_format vaapi -hwaccel vaapi -i input.mp4 \ -vf 'scale_vaapi=w=720:h=480' -c:v hevc_vaapi -f null - Signed-off-by: Haihao Xiang --- libavfilter/vaapi_vpp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c index 59961bfa4a..0755d674ac 100644 --- a/libavfilter/vaapi_vpp.c +++ b/libavfilter/vaapi_vpp.c @@ -203,7 +203,10 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink) output_frames->width = ctx->output_width; output_frames->height = ctx->output_height; - output_frames->initial_pool_size = 4; + if (ctx->hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_DYNAMIC_SURFACE_POOL) + output_frames->initial_pool_size = 0; + else + output_frames->initial_pool_size = 4; err = ff_filter_init_hw_frames(avctx, outlink, 10); if (err < 0) @@ -219,6 +222,8 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink) va_frames = output_frames->hwctx; av_assert0(ctx->va_context == VA_INVALID_ID); + av_assert0(output_frames->initial_pool_size || + (va_frames->surface_ids == NULL && va_frames->nb_surfaces == 0)); vas = vaCreateContext(ctx->hwctx->display, ctx->va_config, ctx->output_width, ctx->output_height, VA_PROGRESSIVE,