From patchwork Sat Sep 28 02:26:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15347 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 1D241449F5A 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 09E4E68A588; 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-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 19613689A59 for ; Sat, 28 Sep 2019 05:34:02 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id a6so7765351wma.5 for ; Fri, 27 Sep 2019 19:34:02 -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=1+3F/bypv2y5i8uOJOLRQeSSnKElLlFqKoLbFJFNoQQ=; b=IVIQEB9kSi2J3eymrdcn05W5E8+4lqLTO3YE0voH1UlisRWTirt9CegNC0yt3Ced+I srteAkQxkW6qtSvjPdwqkEXkPfYvSBOLmZmxDZITZNT639QwScjZQ7+ctFkYGsWeTp2E fIvxfhn6BNc0Tm0H9rQyJbT9PJBZxa52DGhMh29gSSWxJXR3dabyzeKKWEW5Bnsyzie2 nuw4zGV7dxol618APblpV1fq7dhDhQVAKPlC4JJgOwTqYkIMazmLv7gguNE0TbrOPelO qyA3h2xaRmMjtZztHPOC/zUn4+1PqQZrY6xEhmYYj4BM2/aNLSVWi6GWrd5V4H46e+Ci scog== 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=1+3F/bypv2y5i8uOJOLRQeSSnKElLlFqKoLbFJFNoQQ=; b=Oe/EmXMm9ytO+/jPO5995gWR0EwtLFhP5DNnwQFhIGNMLDO9YyeOWeXs4PVuL7m/hT 8RMxioorsLUDH6wBL8OwMCn2H3GbFBv8hM0qk9Yy07Ir6Mn1T4I+W9xQjIDHDlrAIO9w MDUkzFiT4vG3lhZ73bPuZ5fWhiY6dpIi5SKtyE7RHpn/zSoABHX/DkiYjQH/UCoJWW0V smAHgYXRrPoBdIvFVtKd4XokKixEwgpyhocqcNFv7nZWJvBF+skQSNpBwxyptciU0wIA RN3l5Wv62F7qCISXlM7AtGw7NqSR5xXXpx44SzHKTecaVUqTrQr6cFYJOSMmqzJuE7wF a/jA== X-Gm-Message-State: APjAAAXC3IqnhtstTKRmVAvn1Nbx7gBpnYitHlF6AkG8JX9WtXb64pC1 ujdk8zOd7n4CCULFnG/5lMB95LPN X-Google-Smtp-Source: APXvYqwdx6/x4/AHco/PupEXxNsPVRcoM+Ky1+fIA/lyNfCIEPlkjk/Wp4VpoemNsmWZgUl9oN0KEw== X-Received: by 2002:a1c:66c2:: with SMTP id a185mr9160949wmc.2.1569638041451; Fri, 27 Sep 2019 19:34:01 -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.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 19:34:01 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Sep 2019 04:26:06 +0200 Message-Id: <20190928022610.5903-11-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 11/15] avcodec/dnxhdenc: 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 61 FATE-tests: 60 vsynth tests and lavf-mxf_opatom. Signed-off-by: Andreas Rheinhardt --- libavcodec/dnxhdenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index c82c5d5140..2feb8baf21 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -220,7 +220,7 @@ static av_cold int dnxhd_init_vlc(DNXHDEncContext *ctx) ctx->vlc_bits = ctx->orig_vlc_bits + max_level * 2; for (level = -max_level; level < max_level; level++) { for (run = 0; run < 2; run++) { - int index = (level << 1) | run; + int index = level * (1 << 1) | run; int sign, offset = 0, alevel = level; MASK_ABS(sign, alevel); @@ -618,7 +618,7 @@ void dnxhd_encode_block(DNXHDEncContext *ctx, int16_t *block, slevel = block[j]; if (slevel) { int run_level = i - last_non_zero - 1; - int rlevel = (slevel << 1) | !!run_level; + int rlevel = slevel * (1 << 1) | !!run_level; put_bits(&ctx->m.pb, ctx->vlc_bits[rlevel], ctx->vlc_codes[rlevel]); if (run_level) put_bits(&ctx->m.pb, ctx->run_bits[run_level], @@ -698,7 +698,7 @@ int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, int16_t *block, int last_index) level = block[j]; if (level) { int run_level = i - last_non_zero - 1; - bits += ctx->vlc_bits[(level << 1) | + bits += ctx->vlc_bits[level * (1 << 1) | !!run_level] + ctx->run_bits[run_level]; last_non_zero = i; }