Commit Graph

43 Commits

Author SHA1 Message Date
Ronald S. Bultje
9918f57dcf get_bits: Return pointer to buffer that is the result of the alignment
This allows more transparent mixing of get_bits and whole-byte access
without having to touch get_bits internals.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-02-19 22:33:52 +02:00
Diego Biurrun
4af5310d29 get_bits/put_bits: K&R formatting cosmetics
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2013-01-21 17:03:41 +01:00
Luca Barbato
4603ec85ed get_bits: change the failure condition in init_get_bits
Too much code relies in having init_get_bits fed with a valid
buffer and set its dimension to 0.

Check for NULL buffer instead.
2013-01-20 13:37:56 +01:00
Luca Barbato
e28ac6e5e2 lavc: introduce the convenience function init_get_bits8
Accept the buffer size in bytes and check for overflow before passing
the value in bits to init_get_bits.
2013-01-14 04:49:14 +01:00
Luca Barbato
d9cf5f5169 lavc: check for overflow in init_get_bits
Fix an undefined behaviour and make the function return a proper
error in case of overflow.

CC: libav-stable@libav.org
2013-01-14 04:49:14 +01:00
Michael Niedermayer
41540b36a1 bitstream: add get_bits64() to support reading more than 32 bits at once
Also remove a duplicate function in the MPEG-TS demuxer.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
2012-12-07 16:15:02 -05:00
Diego Biurrun
e00215040a get_bits: const correctness for get_bits_trace()/get_xbits_trace() arguments 2012-09-27 19:10:10 +02:00
Ronald S. Bultje
b44b41633f get_bits: add HAVE_BITS_REMAINING macro. 2012-02-24 07:28:14 -08:00
Martin Storsjö
e96b4a53df vlc/rl: Add ff_ prefix to the nonstatic symbols
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-02-15 22:06:26 +02:00
Diego Biurrun
aaf47bcde7 Drop ALT_ prefix from BITSTREAM_READER_LE name.
The prefix is a historic remnant that probably meant "alternative".
Now that the A32 bitstream reader has been dropped it makes no sense anymore.
2011-12-22 16:51:23 +01:00
Mans Rullgard
86a10281c7 get_bits: remove LAST_SKIP_CACHE macro
This macro is empty since the removal of the A32 bitstream reader.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-12-17 20:04:28 +00:00
Mans Rullgard
5d8122db5c get_bits: remove strange/obsolete comments
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-12-17 18:36:20 +00:00
Mans Rullgard
e42bb0ee01 get_bits: whitespace (mostly) cosmetics
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-12-17 18:36:20 +00:00
Mans Rullgard
adb28c49bd get_bits: remove unnecessary #includes
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-12-17 17:53:57 +00:00
Ronald S. Bultje
8cfbbd928c get_bits: introduce safe bitreading to prevent overreads.
When turned on, H264/CAVLC gets ~15% (CVPCMNL1_SVA_C.264) slower for
ultra-high-bitrate files, or ~2.5% (CVFI1_SVA_C.264) for lower-bitrate
files. Other codecs are affected to a lesser extent because they are
less optimized; e.g., VC-1 slows down by less than 1% (all on x86).
The patch generated 3 extra instructions (cmp, cmovae and mov) per
call to get_bits().

The performance penalty on ARM is within the error margin for most
files, up to 4% in extreme cases such as CVPCMNL1_SVA_C.264.

Based on work (for GCI) by Aneesh Dogra <lionaneesh@gmail.com>, and
inspired by patch in Chromium by Chris Evans <cevans@chromium.org>.
2011-12-17 14:03:41 +00:00
Mans Rullgard
a1e98f198e get_bits: remove A32 variant
The A32 bitstream reader variant is only used on ARMv5 and for
Prores due to the larger bit cache this decoder requires.

In benchmarks on ARMv5 (Marvell Sheeva) with gcc 4.6, the only
statistically significant difference between ALT and A32 is
a 4% advantage for ALT in FLAC decoding.  There is thus no (longer)
any reason to keep the A32 reader from this point of view.

