diff mbox

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

Message ID CAB0OVGpHPW1cF9EYGULwZmjo9f7cUiYniTHVfdMMgASfiDhpBw@mail.gmail.com
State Superseded
Headers show

Commit Message

Carl Eugen Hoyos Nov. 1, 2017, 4:13 p.m. UTC
Hi!

Attached patch silences a gcc warning, tested with Fever.vob

Please comment, Carl Eugen

Comments

Hendrik Leppkes Nov. 1, 2017, 5:18 p.m. UTC | #1
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.

- Hendrik
diff mbox

Patch

From 3bd16ab2446bd2450bdbf4d333846a9c7ae45c6c Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Wed, 1 Nov 2017 17:10:12 +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 |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 0a751a8..acd9c30 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,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);
-- 
1.7.10.4