summaryrefslogtreecommitdiff
path: root/libavcodec/decode.c
Commit message (Collapse)AuthorAge
* avcodec/avcodec: Stop including channel_layout.h in avcodec.hAndreas Rheinhardt2021-07-22
| | | | | | Also include channel_layout.h directly wherever used. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/avcodec: Stop including bsf.h in avcodec.hAndreas Rheinhardt2021-07-22
| | | | | | Also include bsf.h directly wherever it is used. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Pass HDR10+ metadata to packet side data in VP9 encoderMohammad Izadi2021-06-24
| | | | | | | | | | | | | HDR10+ metadata is stored in the bit stream for HEVC. The story is different for VP9 and cannot store the metadata in the bit stream. HDR10+ should be passed to packet side data an stored in the container (mkv) for VP9. This CL is taking HDR10+ from AVFrame side data in libvpxenc and is passing it to the AVPacket side data. Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Zern <jzern@google.com>
* avcodec/decode: reindent after the previous commitJames Almer2021-06-21
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: add an internal codec flag to signal a decoder sets all ↵James Almer2021-06-21
| | | | | | | | | | output frame properties Decoders like cuviddec ignore and overwrite all the properties set by the generic code as derived from AVCodecInternal.last_pkt_props. This flag ensures libavcodec will not store and potentially queue input packets that ultimately will not be used. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: fetch packets from the pkt_props FIFO on every frame returnedJames Almer2021-06-21
| | | | | | | Fixes memleaks on decoders that don't call ff_decode_frame_props(), like libdav1d. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: stop trying to initialize palette values in ↵James Almer2021-05-05
| | | | | | | | | | avcodec_default_get_buffer2() avpriv_set_systematic_pal2() is meant to fill fixed vales for formats that until recently were tagged as "pseudo pal". This is no longer the case, so this call is a no-op when used on real PAL formats. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-27
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/pixdesc: Remove deprecated AV_PIX_FMT_FLAG_PSEUDOPALAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in d6fc031caf64eed921bbdef86d79d56bfc2633b0. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: Remove deprecated AVFrame.pkt_pts fieldAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in 32c8359093d1ff4f45ed19518b449b3ac3769d27. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove deprecated old encode/decode APIsAndreas Rheinhardt2021-04-27
| | | | | | | | Deprecated in commits 7fc329e2dd6226dfecaa4a1d7adf353bf2773726 and 31f6a4b4b83aca1d73f3cfc99ce2b39331970bf3. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove deprecated ASS with inline timingAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in 22ebbda637257a432c99330ca4c6024665418f0e. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Factor updating palette outAndreas Rheinhardt2021-03-22
| | | | | | | | | Because the properties of frames returned from ff_get/reget_buffer are not reset at all, lots of returned frames had palette_has_changed wrongly set to 1. This has been changed, too. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/avcodec: Move decoder channel count check to ff_decode_preinitAndreas Rheinhardt2021-03-20
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/avcodec: Perform sub_charenc/iconv checks before AVCodec.init()Andreas Rheinhardt2021-03-20
| | | | | | Also move them to ff_decode_preinit(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavc: move decoder bsf init into decoder-specific codeAnton Khirnov2021-03-16
|
* lavc: factor decoder validation/setup from avcodec_open2()Anton Khirnov2021-03-16
|
* avcodec/decode: Remove outdated commentAndreas Rheinhardt2021-03-15
| | | | | | | Removing it was forgotten in 417d473bde220a1f267bc694835c129a5adc4309. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: ReindentationAndreas Rheinhardt2021-03-12
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Remove always-true checkAndreas Rheinhardt2021-03-12
| | | | | | | Forgotten in 1fd76277708cf83572ba243e98f9e848c652f83d. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: Reindent after previous commitsAndreas Rheinhardt2021-03-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Don't needlessly copy side-data for subtitlesAndreas Rheinhardt2021-03-09
| | | | | | | | AVCodecInternal.last_pkt_props is not used when decoding subtitles; ergo it makes no sense to set it at all. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Avoid stack packets when decoding subtitlesAndreas Rheinhardt2021-03-09
| | | | | | | | | | | | | Use AVCodecInternal.buffer_pkt (previously only used in avcodec_send_packet) instead of stack packets when decoding subtitles. Also stop sharing side-data between packets and use the user-supplied packet directly for decoding when possible (no subtitle decoder ever modifies the packet it is given). Reusing AVCodecInternal.buffer_pkt is based upon an idea from James Almer. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Check size before opening iconvAndreas Rheinhardt2021-03-05
| | | | | | | Avoids closing iconv when the size check fails. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: Return early upon failureAndreas Rheinhardt2021-03-05
| | | | | | | Allows to remove one level of indentation. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/decode: constify the source packet parameter in extract_packet_props()James Almer2021-03-03
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: port last_pkt_props to AVFifoBufferJames Almer2021-03-03
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: shedule old encoding/decoding API for removalAnton Khirnov2021-01-26
| | | | | | | | It has been deprecated for 4 years and certain new codecs do not work with it. Also include AVCodecContext.refcounted_frames, as it has no effect with the new API.
* lavc/decode: move unrefcount_frame() right before its only callerAnton Khirnov2021-01-26
| | | | Will make wrapping it in deprecation guards simpler.
* avcodec/decode: set best_effort_timestamp on output frames for all decodersJames Almer2020-12-13
| | | | | | | | | Fixes a decoding regression introduced by e9a2a87773, and as a side effect also fixes bogus values set to certain audio frames that had some samples discarded, where the offsets added to pts, pkt_dts and pkt_duration were not reflected in best_effort_timestamp. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode/ff_get_buffer: Check for overflow in FFALIGN()Michael Niedermayer2020-10-20
| | | | | | | | Fixes: signed integer overflow: 2147483647 + 64 cannot be represented in type 'int' Fixes: 26218/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5734075396259840 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: Consider discarded samples in max_samplesMichael Niedermayer2020-10-18
| | | | | | | | Fixes: Timeout (several minutes -> 3 sec) Fixes: 25246/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5943400661254144 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: use a packet list to store packet propertiesJames Almer2020-09-15
| | | | | | | | | Keeping only the latest packet fed to the decoder works only for decoders that return a frame immediately after every consumed packet. Decoders that consume several packets before they return a frame will fill said frame with properties taken from the last consumed packet instead of the earliest. Signed-off-by: James Almer <jamrial@gmail.com>
* libavcodec/decode: avoid UB when getting plane sizesBrian Kim2020-07-22
| | | | | | | | This uses av_image_fill_plane_sizes instead of av_image_fill_pointers when we are getting plane sizes to avoid UB from adding offsets to NULL. Signed-off-by: Brian Kim <bkkim@google.com> Signed-off-by: James Almer <jamrial@gmail.com>
* API: add AV_PKT_DATA_S12M_TIMECODE to AVPacketSideDataTypeLimin Wang2020-07-15
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* 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>