diff mbox

[FFmpeg-devel,00/17] Various undefined behaviour fixes

Message ID 0f494063-0134-9d26-f5eb-07f3661a63a8@gmail.com
State Accepted
Commit 659a925939011338cac1ab3c21d58d4b077fc926
Headers show

Commit Message

Andreas Rheinhardt March 27, 2021, 1:31 a.m. UTC
Hello,

attached patches fix several instances of undefined behaviour
encountered when running the FATE suite.

- Andreas
Subject: [PATCH 01/17] avcodec/dcaenc: Fix undefined left shift of negative
 numbers

Affected the acodec-dca and acodec-dca2 FATE tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/dcaenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andreas Rheinhardt March 31, 2021, 7:30 p.m. UTC | #1
On Sat, Mar 27, 2021 at 2:31 AM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> Hello,
>
> attached patches fix several instances of undefined behaviour
> encountered when running the FATE suite.
>
> - Andreas
>
> Will apply this patchset tomorrow (without the FF_PTR_ADD macro; the
patches that depend upon it will be applied when the macro has been
applied) unless there are objections.

- Andreas
diff mbox

Patch

diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index a40d2e0ca0..87fb5f5457 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -925,10 +925,10 @@  static void fill_in_adpcm_bufer(DCAEncContext *c)
              * But there are no proper value in decoder history, so likely result will be no good.
              * Bitstream has "Predictor history flag switch", but this flag disables history for all subbands
              */
-            samples[0] = c->adpcm_history[ch][band][0] << 7;
-            samples[1] = c->adpcm_history[ch][band][1] << 7;
-            samples[2] = c->adpcm_history[ch][band][2] << 7;
-            samples[3] = c->adpcm_history[ch][band][3] << 7;
+            samples[0] = c->adpcm_history[ch][band][0] * (1 << 7);
+            samples[1] = c->adpcm_history[ch][band][1] * (1 << 7);
+            samples[2] = c->adpcm_history[ch][band][2] * (1 << 7);
+            samples[3] = c->adpcm_history[ch][band][3] * (1 << 7);
         }
      }
 }