summaryrefslogtreecommitdiff
path: root/libavcodec/clearvideo.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/clearvideo: Avoid allocations when decoding tilesAndreas Rheinhardt2022-11-101-68/+31
| | | | | | | | | | | | | | Up until now, the ClearVideo decoder separates parsing tiles and actually using the parsed information: The information is instead stored in structures which are constantly allocated and freed. This commit changes this to use the information immediately, avoiding said allocations. This e.g. reduced the amount of allocations for [1] from 2,866,462 to 24,720. For said sample decoding speed improved by 143%. [1]: https://samples.ffmpeg.org/V-codecs/UCOD/AccordianDance-300.avi Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/clearvideo: Use const where appropriateAndreas Rheinhardt2022-11-101-7/+8
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/clearvideo: Redo updating predicitionAndreas Rheinhardt2022-11-101-8/+16
| | | | | | This is in preparation for further commits. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/clearvideo: Move tile_do_block() upwardsAndreas Rheinhardt2022-11-101-14/+14
| | | | | | Will avoid a forward-declaration later. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/clearvideo: Remove unnecessary level parameterAndreas Rheinhardt2022-11-101-12/+11
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-031-1/+1
| | | | | | | | 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>
* avcodec/internal: Move ff_set_dimensions() to decode.hAndreas Rheinhardt2022-08-271-1/+0
| | | | | | | | | Decoder-only, as the dimensions are set by the user when encoding. Also fixup the other headers a bit while removing unnecessary internal.h inclusions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move ff_reget_buffer() to decode.hAndreas Rheinhardt2022-08-271-0/+1
| | | | | | | | | 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>
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-181-1/+1
| | | | | | | | | | | 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>
* avcodec/vlc: Use structure instead of VLC_TYPE array as VLC elementAndreas Rheinhardt2022-06-171-1/+1
| | | | | | | | | | | | | | | | | | 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>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-051-1/+1
| | | | | | | | | | | 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>
* avcodec/codec_internal: Make FFCodec.decode use AVFrame*Andreas Rheinhardt2022-04-051-2/+2
| | | | | | | | 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>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-211-6/+6
| | | | | | | | | | | | | | | | 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>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-211-0/+1
| | | | | | | | | | 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>
* avcodec/clearvideo: Check tile_size to be not too largeMichael Niedermayer2021-06-291-2/+2
| | | | | | | | Fixes: left shift of 1 by 31 places cannot be represented in type 'int' Fixes: 35023/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-6740166587842560 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: Check for 0 tile_shiftMichael Niedermayer2021-05-121-2/+2
| | | | | | | | Fixes: shift exponent -1 is negative Fixes: 33401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5908683596890112 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | | | | 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>
* lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bumpAnton Khirnov2021-01-011-0/+1
| | | | They are not properly namespaced and not intended for public use.
* avcodec/clearvideo: Make VLC tables staticAndreas Rheinhardt2020-12-081-62/+55
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Apply VLC offset during initAndreas Rheinhardt2020-12-081-4/+3
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Use minimal max_depth in get_vlc2()Andreas Rheinhardt2020-12-081-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Inline constantsAndreas Rheinhardt2020-12-081-9/+12
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Improve handling of VLC escape valuesAndreas Rheinhardt2020-12-081-6/+2
| | | | | | | | | | | | | | Both the motion vector as well as the bias VLCs have an escape code; for the motion vectors, this value depended on the specific VLC table, whereas all the bias VLCs used the same value; the escape value has not been inlined in the latter case. But for both kinds of VLCs there are lots of values that are unused for all the VLCs of each kind and each of these can be used as common escape value, thus allowing to inline the escape value. This commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Avoid huge VLC length tablesAndreas Rheinhardt2020-12-081-7/+27
| | | | | | | | | | After the motion vector and bias values tables have been reordered so that the codes are ordered from left to right, it emerged that the length of these entries are actually ascending for every table. Therefore it is possible to encode them in a run-length style and create the actual length tables during runtime. This commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Avoid code duplication when initializing VLCsAndreas Rheinhardt2020-12-081-166/+35
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Avoid code tables for initializing VLCsAndreas Rheinhardt2020-12-081-85/+69
| | | | | | | | | | | | | | | | | | | | The ClearVideo decoder uses VLC tables that are initialized at runtime from static length, symbol and codes tables. Yet the code tables can be omitted by subjecting all of these tables to the permutation that orders the codes from left to right in the tree. After this is done, the codes can be easily computed at runtime from the lengths and therefore omitted. This saves about 10KB. Only one minor complication is encountered when doing so: The tree corresponding to the AC VLC codes is incomplete; but this can be handled by adding an entry with negative length. Furthermore, there are also VLCs that are only initialized with lengths and codes tables with codes of type uint16_t. These have also been switched to ff_init_vlc_from_lengths() as this means that one can replace the uint16_t codes tables with uint8_t symbols tables. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/clearvideo: Don't check for errors for complete VLCAndreas Rheinhardt2020-10-291-2/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: add a flags parameter to ff_reget_buffer()James Almer2019-09-041-2/+2
| | | | | | | | | | 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>
* avcodec/clearvideo: fix invalid shift in tile size checkMichael Niedermayer2019-08-031-1/+1
| | | | | | | | Fixes: left shift of 1 by 31 places cannot be represented in type 'int' Fixes: 15631/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5690110605000704 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: Check remaining data in P framesMichael Niedermayer2019-03-171-0/+3
| | | | | | | | Fixes: Timeout (19sec -> 419msec) Fixes: 13411/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5733153811988480 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: Check remaining input bits in P macro block loopMichael Niedermayer2018-12-141-0/+2
| | | | | | | | Fixes: Timeout Fixes: 11083/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5657180351496192 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: display warning if decoder overreads inputPaul B Mahol2018-04-241-0/+3
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avcodec/clearvideo: do not try to return frame when it is same as previous onePaul B Mahol2018-04-241-5/+2
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* lavc/clearvideo: Allow decoding without extradata.Carl Eugen Hoyos2018-04-071-0/+2
|
* avcodec/clearvideo: fix mixed code and declarationsJames Almer2018-04-041-4/+5
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/clearvideo: add inter-frame decodingPaul B Mahol2018-04-031-105/+614
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* Merge commit '189157c3fc8eeb691e3684b09d971eb5ddb47d5b'James Almer2017-10-301-26/+30
|\ | | | | | | | | | | | | | | | | * commit '189157c3fc8eeb691e3684b09d971eb5ddb47d5b': Add ClearVideo decoder See a63496cc882428aefafc85d2f60e0908b020bffe Merged-by: James Almer <jamrial@gmail.com>
| * Add ClearVideo decoderKostya Shishkov2017-04-251-0/+391
| | | | | | Only I-frames are decoded for now. Signed-off-by: Diego Biurrun <diego@biurrun.de>
* avcodec/clearvideo: Only output a frame if one is coded in the packetMichael Niedermayer2017-09-111-10/+11
| | | | | | | | Fixes: Timeout (183 ms instead of about 20 sec) Fixes: 3147/clusterfuzz-testcase-4870592182353920 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: Check buf_size before decoding frameMichael Niedermayer2017-05-261-0/+5
| | | | | | | | Fixes; Timeout Fixes: 1826/clusterfuzz-testcase-minimized-5728569256837120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: Fix runtime error: signed integer overflow: 181 * ↵Michael Niedermayer2017-05-091-2/+2
| | | | | | | | | 18050756 cannot be represented in type 'int' Fixes: 1417/clusterfuzz-testcase-minimized-6606778030620672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: Fix multiple runtime error: left shift of negative value ↵Michael Niedermayer2017-05-061-2/+2
| | | | | | | | | -1024 Fixes: 1360/clusterfuzz-testcase-minimized-5606472043986944 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/clearvideo: Do not lose the return code of decode_mb()Michael Niedermayer2017-03-301-2/+5
| | | | | | | | Fixes CID1401671 Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: stop using deprecated codec flagsJames Almer2017-03-251-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: add ClearVideo decoderKostya Shishkov2017-03-021-0/+387
Only I-frames are decoded for now. Signed-off-by: Paul B Mahol <onemda@gmail.com>