From patchwork Wed Jan 22 14:52:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17469 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 AC87944B95F for ; Wed, 22 Jan 2020 16:57:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8698968B21C; Wed, 22 Jan 2020 16:57:49 +0200 (EET) 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 CF69868AF79 for ; Wed, 22 Jan 2020 16:57:42 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id u2so7524880wmc.3 for ; Wed, 22 Jan 2020 06:57:42 -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=mOOBUQM1UD32MQMUdFdD+hrtVOST+N2GF3FbcAhh5f4=; b=qN0z58vNP8wukQmLhM1D4VqqKiNKLNTpkNDRIJJI7rVw307WCM51QFrhRzeIR6bl5O gPgR5PTbADCnohKb4lEyu8HvP4ADlDoMYZ2vWFujbXXn1Ipk8jDFt9pD+RDs+Go2rY/+ vrlI6m3wcYwCG/FclLQmpk2AFMx6vDR8X3WeE/RggDkvRV1DoTt2VOsRQJmgte67XR8L BLLfszDpYOcxDulOwOiQPwmAWpctN7Lr0u2zYPISC4eZcK/XWTkWHvhAHxvKFJkRzeuh VzKvoEkhy2AXbQyti8YgQIo1aw4pYTMDGQvnuhXQ0oy0wdYqEwnl7pZZzLLV2QHBGJAz zYgg== 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=mOOBUQM1UD32MQMUdFdD+hrtVOST+N2GF3FbcAhh5f4=; b=iuHGrowSP/pyuBKPJlRqPCya+QggFbwQRpOsEtZa7SBYXWvyMJeRPnrVxYLggharg5 Bml9POuNDc36zEN/lbqEAR8+LApI/aiF/NCVjURs6PjSZCSk1wx6+3qCatquVf3QCLiO vUn9/LSL8HqUpARBjKbsVm77pYZ00nGZHIgGNB/c0l4PAI6SGtrbVlqHk/wwPYQQzgf5 kKiVLq6gj8Duwurkx6FqNPnCgozF1OBxTRmnUDEe7bGaGdVbiDI6smehQua3QdjyfOc8 4hqIepQ6GYbONm20DoncxHzP3T6dO++BDL/PbduO5amKmHYnqeSIY6+ac+RHLiYDk586 T7IQ== X-Gm-Message-State: APjAAAX99vs2oaAAsnP7nRt44gq5uZcAguOtSTp9TuALU58B/jqhg0Y4 0Vw5Rov5bHrT7+3VoiVOhtCZlmtp X-Google-Smtp-Source: APXvYqwMaKilHAHGk6eD8F6cerYLpFxt8aTUIybPjbOxOaIZfnJW3Lz4sz7t7I/ZcH+Vm7LZpwShZg== X-Received: by 2002:a1c:1b15:: with SMTP id b21mr3310294wmb.17.1579704739887; Wed, 22 Jan 2020 06:52:19 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id t81sm4452092wmg.6.2020.01.22.06.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 06:52:19 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Jan 2020 15:52:07 +0100 Message-Id: <20200122145210.6898-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/startcode: Use AV_RN due to UBSan warning about unaligned access 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" when directly accessing a buffer via a pointer to uint8_t cast to a pointer to uint64_t/uint32_t. This happened only if HAVE_FAST_UNALIGNED was set, so it was ok, but UBSan nevertheless complained about unaligned accesses. So simply use AV_RNxx to read the buffer; this also improves readability. This affected many FATE-tests (namely 228 of them; e.g. the cbs-h264 tests) and it has also been reported in tickets #8138 and #8485. Signed-off-by: Andreas Rheinhardt --- libavcodec/startcode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/startcode.c b/libavcodec/startcode.c index 9efdffe8c6..d84f326521 100644 --- a/libavcodec/startcode.c +++ b/libavcodec/startcode.c @@ -25,6 +25,7 @@ * @author Michael Niedermayer */ +#include "libavutil/intreadwrite.h" #include "startcode.h" #include "config.h" @@ -38,14 +39,14 @@ int ff_startcode_find_candidate_c(const uint8_t *buf, int size) */ #if HAVE_FAST_64BIT while (i < size && - !((~*(const uint64_t *)(buf + i) & - (*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) & + !((~AV_RN64(buf + i) & + (AV_RN64(buf + i) - 0x0101010101010101ULL)) & 0x8080808080808080ULL)) i += 8; #else while (i < size && - !((~*(const uint32_t *)(buf + i) & - (*(const uint32_t *)(buf + i) - 0x01010101U)) & + !((~AV_RN32(buf + i) & + (AV_RN32(buf + i) - 0x01010101U)) & 0x80808080U)) i += 4; #endif From patchwork Wed Jan 22 14:52:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17472 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 CEF72449947 for ; Wed, 22 Jan 2020 17:06:47 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B104068B129; Wed, 22 Jan 2020 17:06:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 24F0A6881B6 for ; Wed, 22 Jan 2020 17:06:41 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id j42so7598073wrj.12 for ; Wed, 22 Jan 2020 07:06:41 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qo+iUt84EDzw+gNy9ilcWEVS7Gj5yh2JzKwQM8I5hQI=; b=NA/0LKA90yiDCu2s7aMsuzUfS5u2ceTM3zyc+dpW3w85Q9KhgPOvVPhBnG5Mn/waVU kPzaGK5umUgWSkTB9oe80Jb7d0D2Q3Ni29HGyx0gkhN/20I6nF/I1FfF2veUYGhJl8ar NN5sHVUbxUsbNn+Acqo2w9UiQB7KN1r8tfW7D5AAfl2hxKBXCfqtmfJo/45GDTI91kEQ XnVRrWjIlFQAyRpAWdcoBJDQrF/7LbPdkfa39bx3xRYe48JoC9anIAD/7kELRyaYZFFl OCwgkVRftzG7fwEH9w+rlr5+vmqHSRE5RSQ7Ro3aDb0wtifG0XaeOPzA6iKrfHd5ghbO IC/Q== 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=Qo+iUt84EDzw+gNy9ilcWEVS7Gj5yh2JzKwQM8I5hQI=; b=ZfcV+m7mQX/uy/z/k7zCFtg9IhKgnhZLsSjnd7QmwH4uW/AuoXS1rKziKX+Lvai9OD 6sSIeP5XXl28evCB3HlBEky06I9rB0NEyTl3cUrETFRzWAFS0w8hw/adq+9Jiu3hpcqn OaX93lp8YyA4mJlnoZ+5kkAMukS333p4A3WOFwILmEYwn56XJS0GvBdOhRMr2eIHW48+ ZbZ6KLh36chnuDdVdpsTJR7vX2DN7TbLAANIn3DBobmM5Z7hk500+AQNvZ17+gaW8PBu ndDWS1+NcK8C6KsIx+LmQr9+O/rPMqz8f9/NTPO8II+Xhg4+JMQo1NcQ/hpIwkHZrx5U j10Q== X-Gm-Message-State: APjAAAU7ES8q0dOh+srguuWGvBp+VfJonxSSPdr+3yaPjShOWU55MXQq tOHTmcD9ScZ7Aykqqmj7/FXk8Eom X-Google-Smtp-Source: APXvYqzeMdTJyo3i06ON4MriP/gJlOB0qpzKO09yhouE5cys4Mvv+ytrNrwl9/xhZgTbG1pDt6i3gA== X-Received: by 2002:adf:dc86:: with SMTP id r6mr11651683wrj.68.1579705201662; Wed, 22 Jan 2020 07:00:01 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id t81sm4452092wmg.6.2020.01.22.07.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 07:00:01 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Jan 2020 15:52:08 +0100 Message-Id: <20200122145210.6898-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200122145210.6898-1-andreas.rheinhardt@gmail.com> References: <20200122145210.6898-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] avfilter/vf_paletteuse: Fix left shift outside of range of int 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" by keeping the variable uint32_t which in this situation is the natural type anyway. This affected the FATE-test filter-paletteuse-sierra2_4a. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_paletteuse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index ed128813d6..c9603601aa 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -158,9 +158,10 @@ static int query_formats(AVFilterContext *ctx) return 0; } -static av_always_inline int dither_color(uint32_t px, int er, int eg, int eb, int scale, int shift) +static av_always_inline uint32_t dither_color(uint32_t px, int er, int eg, + int eb, int scale, int shift) { - return av_clip_uint8( px >> 24 ) << 24 + return px >> 24 << 24 | av_clip_uint8((px >> 16 & 0xff) + ((er * scale) / (1<> 8 & 0xff) + ((eg * scale) / (1< X-Patchwork-Id: 17470 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 4F05744B987 for ; Wed, 22 Jan 2020 17:00:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3002368B31F; Wed, 22 Jan 2020 17:00:10 +0200 (EET) 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 40BDF68AF71 for ; Wed, 22 Jan 2020 17:00:03 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id q9so7128981wmj.5 for ; Wed, 22 Jan 2020 07:00:03 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fi+hHALQb3RIWtPJVO0AK8IVjszvivhbVjMsn9jr0xI=; b=O1fPryH/7LK7xqcOEeaXE9HkgfEidnLY8rAVJLTEVaUyPtf6ZFgpqcenkKFcTJ0PUi bR9TbnjrUmze7/LBVmTylhlmrM7YAlf0cijAiJh9bk5aVqNuRTDUgl+aYbleQQevlJP0 wkCCDE+02M24SdIv72cdGIxwfkgdqlYG9pkD1CCQZsOAwSoPNZ+N6Lyb9tPvMpwQA6QJ VIGF3dvsw8dKFFsscEGhywNXug+KmmRZDFL/aKQsucQ+09vKYjqiVH7z+iywu+4b22zG Pru8CZD/6BhKj8Pr4+3tEjhaICF/h3Y5CGrqP5sJjN8VQoqTxWmUdydqHGDDtSObQcWq 5C2A== 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=Fi+hHALQb3RIWtPJVO0AK8IVjszvivhbVjMsn9jr0xI=; b=F8lU9+hYOWCRUybIJmBvx03RjVNr/kYS94iTgxJT76c+kv04jOfNou7RvcFHhLQ585 crNb3HKjdckv/a2Pxm2KBexSyNEAcbebGp+iHGLmQ58xceUpIa9QUDS6qoNRsjMKRGne qiSrtoXPx2AUaX6cZ2PADrSxTSV9p8dANen4e0+CVKXAGrC0M5SKOCnWdVlEsMk8tL8g gFoOXS+GXAKrYvSn6/llzON2l7i2tt1juxXpRmuToAz+5mzAAlTAbbAVJ3KhfnE9pnac kgc7ELe9rJGo/feRm3/vs2mezFWBxqmXZpyUqDtiyH5IDfSBe5QTTgS5DlKiel/pldMq IlIw== X-Gm-Message-State: APjAAAWIrUdgetWVs/CHZOmDb1uFB/GdPpAcSPmVUMmA6EoDFWbtc1Tr 6gcdmuJ+qg94758tNK87mqYpYol+ X-Google-Smtp-Source: APXvYqxLgO7RGipD9PbgGdZV8LYyOXTLVzsbptO1J6O6YTppEmezNoHqFH1l22XYoVNrZRQL+2eY6w== X-Received: by 2002:a1c:a584:: with SMTP id o126mr3280701wme.163.1579705202604; Wed, 22 Jan 2020 07:00:02 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id t81sm4452092wmg.6.2020.01.22.07.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 07:00:02 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Jan 2020 15:52:09 +0100 Message-Id: <20200122145210.6898-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200122145210.6898-1-andreas.rheinhardt@gmail.com> References: <20200122145210.6898-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] avfilter/asrc_sine: 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" by using a multiplication instead. The multiplication can never overflow an int because the sin-factor is only an int16_t. Affected the FATE-tests filter-concat and filter-concat-vfr. Signed-off-by: Andreas Rheinhardt --- libavfilter/asrc_sine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/asrc_sine.c b/libavfilter/asrc_sine.c index 3a87210b4b..61499ee2cd 100644 --- a/libavfilter/asrc_sine.c +++ b/libavfilter/asrc_sine.c @@ -247,7 +247,7 @@ static int request_frame(AVFilterLink *outlink) samples[i] = sine->sin[sine->phi >> (32 - LOG_PERIOD)]; sine->phi += sine->dphi; if (sine->beep_index < sine->beep_length) { - samples[i] += sine->sin[sine->phi_beep >> (32 - LOG_PERIOD)] << 1; + samples[i] += sine->sin[sine->phi_beep >> (32 - LOG_PERIOD)] * 2; sine->phi_beep += sine->dphi_beep; } if (++sine->beep_index == sine->beep_period) From patchwork Wed Jan 22 14:52:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17471 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 2619544B987 for ; Wed, 22 Jan 2020 17:00:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0C8EF68B361; Wed, 22 Jan 2020 17:00:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26A4868AF71 for ; Wed, 22 Jan 2020 17:00:04 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id 20so7506643wmj.4 for ; Wed, 22 Jan 2020 07:00:04 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ElRvesYQrOMc2uNDYUPueAm6ACnP8eXtt4ftLvTk0N4=; b=hd2Xu9ijKRf32H5daYCxxXWI8KVEpv0VQk92DbROlvfDim4PVv68+dlzdUcg2FaOJm K4d/+sLZ+3Cl4SjPx5FstgmKx2Ts8dMFprVlFcRKOtCOaZ6iWBNebJy5qezP/tT+aP3X taFbtGIWxRyh8Q9Jg6jl9M1PyE2EvlsPtPRfLuuylDoOMqjdbLkPD3COfkr+l238AYIC NMfSfBDiGMgij/QVxCZL24PQcyBK7eIUwqawUmNovKJqn0Qk3wlnTuXv1CcbLyGg1SE2 ZMbaPQslSIebI0Sz0uM8FLY9T+YhzvkJSx2ZFrxhDVFiIGUtFlMoNrcDtvP5byiuIIaD FRIA== 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=ElRvesYQrOMc2uNDYUPueAm6ACnP8eXtt4ftLvTk0N4=; b=r5ML/d4DyJhYYcqhqyWod8u6N9YtDfFk0oNceqkJc+0wSlSGEKztqZYMfOMK/ioeam o3GlPqbkKV9qHQrrFwTxGxGCb+QAlyu67tCLLy0fWzuq87UvM+HqrT0B6u1XOVn7v0T4 BXpZ101izja1SYxtpgKaDjDalo1ZARUtrNXAc0bPEWmeVYy5UJ97kHWNdcRipoM3JDnP vEhmqPnltcgGOirCtugpeOr6MJhs5nsc2NAgu4DTuuT8WYAAavIAuAyTkjVsFM9pIlLU GHXDA6roDzh3hTZd/dslbfaGO5zPPs0B1If7rwf2Zm96w3dV49zyCLVGhmGo++BIkYYz q6ZA== X-Gm-Message-State: APjAAAWXa7e6ZmV7O4d2sD1lzSEIGjPKuVWJgpUm5bpizvy2EK6oIYv4 xtVcQ2YxX7d1PFXLB8WvctwTUJda X-Google-Smtp-Source: APXvYqwJ1l8Dp3jNcEF5C7GSwph3yD+HKtfn1G+NI8UEXUj8ve9tPfxQpYGMf4xzKmyJKOTu3kzGCg== X-Received: by 2002:a05:600c:211:: with SMTP id 17mr3401052wmi.60.1579705203524; Wed, 22 Jan 2020 07:00:03 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id t81sm4452092wmg.6.2020.01.22.07.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 07:00:03 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Jan 2020 15:52:10 +0100 Message-Id: <20200122145210.6898-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200122145210.6898-1-andreas.rheinhardt@gmail.com> References: <20200122145210.6898-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/ra144enc: 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" by replacing it with a multiplication. Said multiplication can't overflow an int32_t because lpc_coefs is limited to 16 bit precision. Fixes the FACE-test acodec-ra144 as well as part of #8217. Signed-off-by: Andreas Rheinhardt --- I am unable to reproduce the division by zero mentioned in ticket #8217; probably just an error on the reporter's part. libavcodec/ra144enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index cc4f381606..059f582334 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -477,8 +477,8 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, LPC_ORDER, 16, lpc_coefs, shift, FF_LPC_TYPE_LEVINSON, 0, ORDER_METHOD_EST, 0, 12, 0); for (i = 0; i < LPC_ORDER; i++) - block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] << - (12 - shift[LPC_ORDER - 1])); + block_coefs[NBLOCKS - 1][i] = -lpc_coefs[LPC_ORDER - 1][i] + * (1 << (12 - shift[LPC_ORDER - 1])); /** * TODO: apply perceptual weighting of the input speech through bandwidth