Commit Graph

878 Commits

Author SHA1 Message Date
Mans Rullgard
edb5238ccb libavformat: add const to AVCodec pointers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-08-18 14:20:57 +01:00
Martin Storsjö
bdefe22b8e lavf: Detect discontinuities in timestamps for framerate/analyzeduration calculation
If the dts difference is more than 1000 times the average dts
difference, restart the analysis.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-08-12 12:39:49 +03:00
Martin Storsjö
30c26c2442 lavf: Initialize the stream info timestamps in avformat_new_stream
These are normally initialized to AV_NOPTS_VALUE at the start
of avformat_find_stream_info, but if a new stream is found while
this function is running (e.g. like in mpegts), the newly added
AVStreams didn't have these values properly initalized, leading
to avformat_find_stream_info terminating too soon (when the
first timestamps are far from 0).

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-08-12 12:39:47 +03:00
Anton Khirnov
885da7b082 lavf: simplify is_intra_only() by using codec descriptors. 2012-08-11 11:34:24 +02:00
Mans Rullgard
987170cb9d dict: add av_dict_count()
This adds a function to retrieve the number of entries in a
dictionary and updates the places directly accessing what should
be an opaque struct to use this new function instead.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-08-10 15:15:00 +01:00
Anton Khirnov
36ef5369ee Replace all CODEC_ID_* with AV_CODEC_ID_* 2012-08-07 16:00:24 +02:00
Martin Storsjö
6c071a2b38 lavf: Declare an AVRational struct without a struct literal
At this place, the normal way of initializing a struct works
fine, there's no need for a struct literal.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-08-06 00:48:58 +03:00
Anton Khirnov
aba232cfa9 lavf: deprecate r_frame_rate.
According to its description, it is supposed to be the LCM of all the
frame durations. The usability of such a thing is vanishingly small,
especially since we cannot determine it with any amount of reliability.
Therefore get rid of it after the next bump.

Replace it with the average framerate where it makes sense.

FATE results for the wtv and xmv demux tests change. In the wtv case
this is caused by the file being corrupted (or possibly badly cut) and
containing invalid timestamps. This results in lavf estimating the
framerate wrong and making up wrong frame durations.
In the xmv case the file contains pts jumps, so again the estimated
framerate is far from anything sane and lavf again makes up different
frame durations.

In some other tests lavf starts making up frame durations from different
frame.
2012-07-29 08:06:30 +02:00
Anton Khirnov
f66eeff1c8 lavf: round estimated average fps to a "standard" fps. 2012-07-29 08:05:46 +02:00
Anton Khirnov
fe1c1198e6 lavf: use dts difference instead of AVPacket.duration in find_stream_info()
AVPacket.duration is mostly made up and thus completely useless, this is
especially true for video streams.
Therefore use dts difference for framerate estimation and
the max_analyze_duration check.

The asyncts test now needs -analyzeduration, because the default is 5
seconds and the audio stream in the sample appears at ~10 seconds.
2012-07-29 08:04:42 +02:00
Luca Barbato
681ed00099 avf: introduce nobuffer option
Useful in cases where a significant analyzeduration is
still needed, while minimizing buffering before output.

An example is processing low-latency streams where all
media types won't necessarily come in if the
analyzeduration is small.

Additional changes by Josh Allmann <joshua.allmann@gmail.com>

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2012-07-29 07:58:00 +02:00
Anton Khirnov
efd34918ba lavf: remove commented out cruft in avformat_find_stream_info() 2012-07-28 10:00:38 +02:00
Anton Khirnov
c4ef6a3e4b Add missing libavutil/time.h includes. 2012-07-28 09:02:07 +02:00
Mans Rullgard
ae0a301668 Move av_gettime() to libavutil
Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-06-20 17:09:03 +01:00
Anton Khirnov
a5db8e4a1a lavf: don't segfault when a NULL filename is passed to avformat_open_input()
This can easily happen when the caller is using a custom AVIOContext.

Behave as if the filename was an empty string in this case.

