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 5AB7640423 for ; Wed, 23 Feb 2022 13:33:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 57C0E68B2C9; Wed, 23 Feb 2022 15:33:36 +0200 (EET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 318B368B1F8 for ; Wed, 23 Feb 2022 15:33:28 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645623214; x=1677159214; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=bRkOWWdXgo8yebPgQBlZMdLYZUeESYFwPh+9K/4ZYwk=; b=EXSItOfPL+tTgJJTA/wxOeHwo0vKumDvnYWkTaBdgzTPkJQMtWLZ1k/q EgDFz0zVmwMaKo/THkTl9yRdm+Z/n8pFfJybleRJllXSGf57YULS89fc5 M/aA6Owww9hxD9uibJJPEXKdgHbA+r7aexcpnxdxPg2M6nIMT/mXz2ROx MjKklNYka9HhoSCqTL3h0d0OaJGfq7bc/EOkZ5aTPAQNwIzvp1RgDNasr 16hice2dNepr1FMMzMvq9nIX9lxfPYwgENj1PWp54IxNnvJX5mUwyozuJ rVmvCvjkWk+x3kWv7f7PYvarmJ4Cs5ZI8x6h7q33AHuh5cSqwiejtrmCM w==; X-IronPort-AV: E=McAfee;i="6200,9189,10266"; a="251881310" X-IronPort-AV: E=Sophos;i="5.88,391,1635231600"; d="scan'208";a="251881310" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2022 05:33:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,391,1635231600"; d="scan'208";a="639306942" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga004.jf.intel.com with ESMTP; 23 Feb 2022 05:33:25 -0800 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 23 Feb 2022 05:33:24 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Wed, 23 Feb 2022 05:33:24 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.105) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Wed, 23 Feb 2022 05:33:24 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qcag5mCAhhpIFM+Egz8gBpMtnkP26QYYQEbx6gMnjIDt8JxnDGRjzJ2jzgaZGbYEY+90RgL2IrE1n66rpO9usyx+aS15oEbxcqtyJSd1ghgWYM9si2AevmrULg+KiQF8yZTb3zkkY7BufyEOIN5w5J9ykWsM9pjv4VPruinhpr1c7EFq5tfJZXpVquRA0Bh4sJdpEU0nderkqzxFw8poVk8psAhUjhd2xNZtFLj3nKT62ILXM1GiPInR/tvACDqnn8+v+wHXF6m9U/lDYcNYRdfSCS+EaVKytjYy33Z7oylgLYkx0txNFdZ4KsxwF300iEtezwQD/DTI7zTJ5PlSgg== 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=FtknDC27Ix+kIxKPI55aSRsNIhGo7jH1ctb0E/cxFgI=; b=ekJekNMARQCNd7eAW3NybUfycxth4kGAwg20Rfvz1xnEHv/9bfhFYpbb9o9+HTSo5FH0m98ddeRqQnrC0lThbvUCB1ifl8PBmuprvtjZnSIi46QWmskAbs4/Cja0UddV3D+xWPMvD2fZtXpNEbn6T4w/F0E+K+mdEPAdY4EG+hZ+u0QQHpregxl+dl5uMFsbjftmlSdaeyJloZk+FqS6k1mldjS3b4Q39HBTKQSyvoOExrTJoggw7WnOVes2kODehEMJjhGdVRjEuU4xlYxpbe9U8WwM02B5WDiIekzhCWIadM+/CW1QV7qSkRBr3wCpxeCaVoeZULHHm83jLL6KYQ== 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 PH0PR11MB5030.namprd11.prod.outlook.com (2603:10b6:510:41::5) by MWHPR11MB1424.namprd11.prod.outlook.com (2603:10b6:300:26::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.24; Wed, 23 Feb 2022 13:33:23 +0000 Received: from PH0PR11MB5030.namprd11.prod.outlook.com ([fe80::600d:3095:b0:f8c1]) by PH0PR11MB5030.namprd11.prod.outlook.com ([fe80::600d:3095:b0:f8c1%5]) with mapi id 15.20.4995.028; Wed, 23 Feb 2022 13:33:23 +0000 From: "Wang, Fei W" To: FFmpeg development discussions and patches Thread-Topic: [FFmpeg-devel] [PATCH v2 1/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi Thread-Index: AQHYJsli8kR3hmzsMUyqPODCQofIfqyd6V8AgAEoL4CAADGWgIABz7LA Date: Wed, 23 Feb 2022 13:33:23 +0000 Message-ID: References: <20220221021337.2190359-1-fei.w.wang@intel.com> <03ec8c31-088a-95b6-a514-6fbf14518537@jkqxz.net> <3b94feeb89d9a990cc11d8b2b35a0949736e6fb6.camel@intel.com> <757b53c74767bedb2f98a1373213feca3efd98b3.camel@intel.com> In-Reply-To: <757b53c74767bedb2f98a1373213feca3efd98b3.camel@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.200.16 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: 67e92077-26e7-43f2-89b2-08d9f6d1105b x-ms-traffictypediagnostic: MWHPR11MB1424:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0kzqOhEsVGe1dn4dWKlKsJs/4l+JyeuCgB42Svs1lOfnFDqN/kmt3/hWH7+o7OJ/Gr0XY7ZTJtmdn/ObcUWOOlnnamMxoTlCFGf9GzDiWf7/z48MLXPYPrLi77FH43EfITMfUt65RgohcRpnqPsL71qSl3hwtQv+6d7W/gAZPS6rJVMU9dm/JImjy6mKFdnkAxRcKhiqGPAGcDVLzj700HMqw+L1pdBOSeLKrFMTw1MUo4dXfA9FrSFUDScOsxabU/bP8V+vm/+XC98xNm+nmq9bguPCcd46WMz08EI1tMkANVrZI0lcyO49QJ4sdItBJ0wtSdkri/ZbAphzWBhlpThcKx0ePovchpTejyZmJTovoL4oBu8Kj96J6x5Y0p1iCDTbOk0Iy0+k3IRZFvQTv93EK2oSoWRg2EKDzV6cEqBiZFCAXD+TX5E1CY9QYT3ZHpQ8Mk0EtE0zYA/oN6mpXXHudiEclkbYCfNb2zU0IQxuTwnddxqng35zyIFxUpy+s5r1pinGhVMNBNtuCWJhX2/EJ8GIsfj7SmAaDgnKa9NUXn1ICcwGGeKZCC5L9NFB2R1u7DVElbIn30itO+FWujYBFtXFcjl1zM/gtYMaK5F54L+yXkYIAgMnXEUwr8u/blmhTszJ1QdKSnkKOuGppl8wTvx0mkNwamSISiJmqyKzXUuJfRSvfCiS/Wf27sKkigIFf1ieCsUEaJ2vwflqPxRbSxm5hyCM2oYS/YEa5p4nDHv/J7xYFlgE4rizGHBqvlacAkTe8VbxhsLY247VxQL4T2cH3uISDJ9DqtLmhLaQjWyzHHq0VO5SKwXEbpkd x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5030.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6916009)(55016003)(38100700002)(66446008)(83380400001)(8676002)(26005)(186003)(9686003)(86362001)(64756008)(7696005)(76116006)(6506007)(53546011)(84970400001)(66476007)(316002)(966005)(38070700005)(66946007)(2906002)(66556008)(5660300002)(71200400001)(508600001)(52536014)(82960400001)(33656002)(8936002)(122000001)(30864003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Z0sSCRltcAOdUVZAb3tFo/m+jDMkTCodtG7LWYe0/StZ7NrNVrS1NsiptoMd?= =?us-ascii?Q?bjxPuyB0/07NHhCoC5pCbyGEcPSwSaihGDF3U/p/zW6F6ks1Vx1J1JNFh49y?= =?us-ascii?Q?9ZMySWiVhMik38Ff0n03Ytw5NGkpGPqiOGXg2/U4tGHRtGR8l3fjl4JH8dSP?= =?us-ascii?Q?focGbv/o8HgzbjWI3oHZVNLRvK8Fdmxhq+F6iG+f9eTkDwHOmAG7RhZNKc3V?= =?us-ascii?Q?Y4S2iGu/W69xWTQcY5E0lrGwAXmL9aeH7fEso6SHiXOLFrcFZgaxjB8BauFX?= =?us-ascii?Q?XKl+fFOv+9YB9fvEFZbSwGPPUmxOZqOuYn33T0P3MtQdp7MwHlFHCFGo1tT1?= =?us-ascii?Q?QzZJIeTFuZ4D50e55er4ZaeaCIvJJzQy1hSIIWbJG3d131nLH/3I+DXmpENl?= =?us-ascii?Q?4emtHgNZyLBOrUM1hDJS+3wI3KuJKvF4XpBEnBlqJLH5h5WO63NCB/AjEEax?= =?us-ascii?Q?xU/nWt+FOITbQZNEQpfEj8TAnsUrf3DHjZ667zSP6AP2e0655GSq28hy2wyY?= =?us-ascii?Q?KviMjmilCMu+kddK5s7HE96aporYjBCTsUhyBCbgiZJ/EIiU81vJuHDSJxHa?= =?us-ascii?Q?GoMe6za/LeM4DMd/vt7DYD6LmwyXEcoW3Zijj2T6+FLl6qj8udKgKkZHaIab?= =?us-ascii?Q?RBuqfwH6rJd7D1IRmBPks80vxWIX9F8Tq55UtpyIJNvlhVjEPJ7jiXgVtsr/?= =?us-ascii?Q?BsdjokdCKhvAZ4RFs03+8kycTVhnDOFymQi2jVUqjtovdsb+mvu6lwOJivX0?= =?us-ascii?Q?BuvsIGNTRr1h/h9nO5G8pxlzkHaVaTLKS3Cy8435fkvgny293owj3b0E6Ky4?= =?us-ascii?Q?Elz7r9s9Ith7g18CXUi+xnUD4rll2BOJJo8BpFNb4n6i8UjQwk5QrStcwoO5?= =?us-ascii?Q?sQ1ac0gUFXylpBI/vb6FwxaZLiO72Ycrt1WDboxkTm16Ei90dCSmxUGym357?= =?us-ascii?Q?SMtMTXWXgZxTh++wUp/2tzgHpdmCBSf3tQyGZx9K4bHe+nRKPMWW0SSADT/u?= =?us-ascii?Q?f3AqLFRiKNpVcLm+SDTwpaKN48L58TIg1k4zlT96CrgSenNba8fKkScfw3q1?= =?us-ascii?Q?lUsaI81GuaTEEWs1vycvV6azc+39IznPiSXwKTebSbV7QwMqeaPHx6f73gxp?= =?us-ascii?Q?5zElOEpBIBWThSOSXacINRH5T5OlUq0DLfbDCuvIYY0Pbu+rgoPDB9EO8DOT?= =?us-ascii?Q?NxeHpGVkTkLfwv5v3BrWVZN07n27HEKDtOaiLLhDmK2KVyoc5zYCi9J0M5EK?= =?us-ascii?Q?tp3uwmcDoOWH71uhkWs2bIO057+8U4+RpqIw+sScX301OgSy14YCw8cWActA?= =?us-ascii?Q?N9kB2K+5FHJWmnDi+AE9ZRokHHK33FUEZo9zA+gPRdOnGLrcITJNHnLHm5WX?= =?us-ascii?Q?YvSxDzusAY8hP5wQtTMwyDeXJVxnKKbmrPE+Hh1+Ow3vevDVVPTOM2XFPwJw?= =?us-ascii?Q?EL3iXNL4X3sWz9Es2iFXwBlWwuPCptKnMGnPWIc2SftXzXimcyyJGg1024Tw?= =?us-ascii?Q?oqvYsFD7xYyhAVR40VRCosc5ha6z9NkpFFM3KXCJ9WzPt4v1tPjOzzP1ldVx?= =?us-ascii?Q?T8suA05aG/c26n4qLonI9wzIoKzfcU4zJnsPiKMem5/KilJGllsij/TriPHV?= =?us-ascii?Q?ng=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5030.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67e92077-26e7-43f2-89b2-08d9f6d1105b X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2022 13:33:23.1418 (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: 9oGqb6BQcvEA67W0vE3gCjZLv9yac/R/yCCRFci82fZkOrTI85r9dAOXTxJeNSuVpJgxAQASg+o4ZlQHQPb9VQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1424 X-OriginatorOrg: intel.com Subject: Re: [FFmpeg-devel] [PATCH v2 1/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi 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: > -----Original Message----- > From: ffmpeg-devel On Behalf Of Wang, > Fei W > Sent: Tuesday, February 22, 2022 4:49 PM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v2 1/4] lavc/vaapi_encode_h265: Add P > frame to GPB frame support for hevc_vaapi > > On Tue, 2022-02-22 at 05:46 +0000, Xiang, Haihao wrote: > > On Mon, 2022-02-21 at 12:06 +0000, Mark Thompson wrote: > > > On 21/02/2022 02:13, Fei Wang wrote: > > > > From: Linjie Fu > > > > > > > > Use GPB frames to replace regular P frames if backend driver does > > > > not support it. > > > > > > > > - GPB: > > > > Generalized P and B picture. P frames replaced by B frames > > > > with > > > > forward-predict only, L0 == L1. Normal B frames still have 2 > > > > different ref_lists and allow bi-prediction > > > > > > > > Signed-off-by: Linjie Fu > > > > Signed-off-by: Fei Wang > > > > --- > > > > libavcodec/vaapi_encode.c | 33 > > > > +++++++++++++++++++++++++++++++-- > > > > libavcodec/vaapi_encode.h | 1 + > > > > libavcodec/vaapi_encode_h265.c | 15 +++++++++++++++ > > > > 3 files changed, 47 insertions(+), 2 deletions(-) > > > > > > This always fails immediately on current iHD > > > (7e357b4bea76b2fe2522e6af41ae02ea69cec49e): > > > > > > $ ./ffmpeg_g -v 44 -y -hwaccel vaapi -hwaccel_output_format vaapi -i > > > in.mp4 -an -c:v hevc_vaapi -low_power 1 out.mp4 ... > > > [hevc_vaapi @ 0x560e81d45e80] Using input frames context (format > > > vaapi) with > > > hevc_vaapi encoder. > > > [hevc_vaapi @ 0x560e81d45e80] Input surface format is nv12. > > > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI profile VAProfileHEVCMain > > > (17). > > > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI entrypoint > > > VAEntrypointEncSliceLP (8). > > > [hevc_vaapi @ 0x560e81d45e80] Using VAAPI render target format > > > YUV420 (0x1). > > > [hevc_vaapi @ 0x560e81d45e80] Using CTU size 64x64, min CB size 8x8. > > > [hevc_vaapi @ 0x560e81d45e80] No quality level set; using default > > > (25). > > > [hevc_vaapi @ 0x560e81d45e80] RC mode: CQP. > > > [hevc_vaapi @ 0x560e81d45e80] RC quality: 25. > > > [hevc_vaapi @ 0x560e81d45e80] RC framerate: 30000/1001 (29.97 fps). > > > [hevc_vaapi @ 0x560e81d45e80] Use GPB B frames to replace regular P > > > frames. > > > [hevc_vaapi @ 0x560e81d45e80] Using intra, GPB-B-frames and B- > > > frames (supported references: 3 / 3). > > > [hevc_vaapi @ 0x560e81d45e80] All wanted packed headers available > > > (wanted 0xd, found 0x1f). > > > [hevc_vaapi @ 0x560e81d45e80] Using level 4. > > > ... > > > [hevc_vaapi @ 0x560e81d45e80] Failed to end picture encode issue: > > > 24 (internal > > > encoding error). > > > [hevc_vaapi @ 0x560e81d45e80] Encode failed: -5. > > > Video encoding failed > > > ... > > > $ cat /proc/cpuinfo | grep 'model name' | head -1 > > > model name : Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz > > > $ uname -v > > > #1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09) > > > > > > Do you get this too, or is your setup different somehow? > > > > Hi Mark, > > > > I tested this patchset with iHD > > (7e357b4bea76b2fe2522e6af41ae02ea69cec49e) on CFL (low_power=0), RKL > > and DG1, i965 on SKL, and didn't see this issue before. > > This day I reproduced this issue on ICL. It seems iHD driver doesn't > > return right values for ICL. > > Thanks Mark to report this issue on ICL. > > I tested on TGL and CFL before submitted this patch set, all looks good. I will > check why this fail on ICL. > > And will fix your other comments together in next version. > > Fei > Thanks > > > > > > > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c > > > > index 3bf379b1a0..95eca7c288 100644 > > > > --- a/libavcodec/vaapi_encode.c > > > > +++ b/libavcodec/vaapi_encode.c > > > > @@ -1845,6 +1845,30 @@ static av_cold int > > > > vaapi_encode_init_gop_structure(AVCodecContext *avctx) > > > > ref_l1 = attr.value >> 16 & 0xffff; > > > > } > > > > > > > > + ctx->p_to_gpb = 0; > > > > + > > > > +#if VA_CHECK_VERSION(1, 9, 0) > > > > + attr = (VAConfigAttrib) { VAConfigAttribPredictionDirection > > > > }; > > > > + vas = vaGetConfigAttributes(ctx->hwctx->display, > > > > + ctx->va_profile, > > > > + ctx->va_entrypoint, > > > > + &attr, 1); > > > > > > This probably shouldn't be done at all if the user has selected a > > > codec without B-frames or a configuration which is intra-only, > > > because the log message is confusing: > > > > > > [mjpeg_vaapi @ 0x55b90d72ee00] Driver does not report whether > > > support GPB, use regular P frames. > > > [mjpeg_vaapi @ 0x55b90d72ee00] Using intra frames only. > > > > > > > + if (vas != VA_STATUS_SUCCESS) { > > > > + av_log(avctx, AV_LOG_WARNING, "Failed to query > > > > prediction direction > > > > " > > > > + "attribute: %d (%s).\n", vas, vaErrorStr(vas)); > > > > > > And fail? > > > > 4/4 also ignores the error. It would be better to handle the error in > > the same way and update 4/4 too. > > > > > > + } else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) { > > > > + av_log(avctx, AV_LOG_VERBOSE, "Driver does not report > > > > whether " > > > > + "support GPB, use regular P frames.\n"); > > > > > > "support GPB" is a strange thing to say. It's a constraint - any > > > driver which supports B-frames will let you have the same thing in > > > both RefPicLists, but some require it because they don't support > > > P-frames. > > > > > > So maybe something like "Driver does not report any additional > > > prediction constraints, using P-frames."? > > > > > > > + } else { > > > > + if (attr.value & VA_PREDICTION_DIRECTION_BI_NOT_EMPTY) { > > > > + ctx->p_to_gpb = 1; > > > > + av_log(avctx, AV_LOG_VERBOSE, "Use GPB B frames to > > > > replace " > > > > + "regular P frames.\n"); > > > > > > Maybe "Driver does not support P-frames, replacing them with B- > > > frames."? > > > > > > > + } else > > > > + av_log(avctx, AV_LOG_VERBOSE, "Use regular P > > > > frames.\n"); > > > > + } > > > > +#endif > > > > + > > > > if (ctx->codec->flags & FLAG_INTRA_ONLY || > > > > avctx->gop_size <= 1) { > > > > av_log(avctx, AV_LOG_VERBOSE, "Using intra frames > > > > only.\n"); @@ -1861,8 +1885,13 @@ static av_cold int > > > > vaapi_encode_init_gop_structure(AVCodecContext *avctx) > > > > ctx->p_per_i = INT_MAX; > > > > ctx->b_per_p = 0; > > > > } else { > > > > - av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B- > > > > frames " > > > > - "(supported references: %d / %d).\n", ref_l0, > > > > ref_l1); > > > > + if (ctx->p_to_gpb) > > > > + av_log(avctx, AV_LOG_VERBOSE, "Using intra, GPB-B- > > > > frames and " > > > > + "B-frames (supported references: %d / %d).\n", > > > > + ref_l0, ref_l1); > > > > > > Seems easier to just say intra and B-frames (though this isn't > > > really adding anything to the message above - it's still effectively > > > a P-frame referring to one previous frame, just using B-slices to do > > > it in a strange way). > > > > > > > + else > > > > + av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B- > > > > frames " > > > > + "(supported references: %d / %d).\n", ref_l0, > > > > ref_l1); > > > > ctx->gop_size = avctx->gop_size; > > > > ctx->p_per_i = INT_MAX; > > > > ctx->b_per_p = avctx->max_b_frames; diff --git > > > > a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index > > > > b41604a883..61c5615eb8 100644 > > > > --- a/libavcodec/vaapi_encode.h > > > > +++ b/libavcodec/vaapi_encode.h > > > > @@ -328,6 +328,7 @@ typedef struct VAAPIEncodeContext { > > > > int idr_counter; > > > > int gop_counter; > > > > int end_of_stream; > > > > + int p_to_gpb; > > > > > > > > // Whether the driver supports ROI at all. > > > > int roi_allowed; > > > > diff --git a/libavcodec/vaapi_encode_h265.c > > > > b/libavcodec/vaapi_encode_h265.c index e1dc53dfa9..ea45893508 > > > > 100644 > > > > --- a/libavcodec/vaapi_encode_h265.c > > > > +++ b/libavcodec/vaapi_encode_h265.c > > > > @@ -886,6 +886,7 @@ static int > > > > vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, > > > > VAAPIEncodePictu > > > > re *pic, > > > > VAAPIEncodeSlice > > > > *slice) > > > > { > > > > + VAAPIEncodeContext *ctx = avctx->priv_data; > > > > VAAPIEncodeH265Context *priv = avctx->priv_data; > > > > VAAPIEncodeH265Picture *hpic = pic->priv_data; > > > > const H265RawSPS *sps = &priv->raw_sps; > > > > @@ -908,6 +909,9 @@ static int > > > > vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, > > > > > > > > sh->slice_type = hpic->slice_type; > > > > > > > > + if (sh->slice_type == HEVC_SLICE_P && ctx->p_to_gpb) > > > > + sh->slice_type = HEVC_SLICE_B; > > > > + > > > > sh->slice_pic_order_cnt_lsb = hpic->pic_order_cnt & > > > > (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1; > > > > > > > > @@ -1066,6 +1070,9 @@ static int > > > > vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, > > > > av_assert0(pic->type == PICTURE_TYPE_P || > > > > pic->type == PICTURE_TYPE_B); > > > > vslice->ref_pic_list0[0] = vpic->reference_frames[0]; > > > > + if (ctx->p_to_gpb && pic->type == PICTURE_TYPE_P) > > > > + // Reference for GPB B-frame, L0 == L1 > > > > + vslice->ref_pic_list1[0] = vpic- > > > > >reference_frames[0]; > > > > } > > > > if (pic->nb_refs >= 2) { > > > > // Forward reference for B-frame. > > > > @@ -1073,6 +1080,14 @@ static int > > > > vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, > > > > vslice->ref_pic_list1[0] = vpic->reference_frames[1]; > > > > } > > > > > > > > + if (pic->type == PICTURE_TYPE_P && ctx->p_to_gpb) { > > > > + vslice->slice_type = HEVC_SLICE_B; > > > > + for (i = 0; i < FF_ARRAY_ELEMS(vslice->ref_pic_list0); > > > > i++) { > > > > + vslice->ref_pic_list1[i].picture_id = vslice- > > > > > ref_pic_list0[i].picture_id; > > > > + vslice->ref_pic_list1[i].flags = vslice- > > > > > ref_pic_list0[i].flags; > > > > + } > > > > + } > > > > > > Is it sensible to implement this properly in the generic code rather > > > than having special ad-hoc code here? > > > > > > (Is there any chance this will also be a thing for e.g. H.264 or > > > H.266 in > > > future?) > > > > Considering that VAConfigAttribPredictionDirection is not a specific > > attribute for hevc in VA-API, I think it is acceptable to implement > > this in the generic code. I tried to add the same reference twice into VAAPIEncodePicture.refs, and h265_vaapi can get the correct L0/L1 and picture type without any change, test code: https://github.com/intel-media-ci/ffmpeg/pull/485/commits/f98fa04fe26333f09cdc9a1a11b0bc65783f9ae4 But this change breaks slice header's information get by VAAPIEncodePicture.refs/nb_refs: https://github.com/intel-media-ci/ffmpeg/blob/b14321e307fcd662f8d9aaa17c7f297cba2cbe4a/libavcodec/vaapi_encode_h265.c#L927 A tricky way is to reconstruct pic->refs/nb_refs here and remove the duplicated reference by using pic->refs[i]->priv_data. pic_order_cnt. Seems this way looks even worse compare to the current implementation in this patch. Not sure if you have any better idea? Thanks Fei > > > > Thanks > > Haihao > > > > > > + > > > > return 0; > > > > } > > > > > > > > > > - Mark > > > _______________________________________________ > > > 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". > _______________________________________________ > 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".