From patchwork Sat Jul 16 10:41:56 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: 9233141 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 D66B46075E for ; Sat, 16 Jul 2016 10:44:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6994212CF for ; Sat, 16 Jul 2016 10:44:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB2CF23861; Sat, 16 Jul 2016 10:44:33 +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 65D8B212CF for ; Sat, 16 Jul 2016 10:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751820AbcGPKmw (ORCPT ); Sat, 16 Jul 2016 06:42:52 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:36492 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751661AbcGPKmT (ORCPT ); Sat, 16 Jul 2016 06:42:19 -0400 Received: by mail-lf0-f65.google.com with SMTP id 33so8368855lfw.3; Sat, 16 Jul 2016 03:42:18 -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=gnccdsmHDVwe/7naCX71yBu8m5VlTMlUeVDAHatMzWk=; b=rRrT69zEnsGNb5PdDbtsh32+oCtTBI+Ggrb+SmacamlY8fkdTJALlvVjhqmRAGSCyr GujdoyStoZ0cNl4Biv3TKRm49NKPPBYS4A6enALtNSTdOxgcTvzTbUMK1XvrrGE9Qxgf XAZXl5/dgwnPrSK0oatR7VYfYJ5mi9WQ5lVyNbKn9PP6pE57oeR4BFhMyqHjs06fxRsY ke6q1EEGt8UWu4pcJHZuYEECQfgVTmKnjDCHzcVlCHKVyky0lcMqCwck7vEqNKQOrtEW 7I2OUfDcY4FjeBLJQvDlbttEGQyEEbVaATZxJJs69YkRFsx1DcvKkB3esDdcJSSW9D6a 7i4w== 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=gnccdsmHDVwe/7naCX71yBu8m5VlTMlUeVDAHatMzWk=; b=U5wgX3SOaNO654LWC2AdyU03xaYEwQ1mevgdw7ovGL+LNz+sL9t98f/cucsWkF2OFX p4eG8Mum1AmSorLCTuPatb6K9bmAfBw0ZP/qU2J5FC6tFJfzLZkHkqXvmHR8c65sz1ia 15Kc6L+swLtpnU+K2F1ozUucE4vFoWzE1TXqjvcqRwQhjL/Y5tKyiOCjua9j5pjkPnMK 975IFs7vwwFJpCEh1QmG1KbXzAUJGh5YoD4N2GFiur5VPGi4e5T7a7QxJ+GDGmsXh/nR McyTsCkXCuWuOqdDd4UL0zA2ZaS9Y+YAwja7wfk3yr4/F9q7sVecJdPT7BefwEIcZUi6 36NA== X-Gm-Message-State: ALyK8tK1MvjmzXSXrTWu2YpUK/Opfn23lIaI8yoQnXYtwZmck0x9raY0crXknT7hUPhiUA== X-Received: by 10.46.9.13 with SMTP id 13mr11997444ljj.2.1468665737582; Sat, 16 Jul 2016 03:42:17 -0700 (PDT) Received: from localhost.localdomain (x1-6-74-44-01-e3-62-1a.cpe.webspeed.dk. [80.167.115.215]) by smtp.gmail.com with ESMTPSA id f22sm1779457lji.13.2016.07.16.03.42.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jul 2016 03:42:16 -0700 (PDT) From: Ricardo Ribalda Delgado To: Jonathan Corbet , Mauro Carvalho Chehab , Hans Verkuil , Markus Heiser , Helen Mae Koike Fornazier , Laurent Pinchart , 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 v3 9/9] [media] vivid: Local optimization Date: Sat, 16 Jul 2016 12:41:56 +0200 Message-Id: <1468665716-10178-10-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1468665716-10178-1-git-send-email-ricardo.ribalda@gmail.com> References: <1468665716-10178-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 1c862465e335..2c23c458b1a6 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;