summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
* avcodec/error_resilience: Remove write only ERContext.ref_countAndreas Rheinhardt2022-03-25
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264dec: Constify slices' pointer to the parent contextAndreas Rheinhardt2022-03-25
| | | | | | | | | Modifying the main context by a slice thread is racy; so constify the pointer to it in H264SliceContext. The code itself was already compatible with this change. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264dec: Move ERContext to H264ContextAndreas Rheinhardt2022-03-25
| | | | | | | | | | | | | | | | Since 7be2d2a70cd20d88fd826a83f87037d14681a579 only one context is used. Moving it to H264Context from H264SliceContext is natural. One could access the ERContext from H264SliceContext via H264SliceContext.h264->er; yet H264SliceContext.h264 should naturally be const-qualified, because slice threads should not modify the main context. The ERContext is an exception to this, as ff_er_add_slice() is intended to be called simultaneously by multiple threads. And for this one needs a pointer whose pointed-to-type is not const-qualified. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264_slice: Fix decoding undamaged input with slicesAndreas Rheinhardt2022-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ff_er_frame_start() initializes ERContext.error_count to three times the number of macroblocks to decode. Later ff_er_add_slice() reduces this number by the amount of macroblocks whose AC resp. DC resp. MV have been finished (so every correctly decoded MB counts three times). So the frame has been decoded correctly if error_count is zero at the end. The H.264 decoder uses multiple ERContexts when using slice threading and therefore combines these error counts: The first slice's ERContext is intended to be initialized by ff_er_frame_start(), error_count of all the other slice contexts is intended to be zeroed initially and all afterwards all the error_counts are summed. Yet commit 43b434210e597d484aef57c4139c3126d22b7e2b (probably unintentionally) changed the code to set the first slice's error_count to zero as well. This leads to bogus error messages in case one decodes an input video using multiple slices with slice threading with error concealment enabled (which is not the default) ("concealing 0 DC, 0 AC, 0 MV errors in [IPB] frame"); furthermore the returned frame is marked as corrupt as well (ffmpeg reports "corrupt decoded frame in stream %d" for this). This can be fixed easily given that only the first ERContext is really used since 7be2d2a70cd20d88fd826a83f87037d14681a579: Don't reset the error_count; and don't sum the error counts as well. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/bsf: Add FFBitStreamFilter, hide internals of BSFsAndreas Rheinhardt2022-03-23
| | | | | | | | | | This patch is analogous to 20f972701806be20a77f808db332d9489343bb78: It hides the internal part of AVBitStreamFilter by adding a new internal structure FFBitStreamFilter (declared in bsf_internal.h) that has an AVBitStreamFilter as its first member; the internal part of AVBitStreamFilter is moved to this new structure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec, avformat: Remove unnecessary inclusions of lavc/internal.hAndreas Rheinhardt2022-03-23
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_QSCALE_TYPE_* to mpegvideodec.hAndreas Rheinhardt2022-03-23
| | | | | | These values are only used by mpegvideo-based decoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal, avfilter/qp_table: Remove unused FF_QSCALE_TYPEsAndreas Rheinhardt2022-03-23
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "avcodec/av1dec: Check tile_cols"James Almer2022-03-23
| | | | | | | | This reverts commit 4fdfe430c12225e819f68993474bd2f473c7e8b1. The previous commit ensures this field will never be zero. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1: only set the private context pix_fmt field if ↵James Almer2022-03-23
| | | | | | | | | | | | | | | | | get_pixel_format() succeeds Otherwise get_pixel_format() will not be called when parsing a subsequent Sequence Header in non hwaccel enabled scenarios, allowing frame parsing when it shouldn't. This prevents the scenario seqhdr -> frame_hdr/redundant_frame_hdr -> seqhdr -> redundant_frame_hdr from having the latter redundant frame header parsed as if it was a frame header by the decoder because the former was discarded. Since CBS did not discard it, the latter redundant frame header is output with a zeroed AV1RawFrameHeader struct, which can have undesired results, like division by zero with fields normally guaranteed to be anything else. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libsvtav1: pass color description infoChristopher Degawa2022-03-23
| | | | Signed-off-by: Christopher Degawa <ccom@randomderp.com>
* avcodec/binkaudio: add support for >2 channels dct codecPaul B Mahol2022-03-22
| | | | As presented in .binka files.
* avcodec/internal: Move FF_DEFAULT_QUANT_BIAS to mpegvideoenc.hAndreas Rheinhardt2022-03-21
| | | | | | Only used there. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_SIGNBIT and ff_log2_run to mathops.hAndreas Rheinhardt2022-03-21
| | | | | | | It is a more fitting place for them. Also move the definition of ff_log2_run to mathtables.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/bitstream: Move code for initializing VLCs to file of its ownAndreas Rheinhardt2022-03-21
| | | | | | | | | | | | bitstream.c is currently the disjoint union of three parts: The first part is ff_log2_run, the second part are some auxiliary functions for the PutBits-API; and the third part is the code for creating VLCs. This commit moves the latter into a file of its own. This has the advantage of making one of the hacks in tableprint_vlc.h redundant as vlc.c does not include config.h (whereas the PutBits-API part does). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mathops: Move bitswap_32() to its only userAndreas Rheinhardt2022-03-21
| | | | | | | | Effectively reverts eaff1aa09e90e2711207c9463db8bf8e8dec8178 given that bitswap_32 is no longer used outside of bitstream.c since 03008c2811ec26cf338780a89b6b2b849b399e3c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/allcodecs: Dont play with NULLsMichael Niedermayer2022-03-21
| | | | | | | | | Fixes: member access within null pointer of type 'const FFCodec' (aka 'const struct FFCodec') Fixes: 45726/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6554445419249664 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/av1dec: Check tile_colsMichael Niedermayer2022-03-21
| | | | | | | | | Fixes: division by zero Fixes: 43769/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5392562205097984 Fixes: 43950/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5769210217758720 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/wmaprodec: ensure channel count in the private context and decoder ↵James Almer2022-03-21
| | | | | | | | | | | context are consistent avctx->ch_layout will be reinitialized using channel_mask later in the function. Fixes: 45736/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAPRO_fuzzer-5769886813519872 Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mlpdec: Use 64bit for channel layoutMichael Niedermayer2022-03-21
| | | | | | | | | Fixes: shift exponent 33 is too large for 32-bit type 'int' Fixes: 45645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5651350182035456 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pixlet: Avoid signed integer overflow in scaling in filterfn()Michael Niedermayer2022-03-21
| | | | | | | | Fixes: signed integer overflow: 11494 * 1073741824000000 cannot be represented in type 'long' Fixes: 26586/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-5752633970917376 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/codec_internal: Rename AVCodecDefault->FFCodecDefaultAndreas Rheinhardt2022-03-21
| | | | | | | This structure is no longer declared in a public header, so using an FF-prefix is more appropriate. 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>
* avcodec/opus: always use ambisonic layout for mapping family 2James Almer2022-03-20
| | | | | | | | | | | No need to use a Custom layout when the non diegetic channels can be described as a standard mask. This fixes: 45684/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBOPUS_fuzzer-5039410989629440 Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/bsf: improve doxyAnton Khirnov2022-03-19
|
* lavc/bsf: add general documentationAnton Khirnov2022-03-19
| | | | Also, place the BSF api docs in their own doxygen group.
* avcodec/flashsv2enc: Avoid opening and closing z_streamAndreas Rheinhardt2022-03-19
| | | | | | Instead initialize a z_stream during init and reset it when needed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/lclenc: Use ff_deflate_init/end() wrappersAndreas Rheinhardt2022-03-19
| | | | | | | | | They return nicer error messages on error; furthermore, they also use our allocation functions. It also stops calling deflateEnd() on a z_stream that might not have been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pngenc: Use ff_deflate_init/end() wrappersAndreas Rheinhardt2022-03-19
| | | | | | They return nicer error messages. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/zmbvenc: Use ff_deflate_init/end() wrappersAndreas Rheinhardt2022-03-19
| | | | | | | They emit better error messages (it does not claim that inflateInit failed upon an error from deflateInit!) and uses our allocation functions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/zlib_wrapper: Add wrapper for deflateInit()Andreas Rheinhardt2022-03-19
| | | | | | | | | | | The rationale is the same as for the wrappers for inflateInit(), although the case for it is admittedly not so strong because there are less users of deflateInit(). Also remove an unnecessary inclusion of config.h in libavformat/protocols.c in order to trigger a request for reconfigure (which is needed for CONFIG_DEFLATE_WRAPPER to take effect). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pngenc: Don't use deflateInit2() with default parametersAndreas Rheinhardt2022-03-19
| | | | | | Use deflateInit() instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pngdec: Don't open and close z_streams unnecessarilyAndreas Rheinhardt2022-03-19
| | | | | | | | Instead reuse and reset a single z_stream. Also use FFZStream in decode_zbuf(), because it has nicer error messages. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/lscrdec: Don't open and close z_streams unnecessarilyAndreas Rheinhardt2022-03-19
| | | | | | Instead reuse and reset a single z_stream. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/zlib_wrapper: Use our allocation, freeing functionsAndreas Rheinhardt2022-03-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/flashsv: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | This fixes the problem of potentially closing a z_stream that has never been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/lcldec: Use ff_inflate_init/end(), cleanup genericallyAndreas Rheinhardt2022-03-19
| | | | | | | | | Returns better error messages in case of error and deduplicates the inflateInit() code and also allows to cleanup generically in case of errors as it is save to call ff_inflate_end() if ff_inflate_init() has not been called successfully. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mscc: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | This fixes the problem of potentially closing a z_stream that has never been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mvha: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | This fixes the problem of potentially closing a z_stream that has never been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mwsc: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | This fixes the problem of potentially closing a z_stream that has never been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/rasc: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | This fixes the problem of potentially closing a z_stream that has never been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/tscc: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | Returns better error messages in case of error and deduplicates the inflateInit() code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/wcmv: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | This fixes the problem of potentially closing a z_stream that has never been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/zerocodec: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | This fixes the problem of potentially closing a z_stream that has never been successfully initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/zmbv: Use ff_inflate_init/end()Andreas Rheinhardt2022-03-19
| | | | | | | Returns better error messages in case of error and deduplicates the inflateInit() code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/zlib_wrapper: Add wrappers for zlib inflateInit, inflateEndAndreas Rheinhardt2022-03-19
| | | | | | | | | | | | | | | | | It is not documented to be safe to call inflateEnd() on a z_stream that has never been successfully been initialized by inflateInit(), but just zeroed. It just happens to work and several codecs rely on this (they have FF_CODEC_CAP_INIT_CLEANUP set and even call inflateEnd() when inflateInit() failed or has never been called). To avoid this, other codecs recorded whether their zstream has been initialized successfully or not. This commit adds wrappers for inflateInit() and inflateEnd() that do what these other codecs do; furthermore, they also take care of properly setting up the zstream before inflateInit() and emit an error message in case of error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pngenc: Avoid potentially truncating integersAndreas Rheinhardt2022-03-19
| | | | | | | | | So use 64bits for max_packet_size instead of size_t which might be 32 bits; this is consistent with ff_alloc_packet(). Also remove a redundant size check (ff_alloc_packet() already checks for that). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Keep including the full version.h when headers are included externallyMartin Storsjö2022-03-19
| | | | | | | | | This avoids unnecessary churn and build breakage for users, by making sure the whole version.h is included like it has been so far, while keeping the benefit of not needing to rebuild most files in the ffmpeg tree on minor/micro bumps. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/sonic: Use unsigned for predictor_k to avoid undefined behaviorMichael Niedermayer2022-03-18
| | | | | | | | Fixes: signed integer overflow: -1094995529 * 24 cannot be represented in type 'int' Fixes: 44436/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-4874459459223552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>