summaryrefslogtreecommitdiff
path: root/libavcodec/avpacket.c
Commit message (Collapse)AuthorAge
* avcodec: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet: change side data related public function and struct size ↵James Almer2021-03-10
| | | | | | | | | types to size_t av_packet_add_side_data() already defines size as a size_t, so this makes it consistent across all side data functions Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet: move AVPacketList definition and function helpers over from ↵James Almer2020-09-15
| | | | | | | | | libavformat And replace the flags parameter with a function callback that can be used to copy the contents of the packet (e.g, av_packet_ref and av_packet_copy_props). 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/internal: move packet related functions to their own headerJames Almer2020-06-02
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/avpacket: add missing entry for prft to av_packet_side_data_name()James Almer2020-05-05
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/avpacket: Don't write into non-writable bufferAndreas Rheinhardt2020-04-30
| | | | | | | | | | The data of an AVPacket may be a part of the data of an AVBufferRef; Therefore av_grow_packet() doesn't reallocate if the available space in the actual buffer is sufficient for the enlargement. But given that it also zeroes the padding it also needs to make sure that the buffer is actually writable; this commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavcodec/avpacket: Don't simply forward return value of av_dict_set()Andreas Rheinhardt2020-04-23
| | | | | | | | | | | The documentation of av_dict_set() states that values >= 0 indicate success, whereas av_packet_unpack_dictionary() implies that return values > 0 are impossible. So only forward the return value of av_dict_set() in av_packet_unpack_dictionary() on error. (Btw: av_dict_set() does currently not return values > 0.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavc: add a new sidedata type for DOVIJun Zhao2020-04-23
| | | | | | add a new sidedata type for DOVI. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avcodec.h: split AVPacket API into its own headerAnton Khirnov2020-04-10
|
* avcodec/avcodec, avpacket: Return blank packet on av_packet_ref() failureAndreas Rheinhardt2020-03-28
| | | | | | | | | | | | Up until now, it was completely unspecified what the content of the destination packet dst was on error. Depending upon where the error happened calling av_packet_unref() on dst might be dangerous. This commit changes this by making sure that dst is blank on error, so unreferencing it again is safe (and still pointless). This behaviour is documented. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/avpacket: Always treat dst in av_packet_ref as uninitializedAndreas Rheinhardt2020-03-28
| | | | | | | | | | | | | | | | | | av_packet_ref() mostly treated the destination packet dst as uninitialized, i.e. the destination fields were simply overwritten. But if the source packet was not reference-counted, dst->buf was treated as if it pointed to an already allocated buffer (if != NULL) to be reallocated to the desired size. The documentation did not explicitly state whether the dst will be treated as uninitialized, but it stated that if the source packet is not refcounted, a new buffer in dst will be allocated. This and the fact that the side-data as well as the codepath taken in case src is refcounted always treated the packet as uninitialized means that dst should always be treated as uninitialized for the sake of consistency. And this behaviour has been explicitly documented. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* API: add AV_PKT_DATA_ICC_PROFILE to AVPacketSideDataTypevectronic2020-03-10
| | | | Signed-off-by: vectronic <hello.vectronic@gmail.com>
* avcodec: add a Producer Reference Time AVPacketSideData typeJames Almer2020-01-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/avpacket: Improve allocating packetsAndreas Rheinhardt2019-09-18
| | | | | | | | av_mallocz + av_init_packet leads to the same result as av_mallocz + av_packet_unref, but faster. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/avpacket: check NULL before using the pointerJun Zhao2019-05-12
| | | | | | Need to check NULL before using the pointer Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avcodec/avpacket: add some assertions to ensure pkt->data is not null if ↵Marton Balint2019-03-01
| | | | | | | | | | | pkt->size > 0 This should fix the following Coverity false positives: Coverity CID #1405450. Coverity CID #1430930. Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/avpacket: Avoid unspecific return -1 for av_grow_packet()Michael Niedermayer2019-01-01
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/avpacket: fix whitespaceAman Gupta2018-10-12
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* lavc/avpacket: Add missing conversions from side data enum to name.Jun Zhao2018-09-21
| | | | | | Add missing conversions from side data enum to name. Signed-off-by: Jun Zhao <mypopydev@gmail.com>
* avcodec/avpacket: add av_packet_make_refcounted()James Almer2018-04-01
| | | | | | | | It works as a drop in replacement for the deprecated av_dup_packet(), to ensure a packet is reference counted. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/avpacket: remove unnecessary check in av_packet_make_writable()James Almer2018-03-27
| | | | | | | Zero sized packets are already handled below in the function. This is more in line with av_packet_ref(). Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/avpacket: add av_packet_make_writable()James Almer2018-03-21
| | | | | | | Useful as well to quickly make a packet reference counted when it isn't already so. Signed-off-by: James Almer <jamrial@gmail.com>
* avpacket: reset dst side_data fields in av_packet_copy_propsYusuke Nakamura2018-02-14
| | | | | | | | | | This effectively copies the side data elements from src instead of potentially merging them with those already existing in dst. This by extension also removes the only dependency on existing values in the dst packet. Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: remove ABI portion of the side data merging APIJames Almer2017-10-22
| | | | | | The actual API is left in place until the deprecation period ends. Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/decklink_dec: Added Closed caption decode from VANCKarthick J2017-09-28
| | | | | Signed-off-by: Karthick J <kjeyapal@akamai.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/avpacket: deprecate av_copy_packet()James Almer2017-09-25
| | | | | | It does the same thing as av_packet_ref(). Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/avpacket: Limit iterations in ff_packet_split_and_drop_side_data()Michael Niedermayer2017-06-11
| | | | | | | | | This avoids scaning beyond what a valid packet can contain Fixes: Timeout Fixes: 541/clusterfuzz-testcase-610189291657625 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/avpacket: allow only one element per type in packet side dataJames Almer2017-05-12
| | | | | | | | | | It was never meant to do otherwise, as av_packet_get_side_data() returns the first entry it finds of a given type. Based on code from libavformat's av_stream_add_side_data(). Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/avcodec: Limit the number of side data elements per packetMichael Niedermayer2017-05-12
| | | | | | | | | Fixes: 1293/clusterfuzz-testcase-minimized-6054752074858496 See: [FFmpeg-devel] [PATCH] avcodec/avcodec: Limit the number of side data elements per packet Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Avoid splitting side data repeatedlyMichael Niedermayer2017-05-06
| | | | | | | | Fixes Timeout Fixes: 508/clusterfuzz-testcase-6245747678773248 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* 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>
* Merge commit 'adb0e941c329a4778ade6dd0a326274472992f54'Clément Bœsch2017-04-01
|\ | | | | | | | | | | | | | | | | * commit 'adb0e941c329a4778ade6dd0a326274472992f54': avpacket: Mark src pointer as constant See 5bb3f8825584a319b25b430e4ece2fa5b2b47ff9 Merged-by: Clément Bœsch <u@pkh.me>
| * avpacket: Mark src pointer as constantLuca Barbato2016-11-17
| |
| * avpacket: Error out when creating 0-sized side dataVittorio Giovara2016-06-13
| | | | | | | | | | | | | | | | This mimics the behaviour of other av_*_new_side_data(). This is not caught by the malloc check, since padding is always added to the allocated size. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | 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>
* | lavc/avpacket: Make pkt parameter of av_packet_get_side_data() const.Carl Eugen Hoyos2017-03-16
| | | | | | | | | | Reflects the actual code and silences a gcc warning: libavcodec/utils.c:2102:36: warning: passing argument 1 of 'av_packet_get_side_data' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
* | avcodec/avpacket: Check metadata key in av_packet_unpack_dictionary()Michael Niedermayer2017-03-01
| | | | | | | | | | | | | | | | Fixes timeout Fixes: 501/clusterfuzz-testcase-5672752870588416 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavc/avpacket: Initialize a variable in error path.Carl Eugen Hoyos2017-02-17
| | | | | | | | | | | | Fixes ticket #6153. Tested-by: Tyson Smith
* | lavc: Add spherical packet side data APIVittorio Giovara2016-12-07
| | | | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | avcodec/avpacket: fix leak on realloc in av_packet_add_side_data()James Almer2016-11-19
| | | | | | | | | | | | | | | | | | If realloc fails, the pointer is overwritten and the previously allocated buffer is leaked, which goes against the expected behavior of keeping the packet unchanged in case of error. Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* | lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy().Carl Eugen Hoyos2016-09-22
| | | | | | | | Fixes ticket #5857.
* | avcodec/avpacket: clear side_data_elemsMichael Niedermayer2016-09-12
| | | | | | | | | | | | | | Fixes null pointer dereference Found-by: 连一汉 <lianyihan@360.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy().Carl Eugen Hoyos2016-09-05
| | | | | | | | Fixes ticket #5128.
* | Merge commit '8996515b137f962e3a8691241c285c96437b6c53'Clément Bœsch2016-06-22
|\| | | | | | | | | | | | | | | | | * commit '8996515b137f962e3a8691241c285c96437b6c53': avpacket: fix setting AVPacket.data in av_packet_ref() This commit is a noop, see ed3a02547c71ac06fa27f17ad53116a74f78d927 Merged-by: Clément Bœsch <u@pkh.me>
| * avpacket: fix setting AVPacket.data in av_packet_ref()Anton Khirnov2016-05-16
| | | | | | | | | | | | | | The data field does not necessarily point to the beginning of the underlying AVBuffer. CC: libav-stable@libav.org
* | avcodec/avpacket: Respect payload offset in av_grow_packetAndriy Lysnevych2016-06-02
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/avpacket: Respect payload offset in av_packet_refAndriy Lysnevych2016-05-13
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/avpacket: Fix off by 5 errorMichael Niedermayer2016-04-21
| | | | | | | | | | | | | | | | Fixes out of array read Fixes: mozilla bug 1266129 Found-by: Tyson Smith Tested-by: Tyson Smith Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit 'dbb43b8b83b097585ec255ec638b61e359ebea77'Derek Buitenhuis2016-04-12
|\| | | | | | | | | | | | | * commit 'dbb43b8b83b097585ec255ec638b61e359ebea77': avpacket: properly reset data/size in av_packet_move_ref() Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>