[FFmpeg-devel] lavc/pcm-dvd: Do not use an incompatible pointer on big-endian.

Submitted by Carl Eugen Hoyos on Nov. 6, 2017, 12:57 p.m.

Details

Message ID CAB0OVGrD7zc+k8mPk9yAokhfu+SD0p8TqiNYKzNWibz5UuB6wA@mail.gmail.com
State New
Headers show

Commit Message

Carl Eugen Hoyos Nov. 6, 2017, 12:57 p.m.
2017-11-06 11:53 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
> On Wed, Nov 1, 2017 at 6:33 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> 2017-11-01 18:18 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
>>> On Wed, Nov 1, 2017 at 5:13 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>> Hi!
>>>>
>>>> Attached patch silences a gcc warning, tested with Fever.vob
>>>>
>>>>
>>>> @@ -163,10 +162,12 @@ static void *pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src,
>>>>     switch (avctx->bits_per_coded_sample) {
>>>>     case 16: {
>>>> #if HAVE_BIGENDIAN
>>>> +        int8_t *dst16 = dst;
>>>>         bytestream2_get_buffer(&gb, dst16, blocks * s->block_size);
>>>> -        dst16 += blocks * s->block_size / 2;
>>>> +        dst16 += blocks * s->block_size;
>>>> #else
>>>>         int samples = blocks * avctx->channels;
>>>> +        int16_t *dst16 = dst;
>>>>         do {
>>>>             *dst16++ = bytestream2_get_be16u(&gb);
>>>>         } while (--samples);
>>>
>>> This results in quite misleading code. dst16 is named like that
>>> because its a 16-bit pointer, using the same pointer with different
>>> types based on this ifdef seems error-prone in the future.
>>
>> Agree, new patch attached.
>
> I think you attached the wrong patch, this is an old version of the
> pcm-bluray patch.

New try attached.

Thank you, Carl Eugen

Patch hide | download patch | download mbox

From 244eb73d55e4f1eb85d1f8bcf8f12542d0e57537 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Wed, 1 Nov 2017 18:31:29 +0100
Subject: [PATCH] lavc/pcm-dvd: Do not use an incompatible pointer on
 big-endian.

Fixes the following gcc warning:
libavcodec/pcm-dvd.c:166:37: warning: passing argument 2 of 'bytestream2_get_buffer' from incompatible pointer type
---
 libavcodec/pcm-dvd.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 0a751a8..329b555 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -153,7 +153,6 @@  static void *pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src,
                                     void *dst, int blocks)
 {
     PCMDVDContext *s = avctx->priv_data;
-    int16_t *dst16   = dst;
     int32_t *dst32   = dst;
     GetByteContext gb;
     int i;
@@ -163,15 +162,17 @@  static void *pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src,
     switch (avctx->bits_per_coded_sample) {
     case 16: {
 #if HAVE_BIGENDIAN
-        bytestream2_get_buffer(&gb, dst16, blocks * s->block_size);
-        dst16 += blocks * s->block_size / 2;
+        int8_t *dst8 = dst;
+        bytestream2_get_buffer(&gb, dst8, blocks * s->block_size);
+        return dst8 + blocks * s->block_size;
 #else
         int samples = blocks * avctx->channels;
+        int16_t *dst16 = dst;
         do {
             *dst16++ = bytestream2_get_be16u(&gb);
         } while (--samples);
-#endif
         return dst16;
+#endif
     }
     case 20:
         if (avctx->channels == 1) {
-- 
1.7.10.4