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 08FBB40B7D for ; Tue, 28 Dec 2021 02:05:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3190468B0CD; Tue, 28 Dec 2021 04:05:55 +0200 (EET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D21BF68A5DC for ; Tue, 28 Dec 2021 04:05:45 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640657152; x=1672193152; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=y42rrRRpO9aaASDZcxhb64HDVaOgTkZ1CYYEvVcfGOI=; b=fQzep+9aiHImfINN+O9Fs5dmhwXbXP/qkXgJRy0YX1+nzmK2s/zsEUrY uaRYJNtdhqlPcaCs6AxQ928rNUy1oHx5vTr8Y7onFBFNP88lcIceOYamN vJsEtCU1dgGMtFNM4dRTAILm+xe1rP2niimW/qGJ0choRzAgoEvIxoZTK xPrOx7tQactsIn/uBANG2zhgWQAYEbBDseFMs17mkDyKV8sBjJlDcuWAs v8AQvuWxwNYka2ctfMuzjorfd91uDLAePOcF1quYnUUDAJuZLf5F6Ea/A mfZVtRE/z9Be5eYHUzussFNxIbv/0hYnaz1pmx4aS0a6ENd2RCi2L/Au7 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10210"; a="265522958" X-IronPort-AV: E=Sophos;i="5.88,241,1635231600"; d="scan'208";a="265522958" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 18:05:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,241,1635231600"; d="scan'208";a="523479674" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga008.jf.intel.com with ESMTP; 27 Dec 2021 18:05:36 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 27 Dec 2021 18:05:36 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 27 Dec 2021 18:05:35 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Mon, 27 Dec 2021 18:05:35 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.45) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Mon, 27 Dec 2021 18:05:35 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9W6avN7OTZcqS6zy7kE16HBs1FZlSEN+hhCQggdSVQV2ZLvKJJ92ZasGEEMkM8ClzyjWDym5jxr7kfrr1NIb8+vVZOH31REx1cFLFVJ4DIMpPl9xymbzyI8HV8pgL0DTR7xQueodHBpYd/B8XXkowrSAJVE9n+WJlX2uqyBORIJONeTEW7UTlcBucYIV6nf79+8HFYKdhy1/qUDMcUvo/LBDx4avvXsFsUyYlFGRcG9F6fUhW5qgYNvnpDxmqGr+0RU9zXXjB2r8Z/+ont7gTINkxoA+y3f5IYOPSeW4O0IrA5E2GniU+me5l9UyxGFowCTMvQr11MNiXy8r2dFYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0sUvs7LTxb/4fBnEsnkdM/jlWBCJd3TUl6hi8+w76pc=; b=C6sD+KMZaQ/xPplS1YQbHeSn4ZuTRVk52GePO3pGfoP89kaENUXZhgYGVQn8nGxiaJZDD2u++4CPL2ADIiWg7y+nc3i49uZE2rXVuEmKQLTB8jGK7XUE9izrUrXEAB4FlUW4jgxQEu5m4I/DpHPKMbt6raoh1kk9S5w+cJ+dYdOtAYrrjMut/GGwe/5Ah8IXXMF4+8ivbOS1PCiPxOs7jseNfmERdODfwyH2uZkXWT5N13yeukJ8VdWNNcLdzNdTNW9i9jlVnY2Ka9V+8zDZrUqpsBQpOP5iGy55x69JOI50GV53dQh6LGWFMCHqOKiPo2QyTsVIoi9PI+E70OfNcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BY5PR11MB3879.namprd11.prod.outlook.com (2603:10b6:a03:18f::17) by BYAPR11MB3464.namprd11.prod.outlook.com (2603:10b6:a03:7d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.22; Tue, 28 Dec 2021 02:05:34 +0000 Received: from BY5PR11MB3879.namprd11.prod.outlook.com ([fe80::550:e7c7:13c4:7e0f]) by BY5PR11MB3879.namprd11.prod.outlook.com ([fe80::550:e7c7:13c4:7e0f%6]) with mapi id 15.20.4823.023; Tue, 28 Dec 2021 02:05:34 +0000 From: "Chen, Wenbin" To: FFmpeg development discussions and patches Thread-Topic: [FFmpeg-devel] [PATCH 1/3] libavcodec/vaapi_encode: Change the way to call async to increase performance Thread-Index: AQHXyxEou47jQxS0R0a+JMC16C/yBaxHCeQAgAB9nhA= Date: Tue, 28 Dec 2021 02:05:34 +0000 Message-ID: References: <20211027085705.4114165-1-wenbin.chen@intel.com> <5a7d1a75-57c0-30cb-cc4f-4c8a346876d6@jkqxz.net> In-Reply-To: <5a7d1a75-57c0-30cb-cc4f-4c8a346876d6@jkqxz.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.200.16 dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a0cd157a-0b30-4b69-5cbb-08d9c9a6888c x-ms-traffictypediagnostic: BYAPR11MB3464:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: R3CPbzHvlTzGOOCe0bhdCBnv0P9mAsHP3yQgYxER2KJc8E3lGiPA4m1gGF79k/uowSlQGUABuOBihZsXefV1mJmBqtvPJLzuFKcYkDzg+B5vhYSshOuaThnJKDkM2G1zhQr/25TqD9i6+z9YxoL5FO7+3rOtu0vFWYslJ/Vll3y2zKQCkqEwEUZRdvRnZ4L35DMnORuu9Ewv7fHncUHtA2NXuA/wEE9Z5jwfegJNfnnHgz9Acur5N+/cES32Nq0mMnyoGRSveckZAONj5BbM3tfj7GGtasebXje4KXKSrxAXP1qQFS55KAlV7G81B0E94GdWVeXSBpqH55DEajjQ7Ye4rBO5PWeLrQQkHpTTIAmSOWACp5+Ro3lJoVBcj+oAt6lejl+c3yY/idDw/Qdiw5QgVEYMaaf38EkmvPhytRSTR4+KaobNYqm9EMPeJIura+0Jt/9bFDVnROQ1pylS2prC3PM8QDQMNrvqYRziG7KR6Qs2uQj1F50Wp+qO371HYdoa1ZYbM3rlq7e+wLuX2O4wkMCiCCKQi7OOgs3FW/99ncsoxxnD5hv8M7guynRt5hfQhhLzXkV5jHAOe2UKBLTc0kRxhvxk5KTaEK1qtYjVLm5ST7HG77Yu3NDhI83XW/Q0MLok4YiFTM9c2iUCyS4OIabTTiZ3mDmO036NGWT3yuu6qwjT0KLID7QVvujKqt2S3BBKCjhhI0H01cZJL6XlIge6T5cBUcnGH/brUBD1qKbGXkvCqD+kh+sOklBIaU2hYI6et1HXJyFXIji+mLm9L88EfyOeOHSaOSeM3lzAQtbIMIAkvI05VyAHB9wv x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR11MB3879.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6506007)(7696005)(71200400001)(33656002)(6916009)(53546011)(186003)(9686003)(82960400001)(26005)(8676002)(5660300002)(8936002)(316002)(38070700005)(64756008)(66476007)(66556008)(66946007)(66446008)(86362001)(2906002)(966005)(83380400001)(122000001)(52536014)(55016003)(38100700002)(508600001)(76116006)(43043002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?eRth8tmfmQZ28egb5+nFtgWhvcxxybV4IocHSHnFBTTUf5K+xFSNVOV4/xb3?= =?us-ascii?Q?mCPfLBbwnut4tGgvtc4IcRq084zxey+gX1ZtVOeIcYXNLG4u+QNEoRyTUPPj?= =?us-ascii?Q?7i/7Z7XbUPvGeA7bgj5nwDxnd2qPJjUgm5aemmlWKo6YHv1fosOUdOQuHLv2?= =?us-ascii?Q?7BLK8OS6Q7pCG+s9APdygDp/hBXq6k0vqIidcdcYMRSMmDjWEBEmcUT4gtUP?= =?us-ascii?Q?q1/tQ13VsR+FGqDbjwqhN0KQ13jMx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mXTSOXUtmHK83uI6CoWH27du3z7fYXApJW0fVlriEkgLhBIvIp8tq7bC08s?= =?us-ascii?Q?SKUCimp4CkuDFxnBeNn2YjYOfFI7xd5idzFmn4c15VYH5l0IMhpNB/t3mhv/?= =?us-ascii?Q?YDUj7uAN+2OaOtDJ7IFYX6Iy6jM+dD9upXtF/BmclMS3b3jIXUJIOGwFcRns?= =?us-ascii?Q?4eWZrImofREGLyrdc3F3zqzdYJWy5Dd6Vt1wDoYmayys76pnXglbjqn+qarY?= =?us-ascii?Q?qVEOhBeGfr9OQ7ZnBwn34qYpUuYuHAUp5xqfP1Dq5fDBnI+Q2iqhwssY3Aiz?= =?us-ascii?Q?0gFmFmLyedG8P7OHzUQCHZGV42tK3jolzo1rGLU/H9ZppXzfM4xw1QBEhTZu?= =?us-ascii?Q?X6GNvgm6Y19rIPPi5VWkqsgPsMVMm6ix7bnu1nebKiHeTagEoW+LHqIjILDF?= =?us-ascii?Q?Oawvi8wWF8mAPpPamQxJ2YB3Aci1PYxcOt3Pd63sobDiB422S84E6JI8vFVK?= =?us-ascii?Q?cnIEKn/aUMrSD3hUNv+8OR4=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR11MB3879.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0cd157a-0b30-4b69-5cbb-08d9c9a6888c X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2021 02:05:34.1352 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yscFQ99WXygHl7NO13fLe77H7pu2joV5YMwuseU5QCrngl+8aPyuN2wVV835s7Qah7ScbLKZl1Eka5HgXVMSEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3464 X-OriginatorOrg: intel.com Subject: Re: [FFmpeg-devel] [PATCH 1/3] libavcodec/vaapi_encode: Change the way to call async to increase performance 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-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: > On 27/10/2021 09:57, Wenbin Chen wrote: > > Fix: #7706. After commit 5fdcf85bbffe7451c2, vaapi encoder's performance > > decrease. The reason is that vaRenderPicture() and vaSyncSurface() are > > called at the same time (vaRenderPicture() always followed by a > > vaSyncSurface()). When we encode stream with B frames, we need buffer > to > > reorder frames, so we can send serveral frames to HW at once to increase > > performance. Now I changed them to be called in a > > asynchronous way, which will make better use of hardware. > > 1080p transcoding increases about 17% fps on my environment. > > > > Signed-off-by: Wenbin Chen > > --- > > libavcodec/vaapi_encode.c | 41 ++++++++++++++++++++++++++++----------- > > libavcodec/vaapi_encode.h | 3 +++ > > 2 files changed, 33 insertions(+), 11 deletions(-) > > The API does not allow this behaviour. > > For some bizarre reason (I think a badly-written example combined with the > Intel driver being synchronous in vaEndPicture() for a long time), the sync to > a surface is to the /input/ surface of an encode rather than the output > surface. > > That means you can't have multiple encodes outstanding on the same > surface and expect to sync usefully, because the only argument to > vaSyncSurface() is the surface to sync to without anything about the > associated context. > > Therefore trying to make it asynchronous like this falls down when input > surfaces might appear multiple times, or might be used in the input of > multiple encoders, because you can't tell whether your sync means the thing > you actually wanted to finish has finished. > > (The commit you point to above as having decreased performance fixed this > bug, since it became much more visible with decoupled send/receive.) > > So: put this change after the switch to syncing on output buffers (since that > operation does make sense for this), and leave the existing behaviour for > cases where you have to sync on the input surface. > > - Mark Thanks for your advice. It makes sense to me. I will update the patches Best Regards Wenbin > _______________________________________________ > 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". _______________________________________________ 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".