Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1806376pxb; Mon, 22 Feb 2021 11:20:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5Gt8pN8FKVtvrpV1wqStlPIr9cV0IoS0u9Vcq1K23GGByX11Zd2W6aD5pre9tVlQjQvR0 X-Received: by 2002:a17:906:3685:: with SMTP id a5mr6998999ejc.352.1614021627201; Mon, 22 Feb 2021 11:20:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1614021627; cv=pass; d=google.com; s=arc-20160816; b=dAp25rLm/nB2sxJoHQIcnb6S+fWiTTOD98C/ptuClVwBme7aAFVqjyS936uTH01mvI dGrvUi5hF/8sa+ERFgeAzw76LiqcIsd6yD/qErKEONj2zH7YgaDP+BWy8eHnN27jt/wE eyaagWlOorgOnstQHS+2C5b6eE6MUWgwnxIwV3EjbdbAtsfVMH89ZwWa2JWSAZELiIuo 73nnL/glrhvxf1HBKY919AdhEHUgMeZwIt08kmJEElSDneuTeuyxwMPip+MlW4HzSsx0 88dyk+0UFQ8BcucVE9n5shuMMmMSfj8MjxnPr9EOGuGEbEKDodiaCKy7zxeINCkRYSYc asng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uDKvzVdjGbMHVD1Z3uuw1Yz6DtptNqT1M4/zA6HEkfU=; b=kEYuhy53R7MPEscCEGaAFx8a1OqEAH3mw+819bv1nHf1rEiHFnE0LNX7oncen4965S q2rDDovSGjQq3Y0O83t3BjRlmiuOjq25Cw77zFru4wMgWa8wnaGtBxFbtgJyIxlYsz8q rSSnKEdusb0MDWyYroW//or53e5kMRn26hpH6nh70gkdcowHDtDqnpwma7JqMjLW3TLq IkuOOp9/eZbA3q6ozTiIXguKkTKQTudXHrGTNMNPOLx2016X5zAWGn8xFn82T0UdEchi RqNQlfPaqaS9YQH6bBd946UTlzyEmRLlRsm9oQErlazktb9oc2VDXlSdxma842FGlH8T YRMQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=gmCU6RZY; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si12424145ejf.743.2021.02.22.11.20.04; Mon, 22 Feb 2021 11:20:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=gmCU6RZY; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232895AbhBVTRX (ORCPT + 99 others); Mon, 22 Feb 2021 14:17:23 -0500 Received: from mail-am6eur05on2053.outbound.protection.outlook.com ([40.107.22.53]:59872 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232902AbhBVTMG (ORCPT ); Mon, 22 Feb 2021 14:12:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=njUB281lBQ4bI0T0lf9q0ahDJ+psoy16KsFWs1DoT1vFeIlUO1ZhfqcIA5ezpwrVX6W5j4Ggrb8NsLo/lRB7LbIxknAtoZUIkUhD1wiqA9JtFteqyd8hqUCTaeTza5L+I177JiTM9xeHQLi+FtfMnbGNFsuxmiCZ5d20Xk3lkUgRBHVM8s5J3NGdeh0kcsq2ZUh9fbyACG596o8XkoGB9oe4amp6QCuQC5wUK0bVNb+FApBZofPZs+dEwCp7pL+tMwhppiZnrPRKMJYA55LKNPn4Z7sMfmADeJPUARsBkFY4WMFeJF/Y0f/pRp97j2neP2OcKDU4pZEcalHRlYZGkA== 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=uDKvzVdjGbMHVD1Z3uuw1Yz6DtptNqT1M4/zA6HEkfU=; b=MM1TvU1NBRWNsO/umhhDGi98ED+vZeiG9PPGYeuX9Hm+5Fr+YIdIyvd6VWBcC6AHLs4w+ryWi96paRdTHYeFAEiCId9HX4+Bz5QHcoXDWT5sH5DXKxaxukjnCIOpu7Tq4RjsQa/LFEY9+1NXaJ6mnwRGtlEu0tHoMpZtr0n11ps7dXQZkCJ5EONPaNZs83wH+zvitPyy9qsURa/mD2kOgpqGP9jrfjMMIYZGnmgVWjcucAVZ5P5mMuZNyB0gwrLWU2PeoRob3YuihnkJUJLgwaAn6uvtqMrIwXuPemMBqSXElQjnKWlkLUYORZHwtZYLzAhbwM8OeKz0PfdmsbcmlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uDKvzVdjGbMHVD1Z3uuw1Yz6DtptNqT1M4/zA6HEkfU=; b=gmCU6RZYzVsgssbPmbJLwom0xyrFZniErwmDLjPMNhN3SpG6xrLpp822iHPLQu9O2xUiKyePBK1ohgOfMj096zXsPXSQO3Js8oiVl784Ivdc3FydVGtxrL9AZ5ZyUsxsrYQdajxprXUDyrmv25J6t5HTK/taMX9s4CKTUwIvxkw= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) by AS8PR04MB7591.eurprd04.prod.outlook.com (2603:10a6:20b:297::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26; Mon, 22 Feb 2021 19:08:19 +0000 Received: from AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::618c:8b68:e3d9:a8c6]) by AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::618c:8b68:e3d9:a8c6%7]) with mapi id 15.20.3868.032; Mon, 22 Feb 2021 19:08:19 +0000 From: Mirela Rabulea To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, shawnguo@kernel.org, robh+dt@kernel.org, p.zabel@pengutronix.de Cc: paul.kocialkowski@bootlin.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, s.hauer@pengutronix.de, aisheng.dong@nxp.com, daniel.baluta@nxp.com, robert.chiras@nxp.com, laurentiu.palcu@nxp.com, mark.rutland@arm.com, devicetree@vger.kernel.org, ezequiel@collabora.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, dafna.hirschfeld@collabora.com Subject: [PATCH v8 8/9] media: Avoid parsing quantization and huffman tables Date: Mon, 22 Feb 2021 21:07:37 +0200 Message-Id: <20210222190738.2346378-9-mirela.rabulea@oss.nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210222190738.2346378-1-mirela.rabulea@oss.nxp.com> References: <20210222190738.2346378-1-mirela.rabulea@oss.nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [86.124.171.30] X-ClientProxiedBy: FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) To AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (86.124.171.30) by FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.8 via Frontend Transport; Mon, 22 Feb 2021 19:08:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f0854a99-558a-4cbd-2e2b-08d8d765373b X-MS-TrafficTypeDiagnostic: AS8PR04MB7591: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lW6V6aAjnLRDD7Gk/rKjxR97T4c/VcGDihIANQ7xyKFnxGXC5+NXjXHLvUuPAnmkqv0sstx8iO3B0Wwbx2GC1Q9u16d3jBi+o2gdsIjFNzAV8nmqtbRKTM3NIoDlq9mqAG6DnaeIjotXVMiSBrWy93WTYt95humNNZn2auevyCvRDrvVy+Xx00JlDLBQ4GO/5dsxz2zFDpqmQ4kC5wbAbt0MIA/9DgUvoKeu+CRDv38YlzMMX/39fdDJOqscEn92DTxofF0ZwFuNnNUWbjfksn1Mx0sxP7fv1vMTVIni9lO4ykFtRyEkDwfO55gmG3XQsQniTDFsiJ0kf8db+TPil1+EvwxBbtyoj86+YlAEQ2zqZ/2qUJMLm6/5o5QQvPjHcDV2rtp/E8UxOtVx2bGdaCWVzlhAM36EWNL9PQSwFmqtZ94wLFQtiiZXoMd5NkFPB2RiwgGEzUafWyH5aF9htuVohZ5s3FUYMZd1yzpDR7JxYw1FjoHZ7hY8k9T7xjfDCi+6WFzc6AFd9PQzQflS/37WRe9CzJ2mqcC0Qpbt0vu/nXMB8JRPh1xgRjG5sLd8xnr0JUfmowsnDDP7A7O/Dw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM5PR04MB3137.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(366004)(396003)(346002)(39850400004)(376002)(316002)(6666004)(2906002)(83380400001)(956004)(2616005)(52116002)(8936002)(186003)(69590400012)(1076003)(66476007)(6506007)(86362001)(44832011)(66946007)(5660300002)(478600001)(66556008)(6512007)(6486002)(7416002)(4326008)(16526019)(8676002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?VE8dAb+VXi1hi1URLIocirsMhig2qtf3Z5slRMMYvmK3U8qjZgfteEEJ46R9?= =?us-ascii?Q?3UVjLJkNOypwZUfeSl/0Fb8X4LhYPaWYO+C+hnjsEIg3a6tTnuqE6eGPPcyp?= =?us-ascii?Q?UMa5rLhe6Xo5l0poW4tTAz5EKmZ5/5tM6W2C0qggot/cA2d0HOyr/+MSgIQu?= =?us-ascii?Q?TloCApHgmxCRveAaT9mQPCf78u67huoORoN4kAVqbqukiL7dRxTh7GJQlxVg?= =?us-ascii?Q?ktLF0aV6vi7XyW3QKzDRhljUDSYrEyI/wRWBF4m9BmaGbloHiqYEikxIo2Vi?= =?us-ascii?Q?6AyJ3TD0333vHNoSVpYXHOLOnjX44OBQdrkdC9lI21vbOq/nJR8RjyUJlrZi?= =?us-ascii?Q?xx7Z8Uc8K5VTshaH811jW6c8QszKFKCYa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pyO2SS6xmnFRF3c16sJY7r/XckDEMQ9hERdug/97xFNpkZpPW3ZJ?= =?us-ascii?Q?PeTYpHAKfat678WuGRrVJWOVPtiRhKOh1+QB501i+FVcQg=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0854a99-558a-4cbd-2e2b-08d8d765373b X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3137.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2021 19:08:19.3068 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UGX48Xd+XunD+i2XOdBVr48DpdEoCuyPcwtVGrGwHoPl4VaexIWdHso9ce2ZjUdGruWxtzXNWLO3DQfQD8Jr8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7591 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mirela Rabulea These are optional in struct v4l2_jpeg_header, so skip DHT/DQT segment parsing if huffman_tables/quantization_tables were not requested by user, to save time. However, do count them (num_dht/num_dqt). Signed-off-by: Mirela Rabulea Reviewed-by: Philipp Zabel --- drivers/media/v4l2-core/v4l2-jpeg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-jpeg.c b/drivers/media/v4l2-core/v4l2-jpeg.c index c4c0d6dd4577..c2513b775f6a 100644 --- a/drivers/media/v4l2-core/v4l2-jpeg.c +++ b/drivers/media/v4l2-core/v4l2-jpeg.c @@ -537,6 +537,10 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out) &out->dht[out->num_dht++ % 4]); if (ret < 0) return ret; + if (!out->huffman_tables) { + ret = jpeg_skip_segment(&stream); + break; + } ret = jpeg_parse_huffman_tables(&stream, out->huffman_tables); break; @@ -545,6 +549,10 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out) &out->dqt[out->num_dqt++ % 4]); if (ret < 0) return ret; + if (!out->quantization_tables) { + ret = jpeg_skip_segment(&stream); + break; + } ret = jpeg_parse_quantization_tables(&stream, out->frame.precision, out->quantization_tables); -- 2.25.1