summaryrefslogtreecommitdiff
path: root/libavcodec/mpeg12dec.c
Commit message (Collapse)AuthorAge
* 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: Remove private options from AVCodecContextAndreas Rheinhardt2021-04-27
| | | | | | | | | Several options that were too codec-specific were deprecated between 0e6c8532215790bbe560a9eea4f3cc82bb55cf92 and 0e9c4fe254073b209970df3e3cb84531bc388e99. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h263dec, mpeg12dec: Remove redundant writesAndreas Rheinhardt2021-04-12
| | | | | | ff_mpv_decode_init() already sets MpegEncContext.codec_id. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "avcodec: add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ↵Andreas Rheinhardt2021-04-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ff_mpv_common_init()" This mostly reverts commit 4b2863ff01b1fe93d9a518523c9098d17a9d8c6f. Said commit removed the freeing code from ff_mpv_common_init(), ff_mpv_common_frame_size_change() and ff_mpeg_framesize_alloc() and instead added the FF_CODEC_CAP_INIT_CLEANUP to several codecs that use ff_mpv_common_init(). This introduced several bugs: a) Several decoders using ff_mpv_common_init() in their init function were forgotten: This affected FLV, Intel H.263, RealVideo 3.0 and V4.0 as well as VC-1/WMV3. b) ff_mpv_common_init() is not only called from the init function of codecs, it is also called from AVCodec.decode functions. If an error happens after an allocation has succeeded, it can lead to memleaks; furthermore, it is now possible for the MpegEncContext to be marked as initialized even when ff_mpv_common_init() returns an error and this can lead to segfaults because decoders that call ff_mpv_common_init() when decoding a frame can mistakenly think that the MpegEncContext has been properly initialized. This can e.g. happen with H.261 or MPEG-4. c) Removing code for freeing from ff_mpeg_framesize_alloc() (which can't be called from any init function) can lead to segfaults because the check for whether it needs to allocate consists of checking whether the first of the buffers allocated there has been allocated. This part has already been fixed in 76cea1d2ce3f23e8131c8664086a1daf873ed694. d) ff_mpv_common_frame_size_change() can also not be reached from any AVCodec.init function; yet the changes can e.g. lead to segfaults with decoders using ff_h263_decode_frame() upon allocation failure, because the MpegEncContext will upon return be flagged as both initialized and not in need of reinitialization (granted, the fact that ff_h263_decode_frame() clears context_reinit before the context has been reinited is a bug in itself). With the earlier version, the context would be cleaned upon failure and it would be attempted to initialize the context again in the next call to ff_h263_decode_frame(). While a) could be fixed by adding the missing FF_CODEC_CAP_INIT_CLEANUP, keeping the current approach would entail adding cleanup code to several other places because of b). Therefore ff_mpv_common_init() is again made to clean up after itself; the changes to the wmv2 decoder and the SVQ1 encoder have not been reverted: The former fixed a memleak, the latter allowed to remove cleanup code. Fixes: double free Fixes: ff_free_picture_tables.mp4 Fixes: ff_mpeg_update_thread_context.mp4 Fixes: decode_colskip.mp4 Fixes: memset.mp4 Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12dec: Remove redundant writesAndreas Rheinhardt2021-01-21
| | | | | | | ff_mpv_decode_init() already sets MpegEncContext.avctx. Reviewed-by: Anton Khirnov <anton@khirnov.net> 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>
* mpegvideo: use the AVVideoEncParams API for exporting QP tablesAnton Khirnov2021-01-01
| | | | | | | | | | Do it only when requested with the AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS flag. Drop previous code using the long-deprecated AV_FRAME_DATA_QP_TABLE* API. Temporarily disable fate-filter-pp, fate-filter-pp7, fate-filter-spp. They will be reenabled once these filters are converted in following commits.
* 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/mpegvideo: Merge ff_mpv_decode_defaults into ff_mpv_decode_initAndreas Rheinhardt2020-12-31
| | | | | | | | | | | | | These two are always called directly after each other (with the exception of the calls in mpeg_decode_init() where some irrelevant modifications of the avctx (which could just as well be done before ff_mpv_decode_defaults(), because it doesn't have a pointer to the AVCodecContext at all and therefore can't see these modifications at all) are performed in between), so merge ff_mpv_decode_defaults() in ff_mpv_decode_init(). Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12: Make initializing VLCs thread-safeAndreas Rheinhardt2020-12-31
| | | | | | | | | This automatically makes the eamad, eatqi, ipu and mdec decoders init-threadsafe; in addition to the actual mpeg[12]video decoders, of course. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12dec: Limit maximum A53 CC sizeMichael Niedermayer2020-10-18
| | | | | | | | | | | | | | This is more than 10 times the size of the largest i found. And also alot more than our encoder could handle (our encoder is limited to max 31) Without any limit megabyte+ sized blocks can be reallocated millions of times. Sadly the SCTE-20 spec does not seem to contain any hard limit directly, so this limit here is arbitrary Fixes: Timeout (25sec -> 152ms) Fixes: 25714/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG2VIDEO_fuzzer-5713633336885248 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpeg12: Don't pretend reading dct_dc_size_* VLCs can failAndreas Rheinhardt2020-10-12
| | | | | | | | | | It can't because the corresponding trees don't have any loose ends. Removing the checks also removed an instance of av_log(NULL (with a nonsense message) from the codebase. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12dec: Optimize reading mpeg2 intra escape codesAndreas Rheinhardt2020-10-10
| | | | | | | | | | Said escape code is only six bits long, so that one has at least 25 - 6 bits in the bitstream reader's cache after reading it; therefore the whole following 18 bits (containing the actual code) are already in the bitstream reader's cache, making it unnecessary to reload the cache. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12dec: remove inter block calls in IPU decoderPaul B Mahol2020-09-25
| | | | This is intra only codec.
* avcodec/mpeg12dec: add support for MPEG1 blocks in IPU codecPaul B Mahol2020-09-25
|
* avcodec: add IPU Video decoder and parserPaul B Mahol2020-09-24
|
* avcodec/mpeg12dec: add timecode metadataLimin Wang2020-07-09
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/mpeg12dec: Fix uninitialized data in fate-sub-cc-scte20Limin Wang2020-06-30
| | | | | | | | | The issue is introduced in a705bcd763e344fa, please tested with below command line: make V=1 fate-sub-cc-scte20 TARGET_EXEC="valgrind --error-exitcode=1" Reported-by: Martin Storsjö <martin@martin.st> Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/mpeg12dec: switch to AVBufferRef buffer for a53 captionLimin Wang2020-06-26
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/mpeg12dec: do not discard older a53 captionsPaul B Mahol2020-06-20
| | | | Fixes #6105.
* avcodec: add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ↵Limin Wang2020-06-13
| | | | | | ff_mpv_common_init() Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/mpeg12dec: remove outdated commentsMichael Niedermayer2020-06-11
| | | | | Found-by: Kieran Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpeg12dec: Fix got_outputMichael Niedermayer2020-06-08
| | | | | | | | | | | | | | | | This makes got_output consistent with the code in slice_end() which sets the output in slice_end() if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { int ret = av_frame_ref(pict, s->current_picture_ptr->f); ... } else { Fixes: assertion failure Fixes: 22178/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-5664234440753152 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* 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/mpeg12dec: Add CPB coded side dataNicolas Gaullier2020-03-20
| | | | | | | This fixes mpeg2video stream copies to mpeg muxer like this: ffmpeg -i xdcamhd.mxf -c:v copy output.mpg Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avcodec/mpeg12dec: Do not alter avctx->rc_buffer_sizeNicolas Gaullier2020-03-20
| | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avcodec/mpeg12dec: Fix invalid shift in mpeg2_fast_decode_block_intra()Michael Niedermayer2020-03-11
| | | | | | | | | Fixes: left shift of negative value -695 Fixes: 19232/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-5702856963522560 Fixes: 19555/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-5741218147598336 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpeg12dec: always submit the first field to hwaccelZhong Li2020-01-02
| | | | | | | | | | | | Though this patch to fix ticket #6668, I belive it is unnecessary to set SLICE_FLAG_ALLOW_FIELD flag to other hwaccels(dxva, vdpau, etc). Please also refer the orginal comment of 9cb150c9ab520eba5636bbcf925db6a70e67f3e5 Should also fix ticket #8442. Signed-off-by: Zhong Li <zhong.li@intel.com> Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
* avcodec/mpeg12dec: Sanitize start codes earlierAndreas Rheinhardt2019-09-26
| | | | | | | | | | | | | | | | | | | | | | The MPEG-1/2 decoder uses avpriv_find_start_code to search for start codes and worked with the resulting start code before checking that it is really a start code of a slice. In particular, if the picture is so big that a slice_vertical_position_extension is present, it added the slice_vertical_position_extension as if it had a slice. Then a left shift is performed, without making sure that the value to be shifted is nonnegative. Afterwards the end result is checked, but even if a start code of a non-slice has been found, it might pass these checks: If slice_vertical_position_extension is present a start code < SLICE_MIN_START_CODE can lead to a macroblock-row index that appears valid. Furthermore, the left shift might make an invalid start code appear valid by discarding the highest bit. This has been fixed by checking directly after avpriv_find_start_code has returned. Fixes ticket #8162 (which is about the undefined left shifts). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavcodec/mpeg12dec: Check input for minimal frame sizeMichael Niedermayer2019-09-24
| | | | | | | | | Fixes: Timeout (35sec -> 6sec) Fixes: 16901/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEGVIDEO_fuzzer-5729024726269952 Fixes: 16901/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEGVIDEO_fuzzer-5642388592132096 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* mpeg4video: Add support for MPEG-4 Simple Studio Profile.Kieran Kunhya2018-04-02
| | | | This is a profile supporting > 8-bit video and has a higher quality DCT
* avcodec/mpeg2dec: Fix field selection for skipped macroblocksNekopanda2018-02-11
| | | | | | | | | | For B field pictures, the spec says, > The prediction shall be made from the field of the same parity as the field being predicted. I did it. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpeg12dec: fix preprocessor check for mpeg1_nvdec hwaccelJames Almer2018-01-21
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: Add hardware config metadata for decoders supporting hardware outputMark Thompson2017-11-26
| | | | | | | | | This includes a pointer to the associated hwaccel for decoders using hwaccels - these will be used later to implement the hwaccel setup without needing a global list. Also added is a new file listing all hwaccels as external declarations - this will be used later to generate the hwaccel list at configure time.
* avcodec: Implement mpeg1 nvdec hwaccelPhilip Langdale2017-11-20
| | | | | Once I remembered that there's a separate decoder type for mpeg1, even though params struct is shared with mpeg2, everything worked.
* avcodec: Implement mpeg2 nvdec hwaccelPhilip Langdale2017-11-18
| | | | | | This is mostly straight-forward. The weird part is that it should just work for mpeg1, but I see corruption in my test cases, so I'm going to try and fix that separately.
* avcodec/mpeg12dec: ensure a53_caption_size is reset on malloc failuresAman Gupta2017-11-15
| | | | | Signed-off-by: Aman Gupta <aman@tmm1.net> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpeg12dec: parse A53 caption data embedded in SCTE-20 user dataAman Gupta2017-11-15
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit 'dd343fd986459f467a2d1d70c26101dff1d47d68'James Almer2017-10-23
|\ | | | | | | | | | | | | * commit 'dd343fd986459f467a2d1d70c26101dff1d47d68': lavu: Drop deprecated VDPAU pixel formats Merged-by: James Almer <jamrial@gmail.com>
* | Merge commit '5182a28b5de060c51c21b36053ab205bfbbbbe31'James Almer2017-10-23
|\| | | | | | | | | | | | | * commit '5182a28b5de060c51c21b36053ab205bfbbbbe31': lavc: Drop deprecated global afd field Merged-by: James Almer <jamrial@gmail.com>
| * lavc: Drop deprecated global afd fieldVittorio Giovara2017-03-23
| | | | | | | | Deprecated in 08/2014.
* | Merge commit 'dcc39ee10e82833ce24aa57926c00ffeb1948198'James Almer2017-10-23
|\| | | | | | | | | | | | | * commit 'dcc39ee10e82833ce24aa57926c00ffeb1948198': lavc: Remove deprecated XvMC support hacks Merged-by: James Almer <jamrial@gmail.com>
| * lavc: Remove deprecated XvMC support hacksDiego Biurrun2017-03-23
| | | | | | | | Deprecated in 11/2013.
| * mpeg12dec: move setting first_field to mpeg_field_start()Anton Khirnov2016-12-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For field picture, the first_field is set based on its previous value. Before this commit, first_field is set when reading the picture coding extension. However, in corrupted files there may be multiple picture coding extension headers, so the final value of first_field that is actually used during decoding can be wrong. That can lead to various undefined behaviour, like predicting from a non-existing field. Fix this problem, by setting first_field in mpeg_field_start(), which should be called exactly once per field. CC: libav-stable@libav.org Bug-ID: 999
| * mpeg12dec: avoid signed overflow in bitrate calculationAnton Khirnov2016-12-19
| | | | | | | | | | | | CC: libav-stable@libav.org Bug-Id: 981 Found-By: Agostino Sarubbo
* | Fix visual glitch with XvMC, caused by wrong idct permutation.Ivan Kalvachev2017-10-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the past XvMC forced simple_idct since it was using FF_IDCT_PERM_NONE. However now we have SIMD variants of simple_idct that are using FF_IDCT_PERM_TRANSPOSE and if they are selected XvMC would get coefficients in the wrong order. The patch creates new FF_IDCT_NONE that is used only for this kind of hardware decoding and that fallbacks to the old C only simple idct. Signed-off-by: Ivan Kalvachev <ikalvachev@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | dxva: add support for new dxva2 and d3d11 hwaccel APIswm42017-06-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also adds support to avconv (which is trivial due to the new hwaccel API being generic enough). The new decoder setup code in dxva2.c is significantly based on work by Steve Lhomme <robux4@gmail.com>, but with heavy changes/rewrites. Merges Libav commit f9e7a2f95a7194a8736cc1416a03a1a0155a3e9f. Also adds untested VP9 support. The check for DXVA2 COBJs is removed. Just update your MinGW to something newer than a 5 year old release. Signed-off-by: Diego Biurrun <diego@biurrun.de>
* | avcodec: Rename ff_mpv_decode_mb() to ff_mpv_reconstruct_mbMichael Niedermayer2017-06-19
| | | | | | | | | | | | The new name more accuratly describes what the function does Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/mpeg12dec: Fixes runtime error: division by zeroMichael Niedermayer2017-05-11
| | | | | | | | | | | | | | Fixes: 1464/clusterfuzz-testcase-minimized-4925445571084288 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/mpeg12dec: Fix runtime error: left shift of negative value -1Michael Niedermayer2017-03-13
| | | | | | | | | | | | | | Fixes: 764/clusterfuzz-testcase-6273034652483584 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>