From patchwork Sat Sep 28 02:26:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15348 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DD16F449F5A for ; Sat, 28 Sep 2019 05:34:07 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C578468A59A; Sat, 28 Sep 2019 05:34:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A777689A6F for ; Sat, 28 Sep 2019 05:33:57 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id m18so7302680wmc.1 for ; Fri, 27 Sep 2019 19:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gbgbRAAlhr6daM5LfxDeFQISYXj6cqOCh1C2pm4kb0M=; b=Fv2Dwb9PP0Sb12TleCVYCYTWzQCw+S9a8kVOvhVT8bOdTqffLiAudml53OrSKD8zxc HvhdLk/vtnScL/licLeVVWBk2uFjfNDBvOxBigYRxkVbXo1m6ca5xuDBaQav8UxVs6Yj t0ERPn6aVwX1rtpzD7Q5FgWtOIh3tru9Fn3BN/oTDAUyZM/3BmZ/ATADyNtvGkyw9O9R BGHW744XkDvp1Skz4nBaor1mVGZ4yILINr8U+84Ed94LQlUhL1188DdQaFbwOwpfzswr tYJ9wOUR7C6Y+VNfMxmXoS8vKpyr3B81KKGZlszP6M5s423KX39T60tOvwFAwUeJEamO YNMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gbgbRAAlhr6daM5LfxDeFQISYXj6cqOCh1C2pm4kb0M=; b=rIrGcVNp7V69u5f78/zMw/BslU+kkzTvMySXcdy9P1+G2B75d8ksnUrXsm12AMJdl/ wDSOrMe0tHEltmFe+ohWJw097TtRuE0Gv9WbPGUtn8q+Q8mjO4bhmstXyAyOTl9xHYxU vXQ4i4D6WjnE1u1SE758OypNzsx7fqvwDNYQEUE0wI6JCAOb94wgyeR9VOrWKyOv1/tz ddvQdwC/9KWHD5NVVzP+5HShMojz6rHOWFJVBKDtssBGVIo1gnDongrEqSi6u+dnDuHL IE/7ggBMp1YbbVZ3UsnDwM6va0nDu8KS4Jgbbj3p9VrSqc8Y7DEQLUf+ddta7kAG8CRA 6u0Q== X-Gm-Message-State: APjAAAWh1BoMFJMo3cCd9jBu/gI8buWBY/5y/is9rvn8l49UrtMhnA4U xuiGDvy1lLO83xufxRb5JLvjwVOS X-Google-Smtp-Source: APXvYqwUwlRBVE1gY0+5QRvuX8Rg+b4mX5YBz4z8dXR07YSfz++PI1RafhoJ8e/TPBkksN7D2zRZnA== X-Received: by 2002:a1c:a94b:: with SMTP id s72mr9189927wme.9.1569638036739; Fri, 27 Sep 2019 19:33:56 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id r7sm4484231wrx.87.2019.09.27.19.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 19:33:56 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Sep 2019 04:26:00 +0200 Message-Id: <20190928022610.5903-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190928022610.5903-1-andreas.rheinhardt@gmail.com> References: <20190928022610.5903-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 05/15] avcodec/cavsdsp: Fix undefined left shifts of negative numbers 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Affected the ffmpeg-filter_colorkey FATE-test (but only if the C version of idct8_add is used and not e.g. the x86 SSE2 version). Signed-off-by: Andreas Rheinhardt --- libavcodec/cavsdsp.c | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c index 90a67e910c..ba92121cc9 100644 --- a/libavcodec/cavsdsp.c +++ b/libavcodec/cavsdsp.c @@ -201,20 +201,20 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, ptrdiff_t stride) src[0][0] += 8; for( i = 0; i < 8; i++ ) { - const int a0 = 3*src[i][1] - (src[i][7]<<1); - const int a1 = 3*src[i][3] + (src[i][5]<<1); - const int a2 = (src[i][3]<<1) - 3*src[i][5]; - const int a3 = (src[i][1]<<1) + 3*src[i][7]; + const int a0 = 3 * src[i][1] - 2 * src[i][7]; + const int a1 = 3 * src[i][3] + 2 * src[i][5]; + const int a2 = 2 * src[i][3] - 3 * src[i][5]; + const int a3 = 2 * src[i][1] + 3 * src[i][7]; - const int b4 = ((a0 + a1 + a3)<<1) + a1; - const int b5 = ((a0 - a1 + a2)<<1) + a0; - const int b6 = ((a3 - a2 - a1)<<1) + a3; - const int b7 = ((a0 - a2 - a3)<<1) - a2; + const int b4 = 2 * (a0 + a1 + a3) + a1; + const int b5 = 2 * (a0 - a1 + a2) + a0; + const int b6 = 2 * (a3 - a2 - a1) + a3; + const int b7 = 2 * (a0 - a2 - a3) - a2; - const int a7 = (src[i][2]<<2) - 10*src[i][6]; - const int a6 = (src[i][6]<<2) + 10*src[i][2]; - const int a5 = ((src[i][0] - src[i][4]) << 3) + 4; - const int a4 = ((src[i][0] + src[i][4]) << 3) + 4; + const int a7 = 4 * src[i][2] - 10 * src[i][6]; + const int a6 = 4 * src[i][6] + 10 * src[i][2]; + const int a5 = 8 * (src[i][0] - src[i][4]) + 4; + const int a4 = 8 * (src[i][0] + src[i][4]) + 4; const int b0 = a4 + a6; const int b1 = a5 + a7; @@ -231,20 +231,20 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, ptrdiff_t stride) src[i][7] = (b0 - b4) >> 3; } for( i = 0; i < 8; i++ ) { - const int a0 = 3*src[1][i] - (src[7][i]<<1); - const int a1 = 3*src[3][i] + (src[5][i]<<1); - const int a2 = (src[3][i]<<1) - 3*src[5][i]; - const int a3 = (src[1][i]<<1) + 3*src[7][i]; - - const int b4 = ((a0 + a1 + a3)<<1) + a1; - const int b5 = ((a0 - a1 + a2)<<1) + a0; - const int b6 = ((a3 - a2 - a1)<<1) + a3; - const int b7 = ((a0 - a2 - a3)<<1) - a2; - - const int a7 = (src[2][i]<<2) - 10*src[6][i]; - const int a6 = (src[6][i]<<2) + 10*src[2][i]; - const int a5 = (src[0][i] - src[4][i]) << 3; - const int a4 = (src[0][i] + src[4][i]) << 3; + const int a0 = 3 * src[1][i] - 2 * src[7][i]; + const int a1 = 3 * src[3][i] + 2 * src[5][i]; + const int a2 = 2 * src[3][i] - 3 * src[5][i]; + const int a3 = 2 * src[1][i] + 3 * src[7][i]; + + const int b4 = 2 * (a0 + a1 + a3) + a1; + const int b5 = 2 * (a0 - a1 + a2) + a0; + const int b6 = 2 * (a3 - a2 - a1) + a3; + const int b7 = 2 * (a0 - a2 - a3) - a2; + + const int a7 = 4 * src[2][i] - 10 * src[6][i]; + const int a6 = 4 * src[6][i] + 10 * src[2][i]; + const int a5 = 8 * (src[0][i] - src[4][i]); + const int a4 = 8 * (src[0][i] + src[4][i]); const int b0 = a4 + a6; const int b1 = a5 + a7;