[libav-devel] [PATCH] bitstream: Add bitstream_apply_sign() helper function
Vittorio Giovara
vittorio.giovara at gmail.com
Thu Jun 23 16:53:31 CEST 2016
On Thu, Jun 23, 2016 at 9:54 AM, Diego Biurrun <diego at biurrun.de> wrote:
> This reads a sign bit from the bitstream and flips the sign of the
> provided value accordingly.
> ---
>
> .. as suggested by Anton ..
>
> libavcodec/bitstream.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
> index 539b721..180bf66 100644
> --- a/libavcodec/bitstream.h
> +++ b/libavcodec/bitstream.h
> @@ -377,4 +377,11 @@ static inline int bitstream_decode210(BitstreamContext *bc)
> return 2 - bitstream_read_bit(bc);
> }
>
> +/* Read sign bit and flip the sign of the provided value accordingly. */
> +static inline int bitstream_apply_sign(BitstreamContext *bc, int val)
> +{
> + int sign = bitstream_read_signed(bc, 1);
> + return (val ^ sign) - sign;
> +}
> +
> #endif /* AVCODEC_BITSTREAM_H */
> --
yes, lgtm
--
Vittorio
More information about the libav-devel
mailing list