# HG changeset patch # User reimar # Date 1239221952 0 # Node ID 66e270967340e8fac81225299e850e9ea450b61f # Parent f978e4a699c5fb304a15de4b422b7db52d488edd Add av_shrink_packet function for use in av_get_packet that reduces pkt->size and ensures the following padding is correctly initialized to 0. diff -r f978e4a699c5 -r 66e270967340 avcodec.h --- a/avcodec.h Wed Apr 08 01:45:44 2009 +0000 +++ b/avcodec.h Wed Apr 08 20:19:12 2009 +0000 @@ -2655,6 +2655,14 @@ 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 -r f978e4a699c5 -r 66e270967340 avpacket.c --- a/avpacket.c Wed Apr 08 01:45:44 2009 +0000 +++ b/avpacket.c Wed Apr 08 20:19:12 2009 +0000 @@ -62,6 +62,13 @@ 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) {