[FFmpeg-devel,06/11] avcodec/pcm: Fix undefined shifts

Submitted by Andreas Rheinhardt on Sept. 19, 2019, 10:17 p.m.

Details

Message ID 20190919221706.16529-7-andreas.rheinhardt@gmail.com
State Accepted
Commit 69473bec6f38fefc9a433d95f8e00de101299592
Headers show

Commit Message

Andreas Rheinhardt Sept. 19, 2019, 10:17 p.m.
Fixes the acodec-pcm-u16[lb]e FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Changing the macro for planar decoding is actually unnecessary, as none
of the currently used users of this macro need it. I have nevertheless
done so to minimise the changes between the macros.

 libavcodec/pcm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paul B Mahol Sept. 26, 2019, 12:19 p.m.
applied

On 9/20/19, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> Fixes the acodec-pcm-u16[lb]e FATE-tests.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> Changing the macro for planar decoding is actually unnecessary, as none
> of the currently used users of this macro need it. I have nevertheless
> done so to minimise the changes between the macros.
>
>  libavcodec/pcm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
> index ffcbccc77d..d9176732d9 100644
> --- a/libavcodec/pcm.c
> +++ b/libavcodec/pcm.c
> @@ -303,7 +303,7 @@ static av_cold int pcm_decode_close(AVCodecContext
> *avctx)
>  #define DECODE(size, endian, src, dst, n, shift, offset)                \
>      for (; n > 0; n--) {                                                \
>          uint ## size ## _t v = bytestream_get_ ## endian(&src);         \
> -        AV_WN ## size ## A(dst, (v - offset) << shift);                 \
> +        AV_WN ## size ## A(dst, (uint ## size ## _t)(v - offset) << shift);
> \
>          dst += size / 8;                                                \
>      }
>
> @@ -314,7 +314,7 @@ static av_cold int pcm_decode_close(AVCodecContext
> *avctx)
>          dst = frame->extended_data[c];                                \
>          for (i = n; i > 0; i--) {                                       \
>              uint ## size ## _t v = bytestream_get_ ## endian(&src);     \
> -            AV_WN ## size ## A(dst, (v - offset) << shift);             \
> +            AV_WN ## size ## A(dst, (uint ## size ##_t)(v - offset) <<
> shift); \
>              dst += size / 8;                                            \
>          }                                                               \
>      }
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index ffcbccc77d..d9176732d9 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -303,7 +303,7 @@  static av_cold int pcm_decode_close(AVCodecContext *avctx)
 #define DECODE(size, endian, src, dst, n, shift, offset)                \
     for (; n > 0; n--) {                                                \
         uint ## size ## _t v = bytestream_get_ ## endian(&src);         \
-        AV_WN ## size ## A(dst, (v - offset) << shift);                 \
+        AV_WN ## size ## A(dst, (uint ## size ## _t)(v - offset) << shift); \
         dst += size / 8;                                                \
     }
 
@@ -314,7 +314,7 @@  static av_cold int pcm_decode_close(AVCodecContext *avctx)
         dst = frame->extended_data[c];                                \
         for (i = n; i > 0; i--) {                                       \
             uint ## size ## _t v = bytestream_get_ ## endian(&src);     \
-            AV_WN ## size ## A(dst, (v - offset) << shift);             \
+            AV_WN ## size ## A(dst, (uint ## size ##_t)(v - offset) << shift); \
             dst += size / 8;                                            \
         }                                                               \
     }