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

Paul B Mahol onemda at gmail.com
Mon Dec 17 23:16:23 EET 2018


On 12/17/18, Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
> 2018-12-17 22:02 GMT+01:00, Paul B Mahol <onemda at gmail.com>:
>> On 12/17/18, Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
>>> 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.
>>
>> It does, Are you author of this patch?
>
> This is a poc to show that there is a possible (although
> ugly) alternative to the - imo - unavoidable cast that I
> attached as a git-formatted patch.

Yes, it is poc - patch of crap.


More information about the ffmpeg-devel mailing list