diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2015-10-23 11:11:34 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2015-10-26 18:00:55 +0100 |
commit | a9a60106370f862e191dea58e748626da6a8fe97 (patch) | |
tree | 0bfbeefe8c036d171cec28af34cdeaf21ecb85b6 /libavcodec/avpacket.c | |
parent | 9b56d5c11488656254e9aed8d964ef2b7c2ff5e6 (diff) | |
download | ffmpeg-a9a60106370f862e191dea58e748626da6a8fe97.tar.gz |
avpacket: Provide an alloc and a free function for the struct
Pave the way for having the size of the AVPacket struct not part
of the ABI.
Diffstat (limited to 'libavcodec/avpacket.c')
-rw-r--r-- | libavcodec/avpacket.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index cec5bf89c3..a6eb241785 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -46,6 +46,26 @@ FF_ENABLE_DEPRECATION_WARNINGS pkt->side_data_elems = 0; } +AVPacket *av_packet_alloc(void) +{ + AVPacket *pkt = av_mallocz(sizeof(AVPacket)); + if (!pkt) + return pkt; + + av_packet_unref(pkt); + + return pkt; +} + +void av_packet_free(AVPacket **pkt) +{ + if (!pkt || !*pkt) + return; + + av_packet_unref(*pkt); + av_freep(pkt); +} + static int packet_alloc(AVBufferRef **buf, int size) { int ret; @@ -343,6 +363,19 @@ fail: return ret; } +AVPacket *av_packet_clone(AVPacket *src) +{ + AVPacket *ret = av_packet_alloc(); + + if (!ret) + return ret; + + if (av_packet_ref(ret, src)) + av_packet_free(&ret); + + return ret; +} + void av_packet_move_ref(AVPacket *dst, AVPacket *src) { *dst = *src; |