[FFmpeg-devel] [PATCH 1/3] avcodec/get_bits: add cached bitstream reader
Paul B Mahol
onemda at gmail.com
Fri Jul 7 23:43:35 EEST 2017
On 7/7/17, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> Hi,
>
> On Fri, Jul 7, 2017 at 2:48 PM, Paul B Mahol <onemda at gmail.com> wrote:
>
>> typedef struct GetBitContext {
>> const uint8_t *buffer, *buffer_end;
>> +#ifdef CACHED_BITSTREAM_READER
>> + uint64_t cache;
>> + unsigned bits_left;
>> +#endif
>>
>
> Can you post some stats (from relevant systems, ideally, e.g. 32-bit binary
> on x86, or 32-bit arm) on how a 32bit cache performs compared to a 64bit
> cache on systems with HAVE_FAST_64BIT=0?
I can only post results from 64bit x86 with gcc 6.2.0.
>
>
>> +static inline void refill_32(GetBitContext *s)
>>
> [..]
>
>> +#ifdef BITSTREAM_READER_LE
>> + s->cache = (uint64_t)AV_RL32(s->buffer + (s->index >> 3)) <<
>> s->cache | s->cache;
>>
>
> As said on IRC: middle s->cache should be s->bits_left.
>
> Overall very nice improvement, I would in particular not be surprised if
> this is generally faster for almost all users, except those using the
> lower-level macros (things like SHOW_BITS() etc.) in the old interface. If
> that's true, it may be positive to enable this by default and disable only
> for those using the low-level interface.
>
> (I'm assuming the low-level interface no longer works with the cached
> reader, so can we prevent users from accessing these macros unless
> cached=1?)
They are not supposed to work, Do you mean to not define such macros
if cached is defined?
More information about the ffmpeg-devel
mailing list