From patchwork Wed Jan 8 18:29:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17260 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 92FA144B551 for ; Wed, 8 Jan 2020 20:29:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B5B868ADBB; Wed, 8 Jan 2020 20:29:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DBFBF68A171 for ; Wed, 8 Jan 2020 20:29:27 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id j42so4410770wrj.12 for ; Wed, 08 Jan 2020 10:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mCeSWZEUbuoeCF3m6F3KjyHOwUn2YTOZwQ50fip3I6c=; b=PQVsrYvH/F2zy1cslh6r9dr6Ye93IXholsi+h2OVdKSCVoBlak6pjDhcTUQgQahvfZ TkfACeQ5VbZghOVQxczIgw/hIgz2dgSClptuBqp6G7RR+osLspIA6Y/6+bVLkCVNWf6M ANOqaO9OHm9FGMyuCCWLurvlkpViUJx2Y4EwRZ9xJTaQS2bZkpi4gCQvfBRscAbr2bZB Z6H/HAfZz0Ak6K/Gl4h1ZmGGpBumduadJSJRnapthVP28rAwKlmZxrKVdrVUTuAUvRK3 SK/vyRgtcb6DBu/mS1wxGjTRpaubTaGBToL7RtChWTLm5f5pffKanv7RZ5Vn4YartnNl otEA== 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:mime-version :content-transfer-encoding; bh=mCeSWZEUbuoeCF3m6F3KjyHOwUn2YTOZwQ50fip3I6c=; b=B3G28wHG5voqS3qt5mFatYFf/Hbqv7LOAQ9b/ChqDJLShaCEiAR1PwWQrPTjZWCyKL 9vswr+R24XHM+tB/ZtYZjjzdSb79jsBiQeGcnDGGQwoiX7lxqQP8zNcvzo2vRYiOSWWc +/TtnhQv1rDx1unxqor+CGSy8EiDc518p6bFMC5WFGVHvX7lx/iv4H69J7YrTdvqJv2c VV6iBgA7GaakDXSys4x93U78ZH9YZ1ZNgVb61oH+KBxGDC2IXrGErzwVzQBidDpAGWOa fZSk9YVh6FqdadgAjdBK+2Gyk6QWVewbTEplCteej0UnVKfSnj8ebhwln6fJA+EmtrQ3 T4Aw== X-Gm-Message-State: APjAAAWvjrIkaNk5gxjkbwuSCL8JOHM9sCEDwuYROTwiGuhJAEUARnva SgZ+x5neTrwvW/iDpz86mctbM2Aj X-Google-Smtp-Source: APXvYqzrCbArd73sk/W53rnF9cCffHMmuBt1xSbPPEFbw7B/2PuASxtmbwRzaJDVPLnuuazKl2MH0Q== X-Received: by 2002:a5d:4602:: with SMTP id t2mr6019355wrq.37.1578508167068; Wed, 08 Jan 2020 10:29:27 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id c4sm4715617wml.7.2020.01.08.10.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 10:29:26 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 Jan 2020 19:29:13 +0100 Message-Id: <20200108182913.7758-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/proresenc_anatoliy: Fix invalid left shift of negative number 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" This fixes ticket #7997 as well as the vsynth*-prores_# FATE-tests (where * ranges over { 1, 2, 3, _lena } and # over { , _int, _444, _444_int }). (Given that prev_dc is in the range -0xC000..0x3FFF, no overflow can happen upon multiplication with 2.) Signed-off-by: Andreas Rheinhardt --- Actually, #7997 ran into the same issue as #7979 and so it is no longer reproducible with the given commandline since aef24efb (which fixed #7979). But it is still reproducible with e.g. the null muxer. libavcodec/proresenc_anatoliy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index 0fc79fc1de..1fcb0ae913 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -224,7 +224,7 @@ static void encode_codeword(PutBitContext *pb, int val, int codebook) } #define QSCALE(qmat,ind,val) ((val) / ((qmat)[ind])) -#define TO_GOLOMB(val) (((val) << 1) ^ ((val) >> 31)) +#define TO_GOLOMB(val) (((val) * 2) ^ ((val) >> 31)) #define DIFF_SIGN(val, sign) (((val) >> 31) ^ (sign)) #define IS_NEGATIVE(val) ((((val) >> 31) ^ -1) + 1) #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))