From patchwork Thu Aug 18 14:33:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 9288277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B43D6086A for ; Thu, 18 Aug 2016 14:35:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D5B12922D for ; Thu, 18 Aug 2016 14:35:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 022BA2929F; Thu, 18 Aug 2016 14:35:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F1DD2922D for ; Thu, 18 Aug 2016 14:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947254AbcHROfu (ORCPT ); Thu, 18 Aug 2016 10:35:50 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34332 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1768305AbcHROfq (ORCPT ); Thu, 18 Aug 2016 10:35:46 -0400 Received: by mail-lf0-f66.google.com with SMTP id k135so1878409lfb.1; Thu, 18 Aug 2016 07:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dc1jAANt9Nh71SeWkLhKrv16s7EjY2gEYhMwv765CzY=; b=F0eR1KE01HzSoXaTO70LuyrDQJFeX5b7DFVa4QiQA2qslmDrYoRVb67wILqUnEwMob i2J7mtRn3KdIIDmTSYnTqzk52a5AYoJTJLo1DhBP8euxQHzv6oFaoDny/UqzIvEvfKxL PMibTWrGEOaIrOJsFfC1wYTOCxJF8aVjOSI/QfH2iQ6RTrEyoHUgyeSloIO+Tvx5F8RZ GwypqPPEb2FGCAvCecUVwNke3PPv22FRxB58buodQ2Bq/DnH7r1u3aXG6UhiM4hT7l9L gyVmWvs+z2UAvaQqRfdA+RsYoCCqaQB3h/oJjx6hmk5lriJiyOeY7F560lexwK1pPy1a HTXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dc1jAANt9Nh71SeWkLhKrv16s7EjY2gEYhMwv765CzY=; b=TIKAtA0Myzs7Ol1bdMwSI8KPtuEXF/2VmXj8MAvVnLd2sE7wb5fLNCqyHrPVM6lK4I xKt6oOxQD6L2iuKkcGlzEy3c7FlD/B44PjwRi0vFtoNRsH/VNFt8B+UvXJ3zAE9d/NdO 4OZ/ZW1Yl/W6GkEJ2PiCqNM/oaqBEnnT+Kw6ZbhGcgK4mVrK2L/3t2WYyy9+miOUziVo XZW7CmbHtbun4zfkbBKkGugTXuhTPvNwvfwS7hgPhLRfDXydEmz2p8KegidhWHN74iUS YLJyvwXpJ5jVDKfHnAz7z9eFjPQEivmKHifpv1yCSeJMo/giID2uMSCFLAZGJh40YASA 5MmQ== X-Gm-Message-State: AEkoouuWvPuM4tbRpSF3UcQQYXsk0E1xErjxfUAbA52cIUOjGLxxXpwhtGi8bWTCESBdIQ== X-Received: by 10.25.10.208 with SMTP id 199mr685525lfk.124.1471530834134; Thu, 18 Aug 2016 07:33:54 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id p21sm389218lfp.4.2016.08.18.07.33.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Aug 2016 07:33:53 -0700 (PDT) From: Ricardo Ribalda Delgado To: Mauro Carvalho Chehab , Hans Verkuil , Markus Heiser , Laurent Pinchart , Helen Mae Koike Fornazier , Antti Palosaari , Philipp Zabel , Shuah Khan , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v5 09/12] [media] vivid: Local optimization Date: Thu, 18 Aug 2016 16:33:35 +0200 Message-Id: <1471530818-7928-10-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1471530818-7928-1-git-send-email-ricardo.ribalda@gmail.com> References: <1471530818-7928-1-git-send-email-ricardo.ribalda@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid duplicated clamps when possible. Suggested-by: Philipp Zabel Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c index 7364ced09abc..ed37ae307cac 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c @@ -916,14 +916,18 @@ static void precalculate_color(struct tpg_data *tpg, int k) if (!ycbcr_valid) color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr); + y >>= 4; + cb >>= 4; + cr >>= 4; if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) { - y = clamp(y, 16 << 4, 235 << 4); - cb = clamp(cb, 16 << 4, 240 << 4); - cr = clamp(cr, 16 << 4, 240 << 4); + y = clamp(y, 16, 235); + cb = clamp(cb, 16, 240); + cr = clamp(cr, 16, 240); + } else { + y = clamp(y, 1, 254); + cb = clamp(cb, 1, 254); + cr = clamp(cr, 1, 254); } - y = clamp(y >> 4, 1, 254); - cb = clamp(cb >> 4, 1, 254); - cr = clamp(cr >> 4, 1, 254); switch (tpg->fourcc) { case V4L2_PIX_FMT_YUV444: y >>= 4;