Logo Search packages:      
Sourcecode: blender version File versions

int av_new_packet ( AVPacket *  pkt,
int  size 
)

Allocate the payload of a packet and intialized its fields to default values.

Parameters:
pkt packet
size wanted payload size
Returns:
0 if OK. AVERROR_xxx otherwise.

Definition at line 192 of file utils.c.

References av_destruct_packet(), av_malloc(), and FF_INPUT_BUFFER_PADDING_SIZE.

Referenced by av_get_packet().

{
    void *data;
    if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
        return AVERROR_NOMEM;
    data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
    if (!data)
        return AVERROR_NOMEM;
    memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);

    av_init_packet(pkt);
    pkt->data = data;
    pkt->size = size;
    pkt->destruct = av_destruct_packet;
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index