summaryrefslogtreecommitdiff
path: root/libavcodec/vc1dec.c
Commit message (Collapse)AuthorAge
* avcodec/avcodec: Add FFHWAccel, hide internals of AVHWAccelAndreas Rheinhardt2023-08-07
| | | | | | | | | This commit is the AVHWAccel analogue of commit 20f972701806be20a77f808db332d9489343bb78: It moves the private fields of AVHWAccel to a new struct FFHWAccel extending AVHWAccel in an internal header (namely hwaccel_internal.h). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc: deprecate AVCodecContext.ticks_per_frameAnton Khirnov2023-05-15
| | | | | | | | For encoding, this field is entirely redundant with AVCodecContext.framerate. For decoding, this field is entirely redundant with AV_CODEC_PROP_FIELDS.
* avcodec: use the new AVFrame key_frame flag in all decoders and encodersJames Almer2023-05-04
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: use the new AVFrame interlace flags in all decoders and encodersJames Almer2023-05-04
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/vc1dec: Use av_fast_realloc() for slicesMichael Niedermayer2023-04-02
| | | | | | | | Fixes: Timeout Fixes: 57281/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-4594141064724480 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Remove VC-1 decoders->H.263 decoder dependencyAndreas Rheinhardt2022-11-06
| | | | | | | | | | | | | | The only thing from the H.263 decoder that is reachable by the VC-1 decoder is ff_h263_decode_init(); but it does not even use all of it; e.g. h263dsp is unused and so are the VLCs initialized in ff_h263_decode_init() (they amount to about 77KB which are now no longer touched). Notice that one could also call ff_idctdsp_init() directly instead of ff_mpv_idct_init(); one could even do so in ff_vc1_init_common(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_dec: Don't use MotionEstContext as scratch spaceAndreas Rheinhardt2022-11-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decoders that might use quarter pixel motion estimation (namely MPEG-4 as well as the VC-1 family) currently use MpegEncContext.me.qpel_(put|avg) as scratch space for pointers to arrays of function pointers. (MotionEstContext contains such pointers as it supports quarter pixel motion estimation.) The MotionEstContext is unused apart from this for the decoding part of mpegvideo. Using the context at all is for decoding is actually unnecessary and easily avoided: All codecs with quarter pixels set me.qpel_avg to qdsp.avg_qpel_pixels_tab, so one can just unconditionally use this in ff_mpv_reconstruct_mb(). MPEG-4 sets qpel_put to qdsp.put_qpel_pixels_tab or to qdsp.put_no_rnd_qpel_pixels_tab based upon whether the current frame is a b-frame with no_rounding or not, while the VC-1-based decoders set it to qdsp.put_qpel_pixels_tab unconditionally. Given that no_rounding is always zero for VC-1, using the same check for VC-1 as well as for MPEG-4 would work. Since ff_mpv_reconstruct_mb() already has exactly the right check (for hpeldsp), it can simply be reused. (This change will result in ff_mpv_motion() receiving a pointer to an array of NULL function pointers instead of a NULL pointer for codecs without qpeldsp (like MPEG-1/2). It doesn't matter.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1dec: Split VC-1 decoders from msmpeg4Andreas Rheinhardt2022-11-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only msmpeg4 code that is ever executed by the VC-1 based decoders is ff_msmpeg4_decode_init() and what is directly reachable from it. This is: a) A call to av_image_check_size(), then ff_h263_decode_init(), b) followed by setting [yc]_dc_scale_table and initializing scantable/permutations. c) Afterwards, some static tables are initialized. d) Finally, slice_height is set. The replacement for ff_msmpeg4_decode_init() performs a) just like now; it also sets [yc]_dc_scale_table, but it only initializes inter_scantable and intra_scantable and not permutated_intra_[hv]_scantable: The latter are only used inside decode_mb callbacks which are only called in ff_h263_decode_frame() which is unused for VC-1.* The static tables initialized in c) are not used at all by VC-1 (the ones that are used have been factored out in previous commits); this avoids touching 327KiB of .bss. slice_height is also not used by the VC-1 decoder (setting it in ff_msmpeg4_decode_init() is probably redundant after b34397b4cd780b5692548e7d021ec884c7217dba). *: It follows from this that the VC-1 decoder is not really based upon the H.263 decoder either; changing this will be done in a future commit. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpeg4data: Move data shared between msmpeg4 and VC-1 outAndreas Rheinhardt2022-11-06
| | | | | | | | This is in preparation for splitting VC-1 from msmpeg4. (msmpeg4data.c was originally intended to be just this; 9488b966c76a7a52e9a1f7756bda82dbe1070399 changed it). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1dec: Return early upon errorAndreas Rheinhardt2022-11-06
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1dec: Factor (re)initializing code outAndreas Rheinhardt2022-11-06
| | | | | | | This is in preparation for removing the msmpeg4 dependency from VC-1. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1dec: Don't open and close decoder during initAndreas Rheinhardt2022-11-06
| | | | | | | | | | | | | | | This is done since 16af29a7a6deff3f6081fca1e36ad96cf8fec77d (and is actually unnecessary, because the tables initialized in ff_msmpeg4_decode_init() are only ever used in vc1_block.c which is only entered after a call to ff_msmpeg4_decode_init()) in a very ugly manner; said manner had the byproduct of involving lots of unnecessary allocations and even opening and closing a hwaccel in case one is used. This commit achieves the aim of 16af29a7a6deff3f6081fca1e36ad96cf8fec77d by initializing the VLCs used by VC-1 in ff_vc1_init_common(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1: Move ff_vc1_init_common() to vc1dec.cAndreas Rheinhardt2022-11-06
| | | | | | | This is possible given that it is no longer used by the parser. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1: Move setting res_fasttx-IDCT functions to vc1dec.cAndreas Rheinhardt2022-11-06
| | | | | | It allows to avoid compiling simple_idct.o for the VC-1 parser. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/blockdsp: Remove unused AVCodecContext parameterAndreas Rheinhardt2022-09-21
| | | | | | | Possible since be95df12bb06b183c8d2aea3b0831fdf05466cf3. Reviewed-by: Rémi Denis-Courmont <remi@remlab.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-03
| | | | | | | | 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_get_buffer() to decode.hAndreas Rheinhardt2022-08-27
| | | | | | | | | 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>
* avcodec/internal: Move ff_get_format() to decode.hAndreas Rheinhardt2022-08-27
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/intrax8: Remove unused IDCTDSPContextAndreas Rheinhardt2022-08-03
| | | | 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/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/vc1: Introduce fast path for unescaping bitstream bufferBen Avison2022-04-01
| | | | | | | Includes a checkasm test. Signed-off-by: Ben Avison <bavison@riscosopen.org> Signed-off-by: Martin Storsjö <martin@martin.st>
* 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/msmpeg4dec: Make initializing VLCs thread-safeAndreas Rheinhardt2022-02-18
| | | | | | | | | | | This automatically makes the remaining mpegvideo-decoders (namely msmpeg4v[1-3], mss2, VC-1, VC-1 Image, WMV-[1-3] and WMV-3 Image) init-threadsafe. These were the last native codecs that were not init-threadsafe; only wrappers for external libraries and for hardware accelerations are now not init-threadsafe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move decoder-only stuff to a new headerAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpeg4.h: Move decoder-only parts to a new headerAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo, svq3: Remove unused next_p_frame_damagedAndreas Rheinhardt2022-01-13
| | | | | | Always zero since 4d2858deac5213eaddfdc06f98379b6325d7b953. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc, vc1dec: Remove always-false checkAndreas Rheinhardt2021-12-17
| | | | | | Mpeg1EncContext.droppable is only nonzero for the FLV decoder. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1dec: return value check for init_get_bitsmaryam ebrahimzadeh2021-08-26
| | | | | | As the second argument for init_get_bits(avctx and buf) can be crafted, a return value check for this function call is necessary, so replace init_get_bits with init_get_bits8 and add return value check.
* avcodec/vc1dec: ff_print_debug_info() does not support WMV3 field_modeMichael Niedermayer2021-08-22
| | | | | | | | Fixes: out of array read Fixes: 36331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-5140494328922112.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Disable error concealment for *IMAGEMichael Niedermayer2021-08-10
| | | | | | | | | | | | | | The existing error concealment makes no sense for the image formats, they use transformed source images which is different from keyframe + MC+difference for which the error concealment is designed. Of course feel free to re-enable this if you have a case where it works and improves vissual results Fixes: Timeout Fixes: 36234/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-6300306743885824 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-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/vc1: Remove unused hrd fieldsAndreas Rheinhardt2021-04-12
| | | | | | Unused since be3492ec7eb2dbb0748c123af911a06c125c90db. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1: Don't pretend ff_vc1_init_common() can failAndreas Rheinhardt2021-04-12
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vc1dec: Fix memleak upon allocation errorAndreas Rheinhardt2021-04-08
| | | | | | | | | | ff_vc1_decode_init_alloc_tables() had one error path that forgot to free already allocated buffers; these would then be overwritten on the next allocation attempt (or they would just not be freed in case this happened during init, as the decoders for which it is used do not have the FF_CODEC_CAP_INIT_CLEANUP set). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1dec: Postpone allocating sprite frame to avoid segfaultAndreas Rheinhardt2021-03-25
| | | | | | | | | | | | | | Up until now, the VC-1 decoders allocated an AVFrame for usage with sprites during vc1_decode_init(); yet said AVFrame can be freed if (re)initializing the context (which happens ordinarily during decoding) fails. The AVFrame does not get allocated again lateron in this case, leading to segfaults. Fix this by moving the allocation of said frame immediately before it is used (this also means that said frame won't be allocated at all any more in case of a regular (i.e. non-image) stream). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* Mark some pointers as constAndreas Rheinhardt2021-01-01
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavc: Rename hwaccel.h to hwconfig.hMark Thompson2020-04-26
| | | | | This already applied to decoders as well as hwaccels, and adding encoder support was going to make the name even more inaccurate.
* avcodec/vc1dec: Allocate only as much space as is unescapedMichael Niedermayer2020-01-18
| | | | | | | | | Fixes: OOM Fixes: 18137/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5723834900021248 Fixes: 20037/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5683758976204800 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/vc1: Remove bits variableMichael Niedermayer2020-01-11
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Check field_mode for spritesMichael Niedermayer2020-01-11
| | | | | | | | Fixes: Out of array read Fixes: 19263/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5389219325542400 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Limit bits by the actual bitstream sizeMichael Niedermayer2020-01-11
| | | | | | | | Fixes: Timeout (350 ->19sec) Fixes: 19249/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-6566896438870016 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Fix "return -1" casesMichael Niedermayer2019-12-28
| | | | | Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Free sprite_output_frame on errorMichael Niedermayer2019-12-28
| | | | | | | | Fixes: memleaks Fixes: 19471/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5688035714269184 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: remove the unneeded ()Limin Wang2019-12-26
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Require res_sprite for wmv3imagesMichael Niedermayer2019-08-31
| | | | | | | | | | | non res_sprite leads to decoder delay which leads to assertion failure Fixes: Assertion failure Fixes: 16402/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5704510034411520 Fixes: left shift of 1073741824 by 1 places cannot be represented in type 'int' Fixes: 16425/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5692858838810624 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1: fix check for missing CBPTABJerome Borsboom2018-06-29
| | | | | | CBPTAB must be present in (non skipped) P and B pictures. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>