Commit Graph

779 Commits

Author SHA1 Message Date
Vittorio Giovara d5d62ce6d6 mov: Fix identity matrix boolean logic
This prevented the code from correctly exporting the rotation matrix
which caused a few samples to be displayed wrong.
Introduced in ecd2ec69ce.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-11-16 11:17:06 -05:00
Vittorio Giovara de6e2ff3dd mov: Read multiple stsd from DV
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-11-08 11:22:29 -05:00
Vittorio Giovara 47a795727f hevc: Support extradata changes from multiple stsd
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-11-08 11:22:29 -05:00
Vittorio Giovara ecd2ec69ce mov: Evaluate the movie display matrix
This matrix needs to be applied after all others have (currently only
display matrix from trak), but cannot be handled in movie box, since
streams are not allocated yet. So store it in main context, and apply
it when appropriate, that is after parsing the tkhd one.

Fate tests are updated accordingly.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-11-01 12:19:00 -04:00
Diego Biurrun c454dfcff9 Use ISO C printf conversion specifiers where appropriate 2016-10-28 13:24:44 +02:00
Diego Biurrun 1263b2039e Adjust printf conversion specifiers to match variable signedness 2016-10-28 11:22:21 +02:00
Diego Biurrun ca1e5eea0c Remove some pointless TRACE level debug code
This also kills some warnings with certain compiler options.
2016-10-27 12:54:14 +02:00
Vittorio Giovara 4b07ebf1eb mov: Update colr values
For 'nclx', the latest edition of the standard switched from JPEG XR
to 23001-8, which matches the current order of our entries. Bounds
are preserved as a sanity check.

For 'nclc', qtff edition 2016-09-13 introduced a few new entries.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-10-21 17:15:04 -04:00
Anton Khirnov 83548fe894 lavf: fix usage of AVIOContext.seekable
It is supposed to be a flag. The only currently defined value is
AVIO_SEEKABLE_NORMAL, but other ones may be added in the future.
However all the current lavf code treats this field as a bool (mainly
for historical reasons).
Change all those cases to properly check for AVIO_SEEKABLE_NORMAL.
2016-09-30 16:54:33 +02:00
Derek Buitenhuis 8db804e8f5 mov: Remove old b-frame/video delay heuristic
This was added before edts support existed, and is no longer
valid.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-08-29 15:31:03 +02:00
Derek Buitenhuis eb96505b76 mov: Remove ancient heuristic hack
This breaks files with legitimate single-entry edit lists,
and the hack, introduced in f03a081df0,
has no link to any known sample in its commit message.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-08-29 15:31:03 +02:00
Luca Barbato 2ac00d2d1d mov: Validate the ID number
IDs in MOV start from 1.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-07-29 18:46:48 +02:00
Vittorio Giovara ed9b2a5178 mov: Rework the check for invalid indexes in stsc
There are samples with invalid stsc that may work fine as is and
do not need extradata change. So ignore any out of range index, and
error out only when explode is set.

Found-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-07-20 19:30:22 +02:00
Vittorio Giovara 90bc423212 mov: Wrap stsc index and count compare in a separate function 2016-07-20 19:30:21 +02:00
Matthieu Bouron 209ee680ce mov: Fix stsc_count comparison
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-07-20 19:28:35 +02:00
Matthieu Bouron 61cb9fac47 mov: fix stream extradata_size allocation
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-07-15 13:27:43 +03:00
Vittorio Giovara 029cf99c51 mov: Save number of stsd elements after stream extradata allocation
Avoid freeing an unallocated array in mov_read_close() in case
of a malloc failure.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-06-29 15:25:42 -04:00
Vittorio Giovara 846a3e78a5 mov: Support prores with multiple stsd
This function needs to return false, or data in the additional tables
will be skipped, and the decoder will not be able to decode frames
associated with them.
2016-06-17 11:38:33 -04:00
Vittorio Giovara 7672997004 mov: Implement support for multiple sample description tables
Store data from each stsd in a separate extradata buffer, keep track of
the stsc index for read and seek operations, switch buffers when the
index differs. Decoder is notified with an AV_PKT_DATA_NEW_EXTRADATA
packet side data.

