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

Rostislav Pehlivanov atomnuker at gmail.com
Mon Dec 17 22:35:30 EET 2018


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().
>
> Please comment, Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


NAK, we don't do anyonymous unions. To silence the warning the const can be
just removed, but I've never seen a single warning on platforms I've tried.


More information about the ffmpeg-devel mailing list