summaryrefslogtreecommitdiff
path: root/libavcodec/v4l2_m2m_enc.c
Commit message (Collapse)AuthorAge
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* 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: 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_enc: reindent after previous commitAndriy Gelman2020-08-23
| | | | Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m_enc: buffer frame if it cannot be enqueuedAndriy Gelman2020-08-23
| | | | | | | | | Currently if the frame buffers are full, the frame is unrefed and dropped. Instead buffer the frame so that it is enqueued in the next v4l2_receive_packet() call. The behavior was observed on DragonBoard 410c. Signed-off-by: Andriy Gelman <andriy.gelman@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/encode: restructure the core encoding codeJames Almer2020-06-18
| | | | | | | | | | | | | | | | This commit follows the same logic as 061a0c14bb, but for the encode API: The new public encoding API will no longer be a wrapper around the old deprecated one, and the internal API used by the encoders now consists of a single receive_packet() callback that pulls frames as required. amf encoders adapted by James Almer librav1e encoder adapted by James Almer nvidia encoders adapted by James Almer MediaFoundation encoders adapted by James Almer vaapi encoders adapted by Linjie Fu v4l2_m2m encoders adapted by Andriy Gelman Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/v4l2_m2m_enc: Avoid ;;Andreas Rheinhardt2020-06-08
| | | | | | | | | | | | | Inside a function, the second ; in a double ;; is a null statement, but outside of functions a double ;; is simply invalid C that compilers happen to accept. v4l2_m2m_enc.c contained several ;; as a result of macro-expansion. So change the underlying macro so that it doesn't happen any longer. This fixes warnings when compiling with -pedantic: "ISO C does not allow extra ‘;’ outside of a function". Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: move mpeg4 profiles to profiles.hMarton Balint2020-05-22
| | | | | | Also bump micro version after the recent option changes. Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/v4l2_m2m_enc: Support changing qmin/qmaxAndriy Gelman2020-05-05
| | | | | | | | | Hard coded parameters for qmin and qmax are currently used to initialize v4l2_m2m device. This commit uses values from avctx->{qmin,qmax} if they are set. Reviewed-by: Ming Qian <ming.qian@nxp.com> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m_enc: reindent codeLimin Wang2020-05-05
| | | | | Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/v4l2_m2m_enc: Enable frame level rate control by defaultAndriy Gelman2020-04-28
| | | | | | | | Without this setting, bitrate and qmin/qmax options have no effect on the s5p-mfc hardware encoder. Reviewed-by: Ming Qian <ming.qian@nxp.com> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m_enc: Reduce log verbosity for some paramsAndriy Gelman2020-04-28
| | | | | | | | | Currently the user gets unhelpful warnings when some default parameters are not supported by the device. The verbosity of these log messages has been changed to AV_LOG_DEBUG. Reviewed-by: Ming Qian <ming.qian@nxp.com> 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: fix setting frame periodMing Qian2020-03-31
| | | | | | | | Currently the driver's frame period is incorrectly set to the frame rate. This is fixed in the commit. Signed-off-by: Ming Qian <ming.qian@nxp.com> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m: Fix typo in log message and cosmeticsAndriy Gelman2020-02-16
| | | | Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m: Simplify capture buffer init checkAndriy Gelman2020-02-01
| | | | | | | | Before this commit s->avctx == NULL was used to infer that an encoder is being initialzed. Code readability has been improved by directly using !av_codec_is_decoder() instead. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on deviceAndriy Gelman2019-12-27
| | | | | | | | | | | | | | | | | | | Fixes #8079 During initialization of a v4l2m2m device, the configured pix_fmt can be different to the pix_fmt of the encoder (i.e. avctx->pix_fmt). For example on the Odroid XU4: ./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264 will configure the v4l2 encoder to pix_fmt nv21, whereas the input frames will be yuv444p. This commit checks that the configured v4l2 pix_fmt on device is the same as avctx->pix_fmt. If they are different the initialization fails and an error is returned. Tested on RPI4 and Odroid XU4. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avcodec/v4l2: fix compile with older videodev2.hAman Gupta2019-09-15
| | | | | | Some of these symbols are only defined in newer kernel releases. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m_enc: fix indentation and add M2MENC_CLASS macroAman Gupta2019-09-10
| | | | 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_m2m_enc: add support for -force_key_framesAman Gupta2019-09-10
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m_enc: fix typo in log messageAman Gupta2019-09-02
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/v4l2_m2m_enc: log errno on v4l2_set_ext_ctrl failuresAman Gupta2019-09-02
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* lavc/v4l2_m2m_enc: Add missing braces around initializers.Carl Eugen Hoyos2018-08-31
| | | | | | Fixes the following warnings: libavcodec/v4l2_m2m_enc.c:51:12: warning: missing braces around initializer libavcodec/v4l2_m2m_enc.c:71:12: warning: missing braces around initializer
* 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.
* avcodec/v4l2_m2m_enc: fix usage of deprecated codec flagJames Almer2017-10-21
|
* lavc/v4l2: Fix printf format for int64_tMark Thompson2017-10-05
|
* lavc/v4l2: Mark static const tables as suchMark Thompson2017-10-04
|
* lavc/v4l2: Remove use of lfind()Mark Thompson2017-10-04
| | | | | This is not present in older bionic and therefore fails to build there, and the code is much simpler without it anyway.
* 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>