summaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2003-02-03 22:58:29 +0000
committerFabrice Bellard <fabrice@bellard.org>2003-02-03 22:58:29 +0000
commit6fa5a56c1ba7ee770e48ddc8f785d85c00ba9c4d (patch)
treec60e1a61c337ae83557526b1bbe229a52219479a /libavformat/utils.c
parentcdc90af00835297b8d5f3f06c47cf2c53267c3a3 (diff)
downloadffmpeg-streaming-6fa5a56c1ba7ee770e48ddc8f785d85c00ba9c4d.zip
ffmpeg-streaming-6fa5a56c1ba7ee770e48ddc8f785d85c00ba9c4d.tar.gz
zero copy packet handling for DV1394 by Max Krasnyansky
Originally committed as revision 1542 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c2e9328..d295e9a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -151,6 +151,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.
*
* @param pkt packet
@@ -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;
- 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;
+ 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;
}
-/**
- * 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)
OpenPOWER on IntegriCloud