CC: libav-stable@libav.org
2012-06-16 17:09:33 +02:00
Alex Converse
f0ff9eb493 avformat: Probe codecs at score 0 on buffer exhaustion conditions. 2012-06-05 09:51:51 -07:00
Alex Converse
62bebf6edb avformat: Factorize codec probing. 2012-06-05 09:51:51 -07:00
James Zern
e9cef89702 avformat: Add a flag to mark muxers that allow (non strict) monotone timestamps.
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
2012-05-20 19:50:32 -04:00
Mans Rullgard
81ad97eeda lavf: make output format matching case insensitive
This is consistent with how input formats are matched.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-05-19 19:44:15 +01:00
Mans Rullgard
db465be45d lavf: add mdec to is_intra_only() list
Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-05-15 15:49:56 +01:00
Justin Ruggles
e5356ebf22 cosmetics: indentation 2012-05-03 16:28:08 -04:00
Justin Ruggles
8916f1fbcb avformat: only fill-in interpolated timestamps if duration is non-zero
This avoids returning duplicate timestamps for multiple packets when the
demuxer does not provide all timestamps and packet duration is not known.
2012-05-03 16:28:08 -04:00
Justin Ruggles
ff499157a1 avformat: remove a workaround for broken timestamps
This modifies pts in situations other than what was intended, leading to
invalid timestamps.

Reverts commit 90bb394dcc
2012-05-03 16:28:08 -04:00
Luca Barbato
8b97ae6484 avf: fix faulty check in has_duration
An invalid duration is AV_NOPTS_VALUE not 0.
2012-04-25 11:40:22 -07:00
Luca Barbato
cbf767a87c avf: has_duration does not check the global one
Some container formats report a global duration, but not a per stream
one.
2012-04-13 12:03:16 -07:00
Joakim Plate
ba24f12982 libavformat: Only require first packet to be known for audio/video streams
It can take a long time before subtitles or data streams show up,
so we shouldn't wait for those before assuming we have all info
for streams.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-04-06 20:51:18 +03:00
Diego Biurrun
a92be9b856 Replace memset(0) by zero initializations.
Also remove one pointless zero initialization in rangecoder.c.
2012-03-28 09:38:33 +02:00
Jindrich Makovicka
904100e5fc make av_interleaved_write_frame() flush packets when pkt is NULL
This patch allows the user to force flushing of all queued packets
by calling av_interleaved_write_frame() with pkt set to NULL.

Signed-off-by: Jindrich Makovicka <jindrich.makovicka@nangu.tv>
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-03-27 11:12:55 +03:00
Anton Khirnov
a6733202cc lavf: make av_interleave_packet_per_dts() private.
There is no reason for it to be public, it's only meant to be used
internally.
2012-03-20 20:12:16 +01:00
Anton Khirnov
3c90cc2ef2 lavf: deprecate av_read_packet().
The caller can achieve the same effect (i.e. getting raw unparsed/mangled
packets) with av_read_frame() and AVFMT_FLAG_NOPARSE |
AVFMT_FLAG_NOFILLIN
2012-03-20 20:12:16 +01:00
Anton Khirnov
40b41be3fa lavf: use AVStream.discard to disable queueing attached pictures. 2012-03-20 06:53:44 +01:00
Anton Khirnov
01fcc42b90 lavf: requeue attached pictures after seeking.
This allows the caller to get them without special code even after
seeking before receiving any data.
2012-03-20 06:52:33 +01:00
Martin Storsjö
57151f8674 libavformat: Use AVFormatContext.probesize in init_input
This was forgotten in the transition from av_open_input_file to
avformat_open_input, see 603b8bc2a1.

