From patchwork Tue Oct 24 08:02:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz X-Patchwork-Id: 5671 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp345807jah; Tue, 24 Oct 2017 01:02:51 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qaf8yT+Jnqbnw4iilgnVfwnBFHXd1hFVkSRB8cY3KK3O859lw0Mih/RPp1nJ1A166bieqx X-Received: by 10.223.159.81 with SMTP id f17mr12989528wrg.4.1508832171670; Tue, 24 Oct 2017 01:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508832171; cv=none; d=google.com; s=arc-20160816; b=rQXqg+lORPqRLk6EPms5pSWf2n4grN7piXomZMBGuFPqjPRUq2bDKwFTxTMPIaYmC5 ZGgS8ROadmtZrj0qp+eHZOKNLIDwbtGLPHJVNTmCM318McgsvKQpYWcbpCtzbWSqa4d4 cX4w6DyKE1vYLnrEw6tkikvNbQ0y5BJ+5WtXfe4BTd27pWE5L6vdWk0t4DXK2s0O5tcD RUFhwYaizgxxepYSLuWsaRfipVzt3IlXD52ppGrznIEaYuDEN8ampR3ITBsLzdkjK3ed s0si6/pEOH2XID77ciUxqaQtl72th9qlJ7DDjRb5kOSsTlsc39cxvd7xDa2oF6KNX8va i/yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=H/RSrG3TTsOVrnIZQX6tpDW0BohR6fkqgmMSlJA9ICM=; b=cI5r2whKl9WhVIV5k0zsBnh7KiHkjWpGdp4rmHu53V8DFBS33ycLJzdK79Zuwr7sER uZk+LfH0V9qT7zZz2q6DCzgd1hkLXKM9Z2YU44mQ6MQ6OtXZQGk8127yZMBrF61vnupL ZkhZ7BEXn+TEG0ppzaeHk1HpHK8YgQEDB6H74BhYdMXU9uNvmIYixzPEBQ0kX52dNRGN oyfxCb2Lga/6bM2RVdTpICrg6G5KToN7qE1qfzjVadR4sEGJl1Xs40zJGDl3V5e8TClG VX79eN1kkwZal6YzTX+LnYKrlUheDTPB0ZZBtDBnwJlmLMTSuYHKanysNCaZNM7VmknS H9Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@poczta.onet.pl header.s=2011 header.b=Uh1//XR2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k75si612838wmg.85.2017.10.24.01.02.51; Tue, 24 Oct 2017 01:02:51 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@poczta.onet.pl header.s=2011 header.b=Uh1//XR2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5BB4168A27D; Tue, 24 Oct 2017 11:02:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpo67.poczta.onet.pl (smtpo67.poczta.onet.pl [141.105.16.17]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 892CA68A213 for ; Tue, 24 Oct 2017 11:02:27 +0300 (EEST) Received: from localhost.localdomain (afgl227.neoplus.adsl.tpnet.pl [95.49.167.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mateuszb@poczta.onet.pl) by smtp.poczta.onet.pl (Onet) with ESMTPSA id 3yLm2s4ZQWz18VWfZ; Tue, 24 Oct 2017 10:02:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poczta.onet.pl; s=2011; t=1508832150; bh=La98aLuCWdSUmUqYDgzcPydVeUV+L4avqSKVzgFVIdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uh1//XR2sbv4dMIHHyVSnmOoElpW914Ky6NPzDwVIiAQjXCB79osGbKjx+yjBrZRr c/+WQgCXCzVJH5IaTVREXflwRhMi3aCCt1rzHdOtzdYbRfuwVLsZw/wXR8ZKLJUQ7m YLt2A26LCfguWpANXwRxodl1kObcnl1qKLt1Zweo= From: Mateusz To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Oct 2017 10:02:17 +0200 Message-Id: <20171024080217.2868-2-mateuszb@poczta.onet.pl> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20171024080217.2868-1-mateuszb@poczta.onet.pl> References: <20171024080217.2868-1-mateuszb@poczta.onet.pl> Subject: [FFmpeg-devel] [PATCH 2/2] swscale: use dithering in DITHER_COPY only if not set -sws_dither none X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Mateusz Brzostek MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This patch uses dithering in DITHER_COPY macro only if it was not used option '-sws_dither none'. With option '-sws_dither none' it uses downshift. For human eye dithering is OK, for video codecs not necessarily. If user don't want to use dithering, we should respect that. Signed-off-by: Mateusz Brzostek --- libswscale/swscale_unscaled.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 6ffde1ec59..01d6d653bc 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -1485,7 +1485,25 @@ static int packedCopyWrapper(SwsContext *c, const uint8_t *src[], #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\ unsigned shift= src_depth-dst_depth, tmp;\ - if (shiftonly) {\ + if (c->dither == SWS_DITHER_NONE) {\ + for (i = 0; i < height; i++) {\ + for (j = 0; j < length-7; j+=8) {\ + dst[j+0] = dbswap(bswap(src[j+0])>>shift);\ + dst[j+1] = dbswap(bswap(src[j+1])>>shift);\ + dst[j+2] = dbswap(bswap(src[j+2])>>shift);\ + dst[j+3] = dbswap(bswap(src[j+3])>>shift);\ + dst[j+4] = dbswap(bswap(src[j+4])>>shift);\ + dst[j+5] = dbswap(bswap(src[j+5])>>shift);\ + dst[j+6] = dbswap(bswap(src[j+6])>>shift);\ + dst[j+7] = dbswap(bswap(src[j+7])>>shift);\ + }\ + for (; j < length; j++) {\ + dst[j] = dbswap(bswap(src[j])>>shift);\ + }\ + dst += dstStride;\ + src += srcStride;\ + }\ + } else if (shiftonly) {\ for (i = 0; i < height; i++) {\ const uint8_t *dither= dithers[shift-1][i&7];\ for (j = 0; j < length-7; j+=8) {\