From patchwork Tue Oct 29 01:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25948139A for ; Tue, 29 Oct 2019 01:25:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D470218AC for ; Tue, 29 Oct 2019 01:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728412AbfJ2BYv convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:24:51 -0400 Received: from mail-oln040092064104.outbound.protection.outlook.com ([40.92.64.104]:11301 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727778AbfJ2BYv (ORCPT ); Mon, 28 Oct 2019 21:24:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CDuaTpyMaoG8+FJkf945hSqh6/hSGZrt6yM7Tm4hC740nnvYp7D/vzeFgUS/4/e9zIUfUqVI+7liZwnTx9Gtrnlw5dpwCi7D4xW51aaLTx3AepKSZvOHDMC3rtUnsr+sXYHyoF5Esz7y5PAQNqcKC9XG75zWCympksxr/iA7pM1S6R5BhN1lcB+eb3oU9kJXFY5/HUyEysD0hOmPblJp+HDlImdMKXsajHUlloSZSyJTWjrYHqK7t8CJONymYfJAJQwKptM4f7Hy7hPDbBnO6j1HS5gyOh2jjIX+amo8kO6461odiwZ3FsqztQoC3mOYz8k275M9ILMDrRtZ2xG5aA== 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-SenderADCheck; bh=7aLbhRJQoRv2DXpWYkLeNE9oJuFhpQAK5mAIz92B5Jw=; b=Im1SV0MKhn4fWu3YzTl4/BS6V8BxjvEexmDoX6SpKk6g8xNLYaRSDnrLaeg9mOU+WTTiNb6O6QrdLt3CJFxVTUUvVT86XdYQUVW0lzTEwAPGoFaOhZxDBJ0K5raellDPCmsi0CaiSPgDvfZRq6u/FgNlMueWfavHUoSMGwAj5aO0RYQpccRVWGD1yd8Tc9rRrBsK61VhFGNmFHzyQvY+2qn/j+uQG3ZMLNz1AE1u4l/ruEeCz776jXNpJKlJ9gJRLsSL4+F0CRsLjQaSI1oBdriASqzB0fb5bxJEtF5aVCtZcXST0dpWkqbNFNqi0C096cERf/r+9NppkQglly9Uuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.52) by VE1EUR01HT233.eop-EUR01.prod.protection.outlook.com (10.152.3.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:24:47 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:24:47 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:24:47 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 01/10] media: hantro: Fix H264 max frmsize supported on RK3288 Thread-Topic: [PATCH v2 01/10] media: hantro: Fix H264 max frmsize supported on RK3288 Thread-Index: AQHVjfemF2XvaXcsWUeIJgC1r9NXOw== Date: Tue, 29 Oct 2019 01:24:47 +0000 Message-ID: References: In-Reply-To: Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0090.eurprd09.prod.outlook.com (2603:10a6:7:3d::34) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:192CDE21F026038C37B37A2D09E211DEE81BE0F4D1F06E5EC2C0B84E0A7BF455;UpperCasedChecksum:9C4E6B40C89998D2CA4EA53A00051C034470684507E784F215BFE37BCF94CA52;SizeAsReceived:7626;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [NGBzO9L4KPIYzf53JaOBTEWZ16gEAj3B] x-microsoft-original-message-id: <20191029012430.24566-1-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT233: x-ms-exchange-purlcount: 2 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +ckwbhAQx/6R/M7DnKFCEr0XO/f1I10d4KLlLfjdj7CTPRw2/zMeBT2qtWPvFJ7+Fb9riz9Rw2JtusrX8u6RgWbacvvciVmpCcJEug/ptU0XfUgXX0ge+MtETxcnn5zD0ht6O9FYxsYHiaujKMHBbi0ziQ+n+V9V0xif50jTVsATrjV7GWLyr2YNctDi+NHCFVbfhyx7mSSJ8OOZfn+BuAXiWAgVqQShUEoH0w0gHGE= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: eabb34eb-f2ba-44c8-ad2c-08d75c0ec8f8 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:24:47.0660 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT233 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org TRM specify supported image size 48x48 to 4096x2304 at step size 16 pixels, change frmsize max_width/max_height to match TRM at [1]. This patch makes it possible to decode the 4096x2304 sample at [2]. [1] http://www.t-firefly.com/download/firefly-rk3288/docs/TRM/rk3288-chapter-25-video-encoder-decoder-unit-(vcodec).pdf [2] https://4ksamples.com/puppies-bath-in-4k/ Fixes: 760327930e10 ("media: hantro: Enable H264 decoding on rk3288") Signed-off-by: Jonas Karlman Reviewed-by: Boris Brezillon Tested-by: Boris Brezillon --- Changes in v2: - updated commit message with reference to TRM and sample video --- drivers/staging/media/hantro/rk3288_vpu_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/hantro/rk3288_vpu_hw.c b/drivers/staging/media/hantro/rk3288_vpu_hw.c index c0bdd6c02520..f8db6fcaad73 100644 --- a/drivers/staging/media/hantro/rk3288_vpu_hw.c +++ b/drivers/staging/media/hantro/rk3288_vpu_hw.c @@ -67,10 +67,10 @@ static const struct hantro_fmt rk3288_vpu_dec_fmts[] = { .max_depth = 2, .frmsize = { .min_width = 48, - .max_width = 3840, + .max_width = 4096, .step_width = MB_DIM, .min_height = 48, - .max_height = 2160, + .max_height = 2304, .step_height = MB_DIM, }, }, From patchwork Tue Oct 29 01:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2BFD14DB for ; Tue, 29 Oct 2019 01:25:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A93DE217D6 for ; Tue, 29 Oct 2019 01:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728385AbfJ2BYv convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:24:51 -0400 Received: from mail-oln040092064064.outbound.protection.outlook.com ([40.92.64.64]:44830 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728270AbfJ2BYv (ORCPT ); Mon, 28 Oct 2019 21:24:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SuS8V1KYsyhLh8sS5G8Qatj+AEx8YtA+/yzI2w9J+fFDFdFszAweDwAdplc1W3oTSl/nI4Mcvh3bQOWfIAw2eHBIrFMuOfR13DDtMzotKvFrt8iucZ6YUUhbz0E5fTX5PG89nyjq0MfHC+clxcuq0exwBlNRX67dUVfWDx36ZCK7JKO+q0GHA1lquZ2Q2O1NmtsEBjC34RKQnGYkuyDuHnaHSFuRwYNp3MRyFmjNocyGjfvWHl20SRWQHdPVSK/JlXzLPr7PAQ7QPudzZzJQo3jIOZvXll+m24kKEYTiUX2sfwZ3tP9ZK5FjeRoBc6tzG8YNAg9a91jakhj86o6K4Q== 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-SenderADCheck; bh=Rwh4CRZQwbmAdm+lLifQ88BcRQm8NVhKwvxbdI4BOOE=; b=ZAF0v+eY6qbl9J60uF4TKB5bs6uqpJsLKjZ1fWUsUYsGPqTJbeOgAD/rKPIm6EvNVn9yyWE/dIevqECOZMssUwawfzt2rlCYwlPrJ7nDwjPq+8yGazrAgdZQVnACwY3qX4CnA1DdpYh799Ydo7roGWzbMM/YIdGXYioIG5PNSY4UM/8ncTFDr/6+xRQGgOJrc4tZIl8qG+/K+sEcqIiFDhmfiXHxVUWgpSRSZ2hRUvu+bMefNXEE+Hz+C4LvvmHKCbX3oX4eriX8jnszGmy2vd2vsdCHeHI2EYigC8PiJRlbFeY1qDw53SQwMpKq8euEdJyvIFHV5WoeU3e/7uvqAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.60) by VE1EUR01HT115.eop-EUR01.prod.protection.outlook.com (10.152.3.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:24:48 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:24:48 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:24:48 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Francois Buergisser , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jonas Karlman Subject: [PATCH v2 02/10] media: hantro: Fix motion vectors usage condition Thread-Topic: [PATCH v2 02/10] media: hantro: Fix motion vectors usage condition Thread-Index: AQHVjfenYArJWRB04EKt4B7/YEWLRg== Date: Tue, 29 Oct 2019 01:24:47 +0000 Message-ID: References: <20191029012430.24566-1-jonas@kwiboo.se> In-Reply-To: <20191029012430.24566-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0090.eurprd09.prod.outlook.com (2603:10a6:7:3d::34) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:1FCD5D1FA0C4F46DDFBFEB802614D9D63122D073A1E60D0DDAA55BF056F30D8B;UpperCasedChecksum:AC4DFCD5E325C1F32B85A129D572CA7703466C528772D9430732451E5B6E5646;SizeAsReceived:7658;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [BKgQaOLoZRyT1jc/Y1m5HBfPhDaDByDz] x-microsoft-original-message-id: <20191029012430.24566-2-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT115: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: CW98DEbIlwkCgLXIgefj9hwwWf5vpKKATt2PYonj4cJVHxHlaxqv0k5hzmkhjsP4XmOE+FczBtMRYe3J69UjJnWA0N0yPJ4lOuNI6I/1eQNrQUXtBvIfG0lhhacUG4BVe3CC6pxs/oRpkjbsZDGAwy2Kho9VL8EqVKv+bdPdGwG3xQ1POyFRiq7wqRzv9/K0 x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 9545aa21-f7b9-4d5d-49fb-08d75c0ec961 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:24:47.8116 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT115 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Francois Buergisser The setting of the motion vectors usage and the setting of motion vectors address are currently done under different conditions. When decoding pre-recorded videos, this results of leaving the motion vectors address unset, resulting in faulty memory accesses. Fix it by using the same condition everywhere, which matches the profiles that support motion vectors. Fixes: dea0a82f3d22 ("media: hantro: Add support for H264 decoding on G1") Signed-off-by: Francois Buergisser Signed-off-by: Ezequiel Garcia Signed-off-by: Jonas Karlman Reviewed-by: Boris Brezillon Tested-by: Boris Brezillon --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index 29130946dea4..a1cb18680200 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -35,7 +35,7 @@ static void set_params(struct hantro_ctx *ctx) if (sps->flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD) reg |= G1_REG_DEC_CTRL0_SEQ_MBAFF_E; reg |= G1_REG_DEC_CTRL0_PICORD_COUNT_E; - if (dec_param->nal_ref_idc) + if (sps->profile_idc > 66 && dec_param->nal_ref_idc) reg |= G1_REG_DEC_CTRL0_WRITE_MVS_E; if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY) && @@ -245,7 +245,7 @@ static void set_buffers(struct hantro_ctx *ctx) vdpu_write_relaxed(vpu, dst_dma, G1_REG_ADDR_DST); /* Higher profiles require DMV buffer appended to reference frames. */ - if (ctrls->sps->profile_idc > 66) { + if (ctrls->sps->profile_idc > 66 && ctrls->decode->nal_ref_idc) { size_t pic_size = ctx->h264_dec.pic_size; size_t mv_offset = round_up(pic_size, 8); From patchwork Tue Oct 29 01:24:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4F20139A for ; Tue, 29 Oct 2019 01:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEA9C21835 for ; Tue, 29 Oct 2019 01:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728662AbfJ2BZB convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:25:01 -0400 Received: from mail-oln040092064074.outbound.protection.outlook.com ([40.92.64.74]:7032 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728275AbfJ2BYw (ORCPT ); Mon, 28 Oct 2019 21:24:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oh3pGrsfwoLKzLw6R0R02TqUv8feNXZIcY9/egyxpmD5sbFIBG0TkEnPZZ/0EAXXavKS02XTDCyWa3fWFsy8Wu/MGLwpt5KSBt66YbJVcB8d66BqZrnTmt1gEHco4ojCJF/1xAY1hzkO+7cA5c/UDvl+TC64zM6sOm7nLB7s7JqSLiclXeDKLLh/T9aiySEqF5dUN7LXMwoGCR0EgXkP8W2D8h/omRgzsR1LEqSGIOxKaDmQ20qoP/pcDjwSN9qiHm05pNsIrYoMz8x8vpWwWQeTLtPASwhDM0jWwOxKUDA87gnOPNXc7FYG7YoX/0RIs5gadGK4OlHrEvVKvXvu+Q== 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-SenderADCheck; bh=mbdkoqxue9SdJx1tURxrk9ixGLHYdCMeZY0sSbKNWeE=; b=JUki1tvHgyGO8Bwmol16o0bXXG9mWhjiCwRIlIgTlx3rBMcIi40TM97CZnfSmDdCLX+Q+zV6kYgyWbA8XK0lXaUEJ/rYURI4nUXuaIMgT5D8hbMrAjXgRWnsKOYE+FCvCtQGkdAhwGQ7tzUFE4ScActCc3k5mizjAOiA4rbnYqaBOs4mboQ0qr26rvLlqIybZ/4jIBF84UiQO0Zv+PU+y4cU9iq7f91RRbM+56f3If1fsHQPHRsHnlaYMDVemxDhxvXyGudH1iSZic7tJDYUV91Qw2q2CL8LnkFqmErHLHeYVDlBvanjRQyNynf0RV+rOQxZKa4s+Tiqy5rI9m6jeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.60) by VE1EUR01HT223.eop-EUR01.prod.protection.outlook.com (10.152.3.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:24:49 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:24:48 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:24:48 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Francois Buergisser , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jonas Karlman Subject: [PATCH v2 03/10] media: hantro: Fix picture order count table enable Thread-Topic: [PATCH v2 03/10] media: hantro: Fix picture order count table enable Thread-Index: AQHVjfenW+QV7xN1iEKvDJAzBRe6dQ== Date: Tue, 29 Oct 2019 01:24:48 +0000 Message-ID: References: <20191029012430.24566-1-jonas@kwiboo.se> In-Reply-To: <20191029012430.24566-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0090.eurprd09.prod.outlook.com (2603:10a6:7:3d::34) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:A8EDAC8130853A12E0A455885BE22E70B93C42578BBD656B34E7F3E6588FB43A;UpperCasedChecksum:B406E0A90BB57025A2D11D8C2C35EE9CE132AA4162E818331F567F9D0A9C674B;SizeAsReceived:7662;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [g3fkyxEr0Fweu1dI25Or8bnhRokza/OS] x-microsoft-original-message-id: <20191029012430.24566-3-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT223: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 08Y7M+FKsyI7Fmhevi7siRIe4oaNmxgm1rQVhDQpzuyz05xY0ysaZP3iYmSO1JDJcEne1W25f6vAfyIqaVely/R7dclzGvTKwty9R2tCNVTA3Ldg7u5ZSQFitNzvJVGnM/oWaeG2+HO0ToGQiQWx64r5vBonvys9G3FJJ4rQEAzZ0HhZ1x12k+Duw/lhnsax x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 5a7ae417-87ce-4eb2-2b2f-08d75c0ec9d7 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:24:48.6371 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT223 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Francois Buergisser The picture order count table only makes sense for profiles higher than Baseline. This is confirmed by the H.264 specification (See 8.2.1 Decoding process for picture order count), which clarifies how POC are used for features not present in Baseline. """ Picture order counts are used to determine initial picture orderings for reference pictures in the decoding of B slices, to represent picture order differences between frames or fields for motion vector derivation in temporal direct mode, for implicit mode weighted prediction in B slices, and for decoder conformance checking. """ As a side note, this change matches various vendors downstream codebases, including ChromiumOS and IMX VPU libraries. Fixes: dea0a82f3d22 ("media: hantro: Add support for H264 decoding on G1") Signed-off-by: Francois Buergisser Signed-off-by: Ezequiel Garcia Signed-off-by: Jonas Karlman Reviewed-by: Boris Brezillon Tested-by: Boris Brezillon --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index a1cb18680200..70a6b5b26477 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -34,9 +34,11 @@ static void set_params(struct hantro_ctx *ctx) reg = G1_REG_DEC_CTRL0_DEC_AXI_WR_ID(0x0); if (sps->flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD) reg |= G1_REG_DEC_CTRL0_SEQ_MBAFF_E; - reg |= G1_REG_DEC_CTRL0_PICORD_COUNT_E; - if (sps->profile_idc > 66 && dec_param->nal_ref_idc) - reg |= G1_REG_DEC_CTRL0_WRITE_MVS_E; + if (sps->profile_idc > 66) { + reg |= G1_REG_DEC_CTRL0_PICORD_COUNT_E; + if (dec_param->nal_ref_idc) + reg |= G1_REG_DEC_CTRL0_WRITE_MVS_E; + } if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY) && (sps->flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD || From patchwork Tue Oct 29 01:24:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216877 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C1D414DB for ; Tue, 29 Oct 2019 01:25:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 695FA21924 for ; Tue, 29 Oct 2019 01:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728926AbfJ2BZd convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:25:33 -0400 Received: from mail-oln040092066061.outbound.protection.outlook.com ([40.92.66.61]:22016 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728363AbfJ2BZc (ORCPT ); Mon, 28 Oct 2019 21:25:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CCI4+9/3z6IkcALxCtmhdDTQJXvCaafms6ne/7eI3NybbjfWTXSELf2/MczbblEEQyO5V6hv3Opb00nCGO6jDxIoybECg08ZpBFxbD4W2DaVq08HT4fFtIGmEeLdCGkUuW5Ik9s/SlFWQ7JiAltbYG5P3mCwVbOobuk4vpFWMrxA+fnbbSS56SyjlmlXSc54bsi+CfJHdmgjAdXpr/N6YeL9rLI9hJwthScd6QXXEK1nuHXvdD5arQq4QtDG9aBzByY7H9Mv9/eO09Nyl+LSqPNTbbDkoNx6aBWuxdyBskxXcCibsRU1/ULQoa14tq+BzQBvzKulvthB10cWc9EzYQ== 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-SenderADCheck; bh=CjkXWgQoItBzowBktBSSrmBy4zZbONIpUEGe13cubQY=; b=QS9tthlGhSYNaDmpvnnc7J1dwywARd6/t/5T5M+xKV5o27RSkjDPBujfts3xSgeuzaloJA777gatf11oPdA+hsWZJLjDXv+XQtDuvc+eYvrbVpz1ZFebn1MnhkmPMQH/cGHwOYN3E7JT8JTbcxpWPZehxgtwceGhGvlvOLrjLIt1Rl7HqFl90GnDXjhw9IuUp/nhn3+mfhjVQZ2QA72tESnIswKd41c/do7f8XK9eY4We+kwBec9Jz4tu7pTwgqAPzcoOfnoktjUO33tULY5NEzabolsykpv3xqNBhyX5XJUDQzGe06vpzjsIIy3UuzZocN5GNoFdPTL7ldc6dEbAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.55) by VE1EUR01HT182.eop-EUR01.prod.protection.outlook.com (10.152.3.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:24:49 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:24:49 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:24:49 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 04/10] media: hantro: Fix H264 motion vector buffer offset Thread-Topic: [PATCH v2 04/10] media: hantro: Fix H264 motion vector buffer offset Thread-Index: AQHVjfeopTA6Bcvow0iTWFRfp5QfqA== Date: Tue, 29 Oct 2019 01:24:49 +0000 Message-ID: References: <20191029012430.24566-1-jonas@kwiboo.se> In-Reply-To: <20191029012430.24566-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0090.eurprd09.prod.outlook.com (2603:10a6:7:3d::34) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:D3B570380C971082EB1073675FF7FA740E873773E58A726EBF5DA27FB527E62F;UpperCasedChecksum:DDE70B0111C27B8206B3CB4758D5255F7C566BF2200E18AF8C4F9316EC590334;SizeAsReceived:7615;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [0XDZBUTqKt1RW3TidFtvX5MqCnYiTE99] x-microsoft-original-message-id: <20191029012430.24566-4-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT182: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KMg21dBCb1GKakxCG03MB3K8tcasC++aCeWZhK50zOe22hmF2YT4TqJ0BPiKr7PujBG1X+eDK3FwHNAzjCGRUVgL62MWw7raPovNlb4lzpvd0GkvrlZka5RAuzc1fZqM6pW3DxxIPGB2sQKUHfpCUWibl5Zp3KmOdh+OfbgPWantGVoT0AbNaDlgObiqrKPo x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: bf9cf040-c3db-4fef-50cd-08d75c0eca5a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:24:49.4066 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT182 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org A decoded 8-bit 4:2:0 frame need memory for up to 448 bytes per macroblock and is laid out in memory as follow: +---------------------------+ | Y-plane 256 bytes x MBs | +---------------------------+ | UV-plane 128 bytes x MBs | +---------------------------+ | MV buffer 64 bytes x MBs | +---------------------------+ The motion vector buffer offset is currently correct for 4:2:0 because the extra space for motion vectors is overallocated with an extra 64 bytes x MBs. Wrong offset for both destination and motion vector buffer are used for the bottom field of field encoded content, wrong offset is also used for 4:0:0 (monochrome) content. Fix this by setting the motion vector address to the expected 384 bytes x MBs offset for 4:2:0 and 256 bytes x MBs offset for 4:0:0 content. Also use correct destination and motion vector buffer offset for the bottom field of field encoded content. While at it also extend the check for 4:0:0 (monochrome) to include an additional check for High Profile (100). Fixes: dea0a82f3d22 ("media: hantro: Add support for H264 decoding on G1") Signed-off-by: Jonas Karlman Reviewed-by: Boris Brezillon --- Changes in v2: * address remarks from Philipp and Ezequiel - update commit message - rename offset to bytes_per_mb - remove MV_OFFSET macros - move PIC_MB_WIDTH/HEIGHT_P change to separate patch --- .../staging/media/hantro/hantro_g1_h264_dec.c | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index 70a6b5b26477..71bf162eaf73 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -81,7 +81,7 @@ static void set_params(struct hantro_ctx *ctx) reg |= G1_REG_DEC_CTRL4_CABAC_E; if (sps->flags & V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE) reg |= G1_REG_DEC_CTRL4_DIR_8X8_INFER_E; - if (sps->chroma_format_idc == 0) + if (sps->profile_idc >= 100 && sps->chroma_format_idc == 0) reg |= G1_REG_DEC_CTRL4_BLACKWHITE_E; if (pps->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED) reg |= G1_REG_DEC_CTRL4_WEIGHT_PRED_E; @@ -234,6 +234,7 @@ static void set_buffers(struct hantro_ctx *ctx) struct vb2_v4l2_buffer *src_buf, *dst_buf; struct hantro_dev *vpu = ctx->dev; dma_addr_t src_dma, dst_dma; + size_t offset = 0; src_buf = hantro_get_src_buf(ctx); dst_buf = hantro_get_dst_buf(ctx); @@ -244,18 +245,28 @@ static void set_buffers(struct hantro_ctx *ctx) /* Destination (decoded frame) buffer. */ dst_dma = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0); - vdpu_write_relaxed(vpu, dst_dma, G1_REG_ADDR_DST); + /* Adjust dma addr to start at second line for bottom field */ + if (ctrls->slices[0].flags & V4L2_H264_SLICE_FLAG_BOTTOM_FIELD) + offset = ALIGN(ctx->dst_fmt.width, MB_DIM); + vdpu_write_relaxed(vpu, dst_dma + offset, G1_REG_ADDR_DST); /* Higher profiles require DMV buffer appended to reference frames. */ if (ctrls->sps->profile_idc > 66 && ctrls->decode->nal_ref_idc) { - size_t pic_size = ctx->h264_dec.pic_size; - size_t mv_offset = round_up(pic_size, 8); - + unsigned int bytes_per_mb = 384; + /* DMV buffer for monochrome start directly after Y-plane */ + if (ctrls->sps->profile_idc >= 100 && + ctrls->sps->chroma_format_idc == 0) + bytes_per_mb = 256; + offset = bytes_per_mb * MB_WIDTH(ctx->dst_fmt.width) * + MB_HEIGHT(ctx->dst_fmt.height); + + /* DMV buffer is split in two for field encoded frames, + * adjust offset for bottom field + */ if (ctrls->slices[0].flags & V4L2_H264_SLICE_FLAG_BOTTOM_FIELD) - mv_offset += 32 * MB_WIDTH(ctx->dst_fmt.width); - - vdpu_write_relaxed(vpu, dst_dma + mv_offset, - G1_REG_ADDR_DIR_MV); + offset += 32 * MB_WIDTH(ctx->dst_fmt.width) * + MB_HEIGHT(ctx->dst_fmt.height); + vdpu_write_relaxed(vpu, dst_dma + offset, G1_REG_ADDR_DIR_MV); } /* Auxiliary buffer prepared in hantro_g1_h264_dec_prepare_table(). */ From patchwork Tue Oct 29 01:24:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2C7614DB for ; Tue, 29 Oct 2019 01:24:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E54C21D80 for ; Tue, 29 Oct 2019 01:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728551AbfJ2BYx convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:24:53 -0400 Received: from mail-oln040092066099.outbound.protection.outlook.com ([40.92.66.99]:32085 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728445AbfJ2BYx (ORCPT ); Mon, 28 Oct 2019 21:24:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=foDg+z3ACmPyZQCPSp6f68ox5bq6nonodXB8sD/IkA3HEzUrKfjNq+zp9bcV9k/BWyJiRnBZ34lL2FwU40AV+jtk1qldYPC17WioRkrfubj8OgJn0cUSbJmV0YCdTdDvFjInnyMnTkrKjvIil3ZEWDsYG4n8zUlEsDsGJd9L5HZehS/5i8TJ6sj5E5ovXdw3DalhEIMjGnjISDpHPHW/JJ163nDEGbGtwK3OFxx6Yq4Z071WE3fkMXD6qo6g4TUTn8H19MofxIl28cAwdRCqyO2EvmUvpPAmXu38FZMPPiOHpXgd/wps884xBcKLYpJy0zyPqU6Hg1P9uG8K2rHHrQ== 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-SenderADCheck; bh=XyXz7Yc9Hv1qOM3igLbfydxqYNhZoxCA4rytODrLUxo=; b=hwFGJ5W4e93lRPEq50pvOwpXDHl0Mk+GzWOf7/kNLUboHcjjzVHZ+HsLOOmqssyHTI0vIsdXUieHPE0iSgiDSR3PNF7Ysa13Bz0rDF0DGfDlvyg1xPDO95vloWo5ctK8gDdD3IFBH5EmW624mksMVF5lVjsSVNSsNS1mB98CzOpYxjnYOOvyiPqZfVifxsnBoskPR3nqQH3ZCrkeNMh14EK60rhlrm7lzf6wRl5vV4ueNeUzUKUH751mZqQiCpJJSmcuE7dBkmAZDSz0/P0sVjxH4G2bFojDZhOcB0LrH0BbGf9fkLyOe79daaN8IkD8Q4vq+/TeKzBEC76srbWASA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.53) by VE1EUR01HT139.eop-EUR01.prod.protection.outlook.com (10.152.3.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:24:50 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:24:50 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:24:50 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 05/10] media: hantro: Reduce H264 extra space for motion vectors Thread-Topic: [PATCH v2 05/10] media: hantro: Reduce H264 extra space for motion vectors Thread-Index: AQHVjfeo82yZ/o1JSUKXch8trRudlg== Date: Tue, 29 Oct 2019 01:24:50 +0000 Message-ID: References: <20191029012430.24566-1-jonas@kwiboo.se> In-Reply-To: <20191029012430.24566-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0090.eurprd09.prod.outlook.com (2603:10a6:7:3d::34) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:A47A365794BAB41714C3A544477806C33515EC5B456862A11A8C6B1084E7AD17;UpperCasedChecksum:2608D3E58CDA59C206FD4A05819EECE95D372DDC48620A78E867D595CDEE02F4;SizeAsReceived:7647;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [YnRDKRoe9ImjT5DU6PZRPyKiBR9En3Gl] x-microsoft-original-message-id: <20191029012430.24566-5-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT139: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gyX33lnAAr6Yjw+C6isqyL9Zw1+9Y4LIkpJMzAWOOc6jyt6OISgd/xIa9rYOol2msgWE2pDjgASXEGyCMPK6/W9l0oZvelAIu5huBG+KstHFiuUYtQST7+ZvBxmlKrlzpJXx5aR351eKNJQapnzKDNcLjm8zhw5ZhJBEzC7C96bd6Wvc+1/BRRenW9D4J7LF x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: a100ff32-346b-4a92-59d3-08d75c0ecac7 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:24:50.1661 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT139 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org A decoded 8-bit 4:2:0 frame need memory for up to 448 bytes per macroblock with additional 32 bytes on multi-core variants. Memory layout is as follow: +---------------------------+ | Y-plane 256 bytes x MBs | +---------------------------+ | UV-plane 128 bytes x MBs | +---------------------------+ | MV buffer 64 bytes x MBs | +---------------------------+ | MC sync 32 bytes | +---------------------------+ Reduce the extra space allocated now that motion vector buffer offset no longer is based on the extra space. Only allocate extra space for 64 bytes x MBs of motion vector buffer and 32 bytes for multi-core sync. Fixes: a9471e25629b ("media: hantro: Add core bits to support H264 decoding") Signed-off-by: Jonas Karlman Reviewed-by: Boris Brezillon --- Changes in v2: - updated commit message --- drivers/staging/media/hantro/hantro_v4l2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c index 3dae52abb96c..b3a4368b37de 100644 --- a/drivers/staging/media/hantro/hantro_v4l2.c +++ b/drivers/staging/media/hantro/hantro_v4l2.c @@ -242,12 +242,12 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f, /* * The H264 decoder needs extra space on the output buffers * to store motion vectors. This is needed for reference - * frames. + * frames. 32 extra bytes is used for multi-core sync. */ if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_H264_SLICE) pix_mp->plane_fmt[0].sizeimage += - 128 * DIV_ROUND_UP(pix_mp->width, 16) * - DIV_ROUND_UP(pix_mp->height, 16); + 64 * MB_WIDTH(pix_mp->width) * + MB_WIDTH(pix_mp->height) + 32; } else if (!pix_mp->plane_fmt[0].sizeimage) { /* * For coded formats the application can specify From patchwork Tue Oct 29 01:24:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 521EA14DB for ; Tue, 29 Oct 2019 01:25:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DF08218AC for ; Tue, 29 Oct 2019 01:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728581AbfJ2BYz convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:24:55 -0400 Received: from mail-oln040092064015.outbound.protection.outlook.com ([40.92.64.15]:56782 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728523AbfJ2BYy (ORCPT ); Mon, 28 Oct 2019 21:24:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HwYWMTpavPJLAs26IMwPHzjSN1eU9XqP8T2UblmskOnVdxEdeYpI1jAB9AuZ8vT9rmrJ/P/1L1uC7xxIpYa9EM7bM+JSsfNIYFyrHvuDkoMxVjHb3fADNT3WwjpOLXGWu41hqTCLc+nDxQ6ZPSAe9oJ63Tc+92qAq2H0qQuyMNTcyqMlBhOJMR4dXYkkBvjZ+diLpC8YRV5ga9S3qTb6XiJ3HQU8vt7U3knwfqJy5T4j7LokdXHFSdKqpmGJ/MERfcB37aRaVmYkIqLDQKgIjersmukRz5uwWW+m8904pejSnFvFUoWVtLa7AoZpkgmZpCXx8FYKg9aERhtFS9dtKg== 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-SenderADCheck; bh=bNtrZ6vGbJE0ObaYJ1TCXSY1JfUNEiTWQpJIa5L7DTg=; b=c6ec2MU3DVsofFpYoZsTbmRpquU1GaHsDZcM2IqbvaqDmG/ZiugkKmxvCmU5g1Pf2L0LxGmB98qhKQpFVYEFBQQ64yztToJ+LOmXfLv66rnega5J9Iu+53uzbS3/BKXrJFYhMf18K7FQmzGDRKsrj7+9t1MIZXPbcOj4/RFVwBKk+O/muLrdItHUu+OK6fuwsqCFGmNyoKr+CqV3+gEC0w0fs5zuHajciqxp9d3WY1PItglWGr2Khi7iVltmAOhcfOuER29hGerZfVGPn+FD6FYk/PuZPc1YwPozMUS3SX8/FbaUUr/hp5J4z9kqj6yHxIQPD0A/F8d/jCyqn2tIXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.52) by VE1EUR01HT233.eop-EUR01.prod.protection.outlook.com (10.152.3.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:24:51 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:24:51 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:24:51 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 06/10] media: hantro: Use capture buffer width and height for H264 decoding Thread-Topic: [PATCH v2 06/10] media: hantro: Use capture buffer width and height for H264 decoding Thread-Index: AQHVjfeo82jSI9YHWUmKxjQOPPg3vA== Date: Tue, 29 Oct 2019 01:24:50 +0000 Message-ID: References: <20191029012430.24566-1-jonas@kwiboo.se> In-Reply-To: <20191029012430.24566-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0090.eurprd09.prod.outlook.com (2603:10a6:7:3d::34) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:6AE5A82A38F502B304B0D880C8C952D97A55CE5A850562E50F39267229963BF5;UpperCasedChecksum:8C667928A0E4582A42556D31631541D59224DA590EAEE6752BEBC21BD9E4F907;SizeAsReceived:7669;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [gGim5ZXdx0JrTTBQtcpEMpeofKhUFehS] x-microsoft-original-message-id: <20191029012430.24566-6-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT233: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 78uxsjHeZbfyP6b9FAVrA/uS9Woid0VBvu66jDqwaNQ4oyIr9ZKo0K8PDko2zeamSkvbZpBUJQtik5PGQ0L1cVjpYzlMFG9NHA/w2vSsYDrwoLnipLHfYA/Xi/p8XGO7/XgDSrFzkxzW3BjBavbGFdgEEK64eMEyrStu8tlstkCNnXF4BqBlxaIgGCcKbWnA x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: c880f473-f168-4298-ced7-08d75c0ecb38 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:24:50.8637 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT233 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Calculations for motion vector buffer offset is based on width and height from the configured capture format, lets use the same values for macroblock width and height hw regs. Fixes: dea0a82f3d22 ("media: hantro: Add support for H264 decoding on G1") Signed-off-by: Jonas Karlman --- Changes in v2: - new patch split from "media: hantro: Fix H264 motion vector buffer offset" --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index 71bf162eaf73..eeed11366135 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -51,8 +51,8 @@ static void set_params(struct hantro_ctx *ctx) vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL0); /* Decoder control register 1. */ - reg = G1_REG_DEC_CTRL1_PIC_MB_WIDTH(sps->pic_width_in_mbs_minus1 + 1) | - G1_REG_DEC_CTRL1_PIC_MB_HEIGHT_P(sps->pic_height_in_map_units_minus1 + 1) | + reg = G1_REG_DEC_CTRL1_PIC_MB_WIDTH(MB_WIDTH(ctx->dst_fmt.width)) | + G1_REG_DEC_CTRL1_PIC_MB_HEIGHT_P(MB_HEIGHT(ctx->dst_fmt.height)) | G1_REG_DEC_CTRL1_REF_FRAMES(sps->max_num_ref_frames); vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL1); From patchwork Tue Oct 29 01:24:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216875 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08329139A for ; Tue, 29 Oct 2019 01:25:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8D4B218BA for ; Tue, 29 Oct 2019 01:25:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728845AbfJ2BZ1 convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:25:27 -0400 Received: from mail-oln040092066048.outbound.protection.outlook.com ([40.92.66.48]:1507 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728754AbfJ2BZ1 (ORCPT ); Mon, 28 Oct 2019 21:25:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cfgWIjlvzt6bg+FSZq+/mUddgeOSEjIrDzTa3nSV1S5sghGEGoPJh5pqMuPBQbKfamG+fwIwDERUl0X1LXoNLZrxtFA81YIgc3WhMin0DIXHEDtThv/HLys7frjoOAN++GhtDOx8TM5Hej5e0+xQg3wpQE4fm8dWDCn6KzyayyVz+QYnvEjvvlnKpV5GZ35Fx7XeRlWjueyBfftpbnIzBQRhg7i37YFouXOFrnNKz6Wcz4eGQf+CyTtyIt952lKq2eAdzx+5uTsepTU+SdowgMpOOs2FrOyjhpNEuaCnGkd04y7mmZeFnToF/7mFaXw2hCEeGXDkDGGVdCpufjMFtw== 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-SenderADCheck; bh=ZWLA17RhTy/P12QWhXV/uUeryxHKqnl0eWMaGIQpmRo=; b=IqQHwSqd88prj5TGFubSeCFvNX5JBvKksTJUMpKhESrgLoFlyGFL+bKikiWEtux/ExrBO11IoH/fsYNny9YfBNA9eGdK7Zy5PwjEwVj8Fr5aFghFpJYahJgJ+qNUa/mCbrt307GOpnA0kyUgfVBgXS2Fk80J9g0Dpw0Syn/7czy+X+hZtviOSCEQtt6pTeBCbeE6mLufNHNAToX8obj3htMKoq6i5cbb9bd1YJdL7HgkPn1eqshyTRhrKbUmIlSd3b/1Xg9TNpj6AktRItA9B6tm2QQrpDMikjiVmAReIK6y5WLvSYyarmRQtVFUt/Xtk0A+KhLQvq+nd817m9BTGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.55) by VE1EUR01HT182.eop-EUR01.prod.protection.outlook.com (10.152.3.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:24:51 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:24:51 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:24:51 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 07/10] media: hantro: Remove now unused H264 pic_size Thread-Topic: [PATCH v2 07/10] media: hantro: Remove now unused H264 pic_size Thread-Index: AQHVjfepVNzXvr4wxEChzENhNjxOww== Date: Tue, 29 Oct 2019 01:24:51 +0000 Message-ID: References: <20191029012430.24566-1-jonas@kwiboo.se> In-Reply-To: <20191029012430.24566-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0090.eurprd09.prod.outlook.com (2603:10a6:7:3d::34) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:DA2863AF379F9D4AC40C3B3D740CD38C289EA01DAAAA39200AD3BDE89C895BC5;UpperCasedChecksum:D54D73927F7BE65D119DCC12801521C0C0A62EB3F909A56BF22BDF47BDC7D2A9;SizeAsReceived:7620;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [/1ht+c4wAinBGu7RZ8ipog7S040cACHf] x-microsoft-original-message-id: <20191029012430.24566-7-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT182: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: N9Bb1jj9HaBi0RVe4ZeDxonXOSs6nopA58mr/CpG72pHR2a7mhlJAx2ROMs0b/jVoknUbMUOzCwrQyFKnVw/vXY22PT2mSIw6fnQM7IogPQMd04GxS1iWt68M7h6Jy1TO/a/Ucvhg8VXku0OovBSlkPmrQIZTN4prGp2a6D6orNUpsgsUSM1Yi/JciGJqIuW x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: bad8c7ea-194b-493c-77bc-08d75c0ecbad X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:24:51.7002 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT182 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org pic_size in hantro_h264_dec_hw_ctx struct is no longer used, lets remove it. Signed-off-by: Jonas Karlman Reviewed-by: Boris Brezillon --- drivers/staging/media/hantro/hantro_h264.c | 5 ----- drivers/staging/media/hantro/hantro_hw.h | 3 --- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_h264.c b/drivers/staging/media/hantro/hantro_h264.c index 694a330f508e..568640eab3a6 100644 --- a/drivers/staging/media/hantro/hantro_h264.c +++ b/drivers/staging/media/hantro/hantro_h264.c @@ -618,7 +618,6 @@ int hantro_h264_dec_init(struct hantro_ctx *ctx) struct hantro_h264_dec_hw_ctx *h264_dec = &ctx->h264_dec; struct hantro_aux_buf *priv = &h264_dec->priv; struct hantro_h264_dec_priv_tbl *tbl; - struct v4l2_pix_format_mplane pix_mp; priv->cpu = dma_alloc_coherent(vpu->dev, sizeof(*tbl), &priv->dma, GFP_KERNEL); @@ -629,9 +628,5 @@ int hantro_h264_dec_init(struct hantro_ctx *ctx) tbl = priv->cpu; memcpy(tbl->cabac_table, h264_cabac_table, sizeof(tbl->cabac_table)); - v4l2_fill_pixfmt_mp(&pix_mp, ctx->dst_fmt.pixelformat, - ctx->dst_fmt.width, ctx->dst_fmt.height); - h264_dec->pic_size = pix_mp.plane_fmt[0].sizeimage; - return 0; } diff --git a/drivers/staging/media/hantro/hantro_hw.h b/drivers/staging/media/hantro/hantro_hw.h index 69b88f4d3fb3..fa91dd1848b7 100644 --- a/drivers/staging/media/hantro/hantro_hw.h +++ b/drivers/staging/media/hantro/hantro_hw.h @@ -80,15 +80,12 @@ struct hantro_h264_dec_reflists { * @dpb: DPB * @reflists: P/B0/B1 reflists * @ctrls: V4L2 controls attached to a run - * @pic_size: Size in bytes of decoded picture, this is needed - * to pass the location of motion vectors. */ struct hantro_h264_dec_hw_ctx { struct hantro_aux_buf priv; struct v4l2_h264_dpb_entry dpb[HANTRO_H264_DPB_SIZE]; struct hantro_h264_dec_reflists reflists; struct hantro_h264_dec_ctrls ctrls; - size_t pic_size; }; /** From patchwork Tue Oct 29 01:26:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216883 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E632E14DB for ; Tue, 29 Oct 2019 01:26:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDABA218BA for ; Tue, 29 Oct 2019 01:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728998AbfJ2B0D convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:26:03 -0400 Received: from mail-oln040092066055.outbound.protection.outlook.com ([40.92.66.55]:3138 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728978AbfJ2B0D (ORCPT ); Mon, 28 Oct 2019 21:26:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F7MXrH4qGIzMzoZTinbu+ITxc6Zyf/HZO3PrqUPb3BZzmA7GuPMmOfJ5/zJjSSM6xTILWXHxBXstDPKYi+4ooNDaV8iRYdwH1YbQDspt0plzp2T8igLkxPUZSCdgjlD2KLCnwW38wj63t+ruJz7ReG+9MngAndsoCQ8iZiamDrpAfFkxHneR6UQoWJ3JFaMK4po0T8vEi7C9UelomwO+6Sxa8/ybd4S0hnAenRbXpZ8UqBFyId4TqegXNaSCmvbp3NutcZuzfDs0zPDmpkG7/ILd/jPcOk5+Mg+SDt2NSyh8tnhfdS5Z/UdYWAUzizWXIGfDbnZQgB7fyrBkq0Ba9w== 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-SenderADCheck; bh=fUXWKGJjsKsF53zm9MGKy1D9n1aFly1AT9vrIQSgEvc=; b=EJsT+cHwtez19zPO5SDiVgV0YdSroLp/w7mxiKWR+ggV4TBFlKmtF4NQyu9uP2pS7UngQ4hGY0wwiUAboEqCjzSkl6/nd3CFCGMebH4LZODZDdzkEkLEgLYZegHWdqLGzMZFsruBgF5rILcR0cfTjENE5RyzCBwfoKIOWrT3Co4B4/9xqLoSPhfafo3qnQt69y/X19QhEuGru00GLwJ6+r3lykaLNoZenZo0gHbn/Cz1uLd1/Eje08ITednqm/gQ1LufavD1861RyVz2dDakFE8yhIf2q/1x1MJcm1N0zHIsQPzCGUElNdGhm+rYt66mcdvUzRv9dZNk6CfPLySx5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.60) by VE1EUR01HT188.eop-EUR01.prod.protection.outlook.com (10.152.3.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:26:00 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:26:00 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:26:00 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 08/10] media: hantro: Set H264 FIELDPIC_FLAG_E flag correctly Thread-Topic: [PATCH v2 08/10] media: hantro: Set H264 FIELDPIC_FLAG_E flag correctly Thread-Index: AQHVjffSvhTEZV4MtESzVZoKJ6SaYw== Date: Tue, 29 Oct 2019 01:26:00 +0000 Message-ID: References: In-Reply-To: Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0354.eurprd05.prod.outlook.com (2603:10a6:7:92::49) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:71609C14098BAD96D2C40504CBA11777430D3F58488070B2D133B90DF3C9E5C3;UpperCasedChecksum:2EEEC8F3F3969A35FC7792BF040722842D4D7774F87AB4D6F618D21B7C95FB72;SizeAsReceived:7614;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [YQd7JpoAtTmp6k7A6sfIt2aYZjgbHAyf] x-microsoft-original-message-id: <20191029012550.24628-1-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT188: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sJSlAQLo0ftQwHpiZM3IaeF6OdnlA343JREWLW2Xba06QlCLYgfTlFu2OMug8PD/jmdXOnuzSUthJX8J3EDGZdb6q3MHneqEGot7Ox/XWDI8CSEnV7LMbE00EQ/eg2fRKbn+rwRSyv9KV/zqrr82ilqUzdSLHwDzMEvXhfbqlJVvBd9co0r2XpAx4KcDTHhA x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 0abe0bde-b04d-44f0-2a9a-08d75c0ef4ce X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:26:00.5942 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT188 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The FIELDPIC_FLAG_E bit should be set when field_pic_flag exists in stream, it is currently set based on field_pic_flag of current frame. The PIC_FIELDMODE_E bit is correctly set based on the field_pic_flag. Fix this by setting the FIELDPIC_FLAG_E bit when frame_mbs_only is not set. Fixes: dea0a82f3d22 ("media: hantro: Add support for H264 decoding on G1") Signed-off-by: Jonas Karlman Reviewed-by: Boris Brezillon --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index eeed11366135..c07da0ee4973 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -63,7 +63,7 @@ static void set_params(struct hantro_ctx *ctx) /* always use the matrix sent from userspace */ reg |= G1_REG_DEC_CTRL2_TYPE1_QUANT_E; - if (slices[0].flags & V4L2_H264_SLICE_FLAG_FIELD_PIC) + if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY)) reg |= G1_REG_DEC_CTRL2_FIELDPIC_FLAG_E; vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL2); From patchwork Tue Oct 29 01:26:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216881 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADA0414DB for ; Tue, 29 Oct 2019 01:26:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94AE4218BA for ; Tue, 29 Oct 2019 01:26:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729066AbfJ2B0F convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:26:05 -0400 Received: from mail-oln040092064077.outbound.protection.outlook.com ([40.92.64.77]:42990 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728979AbfJ2B0F (ORCPT ); Mon, 28 Oct 2019 21:26:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AqbOzpH1h+PvhGKeFvprSpjkxqQP6DWWEoYfW4aI4F6MSc7odprOz0Ng9+V66XZoQiPCCqDbNVkMPCEvjbHk7Lg6PFGrG3dwZjbmnRMfwDo7y0I9AKGdL8pzmuknHWu651sEBgP+9cURj2o7ZdfpfXf/4tA62eSJeu9wW12yK9yQscFwVFJE0Imkf0tYyqzxrn9YKyBnh7L8bdQrjRsM8LlCFMQgnFHTLO7jpXP5V55/WXHgb+WnMFIKtNObUXHJckoVmFO+bsH+xL1Zal1baynGbyIJDjr4JsbOC7r01n/p/zclt5qhcLx4jKXxGRvoKeXRt+jsUIkn2FgOBg/T/Q== 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-SenderADCheck; bh=hHGX8RgeauXbve47lWHiyQG8got3fHNXmgVNxQYCx1g=; b=Ojpu3C5Mm4mn6kf5JBx1U2LhH+MnrCbn5R1nDe0oDGePLGoofrBj1biD+M0A9nRCIbFB1VtUkTHN2JEEHvMlmOS7x6YzfwqPYWZ8QlyQgiHMVXdP0s0nCrwh6hSknAEhus8zmZBy2c0M1rIFy9XKjj5ZLF5iLx0lbMVSgH/MamwWcua1MB5EcxlC4xemfzUTk1mfzlClHoGDnNOAuq5hlPEYSgl0Kuh5u9Wu5YH3NeKZaEv12c+BI8nFT5pof1t0dl3h1wTHRyl3C2kzGtpXB+STJvTtf8RcsPKdXukjC3+TOcsFybWNcS4xBN6pd6W6ni7nS9Rvrhub9zzkaAWyaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.54) by VE1EUR01HT021.eop-EUR01.prod.protection.outlook.com (10.152.2.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:26:01 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:26:01 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:26:01 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [RFC v2 09/10] media: uapi: h264: Add DPB entry field reference flags Thread-Topic: [RFC v2 09/10] media: uapi: h264: Add DPB entry field reference flags Thread-Index: AQHVjffSYHfHedHWTUmVsr71xfoXjw== Date: Tue, 29 Oct 2019 01:26:01 +0000 Message-ID: References: <20191029012550.24628-1-jonas@kwiboo.se> In-Reply-To: <20191029012550.24628-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0354.eurprd05.prod.outlook.com (2603:10a6:7:92::49) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:0A53B216CA40B2ABDA9206D7CE1F8A4EAAE1059BB37C4B90FAA2E88DE3BAAEC9;UpperCasedChecksum:31A878709745E1D56F1D1D0B717C400512AF1A1B455C357C9EFE871A159496DA;SizeAsReceived:7617;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [qMxT/Iz+QnvHfnBGgYNpXhLidTmhNWAi] x-microsoft-original-message-id: <20191029012550.24628-2-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT021: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xT/aiPdMRcFaKdW42HlFCdXOl4PLbX2q/RJdbW+lv55N51w2h7mAqz6mNRk/4zv5fqBwhxS41Nf8aEGglj2U29rf7WsuGFICx61+AeGzoVplGuxCxEuWySgnGYjeSZMAkv6KLsLEzuSDJlcaojJa9IHZaBbW2Ws/NxSgNRuYvshBnjY+HmzN6pJPhlqQDtk8 x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 0a59a0c7-bd84-46bd-e5a9-08d75c0ef53a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:26:01.3577 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT021 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add DPB entry flags to help indicate when a reference frame is a field picture and how the DPB entry is referenced, top or bottom field or full frame. Signed-off-by: Jonas Karlman --- Documentation/media/uapi/v4l/ext-ctrls-codec.rst | 12 ++++++++++++ include/media/h264-ctrls.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst index 28313c0f4e7c..d472a54d1c4d 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst @@ -2028,6 +2028,18 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - ``V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM`` - 0x00000004 - The DPB entry is a long term reference frame + * - ``V4L2_H264_DPB_ENTRY_FLAG_FIELD_PICTURE`` + - 0x00000008 + - The DPB entry is a field picture + * - ``V4L2_H264_DPB_ENTRY_FLAG_REF_TOP`` + - 0x00000010 + - The DPB entry is a top field reference + * - ``V4L2_H264_DPB_ENTRY_FLAG_REF_BOTTOM`` + - 0x00000020 + - The DPB entry is a bottom field reference + * - ``V4L2_H264_DPB_ENTRY_FLAG_REF_FRAME`` + - 0x00000030 + - The DPB entry is a reference frame ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (enum)`` Specifies the decoding mode to use. Currently exposes slice-based and diff --git a/include/media/h264-ctrls.h b/include/media/h264-ctrls.h index e877bf1d537c..76020ebd1e6c 100644 --- a/include/media/h264-ctrls.h +++ b/include/media/h264-ctrls.h @@ -185,6 +185,10 @@ struct v4l2_ctrl_h264_slice_params { #define V4L2_H264_DPB_ENTRY_FLAG_VALID 0x01 #define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x02 #define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x04 +#define V4L2_H264_DPB_ENTRY_FLAG_FIELD_PICTURE 0x08 +#define V4L2_H264_DPB_ENTRY_FLAG_REF_TOP 0x10 +#define V4L2_H264_DPB_ENTRY_FLAG_REF_BOTTOM 0x20 +#define V4L2_H264_DPB_ENTRY_FLAG_REF_FRAME 0x30 struct v4l2_h264_dpb_entry { __u64 reference_ts; From patchwork Tue Oct 29 01:26:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11216879 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1839139A for ; Tue, 29 Oct 2019 01:26:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C384E217D6 for ; Tue, 29 Oct 2019 01:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbfJ2B0H convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 21:26:07 -0400 Received: from mail-oln040092065061.outbound.protection.outlook.com ([40.92.65.61]:55188 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728978AbfJ2B0G (ORCPT ); Mon, 28 Oct 2019 21:26:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QWiZ4L67ZWZEqOGrr4CyFuvGMpOhzgpIBWHhiqiEtLBRotqH/TZ13mMwteUc05diR5e+P1B0/P0M7q5Ss3Xs9nxOlMNkqPeJFD0/Ne1z3ydiYBcWOHuMsZ2La4/JjdeK2m4JF7OvsKz+GJ3XhwbX6/yGKOftCEnby0NkcM2bf/Rj+34+W6hd+DHQpkmjG6qrEXfH2gxtRQMU2GuPiHJg5y2BZGjdP7rKjNFYrn+itJ+XyGcXFDJQ0nZRx+rNmhxrpfe+WdUmCwCjapaN16JopSYYbXgYz8sgR5ApV9dSt41JDaFrxzpgk4rKlpMV8TM7riNaJ4vTtlFpJr5QSz2nZQ== 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-SenderADCheck; bh=bxbZ3ALB6XSQRDMVTMLhwOnOL8gY0mN4M/4AmMlNX3o=; b=Can4yOtJ7VHHZ9BtNmcjuSSmlHhbIbxY7yplZzkdJmB1U+e6FptuMDrkHpotwd8+dvzTgnlhSQsnYATPvUIUf1a6GbwdkLaurZfYVpqpr/7UNS5qT27iwMJFx9P3sVJV8P19Z8c3YBei8tvPtr1i4+dYe+HrlvsXjHr+bA5wS03CpPFA+yDeylb4b2kLWn1XDox74QqV5ZfoaJ8j+gDvp+ljslC+P/g3bloOOacfxSqMogyVcyCsyPEmxy/7X73jNMgI+5Uh/T5peShFfLEMipdG7443TE1figmGQrqc4V8GWawDSSKLC43xTuwMNF81ZOGQg9upncWIncnJp9l0vA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.52) by VE1EUR01HT223.eop-EUR01.prod.protection.outlook.com (10.152.3.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20; Tue, 29 Oct 2019 01:26:02 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 29 Oct 2019 01:26:02 +0000 Received: from HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc]) by HE1PR06MB4011.eurprd06.prod.outlook.com ([fe80::b1cf:db6f:95fc:84cc%7]) with mapi id 15.20.2387.025; Tue, 29 Oct 2019 01:26:02 +0000 From: Jonas Karlman To: Mauro Carvalho Chehab , Ezequiel Garcia CC: Jonas Karlman , Hans Verkuil , Boris Brezillon , Tomasz Figa , Philipp Zabel , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [RFC v2 10/10] media: hantro: Fix H264 decoding of field encoded content Thread-Topic: [RFC v2 10/10] media: hantro: Fix H264 decoding of field encoded content Thread-Index: AQHVjffTgp3yNElHpkStsNrm+cNs7Q== Date: Tue, 29 Oct 2019 01:26:02 +0000 Message-ID: References: <20191029012550.24628-1-jonas@kwiboo.se> In-Reply-To: <20191029012550.24628-1-jonas@kwiboo.se> Accept-Language: sv-SE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0354.eurprd05.prod.outlook.com (2603:10a6:7:92::49) To HE1PR06MB4011.eurprd06.prod.outlook.com (2603:10a6:7:9c::32) x-incomingtopheadermarker: OriginalChecksum:02C86AD3AF424C2433DF39F015C46E1717665A7ADACEA896458EA2671C0A6EDA;UpperCasedChecksum:A7F8A7684B0B1AE1F4A59E16CFE0731849643AE45FE16773CEB3CF4868F8EE93;SizeAsReceived:7627;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-tmn: [NonxHB7goTnKZ42HtPA33t72KEnb2tp+] x-microsoft-original-message-id: <20191029012550.24628-3-jonas@kwiboo.se> x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR01HT223: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +7xOJsr29HMiP8jZE9b/boFOKG2L3R9G9ZtCTRL1rinreY4ZpyGPIVIk2d4uhHD9HhLXsGfam9Rw9NrBzf7p44tVzxIhIliaERREeiJOOL0O9JxMNftoBywBKojqjfIlS4j0dMENze4Z0aBvKB7sj0iwgJ8y6DDZg2e7tKQMO9ZIGHYinyNlmvsz+P8768Do x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: f49aa186-9339-4fa6-752e-08d75c0ef5a9 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2019 01:26:02.1123 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT223 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This still need code cleanup and formatting Signed-off-by: Jonas Karlman --- .../staging/media/hantro/hantro_g1_h264_dec.c | 17 +-- drivers/staging/media/hantro/hantro_h264.c | 121 ++++++++++++------ drivers/staging/media/hantro/hantro_hw.h | 2 + 3 files changed, 85 insertions(+), 55 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index c07da0ee4973..473d7a0d7338 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -132,25 +132,12 @@ static void set_ref(struct hantro_ctx *ctx) struct v4l2_h264_dpb_entry *dpb = ctx->h264_dec.dpb; const u8 *b0_reflist, *b1_reflist, *p_reflist; struct hantro_dev *vpu = ctx->dev; - u32 dpb_longterm = 0; - u32 dpb_valid = 0; int reg_num; u32 reg; int i; - /* - * Set up bit maps of valid and long term DPBs. - * NOTE: The bits are reversed, i.e. MSb is DPB 0. - */ - for (i = 0; i < HANTRO_H264_DPB_SIZE; ++i) { - if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) - dpb_valid |= BIT(HANTRO_H264_DPB_SIZE - 1 - i); - - if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) - dpb_longterm |= BIT(HANTRO_H264_DPB_SIZE - 1 - i); - } - vdpu_write_relaxed(vpu, dpb_valid << 16, G1_REG_VALID_REF); - vdpu_write_relaxed(vpu, dpb_longterm << 16, G1_REG_LT_REF); + vdpu_write_relaxed(vpu, ctx->h264_dec.dpb_valid, G1_REG_VALID_REF); + vdpu_write_relaxed(vpu, ctx->h264_dec.dpb_longterm, G1_REG_LT_REF); /* * Set up reference frame picture numbers. diff --git a/drivers/staging/media/hantro/hantro_h264.c b/drivers/staging/media/hantro/hantro_h264.c index 568640eab3a6..a405d0f5a0a1 100644 --- a/drivers/staging/media/hantro/hantro_h264.c +++ b/drivers/staging/media/hantro/hantro_h264.c @@ -225,17 +225,65 @@ static void prepare_table(struct hantro_ctx *ctx) { const struct hantro_h264_dec_ctrls *ctrls = &ctx->h264_dec.ctrls; const struct v4l2_ctrl_h264_decode_params *dec_param = ctrls->decode; + const struct v4l2_ctrl_h264_slice_params *slices = ctrls->slices; struct hantro_h264_dec_priv_tbl *tbl = ctx->h264_dec.priv.cpu; const struct v4l2_h264_dpb_entry *dpb = ctx->h264_dec.dpb; + u32 dpb_longterm = 0; + u32 dpb_valid = 0; int i; + /* + * Set up bit maps of valid and long term DPBs. + * NOTE: The bits are reversed, i.e. MSb is DPB 0. + */ + if ((slices[0].flags & V4L2_H264_SLICE_FLAG_FIELD_PIC) || (slices[0].flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD)) { + for (i = 0; i < HANTRO_H264_DPB_SIZE * 2; ++i) { + // check for correct reference use + u32 flag = (i & 0x1) ? V4L2_H264_DPB_ENTRY_FLAG_REF_BOTTOM : V4L2_H264_DPB_ENTRY_FLAG_REF_TOP; + if (dpb[i / 2].flags & flag) + dpb_valid |= BIT(HANTRO_H264_DPB_SIZE * 2 - 1 - i); + + if (dpb[i / 2].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) + dpb_longterm |= BIT(HANTRO_H264_DPB_SIZE * 2 - 1 - i); + } + + ctx->h264_dec.dpb_valid = dpb_valid; + ctx->h264_dec.dpb_longterm = dpb_longterm; + } else { + for (i = 0; i < HANTRO_H264_DPB_SIZE; ++i) { + if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) + dpb_valid |= BIT(HANTRO_H264_DPB_SIZE - 1 - i); + + if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) + dpb_longterm |= BIT(HANTRO_H264_DPB_SIZE - 1 - i); + } + + ctx->h264_dec.dpb_valid = dpb_valid << 16; + ctx->h264_dec.dpb_longterm = dpb_longterm << 16; + } + for (i = 0; i < HANTRO_H264_DPB_SIZE; ++i) { - tbl->poc[i * 2] = dpb[i].top_field_order_cnt; - tbl->poc[i * 2 + 1] = dpb[i].bottom_field_order_cnt; + if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) { + tbl->poc[i * 2] = dpb[i].top_field_order_cnt; + tbl->poc[i * 2 + 1] = dpb[i].bottom_field_order_cnt; + } else { + tbl->poc[i * 2] = 0; + tbl->poc[i * 2 + 1] = 0; + } } - tbl->poc[32] = dec_param->top_field_order_cnt; - tbl->poc[33] = dec_param->bottom_field_order_cnt; + if ((slices[0].flags & V4L2_H264_SLICE_FLAG_FIELD_PIC) || !(slices[0].flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD)) { + if ((slices[0].flags & V4L2_H264_SLICE_FLAG_FIELD_PIC)) + tbl->poc[32] = (slices[0].flags & V4L2_H264_SLICE_FLAG_BOTTOM_FIELD) ? + dec_param->bottom_field_order_cnt : + dec_param->top_field_order_cnt; + else + tbl->poc[32] = min(dec_param->top_field_order_cnt, dec_param->bottom_field_order_cnt); + tbl->poc[33] = 0; + } else { + tbl->poc[32] = dec_param->top_field_order_cnt; + tbl->poc[33] = dec_param->bottom_field_order_cnt; + } reorder_scaling_list(ctx); } @@ -249,21 +297,6 @@ struct hantro_h264_reflist_builder { u8 num_valid; }; -static s32 get_poc(enum v4l2_field field, s32 top_field_order_cnt, - s32 bottom_field_order_cnt) -{ - switch (field) { - case V4L2_FIELD_TOP: - return top_field_order_cnt; - case V4L2_FIELD_BOTTOM: - return bottom_field_order_cnt; - default: - break; - } - - return min(top_field_order_cnt, bottom_field_order_cnt); -} - static void init_reflist_builder(struct hantro_ctx *ctx, struct hantro_h264_reflist_builder *b) @@ -273,7 +306,6 @@ init_reflist_builder(struct hantro_ctx *ctx, const struct v4l2_ctrl_h264_sps *sps; struct vb2_v4l2_buffer *buf = hantro_get_dst_buf(ctx); const struct v4l2_h264_dpb_entry *dpb = ctx->h264_dec.dpb; - struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q; int cur_frame_num, max_frame_num; unsigned int i; @@ -285,21 +317,15 @@ init_reflist_builder(struct hantro_ctx *ctx, memset(b, 0, sizeof(*b)); b->dpb = dpb; - b->curpoc = get_poc(buf->field, dec_param->top_field_order_cnt, - dec_param->bottom_field_order_cnt); + b->curpoc = (slice_params->flags & V4L2_H264_SLICE_FLAG_BOTTOM_FIELD) ? + dec_param->bottom_field_order_cnt : + dec_param->top_field_order_cnt; for (i = 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++) { - int buf_idx; - - if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) + u32 ref_flag = dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_REF_FRAME; + if (!ref_flag) continue; - buf_idx = vb2_find_timestamp(cap_q, dpb[i].reference_ts, 0); - if (buf_idx < 0) - continue; - - buf = to_vb2_v4l2_buffer(vb2_get_buffer(cap_q, buf_idx)); - /* * Handle frame_num wraparound as described in section * '8.2.4.1 Decoding process for picture numbers' of the spec. @@ -311,8 +337,13 @@ init_reflist_builder(struct hantro_ctx *ctx, else b->frame_nums[i] = dpb[i].frame_num; - b->pocs[i] = get_poc(buf->field, dpb[i].top_field_order_cnt, - dpb[i].bottom_field_order_cnt); + if (ref_flag == V4L2_H264_DPB_ENTRY_FLAG_REF_FRAME) + b->pocs[i] = min(dpb[i].bottom_field_order_cnt, dpb[i].top_field_order_cnt); + else if (ref_flag == V4L2_H264_DPB_ENTRY_FLAG_REF_BOTTOM) + b->pocs[i] = dpb[i].bottom_field_order_cnt; + else if (ref_flag == V4L2_H264_DPB_ENTRY_FLAG_REF_TOP) + b->pocs[i] = dpb[i].top_field_order_cnt; + b->unordered_reflist[b->num_valid] = i; b->num_valid++; } @@ -466,8 +497,7 @@ build_b_ref_lists(const struct hantro_h264_reflist_builder *builder, static bool dpb_entry_match(const struct v4l2_h264_dpb_entry *a, const struct v4l2_h264_dpb_entry *b) { - return a->top_field_order_cnt == b->top_field_order_cnt && - a->bottom_field_order_cnt == b->bottom_field_order_cnt; + return a->reference_ts == b->reference_ts; } static void update_dpb(struct hantro_ctx *ctx) @@ -481,13 +511,13 @@ static void update_dpb(struct hantro_ctx *ctx) /* Disable all entries by default. */ for (i = 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++) - ctx->h264_dec.dpb[i].flags &= ~V4L2_H264_DPB_ENTRY_FLAG_ACTIVE; + ctx->h264_dec.dpb[i].flags = 0; /* Try to match new DPB entries with existing ones by their POCs. */ for (i = 0; i < ARRAY_SIZE(dec_param->dpb); i++) { const struct v4l2_h264_dpb_entry *ndpb = &dec_param->dpb[i]; - if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) + if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID)) continue; /* @@ -498,8 +528,7 @@ static void update_dpb(struct hantro_ctx *ctx) struct v4l2_h264_dpb_entry *cdpb; cdpb = &ctx->h264_dec.dpb[j]; - if (cdpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE || - !dpb_entry_match(cdpb, ndpb)) + if (!dpb_entry_match(cdpb, ndpb)) continue; *cdpb = *ndpb; @@ -535,7 +564,11 @@ dma_addr_t hantro_h264_get_ref_buf(struct hantro_ctx *ctx, unsigned int dpb_idx) { struct v4l2_h264_dpb_entry *dpb = ctx->h264_dec.dpb; + const struct v4l2_ctrl_h264_decode_params *dec_param = ctx->h264_dec.ctrls.decode; + const struct v4l2_ctrl_h264_slice_params *slices = ctx->h264_dec.ctrls.slices; dma_addr_t dma_addr = 0; + s32 cur_poc; + u32 flags; if (dpb[dpb_idx].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) dma_addr = hantro_get_ref(ctx, dpb[dpb_idx].reference_ts); @@ -553,7 +586,15 @@ dma_addr_t hantro_h264_get_ref_buf(struct hantro_ctx *ctx, dma_addr = vb2_dma_contig_plane_dma_addr(buf, 0); } - return dma_addr; + cur_poc = slices[0].flags & V4L2_H264_SLICE_FLAG_BOTTOM_FIELD ? + dec_param->bottom_field_order_cnt : + dec_param->top_field_order_cnt; + flags = dpb[dpb_idx].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD_PICTURE ? 0x2 : 0; + flags |= abs(dpb[dpb_idx].top_field_order_cnt - cur_poc) < + abs(dpb[dpb_idx].bottom_field_order_cnt - cur_poc) ? + 0x1 : 0; + + return dma_addr | flags; } int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx) diff --git a/drivers/staging/media/hantro/hantro_hw.h b/drivers/staging/media/hantro/hantro_hw.h index fa91dd1848b7..fb1451e8a80b 100644 --- a/drivers/staging/media/hantro/hantro_hw.h +++ b/drivers/staging/media/hantro/hantro_hw.h @@ -86,6 +86,8 @@ struct hantro_h264_dec_hw_ctx { struct v4l2_h264_dpb_entry dpb[HANTRO_H264_DPB_SIZE]; struct hantro_h264_dec_reflists reflists; struct hantro_h264_dec_ctrls ctrls; + u32 dpb_longterm; + u32 dpb_valid; }; /**