[FFmpeg-devel] [PATCH]lavc/opus_rc: Case a const pointer to uint8_t *

Carl Eugen Hoyos ceffmpeg at gmail.com
Mon Dec 17 22:55:58 EET 2018


2018-12-17 21:53 GMT+01:00, Carl Eugen Hoyos <ceffmpeg at gmail.com>:
> 2018-12-17 21:35 GMT+01:00, Rostislav Pehlivanov <atomnuker at gmail.com>:
>> On Mon, 17 Dec 2018 at 01:47, Carl Eugen Hoyos <ceffmpeg at gmail.com>
>> wrote:
>>
>>> Hi!
>>>
>>> The Opus struct RawBitsContext is used in both the decoder and the
>>> encoder.
>>> The fact that *position is const avoids warnings in the decoder where
>>> it points into the bitstream. The encoder writes into the same
>>> pointer, attached cast silences the warning on targets where AV_WB32()
>>> does not internally cast the qualifier away.
>>>
>>> It is also possible to use a union if anybody prefers this:
>>> diff --git a/libavcodec/opus_rc.h b/libavcodec/opus_rc.h
>>> index 627f832..baad4ce 100644
>>> --- a/libavcodec/opus_rc.h
>>> +++ b/libavcodec/opus_rc.h
>>> @@ -37,9 +37,19 @@ typedef struct RawBitsContext {
>>>      uint32_t cacheval;
>>>  } RawBitsContext;
>>>
>>> +typedef struct RawBitsEncContext {
>>> +    uint8_t *position;
>>> +    uint32_t bytes;
>>> +    uint32_t cachelen;
>>> +    uint32_t cacheval;
>>> +} RawBitsEncContext;
>>> +
>>>  typedef struct OpusRangeCoder {
>>>      GetBitContext gb;
>>> -    RawBitsContext rb;
>>> +    union {
>>> +        RawBitsContext rb;
>>> +        RawBitsEncContext rbe;
>>> +    };
>>>      uint32_t range;
>>>      uint32_t value;
>>>      uint32_t total_bits;
>>>
>>> and use rbe in ff_opus_rc_put_raw().
>
>> NAK, we don't do anyonymous unions.
>
> The suggested patch does not contain unions.
>
>> To silence the warning the const can be
>> just removed,
>
> No, the original data comes from a const pointer.

...when decoding.

>> but I've never seen a single warning on platforms I've tried.
>
> It is shown on platforms where an optimized function (instead
> of the default macro) for AV_RW32() exists, for example Android arm.

Carl Eugen


More information about the ffmpeg-devel mailing list