This patch adds an option to the ALT reader increasing the bit
cache to 32 bits as required by the Prores decoder.  Benchmarking
shows no significant change in speed on Intel i7.  Again, the
A32 reader fails to justify its existence.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-12-16 21:21:48 +00:00
Mans Rullgard
b8909cb364 get_bits: remove useless pointer casts
These pointers are already of the correct type.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-12-16 15:34:35 +00:00
Diego Biurrun
58c42af722 doxygen: misc consistency, spelling and wording fixes 2011-12-12 23:06:23 +01:00
Mans Rullgard
23ce6e7212 get_bits: remove x86 inline asm in A32 bitstream reader
x86 does not use this variant so having inline asm there
is pointless.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-07-01 22:18:50 +01:00
Diego Biurrun
be73d76b34 cosmetics: fix some then/than typos 2011-06-30 22:56:11 +02:00
Mans Rullgard
e01e05ee66 get_bits: add av_unused tag to cache variable
This silences numerous compiler warnings from skip_bits(),
where the cache variable is not used.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-05-28 17:04:47 +01:00
Alex Converse
47bc52f821 get_bits: make cache unsigned to eliminate undefined signed overflow. 2011-05-03 21:14:39 -07:00
Mans Rullgard
2912e87a6c Replace FFmpeg with Libav in licence headers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-19 13:33:20 +00:00
Mans Rullgard
611a6f59ce get_bits: move tracing macros to end of file
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-23 16:40:53 +00:00
Mans Rullgard
fb5c841d5f Sanitise get_bits macros, part 2
These whitespace changes improve the readability of the get_bits
macros.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-23 13:57:56 +00:00
Mans Rullgard
bf5f9b528b Sanitise get_bits macros, part 1
Some of the macros in get_bits.h include a final semicolon,
some do not.  This removes these or adds do {} while(0) around
the macros as appropriate and adds semicolons where needed in
calling code.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-23 13:57:56 +00:00
Mans Rullgard
938f72e199 Remove "libmpeg2" bitstream reader
Using the libmpeg2 reader causes errors in a multitude of places,
including MPEG and H264 codecs.  As the advantage of this reader
is questionable, removing it seems the sensible course of action,
especially considering the simplifications this allows elsewhere
with the bit cache size increasing from 17 to 25 bits as minimum.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-23 13:57:56 +00:00
Måns Rullgård
8fc0162ac4 Add av_ prefix to bswap macros
Originally committed as revision 24170 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-10 22:12:30 +00:00
Måns Rullgård
e6b22522c9 bswap: change ME to NE in macro names
Other parts of FFmpeg use NE (native endian) rather than ME (machine).
This makes it consistent.

Originally committed as revision 24169 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-10 22:09:01 +00:00
Diego Biurrun
ba87f0801d Remove explicit filename from Doxygen @file commands.
Passing an explicit filename to this command is only necessary if the
documentation in the @file block refers to a file different from the
one the block resides in.

Originally committed as revision 22921 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-04-20 14:45:34 +00:00
Måns Rullgård
39261cd8d9 get/show_bits() can read up to MIN_CACHE_BITS bits
The limit for get/show_bits_long() to use get/show_bits() directly
should be MIN_CACHE_BITS, not 17.

Originally committed as revision 21951 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-21 23:28:24 +00:00
Måns Rullgård
7cd7d19e86 Deobfuscate LE SHOW_[SU]BITS; these are simple sign/zero-extend
Originally committed as revision 21948 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-21 21:48:40 +00:00
Måns Rullgård
5e46be96f8 Move NEG_[US]SR32 macros to mathops.h
Originally committed as revision 21873 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-17 23:58:59 +00:00
Alex Converse
fd10543ef2 get_bits: Fix spelling and grammar in GET_VLC() comment.
Originally committed as revision 21868 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-17 21:20:43 +00:00
Michael Niedermayer
d9ef0d2e14 Mark index as unsigend so gcc knows it doesnt need a sign extension on x86_64.
Any tips on how i can convince gcc that it doesnt need a
mov     %eax, %eax
in every get_bits() ?

Originally committed as revision 21433 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-01-24 19:19:09 +00:00
Laurent Aimar
8880c8bcc3 Added missing const to get_bits_count().
Originally committed as revision 21419 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-01-24 16:22:09 +00:00
Måns Rullgård
1a91f1a0da ARM: use ALT_BITSTREAM_READER on cores with fast unaligned access
Originally committed as revision 20911 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-12-22 08:09:46 +00:00
Ronald S. Bultje
c47ca25e74 Make get_bits_left() available for use in libavcodec (was previously held
private in dv.c for some reason). See "[PATCH] get_bits_left()" thread.

Originally committed as revision 20490 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-11-09 22:10:43 +00:00
Francesco Lavra
91cc5d3767 Move ff_reverse in libavcodec to av_reverse in libavutil.
Patch by Francesco Lavra, francescolavra interfree it

Originally committed as revision 20484 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-11-09 09:11:35 +00:00
Reimar Döffinger
595324e143 Completely remove INIT_VLC_USE_STATIC, it is deprecated since ages and
finally no longer used anywhere.

Originally committed as revision 20013 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-09-24 15:13:34 +00:00
Lars Täuber
6249c33e5a Fix a typo in the documentation.
Patch by Lars Täuber: firstname taeuber gmx net

Originally committed as revision 19820 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-09-11 06:20:05 +00:00
Reimar Döffinger
17f0c3be8e Try to clarify that anyone using get_bits must check for buffer overrun
themselves, get_bits does not do anything in that regard.

Originally committed as revision 19794 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-09-08 08:30:56 +00:00
Stefano Sabatini
9106a698e7 Rename bitstream.h to get_bits.h.
Originally committed as revision 18494 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-04-13 16:20:26 +00:00