diff mbox series

[FFmpeg-devel,4/4] avcodec/ra144enc: Fix invalid left shift of negative number

Message ID 20200122145210.6898-4-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avcodec/startcode: Use AV_RN due to UBSan warning about unaligned access
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt Jan. 22, 2020, 2:52 p.m. UTC
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 <andreas.rheinhardt@gmail.com>
---
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(-)

Comments

Michael Niedermayer Jan. 23, 2020, 11:21 a.m. UTC | #1
On Wed, Jan 22, 2020 at 03:52:10PM +0100, Andreas Rheinhardt wrote:
> 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 <andreas.rheinhardt@gmail.com>
> ---
> 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(-)

will apply

thx

[...]
diff mbox series

Patch

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