summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
...
* avcodec/cuviddec: avoid copy of uninitialized extradata pointerTimo Rothenpieler2020-10-01
|
* avcodec/cuviddec: use correct type for extradata_sizeTimo Rothenpieler2020-10-01
|
* avcodec/cuviddec: fix copy&paste errorTimo Rothenpieler2020-10-01
|
* avcodec/utils: ReindentationAndreas Rheinhardt2020-10-01
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Also free encoder extradata on avcodec_open2() errorAndreas Rheinhardt2020-10-01
| | | | | | It is owned by libavcodec for encoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Don't forget cleaning up when allocating priv_data failsAndreas Rheinhardt2020-10-01
| | | | | | | | | Allocating an AVCodecContext's priv_data used to be the first object allocated in avcodec_open2(), so it was unnecessary to goto free_and_end (which does the cleanup) upon error here. But this is no longer so since f3a29b750a5979ae6847879fba758faf1fae88d0. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Improve check for freeing codec private optionsAndreas Rheinhardt2020-10-01
| | | | | | | | | | Don't check for AVCodec.priv_data_size (which is always true if AVCodec.priv_class is set). Instead check for AVCodecContext.priv_data to actually exist. (Note: av_opt_free(NULL) is a no-op.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Remove always-true checkAndreas Rheinhardt2020-10-01
| | | | | | | | | | | | The first thing avcodec_open2() allocates is the AVCodecInternal. If allocating it fails, a jump to end occurs; but if an error happens after its allocation, a jump to free_and_end happens which frees all allocations performed so far and then jumps to end. Yet free_and_end contained a check for AVCodecInternal (after having already dereferenced it to check whether ff_thread_free() needs to be called) which is of course always true. So remove it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* opusdec: do not fail when LBRR frames are presentAnton Khirnov2020-10-01
| | | | | | Decode and discard them. Fixes ticket 4641.
* avcodec/av1dec: call ff_cbs_flush() on decoder flushJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: fix check for active sequence headerJames Almer2020-09-29
| | | | | | We clear the AV1RawSequenceHeader pointer on flush, not the relevant AVBufferRef. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: parse dimensions from the sequence header in extradataJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_vp9: implement a CodedBitstreamType.flush() callbackJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h2645: implement CodedBitstreamType.flush() callbacksJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_av1: implement a CodedBitstreamType.flush() callbackJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs: add a flush callback to CodedBitstreamTypeJames Almer2020-09-29
| | | | | | Used to reset the codec's private internal state. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cuviddec: handle arbitrarily sized extradataTimo Rothenpieler2020-09-29
|
* avcodec/utils: Only call codec->close if init has been calledAndreas Rheinhardt2020-09-29
| | | | | | | | | | | | | | | | | | | | avcodec_open2() also called the AVCodec's close function if an error happened before init had ever been called if the AVCodec has the FF_CODEC_CAP_INIT_CLEANUP flag set. This is against the documentation of said flag: "The codec allows calling the close function for deallocation even if the init function returned a failure." E.g. the SVQ3 decoder is not ready to be closed if init has never been called. Fixes: NULL dereference Fixes: 25762/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5716279070294016 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavcodec/videotoolboxenc: Fix crash when frame received after errorRick Kern2020-09-28
| | | | Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: move pthread_cond_signal after add buffer to the queueTian Qi2020-09-28
| | | | | | | | | | | | | In the VT encoding insertion by FFmpeg, and vtenc_q_push is callback to add the encoded data to the singly linked list group in VTEncContext, and consumers are notified to fetch it. However, because it first informs consumers of pthread_cond_signal, and then inserts the data into the tail, there is a multi-thread safety hazard. Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: don't wait when flushing dataTian Qi2020-09-28
| | | | | | | | | | because there is run in thread mode, few times will block the workflow at the wait, so check the status is flushing data, don't wait when flushing data. Signed-off-by: Tian Qi <tianqi@kuaishou.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: fix use after destroyZhao Zhili2020-09-28
| | | | | | The lock is used in clear_frame_queue(). Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: fix align issueZhao Zhili2020-09-28
| | | | | | | | bool a53_cc is accessed as int: src/libavutil/opt.c:129:9: runtime error: store to misaligned address 0x7fbf454121a3 for type 'int', which requires 4 byte alignment Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: Allow full range 10bit pixel format inputHarry Mallon2020-09-28
| | | | | Signed-off-by: Harry Mallon <harry.mallon@codex.online> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: Set profile (main/main10) on HEVC encodeHarry Mallon2020-09-28
| | | | | Signed-off-by: Harry Mallon <harry.mallon@codex.online> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/mv30: Fix several integer overflows in idct_1d()Michael Niedermayer2020-09-29
| | | | | | | | Fixes: signed integer overflow: -1846510390 + -361755993 cannot be represented in type 'int' Fixes: 23941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5654696631730176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pgxdec: Fix invalid shift in write_frame_*Michael Niedermayer2020-09-29
| | | | | | | | Fixes: left shift of negative value -121 Fixes: 23911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-4986800258154496 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* pthread_frame: use av_buffer_replace() to simplify codeAnton Khirnov2020-09-28
|
* mpegvideo: use av_buffer_replace() to simplify codeAnton Khirnov2020-09-28
|
* hevcdec: use av_buffer_replace() to simplify codeAnton Khirnov2020-09-28
|
* avcodec: add Argonaut Games Video decoderPaul B Mahol2020-09-27
|
* avcodec/v4l2_buffers: remove unused function argumentAndriy Gelman2020-09-26
| | | | Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/fraps: Use cached bitstream readerAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | | This proved beneficial for performance: For the sample [1] the number of decicycles in one decode call decreased from 155851561 to 108158037 for Clang 10 and from 168270467 to 128847479 for GCC 9.3. For x86-32 compiled with GCC 9.3 and run on an x64 Haswell the number increased from 158405517 to 202215769, so that the cached bitstream reader is only enabled if HAVE_FAST_64BIT is set. These values are the average of 10 runs each looping five times over the input. [1]: samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2593/fraps_flv1_decoding_errors.avi Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/fraps: Use unchecked bitstream readerAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | | | | The fraps decoder already checked for overreads manually (and errored out in this scenario), yet it still enabled implicit checks, leading to worse performance and more code size. This commit disables the implicit bitstream reader checks. For the sample [1] this improves performance from 195105896 to 155851561 decicycles for Clang 10 and from 222801887 to 168270467 decicycles when compiled with GCC 9.3. These values are the average of 10 runs each looping ten times over the input. [1]: samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2593/fraps_flv1_decoding_errors.avi Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utvideo: Move stuff only used by Ut encoder to Ut encoderAndreas Rheinhardt2020-09-26
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utvideo: Remove unused arrayAndreas Rheinhardt2020-09-26
| | | | | | | Unused since 3594788b713e76449eda0bc9d64b38258c86a594. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utvideodec: Avoid qsort when creating Huffman tablesAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Ut video format uses Huffman trees which are only implicitly coded in the bitstream: Only the lengths of the codes are coded, the rest has to be inferred by the decoder according to the rule that the longer codes are to the left of shorter codes in the tree and on each level the symbols are descending from left to right. Because longer codes are to the left of shorter codes, one needs to know how many non-leaf nodes there are on each level in order to know the code of the next left-most leaf (which belongs to the highest symbol on that level). The current code does this by sorting the entries to be ascending according to length and (for entries with the same length) ascending according to their symbols. This array is then traversed in reverse order, so that the lowest level is dealt with first, so that the number of non-leaf nodes of the next higher level is known when processing said level. But this can also be calculated without sorting: Simply count how many leaf nodes there are on each level. Then one can calculate the number of non-leaf nodes on each level iteratively from the lowest level upwards: It is just half the number of nodes of the level below. This improves performance: For the sample from ticket #4044 the amount of decicycles for one call to build_huff() decreased from 1055489 to 446310 for Clang 10 and from 1080306 to 535155 for GCC 9. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utvideodec: Remove code duplication when creating Huffman tablesAndreas Rheinhardt2020-09-26
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utvideodec/enc: Fix edge case of creating Huffman tableAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | | | | | | | The Ut Video format stores Huffman tables in its bitstream by coding the length of a given symbol; it does not code the actual code directly, instead this is to be inferred by the rule that a symbol is to the left of every shorter symbol in the Huffman tree and that for symbols of the same length the symbol is descending from left to right. With one exception, this is also what our de- and encoder did. The exception only matters when there are codes of length 32, because in this case the first symbol of this length did not get the code 0, but 1; this is tantamount to pretending that there is a (nonexistent) leaf of length 32. This is simply false. The reference software agrees with this [1]. [1]: https://github.com/umezawatakeshi/utvideo/blob/2700a471a78402e5c340150b38e8a793ef3676f1/utv_core/HuffmanCode.cpp#L280 Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Don't waste stack spaceAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | | Now that the HuffEntries are no longer sorted by the MagicYUV decoder, their symbols are trivial: The symbol of the element with index i is i. They can therefore be removed. Furthermore, despite the length of the codes being in the range 1..32 bits, the actual value of the codes is <= 4096 (for 12 bit content). The reason for this is that the longer codes are on the left side of the tree, so that the higher bits of these codes are simply zero. By using an uint16_t for the codes and removing the symbols entry, the size of each HuffEntry is decreased from eight to four, saving 16KB of stack space. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Avoid AV_QSORT when creating Huffman tableAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MagicYUV format stores Huffman tables in its bitstream by coding the length of a given symbol; it does not code the actual code directly, instead this is to be inferred by the rule that a symbol is to the left of every shorter symbol in the Huffman tree and that for symbols of the same length the symbol is ascending from left to right. Our decoder implemented this by first sorting the array containing length and symbol of each element according to descending length and for equal length, according to ascending symbol. Afterwards, the current state in the tree got encoded in a variable code; if the next array entry had length len, then the len most significant bits of code contained the code of this entry. Whenever an entry of the array of length len was processed, code was incremented by 1U << (32 - len). So two entries of length len have the same effect as incrementing code by 1U << (32 - (len - 1)), which corresponds to the parent node of length len - 1 of the two nodes of length len etc. This commit modifies this to avoid sorting the entries before calculating the codes. This is done by calculating how many non-leaf nodes there are on each level of the tree before calculating the codes. Afterwards every leaf node on this level gets assigned the number of nodes already on this level as code. This of course works only because the entries are already sorted by their symbol initially, so that this algorithm indeed gives ascending symbols from left to right on every level. This offers both speed- as well as (obvious) codesize advantages. With Clang 10 the number of decicycles for build_huffman decreased from 1561987 to 1228405; for GCC 9 it went from 1825096 decicyles to 1429921. These tests were carried out with a sample with 150 frames that was looped 13 times; and this was iterated 10 times. The earlier reference point here is from the point when the loop generating the codes was traversed in reverse order (as the patch reversing the order led to performance penalties). Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Fix edge case of building Huffman tableAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | | | | | | | The MagicYUV format stores Huffman tables in its bitstream by coding the length of a given symbol; it does not code the actual code directly, instead this is to be inferred by the rule that a symbol is to the left of every shorter symbol in the Huffman tree and that for symbols of the same length the symbol is ascending from left to right. With one exception, this is also what our decoder did. The exception only matters when there are codes of length 32, because in this case the first symbol of this length did not get the code 0, but 1; e.g. if there were exactly two nodes of length 32, then they would get assigned the codes 1 and 2 and a node of length 31 will get the 31-bit code 1 which is a prefix of the 32 bit code 2, making the Huffman table invalid. On the other hand, if there were only one symbol with the length 32, the earlier code would accept this un-Huffman-tree. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Don't invert order unnecessarilyAndreas Rheinhardt2020-09-26
| | | | | | | | | | | | | | The MagicYUV decoder currently sets both the length and the symbol field of an array of HuffEntries; hereby the symbol of the ith entry (0-based) is just i. Then said array gets sorted so that entries with greater length are at the end and entries with the same length are ordered so that those with smaller symbols are at the end. Afterwards the newly sorted array is traversed in reverse order. This commit instead inverts the ordering and traverses the array in its ordinary order in order to simplify understanding. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Replace implicit checks for overread by explicit onesAndreas Rheinhardt2020-09-26
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Use const uint8_t* for pointer to immutable dataAndreas Rheinhardt2020-09-26
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Don't use GetBit API for byte-aligned readsAndreas Rheinhardt2020-09-26
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Check early for invalid slicesAndreas Rheinhardt2020-09-26
| | | | | | | | Every plane of each slice has to contain at least two bytes for flags and the type of prediction used. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/diracdsp: Remove unused variableAndreas Rheinhardt2020-09-26
| | | | | | | Forgotten in ca3c6c981aa5b0af8a5576020b79fdd3cdf9ae9e. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/magicyuv: Improve overread check when parsing Huffman tablesAndreas Rheinhardt2020-09-26
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/bytestream: Add unchecked bytestream2 peek functionsAndreas Rheinhardt2020-09-26
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>