Since H264 supports this notification, and can be reset midstream, enable
this feature only for multiple avcC's. All other stsd types (such as
hvc1 and hev1) need decoder-side changes, so they are left disabled for
now.

This is implemented only in non-fragmented MOVs.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-06-17 11:38:33 -04:00
Michael Niedermayer bc43131997 mov: Also export loci altitude
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-19 10:46:53 +03:00
Michael Niedermayer 94d8141c8c mov: Append place name instead of overwriting for loci
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-19 10:46:52 +03:00
Michael Niedermayer f126365cda mov: Fix parsing short loci
Previously, we required the minimum number of bytes required for
the full box. Don't strictly require the astronomical body and additional
notes fields, but do require an altitude field (which currently isn't
parsed). This matches the initial length check at the start of the function
(which doesn't know about the variable length place field).

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-19 10:46:51 +03:00
Michael Niedermayer 704d2bd18b mov: Print reason of loci parsing failure
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-19 10:46:45 +03:00
Martin Storsjö d34826c33d mov: Add a comment referring to the standard that defines the loci box
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-19 10:46:39 +03:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Diego Biurrun 0f40c90984 Drop pointless assert.h #includes 2016-05-03 15:45:10 +02:00
Luca Barbato 7e01d48cfd mov: Check the entries value when parsing dref boxes
And properly reset the entries count when resetting the entries.

CC: libav-stable@libav.org

Bug-Id: 929
Bug-Id: CVE-2016-3062
2016-03-11 14:29:13 +01:00
Vittorio Giovara d40cb726d2 mov: Trim dref absolute path
Samples produced by Omneon (Harmonic) store external references with
paths ending with 0s. Such movs cannot be loaded properly since every
0 is converted to '/', to keep the same parsing code for dref type 2
and type 18: this makes the external reference point to a non-existing
direactory, rather than to the actual referenced file.

Add a brief trimming loop that drops all ending 0s before trying to
parse the external reference path.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-03-05 08:23:18 -05:00
Anton Khirnov 9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Luca Barbato 3ef98937f5 mov: Force the full parsing of mp3
Some muxer might or might not fit incomplete mp3 frames in
their packets.

Bug-Id: 899

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-02-19 17:35:26 +01:00
Vittorio Giovara b92962436b mov: Fix the format specifier type for size
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-02-16 18:25:47 +01:00
Luca Barbato 5eb562831b mov: Use the correct type for size
An AVIO offset is int64_t.

Bug-Id: 921
2016-02-14 11:44:38 +01:00
Anton Khirnov 9f61abc811 lavf: allow custom IO for all files
Some (de)muxers open additional files beyond the main IO context.
Currently, they call avio_open() directly, which prevents the caller
from using custom IO for such streams.

This commit adds callbacks to AVFormatContext that default to
avio_open2()/avio_close(), but can be overridden by the caller. All
muxers and demuxers using AVIO are switched to using those callbacks
instead of calling avio_open()/avio_close() directly.

(de)muxers that use the URLProtocol layer directly instead of AVIO
remain unconverted for now. This should be fixed in later commits.
2016-01-24 16:45:32 +01:00
Derek Buitenhuis 65d29dd274 mov: Add an option to toggle dref opening
This feature is mostly only used by NLE software, and is
both of dubious value being enabled by default, and a
possible security risk.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-01-21 14:32:39 +01:00
John Stebbins 7f4ec4364b avformat: expose av_stream_new_side_data helper
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-11-18 11:36:27 +01:00
Vittorio Giovara b5f963bfec mov: Drop dref when unable to parse
Some entries might be either empty or contain types we do not parse
(eg. 'url '). In both cases, if an 'alis' is not the first entry,
external references are not loaded, so make sure that the array starts
with an 'alis' dref.
2015-11-12 04:39:14 +01:00
Vittorio Giovara 303f931938 mov: Correctly store dref paths
Rather than reading the alternate absolute path version from dref
type 18, make sure that 0s are considered as '/'. These values are
sometimes present in the full path, and are mistakenly interpreted as
line terminators othewise.

With the correct handling of this dref type, parsing type 18 is not
needed any more.
2015-11-12 04:39:14 +01:00
wm4 f128b8e19a mov: detect cover art pictures by content
I've got some m4a samples that had jpeg cover art marked as png. Since
these files were supposedly written by iTunes, and other software can
read it (e.g. clementine does), this should be worked around.

Since png has a very simple to detect header, while it's apparently a
real pain to detect jpeg in the general case, try to detect png and
assume jpeg otherwise. Not bothering with bmp, as I have no test case.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-11-03 15:03:12 +01:00
wm4 948f3c19a8 lavc: Make AVPacket.duration int64, and deprecate convergence_duration
Note that convergence_duration had another meaning, one which was in
practice never used. The only real use for it was a 64 bit replacement
for the duration field. It's better just to make duration 64 bits, and
to get rid of it.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-29 14:33:00 +02:00
Martin Storsjö 7cad1bf075 mov: Allow more than one keyframe per trun
The previous restriction was partially designed to fix certain
(broken) samples from bug 215. There should be no restriction on the
number of keyframes per fragment or trun.

The spec suggests that all frames lacking MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC
are key frames, but we require the flag MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES
to be unset as well. This works for (possibly broken) media that never
sets the NON_SYNC flag and should also be correct for any spec-compliant
file.

For files that never set either of the flags, all samples are marked
as keyframes.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-09-06 21:24:37 +03:00
Vittorio Giovara 059a934806 lavc: Consistently prefix input buffer defines
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:59 +01:00
Vittorio Giovara f1840b070d Revert "mov: Double-check that alias path is not an absolute path"
This reverts commit 9286de0459.
The change broke support for legit absolute file paths.

Reported-by: Maksym Veremeyenko <verem@m1stereo.tv>.
2015-07-17 01:44:22 +01:00
Luca Barbato d80811c94e riff: Use the correct logging context 2015-07-11 18:45:44 +02:00
Vittorio Giovara a1e2caa93e mov: Log format rather than fourcc in stsd in trace mode
This will fix remaining format warnings.
2015-07-01 00:13:58 +01:00
Vittorio Giovara 2eef75fd7e mov: Adjust variable types to fix format warnings 2015-07-01 00:13:58 +01:00
nu774 6ec688e1bc mp3: enable packed main_data decoding in MP4
14496-3 suggests packing main_data of MP3 that is usually scattered
into multiple frames due to bit reservoir.

However, after packing main_data into a access unit, bitrate index
in the MPEG audio frame header doesn't match with actual frame size.

In order to accept this, this patch removes unnecessary frame size
checking on mp3 decoder.

Also, mov demuxer was changed to use MP3 parser only on special cases
(QT MOV with specific sample description) to avoid re-packetizing.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-06-20 12:18:01 +03:00
Vittorio Giovara 6308cd4868 mov: Check memory allocation
CC: libav-stable@libav.org
Bug-Id: CID 1292518
2015-06-08 13:03:39 +01:00
Andreas Cadhalpun 5c720657c2 mov: always check avio_read return value
If avio_read fails, the buffer can contain uninitialized data.

This fixes 'Conditional jump or move depends on uninitialised value(s)'
valgrind warnings, and addresses a few memleaks.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-05-31 13:05:13 +02:00
Andreas Cadhalpun cffb9ea81b mov: reject zero bytes_per_frame with non-zero samples_per_frame
In this case the mov demuxer can return a large number of empty packets.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-05-31 13:05:12 +02:00
Luca Barbato a8a90906fb mov: Correctly allocate ctts_data
It can be reallocated.

CC: libav-stable@libav.org
2015-05-31 13:05:12 +02:00