This doesn't change anything for the default case where the
option isn't set, since PROBE_BUF_MAX is 1048576 (which was
used as max probe size earlier) while the default value for
the probesize option is 5000000, which for the probe function
is clipped to PROBE_BUF_MAX anyway.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-03-19 16:08:08 +02:00
Anton Khirnov
8bc5d90a7e lavf: remove some disabled code. 2012-03-17 22:37:55 +01:00
Anton Khirnov
f35f8eeb0d lavf: only set average frame rate for video. 2012-03-17 22:36:56 +01:00
Anton Khirnov
9ade26ee91 lavf: remove a pointless check.
Timebase is already checked in avpriv_set_pts_info().
2012-03-17 22:36:48 +01:00
Anton Khirnov
cd9a3c3512 lavf: don't select an attached picture as default stream for seeking. 2012-03-15 14:01:05 +01:00
Justin Ruggles
94cf64b81f cosmetics: reindent 2012-03-05 13:08:19 -05:00
Justin Ruggles
8c1d6ac66a avformat: do not require a pixel/sample format if there is no decoder
Also, do not keep trying to find and open a decoder in try_decode_frame() if
we already tried and failed once.

Fixes always searching until max_analyze_duration in
avformat_find_stream_info() when demuxing codecs without a decoder.
2012-03-05 13:08:18 -05:00
Justin Ruggles
a7fa75684d avformat: do not fill-in audio packet duration in compute_pkt_fields()
Use the estimated duration only to calculate missing timestamps if needed.
2012-03-05 13:08:18 -05:00
Justin Ruggles
6c65cf58fd lavf: Use av_get_audio_frame_duration() in get_audio_frame_size()
Also, do not give AVCodecContext.frame_size priority for muxing.

Updated 2 FATE references:
dxa-feeble - adds 1 audio frame that is still within 2 seconds as specified
             by -t 2 in the FATE test
wmv8-drm-nodec - durations are not needed. previously they were estimated
                 using the packet size and average bit rate.
2012-03-05 13:08:18 -05:00
Justin Ruggles
9c365fe8ae avformat: do not require frame_size in avformat_find_stream_info() for CELT
In Ogg/CELT, frame_size is found in the same place as the sample_rate and
channels, so we do not need to force the frame_size to be parsed.
2012-03-05 13:08:16 -05:00
Justin Ruggles
fbc8c59679 avformat: do not require frame_size in avformat_find_stream_info() for MP1/2/3
It was only needed to avoid a bad time base (and thus non-monotone timestamps)
for stream copy to avi.
2012-03-05 13:08:16 -05:00
Justin Ruggles
84b6ae0808 avformat: do not require frame_size in avformat_find_stream_info() for AAC
We already will get the needed info because of CODEC_CAP_CHANNEL_CONF
2012-03-05 13:08:16 -05:00
Anton Khirnov
27c7ca9c12 lavf: deobfuscate read_frame_internal().
Split off packet parsing into a separate function. Parse full packets at
once and store them in a queue, eliminating the need for tracking
parsing state in AVStream.

The horrible unreadable loop in read_frame_internal() now isn't weirdly
ordered and doesn't contain evil gotos, so it should be much easier to
understand.

compute_pkt_fields() now invents slightly different timestamps for two
raw vc1 tests, due to has_b_frames being set a bit later. They shouldn't
be more wrong (or right) than previous ones.
2012-03-05 18:47:05 +01:00
Anton Khirnov
dcee811505 lavf: make read_from_packet_buffer() more flexible.
Make packet buffer a parameter, don't hardcode it to be
AVFormatContext.packet_buffer.

Also move the function higher in the file, since it will be called from
read_frame_internal().
2012-03-05 18:44:45 +01:00
Anton Khirnov
52b0943f10 lavf: factorize freeing a packet buffer. 2012-03-05 18:44:30 +01:00
Justin Ruggles
5602a464c9 avcodec: add a Vorbis parser to get packet duration
This also allows for removing some of the Vorbis-related hacks.
2012-03-03 16:43:11 -05:00
Anton Khirnov
393fd0d89e id3v2: remove unused ff_id3v2_read().
Rename ff_id3v2_read_all to ff_id3v2_read().
2012-02-29 14:19:42 +01:00
Anton Khirnov
079ea6ca5f lavf: export id3v2 attached pictures as streams. 2012-02-29 14:16:32 +01:00