summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
...
* avcodec/pthread_slice: Don't use static variable, fix raceAndreas Rheinhardt2020-12-02
| | | | | | | | | | | | | | | | | | | | | | ff_slice_thread_init() uses a static variable to hold a function pointer, although the value of said pointer needn't be saved between different runs of this function at all. The reason for this being so is probably that said pointer points to a static function (if used); but storage class specifiers like "static" are not part of the type of an object and so including it in the pointer declaration is wrong (anyway, "static" means different things in both contexts: for the function declaration it affects linkage, for the variable storage duration). Using a static variable here can lead to races, e.g. when initializing VP9 (for which said function pointer was added) and H.264 with slice threading. The latter has the FF_CODEC_CAP_INIT_THREADSAFE flag set and is therefore unaffected by the lock guarding initializations of decoders. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12enc: Disallow using MPEG-2 intra VLC table for mpeg1videoAndreas Rheinhardt2020-12-02
| | | | | | | | | | | | Using MPEG-2 intra VLC tables is spec-incompliant for MPEG-1 and given that an MPEG-1 bitstream can't signal whether MPEG-2 intra VLC tables have been used the output is broken. Therefore this option is removed immediately without any deprecation period. Reviewed-by: James Almer <jamrial@gmail.com> Reviewed-by: Marton Balint <cus@passwd.hu> Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/cbs_h2645: remove dead code in cbs_h2645_replace_ps()James Almer2020-12-01
| | | | | | | Missed in 0720e15c0330f0f101c02d5c2c6548e964079f6d. PS units are now guaranteed to always be reference counter. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_av1: ensure Sequence Header unit content is always reference countedJames Almer2020-12-01
| | | | | | Prevents a NULL pointer dereference. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/vaapi_av1: read film grain param values from AV1FramesJames Almer2020-11-30
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/dxva2_av1: read film grain param values from AV1FramesJames Almer2020-11-30
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/nvdec_av1: read film grain param values from AV1FramesJames Almer2020-11-30
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: infer and store film grain param values in AV1FrameJames Almer2020-11-30
| | | | | | | | | They are not always coded in the bistream for each frame. In some cases, the values need to be taken from a reference frame. See section 6.8.20 from the AV1 spec. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_av1: split film grain param fields into their own structJames Almer2020-11-30
| | | | | | Cosmetic change in preparation for the following patches. Signed-off-by: James Almer <jamrial@gmail.com>
* Revert "avcodec/nvdec_av1: fix setting film grain parameters for frames with ↵James Almer2020-11-30
| | | | | | | | | | | update_grain == 0" This reverts commit f9eec6298387fe72cd8035ff45276cfc3da784a8. This does not effectively cover all cases. The values for some frames need to be inferred by the decoder. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/hevc_cabac: Limit value in coeff_abs_level_remaining_decode() tighterMichael Niedermayer2020-11-29
| | | | | | | | | The max depth is 16bps, the max allowed coefficient depth is depth+6 Fixes: signed integer overflow: 1074266112 + 1073725439 cannot be represented in type 'int' Fixes: 26493/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5657763331702784 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/notchlc: Check available space for luma block code and alpha codeMichael Niedermayer2020-11-29
| | | | | | | | Fixes: Timeout (too long -> 2sec) Fixes: 25439/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5688211127664640 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pafvideo: Cleanup generically on init failureAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/pnmenc: Mark encoders as init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/photocd: Mark decoder as init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/pcm-dvdenc: Mark encoder as init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/pcm-dvd: Mark decoder as init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/pafvideo: Mark decoder as init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/pafaudio: Mark decoder as init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/cdxl: Mark decoder as init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/svq1dec: Make decoder init-threadsafeAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/a64multienc: Fix memleak upon init failureAndreas Rheinhardt2020-11-29
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/utils: Require a non zero channels unless AV_CODEC_CAP_CHANNEL_CONF ↵Michael Niedermayer2020-11-28
| | | | | | | | | | | | | | | | is set This avoids per codec checks for channels not being 0 Fixes: division by 0 Fixes: 25419/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FASTAUDIO_fuzzer-5632544761184256 Fixes: 25433/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FASTAUDIO_fuzzer-6215671900536832 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Suggested-by: Paul B Mahol <onemda@gmail.com> See: [FFmpeg-devel] [PATCH 1/3] avcodec/fastaudio: Check channel Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Set AV_CODEC_CAP_CHANNEL_CONF in more decodersMichael Niedermayer2020-11-28
| | | | | | Suggested-by: Paul B Mahol <onemda@gmail.com> See: [FFmpeg-devel] [PATCH 1/3] avcodec/fastaudio: Check channels Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: deprecate thread_safe_callbacksAnton Khirnov2020-11-27
| | | | | | | | | They add considerable complexity to frame-threading implementation, which includes an unavoidably leaking error path, while the advantages of this option to the users are highly dubious. It should be always possible and desirable for the callers to make their get_buffer2() implementation thread-safe, so deprecate this option.
* lavu/film_grain_params: fix typo in type enumLynne2020-11-27
| | | | Ref: xkcd #1015
* libdav1d: correctly copy ar_coeffs_uv to our structLynne2020-11-26
| | | | | | Our struct is a [2][25], libdav1d's is a [2][25 + 3] so the last 3 v coefficients were missing. Copy each plane's coefficients separately.
* libdav1d: use film grain export flag to export AVFilmGrainParams side dataLynne2020-11-25
| | | | | | | | | | | | | | | | | | | | This patch is relatively straightforward with one exception: the decoder option flag. The option was introduced to troubleshoot but its existence is conflicting and redundant now that we have a codec-generic flag. Hence this patch deprecates it. The way it interacts with AV_CODEC_EXPORT_DATA_FILM_GRAIN is as follows: If filmgrain is unset and AV_CODEC_EXPORT_DATA_FILM_GRAIN is present, disable film grain application and export side data. If filmgrain is set to 0, disable film grain and export side data. If filmgrain is set to 1, apply film grain but export side data if the AV_CODEC_EXPORT_DATA_FILM_GRAIN flag is set. This may result in double film grain application, but the user has requested it by setting both.
* libavcodec: add a new AV_CODEC_EXPORT_DATA_FILM_GRAIN flag and optionLynne2020-11-25
| | | | | | This introduces a new field to allow decoders to export their film grain parameters. Will be used by the next patch.
* avcodec/mpeg12enc: ReindentationAndreas Rheinhardt2020-11-25
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12enc: Use ff_thread_once() for static initializationsAndreas Rheinhardt2020-11-25
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpeg12enc: Always initialize MPEG-2 intra VLC table lengthsAndreas Rheinhardt2020-11-25
| | | | | | | | | | | | | The MPEG-1/2 encoders initialize several tables once during the first time one of the encoders is initialized; the table for MPEG-2 intra VLC lengths is only initialized if it is used for this encoder instance. This implies that if the first MPEG-1/2 encoder to be initialized does not use it, it will never be initialized even if a later encoder instance makes use of them. Fix this by initializing this table unconditionally. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mlpdec: Avoid code duplication when initializing VLCsAndreas Rheinhardt2020-11-24
| | | | | Reviewed-by: Jai Luthra <me@jailuthra.in> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mlpdec: Make decoders init-threadsafeAndreas Rheinhardt2020-11-24
| | | | | Reviewed-by: Jai Luthra <me@jailuthra.in> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mlp: Make initializing CRCs thread-safeAndreas Rheinhardt2020-11-24
| | | | | Reviewed-by: Jai Luthra <me@jailuthra.in> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mpegaudiodec_template: Don't use unnecessarily many VLC bitsAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/mv30: Don't check for errors for complete VLCsAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/imm4: Don't use too big VLC tableAndreas Rheinhardt2020-11-24
| | | | | | Using more bits than the longest code has makes no sense. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safeAndreas Rheinhardt2020-11-24
| | | | | | | | | | | | | | This table is currently initialized up to three times: Once by the encoder and twice by the decoders (once by the fixed and once by the floating-point decoder); each of these initializations is guarded by an AVOnce, yet the fact that there are three of them implies that there might be data races (the fact that each entry is only written to once (to its final value) when initializing means that this is safe in practice, yet it is still undefined behaviour). Fix this by only initializing the table from one place that is guarded by a single AVOnce. This also avoids unnecessary duplications of the init code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/aactab: Fix conflicting types for ff_aac_codebook*Andreas Rheinhardt2020-11-24
| | | | | | | The header missed that these are arrays of const pointers (to const data). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/qdmc: Don't check for errors for complete VLCsAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/hqx: Don't check for errors for complete VLCsAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/hqx: Inline constantsAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/intrax8: Make ff_intrax8_common_init() thread-safeAndreas Rheinhardt2020-11-24
| | | | | | | In particular, don't reinitialize VLCs every time an IntraX8Context is initialized. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/intrax8: Replace always-false check by assertAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/atrac9tab: Add missing static to internal tableAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/atrac9dec: Replace av_free() by av_freep() in close functionAndreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/atrac9dec: Don't use unnecessarily large VLC tablesAndreas Rheinhardt2020-11-24
| | | | | | Using more bits for a VLC than the longest code has has no advantage. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/atrac9dec: Use least max_depth in calls to get_vlc2()Andreas Rheinhardt2020-11-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/atrac9dec: Don't confuse max_depth of VLC with max codelengthAndreas Rheinhardt2020-11-24
| | | | | | | | | | | | | | | The whole point of VLCs with their tables is to read more than one bit at a time; therefore max_depth, the number of times one has to (maximally) read further bits is given by ceil(max_code_length / table_bits) which in the case of ATRAC9's coefficient VLCs gives an upper bound of two. Instead the maximum length of a code of the given VLC has been used (which is not even a compile-time constant). Use two instead. Furthermore, given that this was the only usage of the field containing the maximum of all the code lengths of a given VLC the field has been removed from its containing struct. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>