On 12/17/18, Carl Eugen Hoyos <ceffm...@gmail.com> wrote: > 2018-12-17 22:02 GMT+01:00, Paul B Mahol <one...@gmail.com>: >> On 12/17/18, Carl Eugen Hoyos <ceffm...@gmail.com> wrote: >>> 2018-12-17 21:35 GMT+01:00, Rostislav Pehlivanov <atomnu...@gmail.com>: >>>> On Mon, 17 Dec 2018 at 01:47, Carl Eugen Hoyos <ceffm...@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. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel