From 1afddbe59e96af75f1c07605afc95615569f388f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 31 Oct 2012 08:53:18 +0100 Subject: avpacket: use AVBuffer to allow refcounting the packets. This will allow us to avoid copying the packets in many cases. This breaks ABI. --- libavformat/id3v2.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'libavformat/id3v2.c') diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 4516ac74ef..204ea745d4 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -420,7 +420,7 @@ finish: static void free_apic(void *obj) { ID3v2ExtraMetaAPIC *apic = obj; - av_freep(&apic->data); + av_buffer_unref(&apic->buf); av_freep(&apic->description); av_freep(&apic); } @@ -476,9 +476,8 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, char *tag goto fail; } - apic->len = taglen; - apic->data = av_malloc(taglen); - if (!apic->data || avio_read(pb, apic->data, taglen) != taglen) + apic->buf = av_buffer_alloc(taglen); + if (!apic->buf || avio_read(pb, apic->buf->data, taglen) != taglen) goto fail; new_extra->tag = "APIC"; @@ -734,14 +733,13 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta) av_dict_set(&st->metadata, "comment", apic->type, 0); av_init_packet(&st->attached_pic); - st->attached_pic.data = apic->data; - st->attached_pic.size = apic->len; - st->attached_pic.destruct = av_destruct_packet; + st->attached_pic.buf = apic->buf; + st->attached_pic.data = apic->buf->data; + st->attached_pic.size = apic->buf->size; st->attached_pic.stream_index = st->index; st->attached_pic.flags |= AV_PKT_FLAG_KEY; - apic->data = NULL; - apic->len = 0; + apic->buf = NULL; } return 0; -- cgit v1.2.3