summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
Commit message (Collapse)AuthorAge
* avcodec/decode: flush the internal bsfs instead of constantly reinitalizing themJames Almer2018-08-16
| | | | | | | Initialize the bsfs once when opening the codec and uninitialize them once when closing it, instead of at every codec flush/seek. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/utils: report insane channel count errorsMarton Balint2018-07-13
| | | | | | More than 64 is not *that* insane, so let's report the error at least. Signed-off-by: Marton Balint <cus@passwd.hu>
* lavc: implement an ATRAC9 decoderRostislav Pehlivanov2018-07-03
| | | | | | | | | | | | | | | | | | | | This commit implements a full ATRAC9 decoder, a simple low-delay codec developed by Sony and used in most PSVita games, some PS3 games and some PS4 games. Its similar to AAC in that it uses Huffman coded scalefactors but instead of vector quantization it just Huffman codes the spectral coefficients (in a way similar to how Opus splits band energy coding into coarse and fine precision). It opts to write rather large Huffman codes by packing several small coefficients into one Huffman coded symbol, though I don't believe this increases efficiency at all. Band extension implements SBC in a simple way, first it mirrors the lower spectrum onto the higher frequencies and then it uses one of 5 filters to shape it. Noise substitution is implemented via 2 of them. Unlike previous ATRAC codecs, there's no QMF, this is a standard MDCT codec. Based off of the reverse engineering work of Alex Barney. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* avcodec/utils: Enforce minimum width also for VP5/6Michael Niedermayer2018-04-13
| | | | | | | | | Fixes: out of array access Fixes: poc_0411 Found-by: GwanYeong Kim <gy741.kim@gmail.com> Tested-by: GwanYeong Kim <gy741.kim@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc: add new API for iterating codecs and codec parsersJosh de Kock2018-02-06
| | | | Based on an unfinished patch by atomnuker.
* avcodec/me_cmp: remove ff_me_cmp_init_static()Muhammad Faiz2018-02-05
| | | | | | | Precalculate and constify ff_square_tab. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
* avcodec/utils: Avoid hardcoding duplicated types in sizeof()Michael Niedermayer2018-01-12
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/util: use a mutex instead of atomics in avcodec_register()James Almer2018-01-05
| | | | | Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: remove complex debug code around avcodec init lockingwm42017-12-26
| | | | | | | | | | | | | | | | | | | | | This is just a lot of complicated and confusing code that had no purpose anymore. Also, the functions return values were checked only sometimes. Locking shouldn't fail anyway, so remove the return values. Barely any other pthread lock calls check the return value (including more important code that is more likely to fail horribly if locking fails). It could be argued that it might be helpful in some debugging situations, or when the user built FFmpeg without thread support against all good advice. But there are dummy atomics too, so the atomic check won't help with ensuring correctness absolutely. You gain very little. Also, for debugging, you can just raise the ASSERT_LEVEL, and then libavutil/thread.h will redefine the locking functions to explicitly check the return values.
* lavc, lavf: move avformat static mutex from avcodec to avformatwm42017-12-26
| | | | | | | | It's completely absurd that libavcodec would care about libavformat locking, but it was there because the lock manager was in libavcodec. This is more stright forward. Changes ABI, but we don't require ABI compatibility currently.
* lavc: replace and deprecate the lock managerwm42017-12-26
| | | | | | | Use static mutexes instead of requiring a lock manager. The behavior should be roughly the same before and after this change for API users which did not set the lock manager at all (except that a minor memory leak disappears).
* Revert "libavcodec/utils.c: simplify avcodec locking with atomics"Hendrik Leppkes2017-12-11
| | | | | | | | | | This reverts commit 590136e78da3d091ea99ab5432543d47a559a461. Atomics are not required for this variable, because it is protected through the lock manager, and the use of atomics here is not compatible with the c11 emulation wrappersi. Fixes FATE on MSVC, among other setups which use the compat wrappers.
* lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()Mark Thompson2017-11-26
|
* lavc: Add codec metadata to indicate hardware supportMark Thompson2017-11-26
|
* libavcodec/utils.c: simplify avcodec locking with atomicsRostislav Pehlivanov2017-11-26
| | | | | | Also makes it more robust than using volatiles. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* lavc/utils.c: use C11 atomics for entangled thread handlingRostislav Pehlivanov2017-11-26
| | | | Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* avcodec: deprecate getters and setters for AVCodecContext and AVCodec fieldsJames Almer2017-11-15
| | | | | | The fields can be accessed directly, so these are not needed anymore. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: fix wrong duration of packets (dvd, bluray)Aleksandr Slobodeniuk2017-11-11
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: drop deprecated vismv optionJames Almer2017-10-23
| | | | | | Deprecated in 08/2014. Signed-off-by: James Almer <jamrial@gmail.com>
* Merge commit '48bb0da050329e5111b00a12dfc154b7e78fb3a3'James Almer2017-10-23
|\ | | | | | | | | | | | | * commit '48bb0da050329e5111b00a12dfc154b7e78fb3a3': lavc: Drop deprecated way of setting audio delay on encode Merged-by: James Almer <jamrial@gmail.com>
| * lavc: Drop deprecated way of setting audio delay on encodeVittorio Giovara2017-03-23
| | | | | | | | Deprecated in 08/2014.
* | Merge commit 'b3739599bda740ac12d3dde31a331b744df99123'James Almer2017-10-23
|\| | | | | | | | | | | | | * commit 'b3739599bda740ac12d3dde31a331b744df99123': lavc: Drop deprecated emu edge functionality Merged-by: James Almer <jamrial@gmail.com>
| * lavc: Drop deprecated emu edge functionalityVittorio Giovara2017-03-23
| | | | | | | | Deprecated in 01/2014.
* | Merge commit '6dca24cd1d570b806b5a3fdaef9d3c8608942a81'James Almer2017-10-21
|\| | | | | | | | | | | | | * commit '6dca24cd1d570b806b5a3fdaef9d3c8608942a81': lavc: Drop deprecated way of setting codec dimensions Merged-by: James Almer <jamrial@gmail.com>
| * lavc: Drop deprecated way of setting codec dimensionsVittorio Giovara2017-03-23
| | | | | | | | Deprecated in 10/2013.
* | Merge commit '0337adfab5d14a17bf4d5060aa0425e4049a9862'James Almer2017-10-21
|\| | | | | | | | | | | | | * commit '0337adfab5d14a17bf4d5060aa0425e4049a9862': lavc: Drop deprecated missing sample log function Merged-by: James Almer <jamrial@gmail.com>
| * lavc: Drop deprecated missing sample log functionVittorio Giovara2017-03-23
| | | | | | | | Deprecated in 01/2013.
| * lavc: Add device context field to AVCodecContextMark Thompson2017-02-13
| | | | | | | | For use by codec implementations which can allocate frames internally.
| * lavc: use av_cpu_max_align() instead of hardcoding alignment requirementsAnton Khirnov2017-02-11
| |
* | Remove some unneeded casts of bit_rate.Carl Eugen Hoyos2017-09-22
| |
* | lavc/utils: Calculate frame duration for little-endian G.726.Carl Eugen Hoyos2017-08-26
| |
* | avcodec/utils: Fix signed integer overflow in rc_initial_buffer_occupancy ↵Vitaly Buka2017-08-23
| | | | | | | | | | | | | | | | | | | | initialization Signed integer overflow is undefined behavior. Detected with clang and -fsanitize=signed-integer-overflow Signed-off-by: Vitaly Buka <vitalybuka@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '972c71e9cb63e24f57ee481e413199c7d88a8813'James Almer2017-04-22
|\| | | | | | | | | | | | | * commit '972c71e9cb63e24f57ee481e413199c7d88a8813': lavc: add support for filtering packets before decoding Merged-by: James Almer <jamrial@gmail.com>
| * lavc: add support for filtering packets before decodingAnton Khirnov2016-12-14
| |
* | Merge commit '061a0c14bb5767bca72e3a7227ca400de439ba09'James Almer2017-04-22
|\| | | | | | | | | | | | | | | | | * commit '061a0c14bb5767bca72e3a7227ca400de439ba09': decode: restructure the core decoding code CUVID decoder adapted by wm4. Merged-by: James Almer <jamrial@gmail.com>
| * decode: restructure the core decoding codeAnton Khirnov2016-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the new decoding API is pretty much just a wrapper around the old deprecated one. This is problematic, since it interferes with making full use of the flexibility added by the new API. The old API should also be removed at some future point. Reorganize the code so that the new send_packet/receive_frame functions call the actual decoding directly and change the old deprecated avcodec_decode_* functions into wrappers around the new API. The new internal API for decoders is now changing as well. Before this commit, it mirrors the public API, so the decoders need to implement send_packet() and receive_frame() callbacks. This turns out to require awkward constructs in both the decoders and the generic code. After this commit, the decoders only implement the receive_frame() callback and call a new internal function, ff_decode_get_packet() to obtain input data, in the same manner to how the bitstream filters now work. avcodec will now always make a reference to the input packet, which means that non-refcounted input packets will be copied. Keeping the previous behaviour, where this copy could sometimes be avoided, would make the code significantly more complex and fragile for only dubious gains, since packets are typically small and everyone who cares about performance should use refcounted packets anyway.
* | Merge commit '549d0bdca53af7a6e0c612ab4b03baecf3a5878f'James Almer2017-04-22
|\| | | | | | | | | | | | | | | | | | | * commit '549d0bdca53af7a6e0c612ab4b03baecf3a5878f': decode: be more explicit about storing the last packet properties Also copy pkt->size in extract_packet_props(), as it's needed for AVFrame.pkt_size Merged-by: James Almer <jamrial@gmail.com>
| * decode: be more explicit about storing the last packet propertiesAnton Khirnov2016-12-14
| | | | | | | | | | | | | | | | | | | | | | The current code stores a pointer to the packet passed to the decoder, which is then used during get_buffer() for timestamps and side data passthrough. However, since this is a pointer to user data which we do not own, storing it is potentially dangerous. It is also ill defined for the new decoding API with split input/output. Fix this problem by making an explicit internally owned copy of the packet properties.
* | Merge commit '0309ddcfb25fd44883bfcdb07509eb4907576b97'Clément Bœsch2017-04-17
|\| | | | | | | | | | | | | * commit '0309ddcfb25fd44883bfcdb07509eb4907576b97': lavc: handle MP3 in get_audio_frame_duration() Merged-by: Clément Bœsch <u@pkh.me>
| * lavc: handle MP3 in get_audio_frame_duration()Anton Khirnov2016-12-14
| |
* | Merge commit '3fe2a01df7f2c193805809f57b61d79607572351'James Almer2017-04-07
|\| | | | | | | | | | | | | * commit '3fe2a01df7f2c193805809f57b61d79607572351': lavc: move decoding-related code from utils.c to a new file Merged-by: James Almer <jamrial@gmail.com>
| * lavc: move decoding-related code from utils.c to a new fileAnton Khirnov2016-11-29
| |
* | Merge commit '328cd2b599bc2d0d38f3c12606fa2a66eeec016e'James Almer2017-04-07
|\| | | | | | | | | | | | | * commit '328cd2b599bc2d0d38f3c12606fa2a66eeec016e': lavc: move encoding-related code from utils.c to a new file Merged-by: James Almer <jamrial@gmail.com>
| * lavc: move encoding-related code from utils.c to a new fileAnton Khirnov2016-11-29
| |
| * Add GBRAP12 pixel format supportKieran Kunhya2016-10-12
| | | | | | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* | lavc: Add Content Light Level side metadata found in HEVCSteve Lhomme2017-04-06
| | | | | | | | | | | | These data are necessary when transmitting HDR over HDMI. Signed-off-by: James Almer <jamrial@gmail.com>
* | pthread_frame: allow per-field ThreadFrame owners.Ronald S. Bultje2017-04-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This tries to handle cases where separate invocations of decode_frame() (each running in separate threads) write to respective fields in the same AVFrame->data[]. Having per-field owners makes interaction between readers (the referencing thread) and writers (the decoding thread) slightly more optimal if both accesses are field-based, since they will use the respective producer's thread objects (mutex/cond) instead of sharing the thread objects of the first field's producer. In practice, this fixes the following tsan-warning in fate-h264: WARNING: ThreadSanitizer: data race (pid=21615) Read of size 4 at 0x7d640000d9fc by thread T2 (mutexes: write M1006): #0 ff_thread_report_progress pthread_frame.c:569 (ffmpeg:x86_64+0x100f7cf54) [..] Previous write of size 4 at 0x7d640000d9fc by main thread (mutexes: write M1004): #0 update_context_from_user pthread_frame.c:335 (ffmpeg:x86_64+0x100f81abb)
* | lavc: fix usages of av_get_codec_tag_string()Clément Bœsch2017-03-29
| |
* | avcodec: remove warning against using frame threading with hwaccelswm42017-03-21
| | | | | | | | | | | | | | libavcodec now automatically serializes decoding for hwaccels which are not thread-safe. This means API users, which rely on the libavcodec native software fallback mechanism, can now simply enable threading without running into problems.
* | avcodec, avformat: deprecate anything related to side data mergingwm42017-03-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch deprecates anything that has to do with merging/splitting side data. Automatic side data merging (and splitting), as well as all API symbols involved in it, are removed completely. Two FF_API_ defines are dedicated to deprecating API symbols related to this: FF_API_MERGE_SD_API removes av_packet_split/merge_side_data in libavcodec, and FF_API_LAVF_KEEPSIDE_FLAG deprecates AVFMT_FLAG_KEEP_SIDE_DATA in libavformat. Since it was claimed that changing the default from merging side data to not doing it is an ABI change, there are two additional FF_API_ defines, which stop using the side data merging/splitting by default (and remove any code in avformat/avcodec doing this): FF_API_MERGE_SD in libavcodec, and FF_API_LAVF_MERGE_SD in libavformat. It is very much intended that FF_API_MERGE_SD and FF_API_LAVF_MERGE_SD are quickly defined to 0 in the next ABI bump, while the API symbols are retained for a longer time for the sake of compatibility. AVFMT_FLAG_KEEP_SIDE_DATA will (very much intentionally) do nothing for most of the time it will still be defined. Keep in mind that no code exists that actually tries to unset this flag for any reason, nor does such code need to exist. Code setting this flag explicitly will work as before. Thus it's ok for AVFMT_FLAG_KEEP_SIDE_DATA to do nothing once side data merging has been removed from libavformat. In order to avoid that anyone in the future does this incorrectly, here is a small guide how to update the internal code on bumps: - next ABI bump (probably soon): - define FF_API_LAVF_MERGE_SD to 0, and remove all code covered by it - define FF_API_MERGE_SD to 0, and remove all code covered by it - next API bump (typically two years in the future or so): - define FF_API_LAVF_KEEPSIDE_FLAG to 0, and remove all code covered by it - define FF_API_MERGE_SD_API to 0, and remove all code covered by it This forces anyone who actually wants packet side data to temporarily use deprecated API to get it all. If you ask me, this is batshit fucked up crazy, but it's how we roll. Making AVFMT_FLAG_KEEP_SIDE_DATA to be set by default was rejected as an ABI change, so I'm going all the way to get rid of this once and for all. Reviewed-by: James Almer <jamrial@gmail.com> Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>