diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-10-31 08:53:18 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-03-08 07:33:45 +0100 |
commit | 1afddbe59e96af75f1c07605afc95615569f388f (patch) | |
tree | 0e8223d9813de6976ec50dc1a5a7c7bf9a099450 /libavformat/id3v2.c | |
parent | 1cec0624d0e6f48590283a57169b58b9fe8449d3 (diff) | |
download | ffmpeg-1afddbe59e96af75f1c07605afc95615569f388f.tar.gz |
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/id3v2.c')
-rw-r--r-- | libavformat/id3v2.c | 16 |
1 files changed, 7 insertions, 9 deletions
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; |