[FFmpeg-devel] lavc/pcm-bluray: Do not use incompatible pointers on big-endian.

Submitted by Carl Eugen Hoyos on Nov. 1, 2017, 6:01 p.m.

Details

Message ID CAB0OVGqbNsW_WbjEjJtH4cp7Uu=QWEW5Hv=tCmDnUkrooBJmAQ@mail.gmail.com
State New
Headers show

Commit Message

Carl Eugen Hoyos Nov. 1, 2017, 6:01 p.m.
2017-11-01 18:31 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
> On Wed, Nov 1, 2017 at 6:25 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> 2017-11-01 18:16 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
>>> On Wed, Nov 1, 2017 at 5:16 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>> Hi!
>>>>
>>>> Attached patch silences two gcc warnings, no sample for odd channel count found.
>>>>
>>>>  #if HAVE_BIGENDIAN
>>>> -                    bytestream2_get_buffer(&gb, dst16, avctx->channels * 2);
>>>> -                    dst16 += avctx->channels;
>>>> +                    uint8_t *dst = frame->data[0];
>>>> +                    bytestream2_get_buffer(&gb, frame->data[0], avctx->channels * 2);
>>>> +                    dst += avctx->channels * 2;
>>>>  #else
>>>>                      channel = avctx->channels;
>>>>                      do {
>>>
>>> This hunk seems fishy. dst is only ever set, never read, and this code
>>> is executed in a loop but always writes to the same position.
>>
>> I had sent the wrong version, please review this one.
>
> That still won't work, dst is declared within the loop, so its reset
> back to the start at the beginning of the frame each iteration.

New try attached.

Thank you, Carl Eugen

Comments

Carl Eugen Hoyos Nov. 4, 2017, 7:33 p.m.
2017-11-01 19:01 GMT+01:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> 2017-11-01 18:31 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
>> On Wed, Nov 1, 2017 at 6:25 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>> 2017-11-01 18:16 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
>>>> On Wed, Nov 1, 2017 at 5:16 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>>> Hi!
>>>>>
>>>>> Attached patch silences two gcc warnings, no sample for odd channel count found.
>>>>>
>>>>>  #if HAVE_BIGENDIAN
>>>>> -                    bytestream2_get_buffer(&gb, dst16, avctx->channels * 2);
>>>>> -                    dst16 += avctx->channels;
>>>>> +                    uint8_t *dst = frame->data[0];
>>>>> +                    bytestream2_get_buffer(&gb, frame->data[0], avctx->channels * 2);
>>>>> +                    dst += avctx->channels * 2;
>>>>>  #else
>>>>>                      channel = avctx->channels;
>>>>>                      do {
>>>>
>>>> This hunk seems fishy. dst is only ever set, never read, and this code
>>>> is executed in a loop but always writes to the same position.
>>>
>>> I had sent the wrong version, please review this one.
>>
>> That still won't work, dst is declared within the loop, so its reset
>> back to the start at the beginning of the frame each iteration.
>
> New try attached.

Ping.

Thank you, Carl Eugen
Hendrik Leppkes Nov. 6, 2017, 10:56 a.m.
On Wed, Nov 1, 2017 at 7:01 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2017-11-01 18:31 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
>> On Wed, Nov 1, 2017 at 6:25 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>> 2017-11-01 18:16 GMT+01:00 Hendrik Leppkes <h.leppkes@gmail.com>:
>>>> On Wed, Nov 1, 2017 at 5:16 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>>> Hi!
>>>>>
>>>>> Attached patch silences two gcc warnings, no sample for odd channel count found.
>>>>>
>>>>>  #if HAVE_BIGENDIAN
>>>>> -                    bytestream2_get_buffer(&gb, dst16, avctx->channels * 2);
>>>>> -                    dst16 += avctx->channels;
>>>>> +                    uint8_t *dst = frame->data[0];
>>>>> +                    bytestream2_get_buffer(&gb, frame->data[0], avctx->channels * 2);
>>>>> +                    dst += avctx->channels * 2;
>>>>>  #else
>>>>>                      channel = avctx->channels;
>>>>>                      do {
>>>>
>>>> This hunk seems fishy. dst is only ever set, never read, and this code
>>>> is executed in a loop but always writes to the same position.
>>>
>>> I had sent the wrong version, please review this one.
>>
>> That still won't work, dst is declared within the loop, so its reset
>> back to the start at the beginning of the frame each iteration.
>
> New try attached.
>

The indentation of the variable declaration seems off. Shouldn't it be
on the level of the do?
Otherwise it should probably work fine.

Wouldn't it be easier to cast the type, though? Just wondering, not
blocking the patch.

- Hendrik

Patch hide | download patch | download mbox

From 37cdd3738a68090330611e4f5aa666f8213b5a95 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Wed, 1 Nov 2017 18:59:26 +0100
Subject: [PATCH] lavc/pcm-bluray: Do not use incompatible pointers on
 big-endian.

Fixes the following gcc warnings:
libavcodec/pcm-bluray.c:172:45: warning: passing argument 2 of 'bytestream2_get_buffer' from incompatible pointer type
libavcodec/pcm-bluray.c:192:49: warning: passing argument 2 of 'bytestream2_get_buffer' from incompatible pointer type
---
 libavcodec/pcm-bluray.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/pcm-bluray.c b/libavcodec/pcm-bluray.c
index 517d7b5..91bcfb1 100644
--- a/libavcodec/pcm-bluray.c
+++ b/libavcodec/pcm-bluray.c
@@ -169,7 +169,7 @@  static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
             samples *= num_source_channels;
             if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
 #if HAVE_BIGENDIAN
-                bytestream2_get_buffer(&gb, dst16, buf_size);
+                bytestream2_get_buffer(&gb, frame->data[0], buf_size);
 #else
                 do {
                     *dst16++ = bytestream2_get_be16u(&gb);
@@ -187,10 +187,11 @@  static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
         case AV_CH_LAYOUT_2_1:
         case AV_CH_LAYOUT_5POINT0:
             if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
+                    uint8_t av_unused *dst = frame->data[0];
                 do {
 #if HAVE_BIGENDIAN
-                    bytestream2_get_buffer(&gb, dst16, avctx->channels * 2);
-                    dst16 += avctx->channels;
+                    bytestream2_get_buffer(&gb, dst, avctx->channels * 2);
+                    dst += avctx->channels * 2;
 #else
                     channel = avctx->channels;
                     do {
-- 
1.7.10.4