summaryrefslogtreecommitdiff
path: root/libavcodec/vp3.c
Commit message (Collapse)AuthorAge
* avcodec: Constify ThreadFrames if possibleAndreas Rheinhardt2022-07-31
| | | | | | | This is possible now that ff_thread_await_progress() accepts a const ThreadFrame*. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-18
| | | | | | | | | | | 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-17
| | | | | | | | | | | | | | | | | | 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-05
| | | | | | | | | | | 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-05
| | | | | | | | 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-21
| | | | | | | | | | | | | | | | 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-21
| | | | | | | | | | 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>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/vp3: Add missing check for av_mallocJiasheng Jiang2022-02-18
| | | | | | | | | | Since the av_malloc() may fail and return NULL pointer, it is needed that the 's->edge_emu_buffer' should be checked whether the new allocation is success. Fixes: d14723861b ("VP3: fix decoding of videos with stride > 2048") Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
* avcodec/threadframe: Add ff_thread_(get|release)_ext_buffer()Andreas Rheinhardt2022-02-09
| | | | | | | | | These will be used by the codecs that need allocated progress and is in preparation for no longer using ThreadFrame by the codecs that don't. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/thread: Move ff_thread_(await|report)_progress to new headerAndreas Rheinhardt2022-02-09
| | | | | | | | | | This is in preparation for further commits that will stop using ThreadFrame for frame-threaded codecs that don't use ff_thread_(await|report)_progress(); the API for those codecs having inter-frame depdendencies will live in threadframe.h. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vp3: Don't output bogus warningAndreas Rheinhardt2022-01-13
| | | | | | | It is perfectly fine to have from one to seven bits left at the end of parsing. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vp3: Check version in all cases when VP4 code is not builtMichael Niedermayer2021-12-01
| | | | | | | | | Fixes: out of array read Fixes: 40284/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-4599568176644096 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vp3: Mark decoders as init-threadsafeAndreas Rheinhardt2021-05-10
| | | | | Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vp3: ReindentationAndreas Rheinhardt2021-05-10
| | | | | Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vp3: Avoid code duplication when initializing coeff_vlcsAndreas Rheinhardt2021-05-10
| | | | | Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vp3: Don't try to decode VP4 when VP4 decoder is disabledAndreas Rheinhardt2021-05-10
| | | | | | | | Otherwise decoding will crash lateron; e.g. because dct_tokens is never set or because a VLC that has not been allocated is used. Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | 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>
* avcodec/vp3: Check input amount in theora_decode_header()Michael Niedermayer2021-01-31
| | | | | | | | | Fixes: Timeout Fixes: 29226/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-6195092572471296 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bumpAnton Khirnov2021-01-01
| | | | They are not properly namespaced and not intended for public use.
* avcodec/vp3: Remove code duplication when initializing Theora VLCsAndreas Rheinhardt2020-12-08
| | | | | | | theora_init_huffman_tables() does essentially the same as ff_init_vlcs_from_lengths(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Use symbols table for VP3 motion vectorsAndreas Rheinhardt2020-12-08
| | | | | | | | | | | | | Expressions like array[get_vlc2()] can be optimized by using a symbols table if the array is always the same for a given VLC. This requirement is fulfilled for the VLC used for VP3 motion vectors. The reason it hasn't been done before is probably that the array in this case contained entries in the range -31..31; but this is no problem with ff_init_vlc_from_lengths(): Just apply an offset of 31 to the symbols before storing them in the table used to initialize VP3 motion vectors and apply an offset of -31 when initializing the actual VLC. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Make tables used to initialize VLCs smallerAndreas Rheinhardt2020-12-08
| | | | | | | | | This is possible by switching to ff_init_vlc_from_lengths() because it allows to replace codes of type uint16_t by symbols of type uint8_t; in some cases (like here) it also allows to replace explicitly coded codes by implicitly coded symbols. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Apply VLC offset during initAndreas Rheinhardt2020-12-08
| | | | | | | | | | By switching to ff_init_vlc_from_lengths() one can apply both positive as well as negative offsets for free; in this case it even saves space because one replaces codes tables that don't fit into an uint8_t by symbols tables that fit into an uint8_t or can even be completely avoided as they are trivial. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Don't check for errors for complete VLCAndreas Rheinhardt2020-10-29
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Make parsing Theora Huffman tables more spec-compliantAndreas Rheinhardt2020-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Theora allows to use custom Huffman tables which are coded in the bitstream as a tree: Whether the next node is a leaf or not is coded in a bit; each node itself contains a five bit token. Each tree can contain at most 32 leafs; typically they contain exactly 32 with the 32 symbols forming a permutation of 0..31. Yet the standard does not impose either of these requirements. It explicitly allows less than 32 leafs and multiple codes with the same token. But our decoder used an algorithm that required the codes->token mapping to be injective and that also presumed that there be at least two leafs: Instead of using an array for codes, tokens and code lengths, the decoder only had arrays for codes and code lengths. The code and length for a given token were stored in entry[token]. As no symbols table was used when initializing the VLC, the default one applied and therefore the entry[token] got the symbol token (if the length of said entry is >0). Yet if multiple codes had the same token, the codes and lengths from the later token would overwrite the earlier codes and lengths. Furthermore, less than 32 leafs could also lead to problems: Namely if this was not the first time Huffman tables have been parsed in which case the array is not zeroed initially so that old entries could make the new table invalid. libtheora seems to always use 32 leafs and no duplicate tokens; I am not aware of any existing valid files that do not. This is fixed by using a codes, symbols and lengths array when initializing the VLC. In order to reduce the amount of stuff kept in the context only the symbols and lengths (which both fit into an uint8_t) are kept in the context; the codes are derived from the lengths immediately before creating the tables. There is now only one thing left which is not spec-compliant: Trees with only one node (which has length zero) are not supported by ff_init_vlc_sparse() yet. Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Unify initializing and freeing VLC tablesAndreas Rheinhardt2020-10-21
| | | | | Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Check allocations of VLCsAndreas Rheinhardt2020-10-21
| | | | | | | It would lead to crashs lateron if they failed. Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: Fix memleak upon init failureAndreas Rheinhardt2020-10-21
| | | | | | | | | | Up until now, there was no cleanup in case initializing the Theora VLC tables failed, leading to memleaks. This commit gets rid of them by setting the FF_CODEC_CAP_INIT_CLEANUP flag for all decoders in vp3.c; this also allows to remove some (now redundant) cleanup code. Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3: fix indentationPeter Ross2020-04-17
|
* pthread_frame: merge the functionality for normal decoder init and ↵Anton Khirnov2020-04-10
| | | | | | | | | | | | | | | | init_thread_copy The current design, where - proper init is called for the first per-thread context - first thread's private data is copied into private data for all the other threads - a "fixup" function is called for all the other threads to e.g. allocate dynamically allocated data is very fragile and hard to follow, so it is abandoned. Instead, the same init function is used to init each per-thread context. Where necessary, AVCodecInternal.is_copy can be used to differentiate between the first thread and the other ones (e.g. for decoding the extradata just once).
* lavc: replace AVCodecInternal.allocate_progress with an internal capAnton Khirnov2020-04-10
| | | | This is a constant codec property, so a capability flag is more appropriate.
* avcodec/vp3: propagate error codesPeter Ross2020-04-07
| | | | | | | throughout vp3_decode_frame the error code was being captured (ret) but never returned. Signed-off-by: Peter Ross <pross@xvid.org> Reviewed-by: Anton Khirnov <anton@khirnov.net>
* vp3: eliminate copy_fieldsAnton Khirnov2020-03-16
| | | | | It is very fragile against fields being moved and hides what is actually being copied. Copy all the fields explicitly instead.
* avcodec: Replace get_bits_long() by get_bits() where possibleMichael Niedermayer2019-12-31
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* vp4: prevent unaligned memory access in loop filterPeter Ross2019-10-30
| | | | | | | | | | | | VP4 applies a loop filter during motion compensation, causing the block offset will often by unaligned. This produces a bus error on some platforms, namely ARMv7 NEON. This patch adds a unaligned version of the loop filter function pointer to VP3DSPContext. Reported-by: Mike Melanson <mike@multimedia.cx> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vp3: Check for end of input in 2 places of vp4_unpack_macroblocks()Michael Niedermayer2019-09-02
| | | | | | | | | Fixes: Timeout (82sec -> 1sec) Fixes: 16411/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5166958151991296 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vp3: Check for end of input in vp4_unpack_vlcs()Michael Niedermayer2019-08-03
| | | | | | | | | Fixes: Timeout (too long -> 1sec) Fixes: 15232/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5769583086010368 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vp3: Check that theora is theoraMichael Niedermayer2019-08-02
| | | | | | | | | | | Theora is forced to be non zero if it is zero and a sample is asked for, as suggested by reimar Fixes: Timeout (2min -> 600ms) Fixes: 15366/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5737849938247680 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* VP4 video decoderPeter Ross2019-06-12
|
* avcodec/vp3: spin off get_eob_run and get_coeff coeff functionsPeter Ross2019-06-12
| | | | these reoutines are shared by vp3 and vp4.
* avcodec/vp3data: combine eob_run_base and eob_run_get_bits tablesPeter Ross2019-06-08
|
* avcodec/vp3dsp: move vp3 init loop filter function to vp3dspPeter Ross2019-01-26
| | | | | | This is also used by the VP6 decoder. Signed-off-by: Peter Ross <pross@xvid.org>
* avcodec/vp3: ref_frame/ref_frames are only required when HAVE_THREADS=1Peter Ross2019-01-14
|
* avcodec/vp3: reindent unpack_superblocks()Michael Niedermayer2018-10-29
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vp3: Do not recalculate coded_fragment_list for keyframesMichael Niedermayer2018-10-29
| | | | | | | | | | This improves decoding speed of keyframes Fixes: Timeout (102->27sec) Fixes: 9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vp3: Reuse local variable in unpack_superblocks()Michael Niedermayer2018-10-29
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vp3: Do not initialize unused tables for keyframes in ↵Michael Niedermayer2018-10-29
| | | | | | | | | | unpack_superblock() Fixes: Timeout (139sec -> 102sec) Fixes: 9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vp3: Fix end of bitstream check in unpack_superblocks()Michael Niedermayer2018-06-02
| | | | | | | | Fixes: regression Found-by: Frank Liberato <liberato@google.com> Tested-by: Frank Liberato <liberato@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>