Revision a08d918e

View differences:

libavcodec/avcodec.h
32 32
#include "libavutil/cpu.h"
33 33

  
34 34
#define LIBAVCODEC_VERSION_MAJOR 52
35
#define LIBAVCODEC_VERSION_MINOR 96
35
#define LIBAVCODEC_VERSION_MINOR 97
36 36
#define LIBAVCODEC_VERSION_MICRO  0
37 37

  
38 38
#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
3027 3027
void av_shrink_packet(AVPacket *pkt, int size);
3028 3028

  
3029 3029
/**
3030
 * Increase packet size, correctly zeroing padding
3031
 *
3032
 * @param pkt packet
3033
 * @param grow_by number of bytes by which to increase the size of the packet
3034
 */
3035
int av_grow_packet(AVPacket *pkt, int grow_by);
3036

  
3037
/**
3030 3038
 * @warning This is a hack - the packet memory allocation stuff is broken. The
3031 3039
 * packet is allocated if it was not really allocated.
3032 3040
 */
libavcodec/avpacket.c
20 20
 */
21 21

  
22 22
#include "avcodec.h"
23
#include "libavutil/avassert.h"
23 24

  
24 25

  
25 26
void av_destruct_packet_nofree(AVPacket *pkt)
......
71 72
    memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
72 73
}
73 74

  
75
int av_grow_packet(AVPacket *pkt, int grow_by)
76
{
77
    void *new_ptr;
78
    av_assert0((unsigned)pkt->size <= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE);
79
    if (!pkt->size)
80
        return av_new_packet(pkt, grow_by);
81
    if ((unsigned)grow_by > INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE))
82
        return -1;
83
    new_ptr = av_realloc(pkt->data, pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE);
84
    if (!new_ptr)
85
        return AVERROR(ENOMEM);
86
    pkt->data = new_ptr;
87
    pkt->size += grow_by;
88
    memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
89
    return 0;
90
}
91

  
74 92
int av_dup_packet(AVPacket *pkt)
75 93
{
76 94
    if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {

Also available in: Unified diff