Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-03-22avcodec/internal: Move FF_SIGNBIT and ff_log2_run to mathops.hAndreas Rheinhardt
It is a more fitting place for them. Also move the definition of ff_log2_run to mathtables.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-22avcodec/bitstream: Move code for initializing VLCs to file of its ownAndreas Rheinhardt
bitstream.c is currently the disjoint union of three parts: The first part is ff_log2_run, the second part are some auxiliary functions for the PutBits-API; and the third part is the code for creating VLCs. This commit moves the latter into a file of its own. This has the advantage of making one of the hacks in tableprint_vlc.h redundant as vlc.c does not include config.h (whereas the PutBits-API part does). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-22avcodec/mathops: Move bitswap_32() to its only userAndreas Rheinhardt
Effectively reverts eaff1aa09e90e2711207c9463db8bf8e8dec8178 given that bitswap_32 is no longer used outside of bitstream.c since 03008c2811ec26cf338780a89b6b2b849b399e3c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-24Remove unnecessary libavutil/(avutil|common|internal).h inclusionsAndreas Rheinhardt
Some of these were made possible by moving several common macros to libavutil/macros.h. While just at it, also improve the other headers a bit. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09avcodec/bitstream: Don't pretend VLCs to be initialized concurrentlyAndreas Rheinhardt
Since the MPEG-4 parser no longer initializes some MPEG-4 VLCs, no VLC is initialized concurrently by multiple threads (initializing static VLCs is guarded by locks and nonstatic VLCs never posed an issue in this regard). So remove the code in bitstream.c that only exists because of this possibility. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22Remove/replace some unnecessary avcodec.h inclusionsAndreas Rheinhardt
Also remove other unnecessary headers and include headers directly while at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-27avcodec/bitstream: Remove avpriv PutBits API functionsAndreas Rheinhardt
Scheduled for removal in 717503f7166d7032e32b935f2819d450524125d1. Also remove PutBitContext.size_in_bits which has been scheduled for removal in e7cbbd90267de2a0ad1b5fa8ccb29ab7bf8a26b8. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2021-02-24avcodec/bitstream: Rewrite code to avoid triggering compiler warningAndreas Rheinhardt
Clang infers from the existence of a default case that said case can be taken. In case of libavcodec/bitstream.c said default case consisted of an av_assert1 that evaluates to nothing in case of the ordinary assert level. In this case (that doesn't happen) a variable wouldn't be initialized, so Clang emitted Wsometimes-uninitialized warnings. Solve this by making sure that the default path also initializes the aforementioned variable. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-08avcodec/bitstream: Allow static VLC tables to be bigger than neededAndreas Rheinhardt
Right now the allocated size of the VLC table of a static VLC has to exactly match the size actually used for the VLC: If it is not enough, abort is called; if it is more than enough, an error message is emitted. This is no problem when one wants to initialize an individual VLC via one of the INIT_VLC macros as one just hardcodes the needed size. Yet it is an obstacle when one wants to initialize several VLCs in a loop as one then needs to add an array for the sizes/offsets of the VLC tables (unless max_depth of all arrays is one in which case the sizes are derivable from the number of bits used). Yet said size array is not necessary if one disables the warning for too big buffers. The reason is that the amount of entries needed for the table is of course generated as a byproduct of initializing the VLC. To this end a flag that disables the warning has been added. So one can proceed as follows: static VLC vlcs[NUM]; static VLC_TYPE vlc_table[BUF_SIZE][2]; for (int i = 0, offset = 0; i < NUM; i++) { vlcs[i].table = &vlc_table[offset]; vlcs[i].table_allocated = BUF_SIZE - offset; init_vlc(); /* With INIT_VLC_STATIC_OVERLONG flag */ offset += vlcs[i].table_size; } Of course, BUF_SIZE should be equal to the number of entries actually needed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-08avcodec/bitstream: Add second function to create VLCsAndreas Rheinhardt
When using ff_init_vlc_sparse() to create a VLC, three input tables are used: A table for lengths, one for codes and one for symbols; the latter one can be omitted, then a default one will be used. These input tables will be traversed twice, once to get the long codes (which will be put into subtables) and once for the small codes. The long codes are then sorted so that entries that should be in the same subtable are contiguous. This commit adds an alternative to ff_init_vlc_sparse(): ff_init_vlc_from_lengths(). It is based upon the observation that if lengths, codes and symbols tables are permuted (in the same way) so that the codes are ordered from left to right in the corresponding tree and if said tree is complete (i.e. every non-leaf node has two children), the codes can be easily computed from the lengths and are therefore redundant. This means that if one initializes such a VLC with explicitly coded lengths, codes and symbols, the codes can be avoided; and even if one has no explicitly coded symbols, it might still be beneficial to remove the codes even when one has to add a new symbol table, because codes are typically longer than symbols so that the latter often fit into a smaller type, saving space. Furthermore, given that the codes here are by definition ordered from left to right, it is unnecessary to sort them again; for the same reason, one does not have to traverse the input twice. This function proved to be faster than ff_init_vlc_sparse() whenever it has been benchmarked. This function is usable for static tables (they can simply be permuted once) as well as in scenarios where the tables are naturally ordered from left to right in the tree; the latter e.g. happens with Smacker, Theora and several other formats. In order to make it also usable for (static) tables with incomplete trees, negative lengths are used to indicate that there is an open end of a certain length. Finally, ff_init_vlc_from_lengths() has one downside compared to ff_init_vlc_sparse(): The latter uses tables that can be reused by encoders. Of course, one could calculate the needed table at runtime if one so wishes, but it is nevertheless an obstacle. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-28put_bits: make avpriv_copy_bits() lavc-localAnton Khirnov
It is not used outside of lavc anymore. Keep the avpriv exported symbol around until the next bump to preserve ABI compatibility.
2020-10-28put_bits: make avpriv_put_string() lavc-localAnton Khirnov
It has not been used outside of libavcodec since 20f325f320c6e18ee88983870d2a1fee94257293
2020-10-28put_bits: make avpriv_align_put_bits() inlineAnton Khirnov
This function is so extremely simple that it is preferable to make it inline rather than deal with all the complications arising from it being an exported symbol. Keep avpriv_align_put_bits() around until the next major bump to preserve ABI compatibility.
2020-10-28avcodec/bitstream: Stop allocating one VLCcode more than neededAndreas Rheinhardt
Allocating one temporary entry more than needed was made necessary by the COPY loop below writing an element before having checked that it should be written at all. But given that this behaviour changed, the need for overallocating is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-28avcodec/bitstream: Check code length before truncating to uint8_tAndreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-27avcodec/bitstream: Consistently treat symbol as VLC_TYPEAndreas Rheinhardt
If a static VLC table gets initialized a second time (or concurrently by two threads) and if said VLC table uses symbols that have the sign bit of VLC_TYPE (a typedef for int16_t) set, initializing the VLC fails. The reason is that the type of the symbol in the temporary array is an uint16_t and so comparing it to the symbol read from the VLC table will fail, because only the lower 16bits coincide. Said failure triggers an assert. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-12avcodec/vlc, bitstream: Allow to use BE codes to initialize LE VLCAndreas Rheinhardt
This is easily possible because ff_init_vlc_sparse() already transforms both LE as well as BE codes to a normal form internally before processing them further. This will be used in subsequent commits. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-01avcodec/bitstream: Remove outdated commentAndreas Rheinhardt
The comment referred to the INIT_VLC_USE_STATIC flag which has been removed in 2009 in 595324e143b57a52e2329eb47b84395c70f93087; the function it referred to was removed even earlier in commit 83422c1940d963d395a64bee0cbb9c637192ce8c in 2008. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-28avcodec/bitstream: Avoid allocation when creating VLC tablesAndreas Rheinhardt
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-28avcodec/bitstream: Don't check for undefined behaviour after it happenedAndreas Rheinhardt
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-06-14avcodec/bitstream: Check for more conflicting codes in build_table()Michael Niedermayer
Fixes: out of array read Fixes: 14563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5646451545210880 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-06-14avcodec/bitstream: Check for integer code truncation in build_table()Michael Niedermayer
Fixes: out of array read Fixes: 14563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5646451545210880 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-01avcodec/bitstream: Return specific error codes when building vlc tablesMichael Niedermayer
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-29Fix all -Wformat warnings raised by DJGPPClément Bœsch
2017-03-22lavc/bitstream: remove unused atomic.h includeClément Bœsch
2017-01-11avcodec: move bitswap_32() into a header fileSteinar H. Gunderson
Allows more codecs than mpeg12video to make use of it.
2017-01-05avcodec/bitstream: Document the values supported for *_size in ↵Michael Niedermayer
ff_init_vlc_sparse() Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-05avcodec/bitstream: assert that *_size in ff_init_vlc_sparse() is validMichael Niedermayer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-23Merge commit 'ffa190d0479d2370dd89c95692f822cbff2cc24c'Clément Bœsch
* commit 'ffa190d0479d2370dd89c95692f822cbff2cc24c': Move VLC and RL_VLC_ELEM structure definitions to a separate header Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'Clément Bœsch
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb': cosmetics: Fix spelling mistakes Merged-by: Clément Bœsch <u@pkh.me>
2016-05-17Move VLC and RL_VLC_ELEM structure definitions to a separate headerAlexandra Hájková
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>
2016-05-04cosmetics: Fix spelling mistakesVittorio Giovara
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-03-29fix some a/an typosLou Logan
Signed-off-by: Lou Logan <lou@lrcd.com>
2016-03-06bitstream.c: improve init_vlc error messages.Reimar Döffinger
Makes it far easier to spot the issue if e.g. caused by a typo in the code table. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2015-10-18avcodec/bitstream: replace qsort with AV_QSORTGanesh Ajjanagadde
Commit 3a0a2f33a6c955823fa4fb12c0b49cd29a496659 claims large performance advantages for AV_QSORT over libc's qsort. The reason is that I suspect that libc's qsort (at least on non LTO builds, like the typical FFmpeg config) can't inline the comparison callback: https://stackoverflow.com/questions/5290695/is-there-any-way-a-c-c-compiler-can-inline-a-c-callback-function. AV_QSORT has two things going for it: 1. The guaranteed inlining of qsort itself. This yields a negligible boost that may be ignored. 2. The more serious possibility of potentially allowing the comparison function to be inlined - this is likely responsible for the large boosts reported. There is a comment explaining that this is a place that could use some performance improvement. Thus AV_QSORT is used to achieve that. Benchmarks deemed unnecessary due to existing claims about AV_QSORT. Tested with FATE. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-06-16doc: avoid incorrect phrase 'allows to'Andreas Cadhalpun
Also fix typo found by Lou Logan: Sacrifying -> Sacrificing Reviewed-by: Lou Logan <lou@lrcd.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-06-14doc: fix spelling errorsAndreas Cadhalpun
Neccessary -> Necessary formated -> formatted thee -> the eventhough -> even though seperately -> separately Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-05-25avcodec/bitstream: Assert that there is enough space left in avpriv_copy_bits()Michael Niedermayer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20Merge commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25'Michael Niedermayer
* commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25': lavc: Replace av_dlog and tprintf with internal macros Conflicts: libavcodec/aacdec.c libavcodec/audio_frame_queue.c libavcodec/bitstream.c libavcodec/dcadec.c libavcodec/dnxhddec.c libavcodec/dvbsubdec.c libavcodec/dvdec.c libavcodec/dvdsubdec.c libavcodec/get_bits.h libavcodec/gifdec.c libavcodec/h264.h libavcodec/h264_cabac.c libavcodec/h264_cavlc.c libavcodec/h264_loopfilter.c libavcodec/h264_refs.c libavcodec/imc.c libavcodec/interplayvideo.c libavcodec/jpeglsdec.c libavcodec/libopencore-amr.c libavcodec/mjpegdec.c libavcodec/mpeg12dec.c libavcodec/mpegvideo_enc.c libavcodec/mpegvideo_parser.c libavcodec/pngdec.c libavcodec/ratecontrol.c libavcodec/rv10.c libavcodec/svq1dec.c libavcodec/vqavideo.c libavcodec/wmadec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-19lavc: Replace av_dlog and tprintf with internal macrosVittorio Giovara
2015-02-14Merge commit '7f9f771eac0d37a632e0ed9bd89961d57fcfb7e0'Michael Niedermayer
* commit '7f9f771eac0d37a632e0ed9bd89961d57fcfb7e0': avcodec: Don't anonymously typedef structs Conflicts: libavcodec/alac.c libavcodec/cinepak.c libavcodec/cscd.c libavcodec/dcadec.c libavcodec/g723_1.c libavcodec/gif.c libavcodec/iff.c libavcodec/kgv1dec.c libavcodec/libopenjpegenc.c libavcodec/libspeexenc.c libavcodec/ra288.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14avcodec: Don't anonymously typedef structsDiego Biurrun
2014-07-02avcodec/bitstream: remove trivial assertMichael Niedermayer
Fixed CID1224273 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-21avcodec/bitstream: document the double volatileMichael Niedermayer
Suggested-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-20avcodec/bitstream: try to workaround internal compiler bug in gcc 4.2Michael Niedermayer
gcc 4.2 seems not maintained anymore so theres no option besides just working around it. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-16avcodec/bitstream: try to make vlc init code inherently thread safeMichael Niedermayer
also remove spinlock, it doesnt work on AIX Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-16avcodec/bitstream: fill invalid vlc tables entries as last pass instead of firstMichael Niedermayer
This avoids writing entries twice Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-16avcodec/bitstream: zero vlc tables on allocationMichael Niedermayer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-08vcodec/bitstream: use av_malloc_array()Michael Niedermayer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-23avcodec/bitstream: assert that no integer overflow happened when writing ↵Michael Niedermayer
codes in build_table() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>