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-09-03avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt
It reduces typing: Before this patch, there were 105 codecs whose long_name-definition exceeded the 80 char line length limit. Now there are only nine of them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-27avcodec/internal: Move ff_get_buffer() to decode.hAndreas Rheinhardt
Only used by decoders (encoders have ff_encode_alloc_frame()). Also clean up the other headers a bit while removing now redundant internal.h inclusions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-27avcodec/internal: Move ff_reget_buffer() to decode.hAndreas Rheinhardt
Only used by decoders. Also clean up the headers a bit while removing now unnecessary internal.h inclusions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-18avcodec: Make init-threadsafety the defaultAndreas Rheinhardt
and remove FF_CODEC_CAP_INIT_THREADSAFE All our native codecs are already init-threadsafe (only wrappers for external libraries and hwaccels are typically not marked as init-threadsafe yet), so it is only natural for this to also be the default state. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-07avcodec/smacker: fix indention after previous commitMichael Niedermayer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07avcodec/smacker: Optimize constant 16bit audio outputMichael Niedermayer
Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-05avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt
This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05avcodec/codec_internal: Make FFCodec.decode use AVFrame*Andreas Rheinhardt
This increases type-safety by avoiding conversions from/through void*. It also avoids the boilerplate "AVFrame *frame = data;" line for non-subtitle decoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-21avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt
Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-21avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt
Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-15smacker: convert to new channel layout APIAnton Khirnov
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27avcodec: Constify AVCodecsAndreas Rheinhardt
Given that the AVCodec.next pointer has now been removed, most of the AVCodecs are not modified at all any more and can therefore be made const (as this patch does); the only exceptions are the very few codecs for external libraries that have a init_static_data callback. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2020-12-08avcodec/smacker: Improve creating Huffman VLC tablesAndreas Rheinhardt
The Smacker Huffman tables are already stored in a tree-like structure; in particular, they are naturally ordered from left to right in the tree and are therefore suitable to be initialized by ff_init_vlc_from_lengths() which avoids traversing the data twice in order to sort only the codes that are so long that they need into a subtable. This improves performance (and reduces codesize): For the sample from ticket #2425 the number of decicycles for parsing and creating the VLCs in smka_decode_frame() decreased from 412322 to 359152 (tested with 10 runs each looping 20 times over the file). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-24avcodec/smacker: Mark decoders as init-threadsafeAndreas Rheinhardt
Both Smacker audio and video decoders don't use/modify any global state. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-17avcodec/smacker: Check remaining bits in SMK_BLK_FULLMichael Niedermayer
Fixes: out of array access Fixes: 26047/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5083031667474432 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-18Revert "avcodec/vlc: Add macro for ff_init_vlc_sparse()"Andreas Rheinhardt
This reverts commit 61669b7c40b8dc3a0841768fb39c7567513b7cfc. This commit broke building with MSVC due to its spec-incompliant handling of ',' in __VA_ARGS__: These are not treated as argument separators for further macros, so that in our case the init_vlc2() macro is treated as having only one argument whenever the init_vlc() macro is used. See [1] for further details. [1]: https://reviews.llvm.org/D69626 Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Avoid code duplicationAndreas Rheinhardt
Besides the obvious advantage of less code this also has a performance impact: For GCC 9 the time spent on one call to smka_decode_frame() for the sample from ticket #2425 decreased from 1693619 to 1498127 decicycles. For Clang 9, it decreased from 1369089 to 1366465 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Use unsigned for prediction valuesAndreas Rheinhardt
Up until now, the Smacker decoder has pretended that the prediction values are signed in code like 'pred[0] += (unsigned)sign_extend(val, 16)' (the cast has been added to this code later to fix undefined behaviour). This has been even done in case the PCM format is u8. Yet in case of 8/16 bit samples, only the lower 8/16 bit of the predicition values are ever used, so one can just as well just use unsigned and remove the sign extensions. This is what this commit does. For GCC 9 the time for one call to smka_decode_frame() for the sample from ticket #2425 decreased from 1709043 to 1693619 decicycles; for Clang 9 it went up from 1355273 to 1369089 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Avoid allocations for decoding SmackerAndreas Rheinhardt
by using buffers on the stack instead. The fact that the effective lifetime of most of the allocated buffers doesn't overlap enables one to limit the stack space used to a fairly modest size (about 1.5 KiB). That all the buffers used in HuffContexts have always the same number of elements (namely 256) makes it possible to include the buffers directly in the HuffContext. Doing so also makes the length field redundant; it has therefore been removed. This is beneficial for performance: For GCC 9 the time for one call to smka_decode_frame() for the sample in ticket #2425 went down from 1794494 to 1709043 decicyles; for Clang 9 it decreased from 1449420 to 1355273 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Use symbols tableAndreas Rheinhardt
Up until now, the return value of get_vlc2() has been used as an index in an array that contained the value one is really interested in. Yet since b613bacca9c256f1483c46847f713e47a0e9a5f6 this is no longer necessary, as one can store the value that is right now stored in the array in the VLC internal table. This also means that all the information from the eight bit Huffman trees are now stored in the corresponding VLC table; this will enable us to remove several allocations lateron. This improved performance: For GCC 9 the time for one call of smka_decode_frame() for the sample from ticket #2425 decreased from 1811706 to 1794494 decicycles; for Clang 9 the number went from 1471663 to 1449420 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Use smaller typesAndreas Rheinhardt
This will mean that we will need less stack space lateron when these arrays are no longer heap-allocated. No discernible speed impact. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Disentangle two contextsAndreas Rheinhardt
Smacker uses two types of Huffman trees: Those for eight bit values and those for 16 bit values. Given that both return their values via arrays and that both need to check not to overrun their array, the context for parsing eight bit values (HuffContext) will necessarily exhibit certain similarities with the context used for parsing 16 bit values (DBCtx). These similarities led to using a HuffContext in addition a DBCtx for parsing 16 bit trees. This stands in the way of further developments for the HuffContext struct (when parsing eight bit trees, the length of the arrays are always 256, so that one can inline said value and move the currently heap-allocated tables directly in the structure). Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Replace implicit checks for overread by explicit onesAndreas Rheinhardt
Using explicit checks has the advantage that one can combine several checks into one and does not have to check every time. E.g. reading a 16bit PCM sample involves two calls to get_vlc2(), each of which may read up to three times up to SMKTREE_BITS (= 9) bits. But given that the padding that the input packet is supposed to have is large enough, it is no problem to only check once for each sample. This turned out to be beneficial for performance: For GCC 9, the time for one call of smka_decode_frame() for the sample from ticket #2425 went down from 2055905 to 1804751 decicycles; for Clang 9 it went down from 1510538 to 1479680 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Remove redundant checks for NULL before freeingAndreas Rheinhardt
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Remove redundant checks when reading VLC codesAndreas Rheinhardt
The VLC codes in question originate from a Huffmann tree and so every sequence of bits that is longer than the longest code contains an initial sequence that is a valid code. Given that it has been checked during reading said tree (and once again in ff_init_vlc_sparse()) that the length of each code is <= 3 * the number of bits read at once when reading codes, get_vlc2() will always find a matching entry. These checks have been added in 71d3c25a7ef442ac2dd7b6fbf7c489ebc0b58e9b at a time when the length of the codes had not been checked when parsing the tree. For GCC 9 and the sample from ticket #2425 this led to a slight performance regression: The time for one call to smka_decode_frame() increased from 2053671 to 2064529 decicycles; for Clang 9, performance improved from 1521288 to 1508459 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Remove redundant check when decoding header treesAndreas Rheinhardt
When length is zero for a leaf node (which happens iff the Huffman tree consists of one leaf node only), prefix is also automatically zero. Performance impact is negligible: For GCC 9 and the sample from #2425, the time for one call to smka_decode_frame() decreased from 2053758 to 2053671 decicycles; for Clang 9 it went from 1523153 to 1521288. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Don't zero-initialize unnecessarilyAndreas Rheinhardt
With the possible exception of the "last" values when decoding video, only the part that is actually initialized with values derived from the bitstream is used afterwards, so it is unnecessary to zero everything at the beginning. This is also no problem for the "last" values at all, because they are reset for every frame anyway. While at it, use sizeof(variable) instead of sizeof(type). Performance increased slightly: For GCC, from 2068389 decicycles per call to smka_decode_frame() when decoding the sample from ticket #2425 to 2053758 decicycles; for Clang, from 1534188 to 1523153 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Use better nb_codes estimate when initializing VLCAndreas Rheinhardt
Using the real number of read codes allows to leave a loop in ff_init_vlc_sparse earlier; notice that all codes not explicitly set by reading data have been set to zero earlier (i.e. they are zero-length codes) and such codes are ignored by ff_init_vlc_sparse. This improves performance: When compiled with GCC 9, the time spent on one call to smka_decode_frame() for the sample from ticket #2425 decreased from 2195367 decicycles to 2068389 decicycles. For Clang 9, it improved from 1602075 to 1534188 decicycles. These tests have been performed 20 times and each times the input file has been looped 32 times to get a sufficient number of frames. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Use unsigned for shiftAndreas Rheinhardt
Given that the code currently accepts only 27 bits long Huffman codes, the shift 1 << (length - 1) with length in 1..28 that is performed when parsing the tree is safe. Yet if this limit were ever expanded to the full 32 bits, this shift would be potentially undefined. So simply use unsigned. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Forward error codesAndreas Rheinhardt
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Use same variable for return values and errorsAndreas Rheinhardt
smacker_decode_header_tree() uses different variables for return values (res) and for errors (err) leading to code like res = foo(bar); if (res < 0) { err = res; goto error; } Given that no positive return value is ever used at all one can simplify the above by removing the intermediate res. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Directly goto error in case of errorAndreas Rheinhardt
The earlier version did not error out directly in case an error happens, because it would lead to a leak: An allocated array is only reachable via a local variable at that time; it is only attached to more permanent storage at the end. While it would be possible to add custom code for freeing on error (instead of reusing the ordinary code for doing so), this commit takes the opposite approach and attaches the newly allocated array to its permanent place immediately after its allocation. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Improve header table error checksAndreas Rheinhardt
The extradata for Smacker video contains Huffman trees as well as a field containing the size (in bytes) of said Huffman tree when stored as a table. Due to three special values the decoder allocates more than the size field indicates; yet when it parses the table it only errors out if the number of elements exceeds the number of allocated elements and not the number of elements as indicated by the size field. As a consequence, there might be less than three elements available at the end, so that another check for this is necessary. This commit changes this: It is always made sure that the three elements reserved to (potentially) use them to store the special values are not used to store ordinary tree entries. This allows to remove the extra check at the end. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Remove code duplication when decoding header treesAndreas Rheinhardt
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Don't warn for Huffmann tables with one elementAndreas Rheinhardt
The Huffmann tables used by Smacker can consist of exactly one leaf only in which case the length of the corresponding code is zero; there is then exactly one value encoded. Our VLC can't handle this and therefore this case needs to be treated separately; it has been implemented in commit 48cbdaea157671d456750e00fde37c6d7595fad6. Yet said commit also made the decoder emit an error message (despite not erroring out) in this case, although it seems that this is rather a limitation of our VLC API. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18avcodec/smacker: Remove write-only and unused variablesAndreas Rheinhardt
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-30avcodec/smacker: Add FF_CODEC_CAP_INIT_CLEANUPAndreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-01-30avcodec/smacker: Check space before decoding typeMichael Niedermayer
Fixes: Timeout (232sec -> 280ms) Fixes: 19682/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5654129649385472 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-20avcodec/smacker: Fix integer overflows in pred[] in smka_decode_frame()Michael Niedermayer
Fixes: signed integer overflow: -2147481503 + -32732 cannot be represented in type 'int' Fixes: 17782/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-5769672225456128 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-16avcodec/smacker: cleanup on errors in smka_decode_frame()Michael Niedermayer
Fixes: multiple memleaks Fixes: 17660/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-5689769928949760 Fixes: 18064/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-5631086809317376 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-24avcodec/smacker: Fix integer overflow in signed int multiply in SMK_BLK_FILLMichael Niedermayer
Fixes: signed integer overflow: 238 * 16843009 cannot be represented in type 'int' Fixes: 16958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5193905355620352 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-04avcodec/decode: add a flags parameter to ff_reget_buffer()James Almer
Some decoders may not need a writable buffer in some specific cases, but only a reference to the existing buffer with updated frame properties instead, for the purpose of returning duplicate frames. For this, the FF_REGET_BUFFER_FLAG_READONLY flag is added, which will prevent potential allocations and buffer copies when they are not needed. Signed-off-by: James Almer <jamrial@gmail.com>
2019-08-23avcodec/smacker: Check that not all tables are skipedMichael Niedermayer
If all tables are skipped it would be impossible to encode any "non black" video. Fixes: Timeout (78sec -> 1ms) Fixes: 15821/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5652598838788096 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-11-12Merge commit '0ccddbad200c1d9439c5a836501917d515cddf76'James Almer
* commit '0ccddbad200c1d9439c5a836501917d515cddf76': smacker: limit recursion depth of smacker_decode_bigtree See 946ecd19ea752399bccc751c9339ff74b815587e Merged-by: James Almer <jamrial@gmail.com>
2017-11-12Merge commit 'cd4663dc80323ba64989d0c103d51ad3ee0e9c2f'James Almer
* commit 'cd4663dc80323ba64989d0c103d51ad3ee0e9c2f': smacker: add sanity check for length in smacker_decode_tree() See b829da363985cb2f80130bba304cc29a632f6446 Merged-by: James Almer <jamrial@gmail.com>
2017-11-11smacker: limit recursion depth of smacker_decode_bigtreeAndreas Cadhalpun
This fixes segmentation faults due to stack-overflow caused by too deep recursion. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Sean McGovern <gseanmcg@gmail.com>
2017-11-11smacker: add sanity check for length in smacker_decode_tree()Michael Niedermayer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Bug-Id: 1098 Cc: libav-stable@libav.org Signed-off-by: Sean McGovern <gseanmcg@gmail.com>
2017-11-01Merge commit '5edded9df31bc4712a023f89941b4c278f1bd6f5'James Almer
* commit '5edded9df31bc4712a023f89941b4c278f1bd6f5': smacker: Improve error handling See c1947015b2eec65c7fbd702e1d8c22248be511e8 Merged-by: James Almer <jamrial@gmail.com>
2017-11-01Merge commit 'b98f082d8ddc0a0d8317114d8414ab51de60ef02'James Almer
* commit 'b98f082d8ddc0a0d8317114d8414ab51de60ef02': smacker: Check that the data size is a multiple of a sample vector See 4a9af07a49295e014b059c1ab624c40345af5892 Merged-by: James Almer <jamrial@gmail.com>
2017-06-01smacker: Improve error handlingDiego Biurrun
Return sensible error values and forward error codes.