diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-03-21 00:15:18 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-03-21 01:33:53 +0100 |
commit | 0ebd83617fe008b7e9766f659cc3d9618b2d80d2 (patch) | |
tree | 23bc388bf6b66cf58d7a90c0d2529e53ed984561 /libavformat/utils.c | |
parent | 745a33a44318ad6d6f74835a417397cdd9dda9a9 (diff) | |
parent | c9594fe0fb6dd123fa25cb27fe5bc976ff3a9051 (diff) | |
download | ffmpeg-0ebd83617fe008b7e9766f659cc3d9618b2d80d2.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (27 commits)
avconv: free packet in write_frame() when discarding due to frame number limit
FATE: use +/- flag option syntax for vp8 emu-edge tests
lavf: make av_interleave_packet_per_dts() private.
lavf: deprecate av_read_packet().
oggdec: output correct timestamps for Vorbis
avconv: pass input stream timestamps to audio encoders
lavc: shrink encoded audio packet size after encoding.
xa: set correct bit rate
xa: do not set bit_rate, block_align, or bits_per_coded_sample
xa: fix end-of-file handling
xa: fix timestamp calculation
bink: fix typo in FFALIGN() argument
bink: align plane width to 8 when calculating bundle sizes
doc: pass -Idoc texi2html and texi2pod
doc: texi2pod: add -I flag
movenc: Add a min_frag_duration option
rtsp: Set the default delay to 0.1 s for the RTSP/SDP/RTP demuxers
libavformat: Set the default for the max_delay option to -1
Generate manpages for AV{Format,Codec}Context AVOptions.
doc/avconv: remove entries for AVOptions.
...
Conflicts:
doc/Makefile
doc/ffmpeg.texi
doc/muxers.texi
ffmpeg.c
libavcodec/Makefile
libavcodec/options.c
libavcodec/vp8.c
libavformat/options.c
tests/fate/demux.mak
tests/ref/fate/truemotion1-15
tests/ref/fate/truemotion1-24
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 72 |
1 files changed, 56 insertions, 16 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index fd973a8330..2921e85c8f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -568,10 +568,22 @@ static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer, AVPacket *pkt, return &pktl->pkt; } +static void 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; + add_to_pktbuf(&s->raw_packet_buffer, ©, &s->raw_packet_buffer_end); + } +} + int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options) { AVFormatContext *s = *ps; - int i, ret = 0; + int ret = 0; AVDictionary *tmp = NULL; ID3v2ExtraMeta *id3v2_extra_meta = NULL; @@ -627,13 +639,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma goto fail; ff_id3v2_free_extra_meta(&id3v2_extra_meta); - /* queue attached pictures */ - for (i = 0; i < s->nb_streams; i++) - if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC) { - AVPacket copy = s->streams[i]->attached_pic; - copy.destruct = NULL; - add_to_pktbuf(&s->raw_packet_buffer, ©, &s->raw_packet_buffer_end); - } + queue_attached_pictures(s); if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->data_offset) s->data_offset = avio_tell(s->pb); @@ -659,7 +665,7 @@ fail: /*******************************************************/ -int av_read_packet(AVFormatContext *s, AVPacket *pkt) +int ff_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, i; AVStream *st; @@ -756,6 +762,14 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) } } +#if FF_API_READ_PACKET +int av_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + return ff_read_packet(s, pkt); +} +#endif + + /**********************************************************/ static int determinable_frame_size(AVCodecContext *avctx) @@ -1228,7 +1242,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) AVPacket cur_pkt; /* read next packet */ - ret = av_read_packet(s, &cur_pkt); + ret = ff_read_packet(s, &cur_pkt); if (ret < 0) { if (ret == AVERROR(EAGAIN)) return ret; @@ -1255,7 +1269,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) cur_pkt.size); } if (s->debug & FF_FDEBUG_TS) - av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", + av_log(s, AV_LOG_DEBUG, "ff_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", cur_pkt.stream_index, cur_pkt.pts, cur_pkt.dts, @@ -1827,7 +1841,8 @@ static int seek_frame_generic(AVFormatContext *s, return 0; } -int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) +static int seek_frame_internal(AVFormatContext *s, int stream_index, + int64_t timestamp, int flags) { int ret; AVStream *st; @@ -1872,14 +1887,29 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f return -1; } +int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) +{ + int ret = seek_frame_internal(s, stream_index, timestamp, flags); + + if (ret >= 0) + queue_attached_pictures(s); + + return ret; +} + int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags) { if(min_ts > ts || max_ts < ts) return -1; if (s->iformat->read_seek2) { + int ret; ff_read_frame_flush(s); - return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags); + ret = s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags); + + if (ret >= 0) + queue_attached_pictures(s); + return ret; } if(s->iformat->read_timestamp){ @@ -2071,7 +2101,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) break; do { - ret = av_read_packet(ic, pkt); + ret = ff_read_packet(ic, pkt); } while(ret == AVERROR(EAGAIN)); if (ret != 0) break; @@ -3354,7 +3384,9 @@ static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacke return comp > 0; } -int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){ +int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, + AVPacket *pkt, int flush) +{ AVPacketList *pktl; int stream_count=0, noninterleaved_count=0; int64_t delta_dts_max = 0; @@ -3413,6 +3445,14 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk } } +#if FF_API_INTERLEAVE_PACKET +int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, + AVPacket *pkt, int flush) +{ + return ff_interleave_packet_per_dts(s, out, pkt, flush); +} +#endif + /** * Interleave an AVPacket correctly so it can be muxed. * @param out the interleaved packet will be output here @@ -3429,7 +3469,7 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in av_free_packet(in); return ret; } else - return av_interleave_packet_per_dts(s, out, in, flush); + return ff_interleave_packet_per_dts(s, out, in, flush); } int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ |