[FFmpeg-devel] [PATCH] new function get_sbits_long()

Måns Rullgård mans
Mon Mar 2 20:47:39 CET 2009


Justin Ruggles <justin.ruggles at gmail.com> writes:

> Michael Niedermayer wrote:
>> On Mon, Mar 02, 2009 at 12:39:05PM -0500, Justin Ruggles wrote:
>>> Hi,
>>>
>>> I need a get_sbits_long() function to support FLAC files that are more
>>> than 24-bit.  There might be a better way to do it, but this works.
>> 
>> only where int is 32bit which isnt guranteed even if likely
>
> Is this better or am I missing the point?
>
> -Justin
>
>
> Index: libavcodec/bitstream.h
> ===================================================================
> --- libavcodec/bitstream.h	(revision 17735)
> +++ libavcodec/bitstream.h	(working copy)
> @@ -707,6 +707,14 @@
>  }
>  
>  /**
> + * reads 0-32 bits as a signed integer.
> + */
> +static inline int get_sbits_long(GetBitContext *s, int n) {
> +    int val = get_bits_long(s, n);
> +    return (int32_t)(val << (32-n)) >> (32-n);
> +}

That's also wrong if int is wider than 32 bits.  It's all explained in
one of the threads I linked in another mail.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list