diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-08 17:28:42 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-08 19:12:03 +0100 |
commit | 2653e125204569b1e9439ee2671c6ebb23a94b80 (patch) | |
tree | 4176f76bccc8cdd1c85b9d329a82867eda37d397 /libavformat/utils.c | |
parent | 532f31a695c9530ce67a847be00d72e6e8acfd11 (diff) | |
parent | 1afddbe59e96af75f1c07605afc95615569f388f (diff) | |
download | ffmpeg-2653e125204569b1e9439ee2671c6ebb23a94b80.tar.gz |
Merge commit '1afddbe59e96af75f1c07605afc95615569f388f'
* commit '1afddbe59e96af75f1c07605afc95615569f388f':
avpacket: use AVBuffer to allow refcounting the packets.
Conflicts:
libavcodec/avpacket.c
libavcodec/utils.c
libavdevice/v4l2.c
libavformat/avidec.c
libavformat/flacdec.c
libavformat/id3v2.c
libavformat/matroskaenc.c
libavformat/mux.c
libavformat/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 7383cdeb9d..9b44166255 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -555,16 +555,20 @@ static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer, AVPacket *pkt, return &pktl->pkt; } -void avformat_queue_attached_pictures(AVFormatContext *s) +int avformat_queue_attached_pictures(AVFormatContext *s) { int i; for (i = 0; i < s->nb_streams; i++) if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC && s->streams[i]->discard < AVDISCARD_ALL) { AVPacket copy = s->streams[i]->attached_pic; - copy.destruct = NULL; + copy.buf = av_buffer_ref(copy.buf); + if (!copy.buf) + return AVERROR(ENOMEM); + add_to_pktbuf(&s->raw_packet_buffer, ©, &s->raw_packet_buffer_end); } + return 0; } int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options) @@ -635,7 +639,8 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma } ff_id3v2_free_extra_meta(&id3v2_extra_meta); - avformat_queue_attached_pictures(s); + if ((ret = avformat_queue_attached_pictures(s)) < 0) + goto fail; if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->data_offset) s->data_offset = avio_tell(s->pb); @@ -1333,8 +1338,12 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) compute_pkt_fields(s, st, st->parser, &out_pkt); if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) { + out_pkt.buf = pkt->buf; + pkt->buf = NULL; +#if FF_API_DESTRUCT_PACKET out_pkt.destruct = pkt->destruct; pkt->destruct = NULL; +#endif } if ((ret = av_dup_packet(&out_pkt)) < 0) goto fail; @@ -2085,7 +2094,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f int ret = seek_frame_internal(s, stream_index, timestamp, flags); if (ret >= 0) - avformat_queue_attached_pictures(s); + ret = avformat_queue_attached_pictures(s); return ret; } @@ -2116,7 +2125,7 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int ret = s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags); if (ret >= 0) - avformat_queue_attached_pictures(s); + ret = avformat_queue_attached_pictures(s); return ret; } |