Commit Graph

10233 Commits

Author SHA1 Message Date
Martin Storsjö
9f810a9b37 libavformat: Check for malloc failures in avformat_new_stream
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-04 20:04:36 +02:00
Martin Storsjö
c4aa0f865f libavformat: Remove a misleading/incorrect comment
This comment can be traced back to the initial commit from 2001,
and it seemed to be misleading/incorect already back then. (It
was used for normal, non-raw file formats already then.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-04 20:04:33 +02:00
Martin Storsjö
f2ad1495f2 avisynth: Use RTLD_LOCAL instead of RTLD_GLOBAL
There shouldn't be any need to add the loaded libraries to the global
symbol namespace.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 02:30:03 +02:00
Martin Storsjö
7a1a63e34f dashenc: Use pts for MPD timeline timestamps
This should be more correct. This also should give more sensible
switching between video streams with different amount of b-frame
delay.

The current dash.js release (1.2.0) fails to start playback of
such files from the start (if the start pts is > 0), but this has
been fixed in the current git version of dash.js.

Also enable the use of edit lists, so that streams in many cases
start at pts=0.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 01:22:09 +02:00
Martin Storsjö
c5e7ea13d2 dashenc: Use delay_moov
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 01:20:55 +02:00
Martin Storsjö
b3b0b35db2 movenc: Get rid of a hack for updating the dvc1 atom
Use the more generic approach with the delay_moov flag, instead of
having a update mechanism specific to this one single atom.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 01:20:40 +02:00
Martin Storsjö
847bf5988f movenc: Add an option for delaying writing the moov with empty_moov
This delays writing the moov until the first fragment is written,
or can be flushed by the caller explicitly when wanted. If the first
sample in all streams is available at this point, we can write
a proper editlist at this point, allowing streams to start at
something else than dts=0. For AC3 and DNXHD, a packet is
needed in order to write the moov header properly.

This isn't added to the normal behaviour for empty_moov, since
the behaviour that ftyp+moov is written during avformat_write_header
would be changed. Callers that split the output stream into header+segments
(either by flushing manually, with the custom_frag flag set, or by
just differentiating between data written during avformat_write_header
and the rest) will need to be adjusted to take this option into use.

For handling streams that start at something else than dts=0, an
alternative would be to use different kinds of heuristics for
guessing the start dts (using AVCodecContext delay or has_b_frames
together with the frame rate), but this is not reliable and doesn't
necessarily work well with stream copy, and wouldn't work for getting
the right initialization data for AC3 or DNXHD either.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 01:19:27 +02:00
Martin Storsjö
c725faebda movenc: Use start_dts/cts instead of cluster[0] for writing edit lists
This allows writing edit lists even when track->entry == 0, if
the start times have been set.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 01:18:52 +02:00
Martin Storsjö
724cbea719 movenc: Remove an unnecessary condition when flushing fragments
If fragments == 0 it means we haven't written any moov atom yet.
If the empty_moov flag is set, we already have written an empty moov
atom at startup. Thus, the check for empty_moov is redundant.

This is in preparation for allowing writing the moov atom later,
even when using the empty moov flag.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 01:18:38 +02:00
Martin Storsjö
355d01a1bf movenc: Factorize writing ftyp and other identification tags to a separate function
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-03 01:18:28 +02:00
Martin Storsjö
8d54bacb78 dashenc: Remove some stray double spaces
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-29 23:26:43 +02:00
Martin Storsjö
b91a5757fc dashenc: Fix writing of timelines that don't start at t=0
When writing an explicit time, reset the cur_time variable to this
value as well. This avoids writing excessive time attributes for each
segment in the timeline, as long as the segments are continuous.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-29 23:26:25 +02:00
Kieran Kunhya
9cfa68c560 mpegts: add support for Opus
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-12-20 11:29:19 +01:00
Martin Storsjö
8ebf02f8f5 libavformat: Only use MoveFileExA when targeting the desktop API subset
The MoveFileExA is available in the headers regardless which API
subset is targeted, but it is missing in the Windows Phone link
libraries. When targeting Windows Store apps, the function is
available both in the headers and in the link libraries, and thus
there is no indication for the build system that this function
should be avoided - such an indication is only given by the
Windows App Certification Kit, which forbids using the MoveFileExA
function.

Therefore check the WINAPI_FAMILY defines instead, to figure out
which API subset is targeted.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-19 23:24:47 +02:00
Martin Storsjö
fc308b30bb rtpenc_mpegts: Call write_trailer for the mpegts muxer even if no output buffer exists
Since the mpegts muxer now can handle being called with a NULL
AVIOContext, we don't need to try to allocate one before calling
write_trailer.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-19 23:14:45 +02:00
Martin Storsjö
e2ce163922 mpegts: Support running the write_trailer function without an AVIOContext
If opening and closing dynamic buffers as AVIOContext, we may
not have any AVIOContext available when wanting to close and
deallocate the muxer. Allow calling write_trailer despite this.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-19 23:13:04 +02:00
Martin Storsjö
4895aa65c6 libavformat: Allow calling av_write_trailer with a NULL AVIOContext
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-19 23:12:58 +02:00
Anton Khirnov
64f7575fbd mov: avoid a memleak when multiple stss boxes are present
CC: libav-stable@libav.org
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
2014-12-19 08:01:46 +01:00
Vittorio Giovara
76ccf114a6 rtsp: check ffurl_get_file_handle() return value
CC: libav-stable@libav.org
Bug-Id: CID 717844
2014-12-18 23:27:14 +01:00
Vittorio Giovara
b1306823d0 check memory errors from av_strdup() 2014-12-18 23:27:14 +01:00
Vittorio Giovara
8b263331c5 mpegts: check get16() return value
And break flow of execution rather than exiting the function.

CC: libav-stable@libav.org
Bug-Id: CID 732186
2014-12-18 23:27:13 +01:00
James Almer
430a816859 oggdec: add support for VP8 demuxing
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2014-12-18 23:27:07 +01:00
Martin Storsjö
59f0275dd0 movenc: Adjust the pts of new fragments similarly to what is done for dts
The pts and the corresponding duration is written in sidx
atoms, thus make sure these match up correctly.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 23:14:27 +02:00
Martin Storsjö
8a70ef94b9 libavformat: Add a muxer wrapping mpegts encoding into RTP
Since this structurally is quite different from normal RTP
(multiple streams are muxed into one single mpegts stream,
which is packetized into one single RTP session), it is kept
as a separate muxer.

Since this structurally also behaves differently than normal
RTP, all of the other muxers that do chained RTP muxing
(rtsp, sap, mp4) would need to be updated similarly to handle
this - in particular, creating one single rtp_mpegts muxer
for the whole presentation instead of one rtp muxer per stream.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 23:12:33 +02:00
Thomas Volkert
a505c0d737 rtp: Initial H.261 support
The packetizer only supports splitting at GOB headers - if
such aren't available frequently enough, it splits at any
random byte offset (not at a macroblock boundary either, which
would be allowed by the spec) and sends a payload header pretend
that it starts with a GOB header.

As long as a receiver doesn't try to handle such cases cleverly
but just drops broken frames, this shouldn't matter too much
in practice.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 23:11:37 +02:00
Martin Storsjö
adc214e679 rtpenc: Avoid brittle switch fallthroughs
Instead explicitly jump to the default case in the cases where
it is wanted, and avoid fallthrough between different codecs,
which could easily introduce bugs if people editing the code
aren't careful.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 23:11:37 +02:00
Martin Storsjö
df07c07b3d rtpdec_h263_rfc2190: Clear the stored bits if discarding buffered data
If we throw away the buffered incomplete frame, make sure to also
throw away the buffered bits of an incomplete byte at the same
time.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 11:59:54 +02:00
Martin Storsjö
42181740a3 rtpenc: Set the AVFMT_TS_NONSTRICT flag
In particular, when packetizing mpegts into rtp, the input packet
timestamp may come from more than one stream, which could cause
multiple packets be written with the same timestamp.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 11:59:19 +02:00
Martin Storsjö
01f251c44d rtpenc: Set the timestamp properly when sending mpegts data, too
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 11:59:12 +02:00
Tristan Matthews
f2c614e8c4 srtpproto: fix option flag type
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-18 11:58:23 +02:00
Martin Storsjö
456e93bfdd dashenc: Adjust the start time of a segment to the end of the previous segment
This is the same adjustment that the mp4 muxer does to the start
timestamp of fragments, since the timestamp of a sample in an mp4
file is implicit from the sum of earlier sample durations.

This avoids gaps in the timeline (which can stop dash.js from
playing it back), and makes sure the timestamp on the segmenter
level matches what the mp4 muxer actually writes into the segments.

This is only an issue if the AVPacket duration of the last
packet of a segment doesn't point to the actual start timestamp
of the next packet (the first in the next segment).

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-17 09:43:08 +02:00
Martin Storsjö
2f628d5943 dashenc: Write segment timelines properly if the timeline has gaps
Write a new start time if the duration of the previous segment
didn't match the start of the next one. Check that segments
actually are continuous before writing a repeat count.

This makes sure timestamps deduced from the timeline actually
match the real start timestamp as written in filenames (if
using a template containing $Time$).

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-17 09:42:30 +02:00
Martin Storsjö
6f4364aba9 mov: Fix handling of zero-length metadata values
Since 3cec81f4d4, a zero-length metadata value would try to
allocate 2*0 bytes, where av_malloc() returns NULL.

Always add one to the allocated length, to allow space for
a null terminator in the zero-length case.

Incidentally, this fixes fate-alac on RVCT 4.0, where a compiler
bug seems to mess up the mov muxer to the point that it writes
the wrong sort of metadata. Previously this bug was undetected,
but since 3cec81f4d4 such mov files started returning
AVERROR(ENOMEM) in the mov demuxer.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-15 23:42:10 +02:00
Xiaohan Wang
490a3ebf36 matroskadec: Fix read-after-free in matroska_read_seek()
In matroska_read_seek(), |tracks| is assigned at the begining of the
function. However, functions like matroska_parse_cues() could reallocate
the tracks and invalidate |tracks|.

This assigns |tracks| only before using it, so that it will not get
invalidated elsewhere.

Bug-Id: chromium/427266
2014-12-15 15:46:34 +01:00
Martin Storsjö
e737a4aaaf dashenc: Change the duration fields to 64 bit
For the last_duration field, it's mostly theoretical, but the
total_duration field more probably may need to actually be 64 bit.

Bug-Id: CID 1254944
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-10 22:51:51 +02:00
Bryan Huh
fa8934d6d6 dashenc: log file output progress in verbose mode
As the manifest/segments are flushed to disk, log to stderr the
progress, when in verbose logging mode

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-10 00:03:16 +02:00
Martin Storsjö
95d880fa64 rtpproto: Fix the input RTP data format check
Only the upper 2 bits of the first byte are known to be
a fixed value.

The lower bits in the first byte of a RTP packet could be set
if the input is from another RTP packetizers than libavformat's,
but for RTCP packets, they would also be set when sending RTCP RR
packets, triggering false warnings about incorrect input format
to the protocol.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-09 23:59:14 +02:00
Martin Storsjö
fccfc22d1f libavformat: Build hevc.o when building the RTP muxer
The RTP muxer enables the actual codepaths within sdp.c,
which depend on hevc.o since e5cfc8fd.

This fixes builds with --disable-everything --enable-muxer=rtp.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-09 16:09:37 +02:00
Dave Rice
3c01039e0b mov: further expand the list of parsed metadata tags
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2014-12-08 14:28:16 +00:00
Vittorio Giovara
e2e07dbaab mov: expand the list of parsed metadata tags
Based on L-Smash code by Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2014-12-08 14:28:09 +00:00
Vittorio Giovara
b704b648f9 mov: parse XMP metadata on demand
The Extensible Metadata Platform tag can contain various kind of data
which are not strictly related to the video file, such as history of edits
and saves from the project file. So display XMP metadata only when the
user explicitly requires it.

Based on a patch by Marek Fort <marek.fort@chyronhego.com>.
2014-12-08 13:53:30 +00:00
Vittorio Giovara
174c5fde90 mov: parse @PRM and @PRQ metadata tags
These tags describe the product and quicktime library version respectively.
They originate from Adobe Premiere, but also some other programs use them.
Contrary to other tags, they contain 'raw' data which is not to be
interpreted as iso639 or mac strings.

Based on a patch by Peter Ross <pross@xvid.org>.
2014-12-08 13:53:20 +00:00
Vittorio Giovara
35384934d6 mov: cosmetics: reorder the list of tags
Alphabetically order the list by the tag to facilitate the insertion of
new ones.
2014-12-08 13:53:10 +00:00
Joakim Plate
90411b333d Allow reading of growing avi files (currently being written)
This uses the RIFF header stored size to figure out the expected AVI
file size, instead of the actual file. To work fully it requires handling
failed avio_seek() instead of assuming they always succeed.

Some fate file has been cut off and contains half a frame at the end which
previously was not output during demuxing. This frame is now output to
encoder, thus the fate diff update.

Bug-Id: 261
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2014-12-08 13:29:33 +00:00
Carl Eugen Hoyos
250e077ee9 riff: Support decoding png in avi (ImageJ) 2014-12-08 13:29:18 +00:00
Martin Storsjö
29bc7bfba2 rtpproto: Write a warning if the input data written isn't RTP packetized
Tell the user that the RTP muxer needs to be used to packetize
the data - using the RTP protocol on its own isn't enough.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-08 11:59:12 +02:00
Luca Barbato
4fd7e63c87 mp3: Tweak the probe scores
Having more than 10 consecutive frames decoded as mp3 should be
considered a clear signal that the sample is mp3 and not mpegps.

Reported-By: Florian Iragne <florian@iragne.fr>
CC: libav-stable@libav.org
2014-12-07 21:50:47 +01:00
Luca Barbato
4f5906a1d7 latm: Do not give a score for a single instance
Bug-Id: 773
CC: libav-stable@libav.org
2014-12-07 13:15:03 +01:00
Matthieu Bouron
8c0a865ad9 mov: skip version and flags attributes in mov_read_chan()
Fixes decting channel layout for files with uncommon audio, such as
FL and FR in two separate streams. Introduced in 3bab7cd.

CC: libav-devel@libav.org
Sample-Id: ticket1474.mov
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2014-12-05 13:03:49 +00:00
Luca Barbato
1c77ead1fb rm: Use the correct codec_data_size signedness
The function takes a size and not an offset.

CC: libav-stable@libav.org
Sample-Id: rm_deadlock.rm

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-12-04 13:14:28 +00:00