summaryrefslogtreecommitdiff
path: root/libavcodec/mediacodecdec.c
Commit message (Collapse)AuthorAge
* avcodec/mediacodecdec: enable NDK mediacodecZhao Zhili2022-11-21
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/mediacodec: add NDK media codec wrapperZhao Zhili2022-11-21
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/mediacodecdec: don't break out if both input and output port return ↵Zhao Zhili2022-11-21
| | | | | | | | | | | | | | | try again At the beginning of decoding, if we feed mediacodec too fast, the input port will return try again. It takes some time for mediacodec to consume bitstream and output frame. So the output port also return try again. It possible that mediacodec_receive_frame doesn't consume any AVPacket and no AVFrame is output. Then both avcodec_send_packet() and avcodec_receive_frame() return EAGAIN, which shouldn't happen. This bug can be produced with decoding benchmark on Pixel 3. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-03
| | | | | | | | It reduces typing: Before this patch, there were 105 codecs whose long_name-definition exceeded the 80 char line length limit. Now there are only nine of them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Add FF_CODEC_CAP_NOT_INIT_THREADSAFEAndreas Rheinhardt2022-07-18
| | | | | | | This is in preparation of switching the default init-thread-safety to a codec being init-thread-safe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* 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: 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>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/h264_parse: Move ff_h264_get_profile() to h264_ps.hAndreas Rheinhardt2022-01-26
| | | | | | It is a more fitting place for it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/mediacodecdec: set codec profile and level from extradata for H264+HEVCsfan52021-12-30
| | | | | | This value is later passed to MediaCodec and checked at decoder init. Notably decoding of 10-bit streams before this commit would "work" without returning errors but only return garbage output (on most Android devices).
* 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/mediacodecdec: do not abort when H264/HEVC extradata extraction failssfan52021-02-14
| | | | | | | Although rare, extradata can be present but empty and extraction will fail. However Android also supports passing codec-specific data inline and will likely play such a stream anyway. So there's no reason to abort initialization before we know for sure.
* lavc: Mark hw_config pointer arrays as constMark Thompson2020-11-08
| | | | They are read-only just like the HWConfig structures they point to.
* 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/mediacodecdec: warn when input buffers are not configured with ↵Aman Gupta2019-09-10
| | | | | | | | | | | | | | | | proper size In rare circumstances, if the codec is not configured with the proper parameters the input buffers can be allocated with a size that's too small to hold an individual packet. Since MediaCodec expects exactly one incoming buffer with a given PTS, it is not valid to split data for a given PTS across two input buffers. See https://developer.android.com/reference/android/media/MediaCodec#data-processing: > Do not submit multiple input buffers with the same timestamp Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/mediacodecdec: try to receive a frame after signaling EOF to the codecMatthieu Bouron2019-06-13
| | | | | | | | | Avoids returning EAGAIN after signaling EOF to the codec in ff_mediacodec_dec_send() so we can try to receive a frame before returning in mediacodec_receive_frame(). This helps avoiding an extra round-trip between avcodec_send_frame() and avcodec_receive_frame() while draining the remaining frames.
* avcodec/mediacodecdec: add workaround for buggy amlogic mpeg2 decoderAman Gupta2018-05-04
| | | | | | | | | | | | | | | | | | I tested the previous mediacodec changes on seven different Android TV devices, with both mpeg2 and h264 content. All except one worked as expected. The exception was the MiBox3 running Android 6.0.1, where playback would freeze on a frame every few seconds. I tested two other AMLogic devices with newer Android versions that did not show the same problem. H264 decoding on the MiBox3 was also not affected, so this workaround applies only to OMX.amlogic.mpeg2.decoder.awesome on Android API22. There is a rumor that Xiaomi is planning to release Android Oreo for the MiBox3, so I will revisit in a few months to confirm whether this is specific to os/driver version or the chipset used in that device. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* avcodec/mediacodecdec: restructure mediacodec_receive_frameAman Gupta2018-05-04
| | | | | | | | | | | | | The new logic follows a recommendation by @rcombs to use dequeueInputBuffer with a timeout of 0 as a way to detect whether the codec wants more data. The dequeued buffer index is kept in MediaCodecDecContext until it can be used next. A similar technique is also used by the Google's official media player Exoplayer: see MediaCodecRenderer.feedInputBuffer(). Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* avcodec/mediacodecdec: clarify delay_flush specific codeAman Gupta2018-04-25
| | | | | | | | | As of 2a0eb8685, ff_mediacodec_dec_is_flushing() only returns true in delay_flush mode. Make this more obvious by adding delay_flush to the if statement. Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com> Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/mediacodecdec: fix immediate EAGAIN with buffered packetAman Gupta2018-03-13
| | | | | | | | | | | | | | In cases where the mediacodec decoder consumed a partial packet, receive_frame() would start returning EAGAIN if the rest of the packet couldn't be flushed and no frames were immediately available. This fixes receive_frame() to perform its normal blocking wait for new frames before returning EAGAIN. Fixes an issue I could reproduce fairly often on a FireOS 6 device, and reported to be happening intermittently by two mpv users. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* avcodec/mediacodecdec: add delay_flush optionAman Gupta2018-03-07
| | | | | | | | | | | | | | | | | | | | | | | | The default behavior of the mediacodec decoder before this commit was to delay flushes until all pending hardware frames were returned to the decoder. This was useful for certain types of applications, but was unexpected behavior for others. The new default behavior with this commit is now to execute flushes immediately to invalidate all pending frames. The old behavior can be enabled by setting delay_flush=1. With the new behavior, video players implementing seek can simply call flush on the decoder without having to worry about whether they have one or more mediacodec frames still buffered in their rendering pipeline. Previously, all these frames had to be explictly freed (or rendered) before the seek/flush would execute. The new behavior matches the behavior of all other lavc decoders, reducing the amount of special casing required when using the mediacodec decoder. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* avcodec/mediacodecdec: factorize codec declarationsMatthieu Bouron2018-03-03
|
* avcodec/mediacodecdec: factorize common extradata functionsMatthieu Bouron2018-03-03
|
* avcodec/mediacodecdec: add missing "libavutil/internal.h" includeMatthieu Bouron2018-03-03
| | | | libavutil/internal.h defines NULL_IF_CONFIG_SMALL.
* avcodec/mediacodecdec: refactor to take advantage of new decoding apiAman Gupta2018-02-19
| | | | | | | | | | | | | | | | | | | | This refactor splits up the main mediacodec decode loop into two send/receive helpers, which are then used to rewrite the receive_frame callback and take full advantage of the new decoding api. Since we can now request packets on demand with ff_decode_get_packet(), the fifo buffer is no longer necessary and has been removed. This change was motivated by behavior observed on certain Android TV devices, featuring hardware mpeg2/h264 decoders which also deinterlace content (to produce multiple frames per field). Previously, this code caused buffering issues because queueInputBuffer() was always invoked before each dequeueOutputBuffer(), even though twice as many output buffers were being generated. With this patch, the decoder will always attempt to drain new frames first before sending more data into the underlying codec. Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* avcodec/mediacodecdec: use ff_hevc_ps_uninit()James Almer2018-01-30
| | | | | | Fixes memleaks. Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/mediacodecdec: remove mediacodec_process_data() indirectionMatthieu Bouron2018-01-06
|
* lavc/mediacodecdec: switch to new decoding APIAman Gupta2018-01-06
| | | | | | | | | | Using the new API gives the decoder the ability to produce N frames per input packet. This is particularly useful with mpeg2 decoders on some android devices, which automatically deinterlace video and produce one frame per field. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* lavc/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if setAman Gupta2017-12-16
| | | | Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* 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.
* mediacodecdec: fix build by including hwaccel.hJan Ekström2017-12-01
| | | | Enables the decoder to utilize the type AVCodecHWConfigInternal.
* lavc: Add hardware config metadata for decoders supporting hardware outputMark Thompson2017-11-26
| | | | | | | | | This includes a pointer to the associated hwaccel for decoders using hwaccels - these will be used later to implement the hwaccel setup without needing a global list. Also added is a new file listing all hwaccels as external declarations - this will be used later to generate the hwaccel list at configure time.
* avcodec/hevc_sei: rename HEVCSEIContext to HEVCSEIJames Almer2017-10-31
| | | | | | | Cosmetic change skipped in 0b30cb8dae5e7edb2a5f35900547321499c217f1 by mistake. Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/mediacodecdec: switch to the new generic filtering mechanismMatthieu Bouron2017-06-13
|
* lavc: add mpeg2 mediacodec decoderAman Gupta2017-06-08
| | | | | | | Android TV and FireOS hardware supports mpeg2 hardware decoding via MediaCodec. Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
* avcodec/hevc_parse: decode SEI message NALUs in extradataJames Almer2017-05-05
| | | | | | | | | | They may be available in hvcc style extradata. Based on a patch by Hendrik Leppkes. Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com> Reviewed-by: Aaron Levinson <alevinsn@aracnet.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/hevc_parse: allow setting apply_defdispwin when decoding SPS NAL unitsJames Almer2017-04-09
| | | | | Reviewed-by: nevcairiel Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/mediacodecdec: set AV_CODEC_CAP_AVOID_PROBING capabilityMatthieu Bouron2017-04-04
|
* lavc/mediacodecdec: switch to AV_CODEC_CAP_DELAYMatthieu Bouron2017-04-04
|
* Merge commit 'c359d624d3efc3fd1d83210d78c4152bd329b765'James Almer2017-03-23
| | | | | | | * commit 'c359d624d3efc3fd1d83210d78c4152bd329b765': hevcdec: move decoder-independent declarations into a separate header Merged-by: James Almer <jamrial@gmail.com>
* avcodec/mediacodec: convert to stdatomicJames Almer2017-03-23
| | | | | Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/mediacodec: use more meaningful filenamesMatthieu Bouron2016-10-19
| | | | | | Adds the following changes: * mediacodecdec.{c,h} -> mediacodecdec_common.{c,h} * mediacodecdec_h2645.c -> mediacodecdec.c
* lavc: add mpeg4 mediacodec decoderMatthieu Bouron2016-10-19
|
* lavc: add vp8/vp9 mediacodec decodersMatthieu Bouron2016-10-19
|
* lavc/mediacodecdec: rename dequeued_buffer_nb to output_buffer_countMatthieu Bouron2016-10-12
|
* lavc/mediacodecdec: remove first output buffer timing debug logMatthieu Bouron2016-10-12
|
* Merge commit '32c8359093d1ff4f45ed19518b449b3ac3769d27'Hendrik Leppkes2016-10-07
| | | | | | | * commit '32c8359093d1ff4f45ed19518b449b3ac3769d27': lavc: export the timestamps when decoding in AVFrame.pts Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
* lavc/mediacodecdec: fix size variable shadowing in ff_mediacodec_dec_decodeMatthieu Bouron2016-10-06
| | | | Fixes incompatible pointer type warning on 64-bit systems.
* lavc: add hevc mediacodec decoderMatthieu Bouron2016-09-15
|