summaryrefslogtreecommitdiff
path: root/libavformat/asfdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-10-31 08:53:18 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:33:45 +0100
commit1afddbe59e96af75f1c07605afc95615569f388f (patch)
tree0e8223d9813de6976ec50dc1a5a7c7bf9a099450 /libavformat/asfdec.c
parent1cec0624d0e6f48590283a57169b58b9fe8449d3 (diff)
avpacket: use AVBuffer to allow refcounting the packets.
This will allow us to avoid copying the packets in many cases. This breaks ABI.
Diffstat (limited to 'libavformat/asfdec.c')
-rw-r--r--libavformat/asfdec.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index d4694310fc..a30bf1aadf 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1232,9 +1232,10 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk
asf_st->ds_span);
} else {
/* packet descrambling */
- uint8_t *newdata = av_malloc(asf_st->pkt.size +
- FF_INPUT_BUFFER_PADDING_SIZE);
- if (newdata) {
+ AVBufferRef *buf = av_buffer_alloc(asf_st->pkt.size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
+ if (buf) {
+ uint8_t *newdata = buf->data;
int offset = 0;
memset(newdata + asf_st->pkt.size, 0,
FF_INPUT_BUFFER_PADDING_SIZE);
@@ -1250,13 +1251,18 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk
asf_st->ds_chunk_size);
offset += asf_st->ds_chunk_size;
}
- av_free(asf_st->pkt.data);
- asf_st->pkt.data = newdata;
+ av_buffer_unref(&asf_st->pkt.buf);
+ asf_st->pkt.buf = buf;
+ asf_st->pkt.data = buf->data;
}
}
}
asf_st->frag_offset = 0;
*pkt = asf_st->pkt;
+#if FF_API_DESTRUCT_PACKET
+ asf_st->pkt.destruct = NULL;
+#endif
+ asf_st->pkt.buf = 0;
asf_st->pkt.size = 0;
asf_st->pkt.data = 0;
asf_st->pkt.side_data_elems = 0;