diff mbox series

[FFmpeg-devel,2/3] avcodec/pcm-dvdenc: Fix encoding 24bit samples

Message ID DB6PR0101MB22148D9158D9C631479D8F178F849@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit d0b050562a140f8cc89905815403edc7ddf8cb36
Headers show
Series [FFmpeg-devel,1/3] avcodec/pcm-dvdenc: Remove unused extra_sample(s|_count) | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 10, 2022, 1:45 p.m. UTC
The earlier code ignored the lower 16 bits and instead used
the highest 8 bits twice.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/pcm-dvdenc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c
index c7f1d46ba3..0881697c17 100644
--- a/libavcodec/pcm-dvdenc.c
+++ b/libavcodec/pcm-dvdenc.c
@@ -146,8 +146,8 @@  static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                 for (int i = 2; i; i--) {
                     bytestream2_put_be16(&pb, src32[0] >> 16);
                     bytestream2_put_be16(&pb, src32[1] >> 16);
-                    bytestream2_put_byte(&pb, (*src32++) >> 24);
-                    bytestream2_put_byte(&pb, (*src32++) >> 24);
+                    bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
+                    bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
                 }
             } while (--blocks);
         } else {
@@ -157,10 +157,10 @@  static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                     bytestream2_put_be16(&pb, src32[1] >> 16);
                     bytestream2_put_be16(&pb, src32[2] >> 16);
                     bytestream2_put_be16(&pb, src32[3] >> 16);
-                    bytestream2_put_byte(&pb, (*src32++) >> 24);
-                    bytestream2_put_byte(&pb, (*src32++) >> 24);
-                    bytestream2_put_byte(&pb, (*src32++) >> 24);
-                    bytestream2_put_byte(&pb, (*src32++) >> 24);
+                    bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
+                    bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
+                    bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
+                    bytestream2_put_byte(&pb, (uint8_t)((*src32++) >> 8));
                 }
             } while (--blocks);
         }