Anton Khirnov
0b33310cd0
lavc/bitstream: avoid UB in bits_{read,peek}_signed(0)
...
bits_*_signed(0) will currently invoke an undefined shift by
8 * sizeof(int).
Add bits_*_signed_nz() that only works for n>0, analogous to
bits_read_nz(). Add an explicit check for n=0 in bits_*_signed().
Found-by: James Almer
2 years ago
Anton Khirnov
fcd557a2c2
lavc/get_bits: add a compat wrapper for the cached bitstream reader
...
Use that instead of the merged version.
2 years ago
Martijn van Beurden
909cfdc205
libavcodec/flacdec: Implement decoding of 32 bit-per-sample PCM
...
Add decoding of FLAC files coding for 32 bit-per-sample PCM to libavcodec.
2 years ago
Anton Khirnov
c9a2506de9
get_bits: move check_marker() to mpegvideodec.h
...
It is only used by mpegvideo-based decoders - specifically mpeg12, intelh263,
ituh263, mpeg4video.
2 years ago
Andreas Rheinhardt
2d764069be
avcodec/vlc: Use structure instead of VLC_TYPE array as VLC element
...
In C, qualifiers for arrays are broken:
const VLC_TYPE (*foo)[2] is a pointer to an array of two const VLC_TYPE
elements and unfortunately this is not compatible with a pointer
to a const array of two VLC_TYPE, because the latter does not exist
as array types are never qualified (the qualifier applies to the base
type instead). This is the reason why get_vlc2() doesn't accept
a const VLC table despite not modifying the table at all, as
there is no automatic conversion from VLC_TYPE (*)[2] to
const VLC_TYPE (*)[2].
Fix this by using a structure VLCElem for the VLC table.
This also has the advantage of making it clear which
element is which.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 years ago
Anton Khirnov
c28823ff97
lavc/get_bits: avoid avcodec.h dependency
...
Include only defs.h, needed for AV_INPUT_BUFFER_PADDING_SIZE.
3 years ago
Ramiro Polla
c2b540d0c7
avcodec/get_bits: cosmetics
...
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
5 years ago
Paul B Mahol
78c8a76536
avcodec/get_bits: unbreak get_bits_le() with cached reader
6 years ago
Marton Balint
694d9d5368
avcodec/get_bits: add assertion to limit ouptut value of get_bits
...
Should fix the following Coverity false positives:
Coverity CID #1415651 .
Coverity CID #1420392 .
Coverity CID #1420473 .
Coverity CID #1433770 .
Coverity CID #1435320 .
Coverity CID #1439573 .
Coverity CID #1439580 .
Coverity CID #1439588 .
Signed-off-by: Marton Balint <cus@passwd.hu>
6 years ago
Marton Balint
902e9334aa
avcodec/get_bits: use unsigned integers in show_bits and get_bits
...
The return value is also unsigned.
Signed-off-by: Marton Balint <cus@passwd.hu>
6 years ago
James Almer
9305bdc68f
avcodec/get_bits: actually make cached reader correctly disabled
6 years ago
Paul B Mahol
ca079b0954
avcodec/get_bits: add cached bitstream reader
...
Signed-off-by: Paul B Mahol <onemda@gmail.com>
6 years ago
Michael Niedermayer
6261ef4251
avcodec/get_bits: Document skip_bits_long()
...
Found-by: Kieran
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 years ago
Michael Niedermayer
e529fe7633
avcodec/get_bits: Make sure the input bitstream with padding can be addressed
...
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 years ago
Michael Niedermayer
4a94ff4ccd
avcodec/get_bits: Document the return code of get_vlc2()
...
Found-by: kierank
Reviewed-by: Kieran Kunhya <kieran618@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 years ago
Steinar H. Gunderson
2a293ec7ac
avcodec: add Newtek SpeedHQ decoder
...
This decoder can decode all existing SpeedHQ formats (SHQ0–5, 7, and 9),
including correct decoding of the alpha channel.
1080p is decoded in 142 fps on one core of my i7-4600U (2.1 GHz Haswell),
about evenly split between bitstream reader and IDCT. There is currently
no attempt at slice or frame threading, even though the format trivially
supports both.
NewTek very helpfully provided a full set of SHQ samples, as well as
source code for an SHQ2 encoder (not included) and assistance with
understanding some details of the format.
8 years ago
Paul B Mahol
14090b7050
avcodec/get_bits: add av_assert2 to get_bits_long()
...
Signed-off-by: Paul B Mahol <onemda@gmail.com>
8 years ago
Michael Niedermayer
c72fa43234
avcodec/get_bits: Fix get_sbits_long(0)
...
Fixes undefined behavior
Fixes: 640889-media
Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
8 years ago
Clément Bœsch
6c98398b0b
lavc/get_bits: add a logging context to check_marker()
...
Based on d338abb664
9 years ago
Diego Biurrun
52567e8198
get_bits: Drop some TRACE-level debug code
...
It will not be provided by the new bit reader anyway.
9 years ago
Alexandra Hájková
ffa190d047
Move VLC and RL_VLC_ELEM structure definitions to a separate header
...
Use the newly created vlc.h directly instead of including get_bits when needed.
The VLC and RL_VLC_ELEM structures are independent from the bitreader.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
9 years ago
Alexandra Hájková
e4b38878da
Move check_marker() from get_bits to mpeg4videodec
...
MPEG-4 is the only decoder which uses check_marker().
Signed-off-by: Anton Khirnov <anton@khirnov.net>
9 years ago
Vittorio Giovara
41ed7ab45f
cosmetics: Fix spelling mistakes
...
Signed-off-by: Diego Biurrun <diego@biurrun.de>
9 years ago
Andreas Cadhalpun
62825236db
lavc: Add get_bitsz()
...
get_bit variant supporting 0-bits reads.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
9 years ago
Kieran Kunhya
46350db737
get_bits: Support max_depth > 2 in GET_RL_VLC_INTERNAL
9 years ago
Andreas Cadhalpun
713654d9d3
get_bits: add get_bitsz for reading 0-25 bits
...
This can be used to simplify code in a couple of places.
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
9 years ago
Kieran Kunhya
906c0b7716
get_bits: Support max_depth > 2 in GET_RL_VLC_INTERNAL
9 years ago
Vittorio Giovara
059a934806
lavc: Consistently prefix input buffer defines
...
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
9 years ago
Vittorio Giovara
6a85dfc830
lavc: Replace av_dlog and tprintf with internal macros
10 years ago
Michael Niedermayer
343f34c0b8
avcodec/get_bits: print details of the location of the missing bit in check_marker()
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
10 years ago
Vittorio Giovara
351d0f8b7a
get_bits: remove unused assignment
...
Bug-Id: CID 1238816
10 years ago
Diego Biurrun
b574e1e97e
get_bits: Add OPEN_READER macro variant w/o size_plus8
...
This avoids a trillion warnings from MSVC.
10 years ago
Diego Biurrun
91d305790e
get_bits: Rename HAVE_BITS_REMAINING --> BITS_AVAILABLE
...
The HAVE_ prefix is reserved for macros set by configure.
10 years ago
Michael Niedermayer
11512d70fa
avcodec/get_bits: add BITS_LEFT() for finding the bits left with an opened reader
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
10 years ago
Timothy Gu
ea6178fff8
get_bits: remove unused assignment
...
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
10 years ago
Michael Niedermayer
e6f9fc4adc
avcodec/bitstream: try to make vlc init code inherently thread safe
...
also remove spinlock, it doesnt work on AIX
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Matthew Lindner
b372f67342
avcodec: better level/index printing
11 years ago
Michael Niedermayer
6df33c4926
avcodec: include GET_RL_VLC() in trace output
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Reimar Döffinger
8cbf0827e1
Various small spelling fixes.
...
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
11 years ago
Michael Niedermayer
44e8e82d34
avcodec/get_bits: add skip_1stop_8data_bits
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Michael Niedermayer
54197c7aae
skip_bits: dont call UPDATE_CACHE
...
UPDATE_CACHE isnt needed and can cause segfaults
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Michael Niedermayer
121fc05b4d
avcodec/get_bits: place volatile at the right spot
...
Should fix Ticket2825
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Michael Niedermayer
43411f416f
avcodec/get_bits: init_state is used for thread sync, make it volatile
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Michael Niedermayer
6af8326354
avcodec/ff_init_vlc_sparse: use a spinlock for thread sync
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Paul B Mahol
48f2750de8
get_bits: add get_bits_le()
...
Signed-off-by: Paul B Mahol <onemda@gmail.com>
12 years ago
Michael Niedermayer
ff130d7363
get_xbits: assert validity of the number of bits
...
similar is already done in the other get_bits() functions
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
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>
12 years ago
Ronald S. Bultje
fd6a021d8e
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: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Diego Biurrun
4af5310d29
get_bits/put_bits: K&R formatting cosmetics
...
Signed-off-by: Diego Biurrun <diego@biurrun.de>
12 years ago
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.
12 years ago