summaryrefslogtreecommitdiff
path: root/libavcodec/decode.c
Commit message (Collapse)AuthorAge
* avcodec, avformat: Remove unnecessary initializations of side data sizeAndreas Rheinhardt2020-06-22
| | | | | Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: actually propagate AVHWAccel.alloc_frame() return valueJames Almer2020-06-04
| | | | | | | Finishes fixing the regression introduced in a1133db30ef07896afd96f067e5c51531a4e85ab after the partial fix in b6d6597bef66531ec07c07a7125b88aee38fb220. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: fix decoding when frames are allocated using ↵James Almer2020-05-27
| | | | | | | | | AVHWAccel.alloc_frame() Regression since a1133db30ef07896afd96f067e5c51531a4e85ab Found-by: comex <comexk@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: move avcodec_flush_buffers from decode.c to utils.cJames Almer2020-05-24
| | | | | | It's not a decoding exclusive function anymore. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: remove ff_decode_bsfs_uninit()James Almer2020-05-21
| | | | | | It's been a wrapper for a simple av_bsf_free() call since c96904f525. Signed-off-by: James Almer <jamrial@gmail.com>
* libavcodec/decode: Mark decode_simple_internal() as inlineMichael Niedermayer2020-05-12
| | | | | | | | This was suggested in https://github.com/google/oss-fuzz/issues/3787 to reduce the grouping errors by oss-fuzz Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/decode: remove unused AVCodecInternal compat_decode fieldJames Almer2020-05-09
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: use a single list bsf for codec decode bsfsMarton Balint2020-05-02
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* 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: Add explicit capability flag for encoder flushingPhilip Langdale2020-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, there was no way to flush an encoder such that after draining, the encoder could be used again. We generally suggested that clients teardown and replace the encoder instance in these situations. However, for at least some hardware encoders, the cost of this tear down/replace cycle is very high, which can get in the way of some use-cases - for example: segmented encoding with nvenc. To help address that use case, we added support for calling avcodec_flush_buffers() to nvenc and things worked in practice, although it was not clearly documented as to whether this should work or not. There was only one previous example of an encoder implementing the flush callback (audiotoolboxenc) and it's unclear if that was intentional or not. However, it was clear that calling avocdec_flush_buffers() on any other encoder would leave the encoder in an undefined state, and that's not great. As part of cleaning this up, this change introduces a formal capability flag for encoders that support flushing and ensures a flush call is a no-op for any other encoder. This allows client code to check if it is meaningful to call flush on an encoder before actually doing it. I have not attempted to separate the steps taken inside avcodec_flush_buffers() because it's not doing anything that's wrong for an encoder. But I did add a sanity check to reject attempts to flush a frame threaded encoder because I couldn't wrap my head around whether that code path was actually safe or not. As this combination doesn't exist today, we'll deal with it if it ever comes up.
* lavc: do not implicitly share the frame pool between threadsAnton Khirnov2020-04-10
| | | | | | | | | | | | | Currently the frame pool used by the default get_buffer2() implementation is a single struct, allocated when opening the decoder. A pointer to it is simply copied to each frame thread and we assume that no thread attempts to modify it at an unexpected time. This is rather fragile and potentially dangerous. With this commit, the frame pool is made refcounted, with the reference being propagated across threads along with other context variables. The frame pool is now also immutable - when the stream parameters change we drop the old reference and create a new one.
* decode: make sure ff_get_buffer() cleans the frame on failureAnton Khirnov2020-04-10
| | | | Merge ff_get_buffer() and get_buffer_internal() to simplify the code.
* avcodec/decode: increase nb_bsfs after av_bsf_alloc in case alloc failedLimin Wang2020-03-22
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* API: add AV_PKT_DATA_ICC_PROFILE to AVPacketSideDataTypevectronic2020-03-10
| | | | Signed-off-by: vectronic <hello.vectronic@gmail.com>
* avcodec/decode: replace avctx->internal with avci for better readabilityLimin Wang2020-01-07
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/decode: Fix integer overflow in max_samples checkMichael Niedermayer2019-12-15
| | | | | | | | Fixes: signed integer overflow: 1677721600 * 32 cannot be represented in type 'int' Fixes: 18885/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5741242185154560 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/decode: Also consider channels in max_samples checkMichael Niedermayer2019-11-09
| | | | | | | | Fixes: Timeout (109sec -> 0.6sec) Fixes: 18309/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_ACM_fuzzer-6226598168100864 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/decode: fix indentationJun Zhao2019-10-06
| | | | | | | | fix indentation. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avcodec/decode: Check max_samples in get_buffer_internal()Michael Niedermayer2019-09-25
| | | | | | This checks max_samples at the same level as max_pixels Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/decode: add a flags parameter to ff_reget_buffer()James Almer2019-09-04
| | | | | | | | | | Some decoders may not need a writable buffer in some specific cases, but only a reference to the existing buffer with updated frame properties instead, for the purpose of returning duplicate frames. For this, the FF_REGET_BUFFER_FLAG_READONLY flag is added, which will prevent potential allocations and buffer copies when they are not needed. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: remove some dead assignmentsMarton Balint2019-08-22
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec: add AV_CODEC_FLAG_DROPCHANGED to flagsGyan Doshi2019-04-20
| | | | Discard decoded frames which differ from first decoded frame in stream.
* lavc/decode: Initialize return value for get_format() failure.Carl Eugen Hoyos2018-12-10
| | | | | Silences a warning: libavcodec/decode.c:1378:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is true
* lavc/decode: Fix the error number report if av_image_fill_pointers fail.Jun Zhao2018-10-30
| | | | | | | | | | -1 will be map to error number "EPERM", and will be map to the error message like "Error while decoding stream #0:0: Operation not permitted", it's a strange error message when debug update_frame_pool fail, now only return the error code from av_image_fill_pointers in case of av_image_fill_pointers failure. Signed-off-by: Jun Zhao <mypopydev@gmail.com>
* Revert "avcodec/decode: copy the output parameters from the last bsf in the ↵James Almer2018-10-24
| | | | | | | | | | | | | | | | | | | chain back to the AVCodecContext" This reverts commit f631c328e680a3dd491936b92f69970c20cdcfc7. The avcodec_parameters_to_context() call was freeing and reallocating AVCodecContext->extradata, essentially taking ownership of it, which according to the doxy is user owned. This is an API break and has produced crashes in some library users like Firefox[1]. Revert until a better solution is found to internally propagate the filtered extradata back into the decoder context, or a decision is made to change the API. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1486080 Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: copy the output parameters from the last bsf in the chain ↵James Almer2018-08-16
| | | | | | | | | back to the AVCodecContext Certain AVCodecParameters, like the contents of the extradata, may be changed by the init() function of any of the bitstream filters in the chain. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: flush the internal bsfs instead of constantly reinitalizing themJames Almer2018-08-16
| | | | | | | Initialize the bsfs once when opening the codec and uninitialize them once when closing it, instead of at every codec flush/seek. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: parse options from AVCodec.bsfsAman Gupta2018-07-19
| | | | | | | | | Fixes a bug that would prevent using multiple comma-separated filters, and allows options to be passed to each filter. Based on similar loop in ffmpeg_opt.c's new_output_stream(). Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/decode: Consider STRIDE_ALIGN in get_buffer_internal() when checking ↵Michael Niedermayer2018-06-15
| | | | | | | | | | | | width STRIDE_ALIGN is not known in libavutil so av_image_check_size* cannot consider it Fixes: OOM Fixes: 8291/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5176528009691136 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/decode: fix warning when decoding pseudo paletted formatswm42018-04-05
| | | | | | The pseudo palette allocation is optional now. But if it's still allocated (like the internal get_buffer2 implementation does, for compatibility), it shouldn't print a warning.
* avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPALwm42018-04-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PSEUDOPAL pixel formats are not paletted, but carried a palette with the intention of allowing code to treat unpaletted formats as paletted. The palette simply mapped the byte values to the resulting RGB values, making it some sort of LUT for RGB conversion. It was used for 1 byte formats only: RGB4_BYTE, BGR4_BYTE, RGB8, BGR8, GRAY8. The first 4 are awfully obscure, used only by some ancient bitmap formats. The last one, GRAY8, is more common, but its treatment is grossly incorrect. It considers full range GRAY8 only, so GRAY8 coming from typical Y video planes was not mapped to the correct RGB values. This cannot be fixed, because AVFrame.color_range can be freely changed at runtime, and there is nothing to ensure the pseudo palette is updated. Also, nothing actually used the PSEUDOPAL palette data, except xwdenc (trivially changed in the previous commit). All other code had to treat it as a special case, just to ignore or to propagate palette data. In conclusion, this was just a very strange old mechnaism that has no real justification to exist anymore (although it may have been nice and useful in the past). Now it's an artifact that makes the API harder to use: API users who allocate their own pixel data have to be aware that they need to allocate the palette, or FFmpeg will crash on them in _some_ situations. On top of this, there was no API to allocate the pseuo palette outside of av_frame_get_buffer(). This patch not only deprecates AV_PIX_FMT_FLAG_PSEUDOPAL, but also makes the pseudo palette optional. Nothing accesses it anymore, though if it's set, it's propagated. It's still allocated and initialized for compatibility with API users that rely on this feature. But new API users do not need to allocate it. This was an explicit goal of this patch. Most changes replace AV_PIX_FMT_FLAG_PSEUDOPAL with FF_PSEUDOPAL. I first tried #ifdefing all code, but it was a mess. The FF_PSEUDOPAL macro reduces the mess, and still allows defining FF_API_PSEUDOPAL to 0. Passes FATE with FF_API_PSEUDOPAL enabled and disabled. In addition, FATE passes with FF_API_PSEUDOPAL set to 1, but with allocation functions manually changed to not allocating a palette.
* avcodec: add a subcharenc mode that disables UTF-8 checkwm42018-03-25
| | | | | | | | This is for applications which want to explicitly check for invalid UTF-8 manually, and take actions that are better than dropping invalid subtitles silently. (It's pretty much silent because sporadic avcodec error messages are so common that you can't reasonably display them in a prominent and meaningful way in a application GUI.)
* avcodec: remove unnecessary calls to ff_init_buffer_info()James Almer2018-02-14
| | | | | | | | And remove the function altogether while at it. It's a duplicate of another. Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* Merge commit 'cad739dace55e3446ef7180de688173cd19fb000'Mark Thompson2018-02-12
|\ | | | | | | | | | | | | * commit 'cad739dace55e3446ef7180de688173cd19fb000': lavc: Add per-thread surfaces in get_hw_frame_parameters() Merged-by: Mark Thompson <sw@jkqxz.net>
| * lavc: Add per-thread surfaces in get_hw_frame_parameters()Mark Thompson2018-02-11
| | | | | | | | | | | | | | | | This number is definitely required when frame threading is enabled, so add it here rather than forcing all users to handle it themselves. DXVA2 contained this addition in specific code as well (therefore being added twice in the internal case) - just remove it from there.
* | Merge commit '5b145290df2998a9836a93eb925289c6c8b63af0'Mark Thompson2018-02-12
|\| | | | | | | | | | | | | * commit '5b145290df2998a9836a93eb925289c6c8b63af0': lavc: Add support for increasing hardware frame pool sizes Merged-by: Mark Thompson <sw@jkqxz.net>
| * lavc: Add support for increasing hardware frame pool sizesMark Thompson2018-02-11
| | | | | | | | | | | | | | | | | | | | AVCodecContext.extra_hw_frames is added to the size of hardware frame pools created by libavcodec for APIs which require fixed-size pools. This allows the user to keep references to a greater number of frames after decode, which may be necessary for some use-cases. It is also added to the initial_pool_size value returned by avcodec_get_hw_frames_parameters() if a fixed-size pool is required.
| * lavc: Mark all AVHWAccel structures as constMark Thompson2017-12-19
| |
| * lavc: Use hardware config information in ff_get_format()Mark Thompson2017-12-19
| | | | | | | | | | | | | | | | | | | | | | This removes the dependency that hardware pixel formats previously had on AVHWAccel instances, meaning only those which actually do something need exist after this patch. Also updates avcodec_default_get_format() to be able to choose hardware formats if either a matching device has been supplied or no additional external configuration is required, and avcodec_get_hw_frames_parameters() to use the hardware config rather than searching the old hwaccel list.
| * lavc: fix hw_device_ctx operationwm42017-10-23
| | | | | | | | | | | | | | Commit b46a77f19d accidentally broke this (requested change that was added to the patch later and which was not fully tested). Signed-off-by: Mark Thompson <sw@jkqxz.net>
* | avcodec/decode: reset codec on receiving packet after EOF in compat_decodeJames Cowgill2017-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit 061a0c14bb57 ("decode: restructure the core decoding code"), the deprecated avcodec_decode_* APIs were reworked so that they called into the new avcodec_send_packet / avcodec_receive_frame API. This had the side effect of prohibiting sending new packets containing data after a drain packet, but in previous versions of FFmpeg this "worked" and some applications relied on it. To restore some compatibility, reset the codec if we receive a new non-drain packet using the old API after draining has completed. While this does not give the same behaviour as the old API did, in the majority of cases it works and it does not require changes to any other part of the decoding code. Fixes ticket #6775 Signed-off-by: James Cowgill <jcowgill@debian.org> Signed-off-by: Marton Balint <cus@passwd.hu>
* | lavc: Mark all AVHWAccel structures as constMark Thompson2017-11-26
| |
* | lavc: Use hardware config information in ff_get_format()Mark Thompson2017-11-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the dependency that hardware pixel formats previously had on AVHWAccel instances, meaning only those which actually do something need exist after this patch. Also updates avcodec_default_get_format() to be able to choose hardware formats if either a matching device has been supplied or no additional external configuration is required, and avcodec_get_hw_frames_parameters() to use the hardware config rather than searching the old hwaccel list. The FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS mechanism is deleted because it no longer does anything (the codec already contains the pointers to the matching hwaccels).
* | Merge commit 'b46a77f19ddc4b2b5fa3187835ceb602a5244e24'James Almer2017-11-11
|\| | | | | | | | | | | | | | | | | * commit 'b46a77f19ddc4b2b5fa3187835ceb602a5244e24': lavc: external hardware frame pool initialization Includes the fix from e724bdfffbd3c27aac53d1f32f20f105f37caef0 Merged-by: James Almer <jamrial@gmail.com>
| * lavc: external hardware frame pool initializationwm42017-10-19
| | | | | | | | | | | | | | | | | | | | | | | | This adds a new API, which allows the API user to query the required AVHWFramesContext parameters. This also reduces code duplication across the hwaccels by introducing ff_decode_get_hw_frames_ctx(), which uses the new API function. It takes care of initializing the hw_frames_ctx if needed, and does additional error handling and API usage checking. Support for VDA and Cuvid missing. Signed-off-by: Anton Khirnov <anton@khirnov.net>
| * decode: add a per-frame private data for hwaccel useAnton Khirnov2017-07-26
| | | | | | | | | | | | This will be useful in the CUVID hwaccel. It should also eventually replace current decoder-specific mechanisms used by various other hwaccels.
| * decode: add a mechanism for performing delayed processing on the decoded framesAnton Khirnov2017-07-26
| | | | | | | | This will be useful in the CUVID hwaccel.
| * decode: add a method for attaching lavc-internal data to framesAnton Khirnov2017-07-26
| | | | | | | | | | | | | | | | Use the AVFrame.opaque_ref field. The original user's opaque_ref is wrapped in the lavc struct and then unwrapped before the frame is returned to the caller. This new struct will be useful in the following commits.
| * decode: avoid leaks on failure in ff_get_buffer()Anton Khirnov2017-07-26
| | | | | | | | | | | | | | If the get_buffer() call fails, the frame might have some side data already set. Make sure it gets freed. CC: libav-stable@libav.org
| * lavc, lavu: move frame cropping to a convenience functionwm42017-07-26
| | | | | | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>