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/flacdec.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/flacdec.c')
-rw-r--r-- | libavformat/flacdec.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index f19f95d901..7aaec9eb26 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -32,7 +32,8 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) { const CodecMime *mime = ff_id3v2_mime_tags; enum AVCodecID id = AV_CODEC_ID_NONE; - uint8_t mimetype[64], *desc = NULL, *data = NULL; + AVBufferRef *data = NULL; + uint8_t mimetype[64], *desc = NULL; AVIOContext *pb = NULL; AVStream *st; int type, width, height; @@ -110,11 +111,11 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) ret = AVERROR_INVALIDDATA; goto fail; } - if (!(data = av_malloc(len))) { + if (!(data = av_buffer_alloc(len))) { ret = AVERROR(ENOMEM); goto fail; } - if (avio_read(pb, data, len) != len) { + if (avio_read(pb, data->data, len) != len) { av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n"); if (s->error_recognition & AV_EF_EXPLODE) ret = AVERROR(EIO); @@ -128,9 +129,9 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) } av_init_packet(&st->attached_pic); - st->attached_pic.data = data; + st->attached_pic.buf = data; + st->attached_pic.data = data->data; st->attached_pic.size = len; - st->attached_pic.destruct = av_destruct_packet; st->attached_pic.stream_index = st->index; st->attached_pic.flags |= AV_PKT_FLAG_KEY; @@ -148,8 +149,8 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) return 0; fail: + av_buffer_unref(&data); av_freep(&desc); - av_freep(&data); av_freep(&pb); return ret; |