summaryrefslogtreecommitdiff
path: root/libavcodec/decode.c
Commit message (Collapse)AuthorAge
* avcodec/decode: parse ICC profilesNiklas Haas2022-07-30
| | | | | | | | | Implementation for the decode side of the ICC profile API, roughly matching the behavior of the existing vf_iccdetect filter. Closes: #9673 Signed-off-by: Niklas Haas <git@haasn.dev>
* avcodec: add common fflcms2 boilerplateNiklas Haas2022-07-30
| | | | | | | | | | | | | Handling this in general code makes more sense than handling it in individual codec files, because it would be a lot of unnecessary code duplication for the plenty of formats that support exporting ICC profiles (jpg, png, tiff, webp, jxl, ...). encode.c and decode.c will be in charge of initializing this state as needed, so we merely need to make sure to uninit it afterwards from the common destructor path. Signed-off-by: Niklas Haas <git@haasn.dev>
* avcodec/aacdec: remove skip samples multiplierJames Almer2022-07-22
| | | | | | | | | The amount of padding samples reported by containers take into account the extended samplerate in HE-AAC. Fixes ticket #9671. Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: use AVFrame.duration instead of AVFrame.pkt_durationAnton Khirnov2022-07-19
|
* avcodec/internal: Hide stuff only used by the core decode APIAndreas Rheinhardt2022-05-12
| | | | | | | | | | | | | | | | | | | | | | The general decoding API uses bitstream filters and an AVFifo and therefore AVCodecInternal contains pointers to an AVBSFContext and to an AVFifo and lavc/internal.h includes lavc/bsf.h and lavu/fifo.h. Yet actually, only two files are supposed to use these, namely avcodec.c and (mainly) decode.c. For all the other files, it should be an opaque type that they should not touch and that they need not know anything about. This can be achieved by not including these headers and using the structs instead of the corresponding typedefs. This also forces translation units that really use the BSF and the FIFO APIs themselves to include the relevant headers directly instead of relying on indirect inclusions (up until now, even avcodec.c and decode.c relied on fifo.h to be included by internal.h). Of course, it also avoids unnecessary rebuilds when bsf.h or fifo.h change. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/avcodec: only allocate decoding packets for decodersAnton Khirnov2022-05-11
|
* lavc/encode: add an encoder-specific get_buffer() variantAnton Khirnov2022-05-11
| | | | | | | | | | | Several encoders (roqvideo, svq1, snow, and the mpegvideo family) currently call ff_get_buffer(). However this function is written assuming it is called by a decoder. Though nothing has been obviously broken by this until now, that may change in the future. To avoid potential future issues, introduce a simple encode-specific wrapper around avcodec_default_get_buffer2() and enforce its use in encoders.
* lavc: move default get_buffer2() to its own fileAnton Khirnov2022-04-13
| | | | | It is also used by some encoders, so decode.c is not the right place for it.
* 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.decode_subAndreas Rheinhardt2022-04-05
| | | | | | | | | This increases type-safety by avoiding conversions from/through void*. It also avoids the boilerplate "AVSubtitle *sub = data;" line for subtitle decoders. Its only downside is that it increases sizeof(FFCodec), yet this can be more than offset lateron. 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>
* lavc: drop temporary compat wrappers for channel layout API changeAnton Khirnov2022-03-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: switch to the new channel layout APIVittorio Giovara2022-03-15
| | | | | | | | Since the request_channel_layout is used only by a handful of codecs, move the option to codec private contexts. Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: deprecate channel count/layout changing side dataAnton Khirnov2022-03-15
| | | | | | | | They are incompatible with the new channel layout scheme and no decoder uses them. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/avcodec: switch to new FIFO APIAnton Khirnov2022-02-07
|
* avcodec/decode: ignore unsupported skip samples packet side data valuesJames Almer2022-02-05
| | | | | | | Same as in the AV_FRAME_FLAG_DISCARD codepath, ensure avci->skip_samples is not negative. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/decode: Reset *got_sub_ptr on errorAndreas Rheinhardt2021-12-16
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/decode: Fix leaks upon subtitle decoding errorsAndreas Rheinhardt2021-12-16
| | | | | | | | | | | | | | Up until now, various subtitle decoders have not cleaned up the AVSubtitle on error; this task must not be left to the user because the documentation explicitly states that the AVSubtitle "must be freed with avsubtitle_free if *got_sub_ptr is set" (which it isn't on error). Leaks happen upon failure in ff_ass_add_rect() or in ass_decode_frame(); freeing generically also allows to remove now redundant freeing code in pgssubdec and dvbsubdec. While just at it, also reset got_sub_ptr generically on error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* all: Use av_memdup() where appropriateAndreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Allow receive_frame codecs to use decode_simple pktAndreas Rheinhardt2021-11-07
| | | | | | | | | | | | | | | | | | Decoders implementing the receive_frame API currently mostly use stack packets to temporarily hold the packet they receive from ff_decode_get_packet(). This role directly parallels the role of in_pkt, the spare packet used in decode_simple_internal for the decoders implementing the traditional decoding API. Said packet is unused by the generic code for the decoders implementing the receive_frame API, so allow them to use it to fulfill the function it already fulfills for the traditional API for both APIs. There is only one caveat in this: The packet is automatically unreferenced in avcodec_flush_buffers(). But this is actually positive as it means the decoders don't have to do this themselves (in case the packet is preserved between receive_frame calls). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc: deprecate AV_CODEC_(FLAG|CAP)_TRUNCATEDAnton Khirnov2021-09-20
| | | | | | | | | | It is supported only by a few decoders (h263, h263p, mpeg(1|2|)video and mpeg4) and is entirely redundant with parsers. Furthermore, using it leads to missing frames, as flushing the decoder at the end does not work properly. Co-authored-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* 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>