diff options
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 8 | ||||
-rw-r--r-- | libavcodec/avpacket.c | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 218e236e9b..f500151e85 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2655,6 +2655,14 @@ void av_init_packet(AVPacket *pkt); int av_new_packet(AVPacket *pkt, int size); /** + * Reduce packet size, correctly zeroing padding + * + * @param pkt packet + * @param size new size + */ +void av_shrink_packet(AVPacket *pkt, int size); + +/** * @warning This is a hack - the packet memory allocation stuff is broken. The * packet is allocated if it was not really allocated. */ diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 107afb3817..d91ee3a10d 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -62,6 +62,13 @@ int av_new_packet(AVPacket *pkt, int size) return 0; } +void av_shrink_packet(AVPacket *pkt, int size) +{ + if (pkt->size <= size) return; + pkt->size = size; + memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); +} + int av_dup_packet(AVPacket *pkt) { if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) { |