zero copy packet handling for DV1394 by Max Krasnyansky
Originally committed as revision 1542 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@@ -150,6 +150,15 @@ AVInputFormat *av_find_input_format(const char *short_name)
|
||||
|
||||
/* memory handling */
|
||||
|
||||
/**
|
||||
* Default packet destructor
|
||||
*/
|
||||
static void av_destruct_packet(AVPacket *pkt)
|
||||
{
|
||||
av_free(pkt->data);
|
||||
pkt->data = NULL; pkt->size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the payload of a packet and intialized its fields to default values.
|
||||
*
|
||||
@@ -159,34 +168,18 @@ AVInputFormat *av_find_input_format(const char *short_name)
|
||||
*/
|
||||
int av_new_packet(AVPacket *pkt, int size)
|
||||
{
|
||||
int i;
|
||||
pkt->data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!pkt->data)
|
||||
void *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;
|
||||
/* sane state */
|
||||
pkt->pts = AV_NOPTS_VALUE;
|
||||
pkt->stream_index = 0;
|
||||
pkt->flags = 0;
|
||||
|
||||
for(i=0; i<FF_INPUT_BUFFER_PADDING_SIZE; i++)
|
||||
pkt->data[size+i]= 0;
|
||||
|
||||
pkt->destruct = av_destruct_packet;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free a packet
|
||||
*
|
||||
* @param pkt packet to free
|
||||
*/
|
||||
void av_free_packet(AVPacket *pkt)
|
||||
{
|
||||
av_freep(&pkt->data);
|
||||
/* fail safe */
|
||||
pkt->size = 0;
|
||||
}
|
||||
|
||||
/* fifo handling */
|
||||
|
||||
int fifo_init(FifoBuffer *f, int size)
|
||||
|
Reference in New Issue
Block a user