summaryrefslogtreecommitdiff
path: root/libavcodec/v4l2_m2m_dec.c
Commit message (Collapse)AuthorAge
* avcodec/v4l2_m2m_dec: dequeue frame if input isn't readyCameron Gutman2021-12-28
| | | | | | | | | | | The V4L2M2M API operates asynchronously, so multiple packets can be enqueued before getting a batch of frames back. Since it was only possible to receive a frame by submitting another packet, there wasn't a way to drain those excess output frames from when avcodec_receive_frame() returned AVERROR(EAGAIN). Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Cameron Gutman <aicommander@gmail.com>
* 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/v4l2_m2m: adapt to call close() on init failAndriy Gelman2020-08-02
| | | | | | | | This fixes several mem leaks when init of encoder/decoder failed. Fixes ticket #8285 Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m_dec: remove redundant packet and fix double freeAndriy Gelman2020-07-16
| | | | | | | | | | | | | | | | | | v4l2_receive_frame() uses two packets s->buf_pkt and avpkt. If avpkt cannot be enqueued, the packet is buffered in s->buf_pkt and enqueued in the next call. Currently the ownership transfer between the two packets is not properly handled. A double free occurs if ff_v4l2_context_enqueue_packet() returns EAGAIN and v4l2_try_start returns EINVAL. In fact, having two AVPackets is not needed and everything can be handled by s->buf_pkt. This commit removes the local avpkt from v4l2_receive_frame(), meaning that the ownership transfer doesn't need to be handled and the double free is fixed. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m: handle v4l2 end of stream eventMing Qian2020-04-14
| | | | | | | | | | | | | | When flushing the capture buffers, the driver may send a V4L2_EVENT_EOS to notify that draining is completed. Currently, v4l2_m2m does not subscribe to this event, which can cause some devices (i.e. imx8qm) to hang at the end of encoding/decoding. Support for handling the event is added in this commit. Some devices may not signal V4L2_EVENT_EOS. This is logged as a warning message during initialization and not treated as a fatal error. Signed-off-by: Ming Qian <ming.qian@nxp.com> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m_dec: Init reserved bytes to zero before ioctl callAndriy Gelman2020-03-31
| | | | | | | | | | struct v4l2_selection contains reserved bytes which should be set to zero before the ioctl call. Fixes valgrind error: Syscall param ioctl(VKI_V4L2_S_SELECTION) points to uninitialised byte(s) Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m: CosmeticsAndriy Gelman2020-02-01
| | | | | | Change pointer symbol position. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m_dec: Fix decoding on Odroid XU4Andriy Gelman2019-11-22
| | | | | | | | | | | | | c0c79461967 unintentianally changed the initialization flow of the decoder: It caused the capture buffers to be initialized on v4l2_m2m.c:180 in v4l2_configure_contexts(). This breaks h264 decoding on the Odroid XU4 (RPI4 was not affected). This commit postpones capture buffer initialization as before c0c79461967 to fix the issue. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/filter: Remove extra '; ' outside of functionsAndreas Rheinhardt2019-10-07
| | | | | | | | They are not allowed outside of functions. Fixes the warning "ISO C does not allow extra ‘;’ outside of a function [-Wpedantic]" when compiling with GCC and -pedantic. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/v4l2_m2m_dec: fix compileAman Gupta2019-09-11
| | | | | | internal.h header required for FF_CODEC_CAP_SETS_PKT_DTS Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m_dec: fix dropped packets while decodingMaxime Jourdan2019-09-11
| | | | | | | | | | * FFmpeg retrieves a packet from the bitstream * It attempts to get an input buffer (from its own list or by dequeuing one from the driver) * If no input buffer is found, the bitstream packet is dropped instead of scheduled for trying again later It's an issue that showed especially at high speeds (like using `-f null -` as output parameters). Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_context: expose timeout for dequeue_frameAman Gupta2019-09-11
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m_dec: set pkt_dts on decoded frames to NOPTSAman Gupta2019-09-11
| | | | | | | | | Without this ffmpeg will attempt to copy the dts from the most recently enqueued packet into the most recently dequeued frame, which does not account for the buffering inside v4l2 and is not accurate. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m_dec: fix indentation and add M2MDEC_CLASS macroLukas Rusak2019-09-10
| | | | | | | This just makes the M2MDEC_CLASS similar to how it is done in rkmpp. It looks clean and has proper indentation Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m: decouple v4l2_m2m helpers from AVCodecContextAman Gupta2019-09-10
| | | | | | This will allow re-use of the m2m backend with AVFilterContext Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_context: use EAGAIN to signal when input buffers are unavailableAman Gupta2019-09-02
| | | | | | | | ENOMEM indicates an allocation failure, and there are no allocations happening here. The buffers are pre-allocated and there are simply none available at this time. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2m2m: fix error handling during buffer initJorge Ramirez-Ortiz2019-09-02
| | | | | Signed-off-by: Jorge Ramirez-Ortiz <jramirez@baylibre.com> Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m_dec: Fix memleak on ff_v4l2_m2m_codec_init() failureMichael Niedermayer2019-06-12
| | | | | | | Fixes: 13579/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1_V4L2M2M_fuzzer-5753560726241280 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* v4l2_m2m: decoder: fix memory leakLukas Rusak2018-06-27
|
* v4l2_m2m: Mark V4L2 M2M decoders as unsuitable for probingMark Thompson2018-06-03
|
* avcodec: v4l2_m2m: fix races around freeing data on closeMark Thompson2018-01-21
| | | | | | | | Refcount all of the context information. This also fixes a potential segmentation fault when accessing freed memory (buffer returned after the codec has been closed). Tested-by: Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>
* v4l_m2m: add missing AV_CODEC_CAP_DELAY flagswm42017-12-21
| | | | | | | | This is pretty much a requirement for any codec that handles modern codecs like h264, but it was missing. Potentially could lead to issues like missing frames at the end of a stream. Tested-by: Jorge Ramirez <jorge.ramirez-ortiz@linaro.org>
* avcodec: add metadata to identify wrappers and hardware decoderswm42017-12-14
| | | | | | | | | | | | | | | | | | | | | Explicitly identify decoder/encoder wrappers with a common name. This saves API users from guessing by the name suffix. For example, they don't have to guess that "h264_qsv" is the h264 QSV implementation, and instead they can just check the AVCodec .codec and .wrapper_name fields. Explicitly mark AVCodec entries that are hardware decoders or most likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing API users listing hardware decoders in a more generic way. The proposed AVCodecHWConfig does not provide this information fully, because it's concerned with decoder configuration, not information about the fact whether the hardware is used or not. AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software implementations in case the hardware is not capable. Based on a patch by Philip Langdale <philipl@overt.org>. Merges Libav commit 47687a2f8aca3f65b6fdd117b1cb66a7409a7fd1.
* libavcodec: v4l2: add support for v4l2 mem2mem codecsJorge Ramirez-Ortiz2017-09-23
This patchset enhances Alexis Ballier's original patch and validates it using Qualcomm's Venus hardware (driver recently landed upstream [1]). This has been tested on Qualcomm's DragonBoard 410c and 820c Configure/make scripts have been validated on Ubuntu 10.04 and 16.04. Tested decoders: - h264 - h263 - mpeg4 - vp8 - vp9 - hevc Tested encoders: - h264 - h263 - mpeg4 Tested transcoding (concurrent encoding/decoding) Some of the changes introduced: - v4l2: code cleanup and abstractions added - v4l2: follow the new encode/decode api. - v4l2: fix display size for NV12 output pool. - v4l2: handle EOS (EPIPE and draining) - v4l2: vp8 and mpeg4 decoding and encoding. - v4l2: hevc and vp9 support. - v4l2: generate EOF on dequeue errors. - v4l2: h264_mp4toannexb filtering. - v4l2: fixed make install and fate issues. - v4l2: codecs enabled/disabled depending on pixfmt defined - v4l2: pass timebase/framerate to the context - v4l2: runtime decoder reconfiguration. - v4l2: add more frame information - v4l2: free hardware resources on last reference being released - v4l2: encoding: disable b-frames for upstreaming (patch required) [1] https://lwn.net/Articles/697956/ System Level view: v42l_m2m_enc/dec --> v4l2_m2m --> v4l2_context --> v4l2_buffers Reviewed-by: Jorge Ramirez <jorge.ramirez-ortiz@linaro.org> Reviewed-by: Alexis Ballier <aballier@gentoo.org> Tested-by: Jorge Ramirez <jorge.ramirez-ortiz@linaro.org> Signed-off-by: wm4 <nfxjfg@googlemail.com>