From patchwork Mon Jul 18 12:42:13 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: 9234511 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 B0F876075D for ; Mon, 18 Jul 2016 12:43:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A34EC205AD for ; Mon, 18 Jul 2016 12:43:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97C5926B41; Mon, 18 Jul 2016 12:43:11 +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 321AB205AD for ; Mon, 18 Jul 2016 12:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752103AbcGRMms (ORCPT ); Mon, 18 Jul 2016 08:42:48 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33951 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751968AbcGRMmp (ORCPT ); Mon, 18 Jul 2016 08:42:45 -0400 Received: by mail-lf0-f65.google.com with SMTP id l69so6709517lfg.1; Mon, 18 Jul 2016 05:42:39 -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=vb5Ok+mm+P7v9nRSrgo0X/gbJwQ/lPkTJMMi0QLvDCM=; b=Wv1InkY7gDHl4la++crWx7pE57nVGg9Wa8ga+zLJ0dtsMIwpmYPraCntYz/lPKm0Gj AMfC4KZVEDHtrXqn3JlZWwLRd7PBYti0tLk041R2WnO5JuczikAZIQ54EevE2XqdSLfS T/czTYdkF+ylSqoRw/LYflPcaJFILT3UEXlpnrXmN+lUqAwGsrzCX34985XinwIDiojv qUGiXWNcgQ+QaLv0s58H8i0+R2eyUwHP/PaUcnC54WF8n/NSI/DgHusnBYrrIwAFIkH3 12OGHdJ4bv5wo78mKQRZrQw2Cie/5OuJPRx/mj+t2nrmsna8XPYV5YaTZ0gG2k70uKX/ j9Qg== 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=vb5Ok+mm+P7v9nRSrgo0X/gbJwQ/lPkTJMMi0QLvDCM=; b=DRHUgSpSww8MT0h9Vk62/vN+aQM1oqjencp5ZJUXcC6sz13/cK8DqLpoQ+aNUh7rnI E5cynWiOKhLnaJkFur5CwlvPetHr9s5KUEFh5o1zTBv9llouIhZsvKvs1/os9Mx1S+Ju k7QtbupP1ejM+qrU5T1uIL4Qmry2rI/8SBUbPRj/LT3G1ADzHpB8K9D6PlMOmpCXCR4R QoOp/e5f0yiPBvL7u67oGkSGoPQyb5dQmgmnw/sTsLM3gSUzMguN3BVy99KtnAj3Ty2Y S+UiXrWBn5BxW0AYGrg06H8sRmyrCtCB7b7OGHwiaESrPqOfN/wzHoaO7YIOAB5kdGjA oPtg== X-Gm-Message-State: ALyK8tI4+h4DizmK+oli+hp997Y+XIs6MWx49bEf0C6btir5qTkXRcbYOrINp4De60hqrw== X-Received: by 10.46.0.39 with SMTP id 39mr12449007lja.48.1468845753210; Mon, 18 Jul 2016 05:42:33 -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 205sm4571672ljj.47.2016.07.18.05.42.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2016 05:42:31 -0700 (PDT) From: Ricardo Ribalda Delgado To: Jonathan Corbet , Mauro Carvalho Chehab , Hans Verkuil , Markus Heiser , Laurent Pinchart , Helen Mae Koike Fornazier , Antti Palosaari , Philipp Zabel , Shuah Khan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v4 09/12] [media] vivid: Local optimization Date: Mon, 18 Jul 2016 14:42:13 +0200 Message-Id: <1468845736-19651-10-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1468845736-19651-1-git-send-email-ricardo.ribalda@gmail.com> References: <1468845736-19651-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 data shifts when possible. Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 13 +++++++------ 1 file changed, 7 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 a26172575e56..7f284c591f25 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c @@ -919,13 +919,14 @@ static void precalculate_color(struct tpg_data *tpg, int k) color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr); 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 >> 4, 16, 235); + cb = clamp(cb >> 4, 16, 240); + cr = clamp(cr >> 4, 16, 240); + } else { + y = clamp(y >> 4, 1, 254); + cb = clamp(cb >> 4, 1, 254); + cr = clamp(cr >> 4, 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;