summaryrefslogtreecommitdiff
path: root/libavformat/mov.c
Commit message (Collapse)AuthorAge
* libavformat/mov: Fix NULL-dereference read for some encrypted content.Jacob Trimble2018-12-20
| | | | | | | | | | | | When reading frames, we need to use the fragment for the correct stream. Sometimes the "current" fragment is not the same as the one the frame is for. Found by Chromium's ClusterFuzz: https://crbug.com/906392 and https://crbug.com/915524 Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Simplify get_stream_info_time()Michael Niedermayer2018-12-19
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/mov: document the dvh1 codec switch based on hvcC availabilityJan Ekström2018-12-17
|
* lavf/mov: ensure only one tkhd per trakchcunningham2018-12-16
| | | | | | | | | | Chromium fuzzing produced a whacky file with extra tkhds. This caused an AVStream that was already in use to be corrupted by assigning it a new id, which blows up later in mov_read_trun because the MOVFragmentStreamInfo.index_entry now points OOB. Reviewed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Use QT format for audio sample descriptors depending on stsd version.Justin Ruggles2018-09-09
| | | | | | | | | | | | | | | | | ISOBMFF does not allow AudioSampleEntryV1 in stsd version 0, so assume the descriptor format is QTFF SoundDescriptionV1. ISOBMFF does not define a version 2. This fixes audio decoding for some MP4 files generated with Apple tools. The additional fields present in SoundDescriptionV1/V2 need to be read in order to correctly read additional boxes that contain information required for decoding the stream. Fixes #7376. Also see: https://github.com/HandBrake/HandBrake/issues/1555 Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* lavf/mov: factor out setting codec_idJohn Stebbins2018-09-08
| | | | | | Since it is performed in all cases now. Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/mov: add AVCodecTag entry for GoPro metadataJohn Stebbins2018-09-08
| | | | | | This allows for validation of the track type Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mov: Error on too large stsd entry counts.Dale Curtis2018-09-01
| | | | | | | | | | | | Entries are always at least 8 bytes per the parsing code, so if we see an impossible entry count avoid massive allocations. This is similar to an existing check in mov_read_stsc(). Since ff_mov_read_stsd_entries() does eof checks, an alternative approach could be to clamp the entry count to atom.size / 8. Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Correct opus-in-mp4 pre-skip to be uint16_t versus int16_t.Dale Curtis2018-08-23
| | | | | | | | | This field is a uint16_t, see docs: http://opus-codec.org/docs/opus_in_isobmff.html#4.3.2 Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Allow saio/saiz in clear content.Jacob Trimble2018-08-22
| | | | | | | | | | | | | | If there is a saio/saiz in clear content, we shouldn't create the encryption index if we don't already have one. Otherwise it will confuse the cenc_filter. The changed method is also used for senc atoms, but they should not appear in clear content. Found by Chromium's ClusterFuzz: https://crbug.com/873432 Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/av1: update ff_isom_write_av1c() to the latest revision of the specJames Almer2018-08-17
| | | | | | | | | | This will get ISOBMFF and Matroska up to date with the revised AV1 Codec Configuration Box spec. For now keep propagating raw OBUs as extradata until all libavcodec modules are adapted to handle AV1CodecConfigurationRecord formatted extradata. Tested-by: Thomas Daede <bztdlinux@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/mov.c: Set start_time for all streams (in case of edit lists).Sasi Inguva2018-08-11
| | | | | | | | | Fixes vorbis mp4 audio files, with edit list specified. Since st->skip_samples is not set in case of vorbis , ffmpeg computes the start_time as negative. Signed-off-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/mov: Force HEVC codec_id for code-point dvh1 and an hvcC atom.Carl Eugen Hoyos2018-08-09
| | | | | | | The mp4 registration authority accepted a code-point for Dolby Vision HEVC that was already used as a fourcc for DVCPRO 100. Fixes ticket #7347.
* avformat/mov: Check default_encrypted_sample before use in ↵Michael Niedermayer2018-07-26
| | | | | | | | | | mov_read_sample_encryption_info() Fixes: 2018-0721-sample Fixes: null pointer dereference Found-by: Nikita Knyzhov (knnikita@yandex.ru) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: add support for AV1 streamsJames Almer2018-07-20
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mov: only set handler_name from mdia->hdlrGyan Doshi2018-07-16
| | | | | | 6 FATE references updated. Fixes #7104
* avformat/mov: Simplify last element computation in mov_estimate_video_delay()Michael Niedermayer2018-07-13
| | | | | | Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Reviewed-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Break out of inner loop early in mov_estimate_video_delay()Michael Niedermayer2018-07-13
| | | | | | | | | | 0.266 <- 0.299 sec (this is time ffmpeg so containing alot other things) Sample for benchmark was: ffmpeg -f rawvideo -pix_fmt yuv420p -s 32x32 -i /dev/zero -t 24:00:00.00 out.mp4 Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Reviewed-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Eliminate variable buf_size from mov_estimate_video_delay()Michael Niedermayer2018-07-12
| | | | | | Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Reviewed-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: remove modulo operations from mov_estimate_video_delay()Michael Niedermayer2018-07-12
| | | | | | | | 0.324 <-0.491 sec Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Reviewed-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Expose encryption info to the app.Jacob Trimble2018-07-04
| | | | | | | | | | This exposes encryption info from the container to the app. This includes key ID, IV, and subsample byte ranges. The info is passed using the new side-data AV_PKT_DATA_ENCRYPTION_DATA and AV_PKT_DATA_ENCRYPTION_INIT_DATA. Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/mov: Do not fail hard for truncated stsz atoms.Carl Eugen Hoyos2018-06-19
| | | | Fixes ticket #6433.
* avformat/mov: Only set pkt->duration to non negative valuesMichael Niedermayer2018-06-14
| | | | | Reviewed-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Add check for per-sample IV size.Jacob Trimble2018-06-13
| | | | | | | Found by Chrome's ClusterFuzz: http://crbug.com/849062. Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Fix reading saio/saiz for clear content.Jacob Trimble2018-06-09
| | | | | | | | | | | This validates that the common encryption saio/saiz atoms only appear when the data is actually encrypted. This also ignores those atoms in clear content. Found by Chrome's ClusterFuzz: http://crbug.com/850389 Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/mov.c: Set st->start_time for video streams explicitly.Sasi Inguva2018-06-06
| | | | | | | If start_time is not set, ffmpeg takes the duration from the global movie instead of the per stream duration. Signed-off-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/mov.c: Fix timestamps to be strictly monotonic for video also.Sasi Inguva2018-06-05
| | | | | | | | | | | We already do this for audio, but it should be done for video too. If we don't, seeking back to the start of the file, for example, can become quite broken, since the first N packets will have repeating and nonmonotonic PTS, yet they need to be decoded even if they are to be discarded. Signed-off-by: Sasi Inguva <isasi@isasi.mtv.corp.google.com> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* libavformat/mov: Fix heap buffer overflow.Jacob Trimble2018-06-02
| | | | | | | Found by Chrome's ClusterFuzz: https://crbug.com/847060 Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: replace a value error by clipping into valid range in ↵Michael Niedermayer2018-05-22
| | | | | | | | mov_read_stsc() Fixes: #7165 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Only fail for STCO/STSC contradictions if both existMichael Niedermayer2018-05-21
| | | | | | | | Fixes regression with playback of GF9720Repeal20the20Eighth20with20Helen20Linehan.m4a See: crbug 822666 Found-by: "Mattias Wadman <mattias.wadman@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Break out early if chunk_count is 0 in mov_build_index()Michael Niedermayer2018-05-21
| | | | | | | | | Without this some operations might overflow (undefined behavior) even though the index adding loop would never execute No testcase known Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* mov: Properly abide by the track's media durationDerek Buitenhuis2018-04-26
| | | | | | | | | | | | | | | | | The track's media duration from the mdhd atom takes precedence over both the stts and elst atom for calculating and setting the track's total duraion. Technically, we shouldn't be using the stts atom at all for calculating stream durations. This fixes incorrect stream and final packet durations on files with edit lists that are longer than the media duration. The FATE changes are expected, and output is more correct (the AAC frame is not 1028 samples). Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/mov: Fix parsing of saio/siaz atoms in encrypted content.Jacob Trimble2018-04-21
| | | | | | | This doesn't support saio atoms with more than one offset. Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Remove old encryption info methods.Jacob Trimble2018-04-19
| | | | | Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Fix memory leak in encryption info.Jacob Trimble2018-04-19
| | | | | Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Increase support for common encryption.Jacob Trimble2018-04-19
| | | | | | | | | | | | | | | | | | - Parse schm atom to get different encryption schemes. - Allow senc atom to appear in track fragments. - Allow 16-byte IVs. - Allow constant IVs (specified in tenc). - Allow only tenc to specify encryption (i.e. no senc/saiz/saio). - Use sample descriptor to detect clear fragments. This doesn't support: - Different sample descriptor holding different encryption info. - Only first sample descriptor can be encrypted. - Encrypted sample groups (i.e. seig). - Non-'cenc' encryption scheme when using -decryption_key. Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Fix extradata memleakMichael Niedermayer2018-04-12
| | | | | | | | Fixes: crbug 822705 Reported-by: Matt Wolenetz <wolenetz@google.com> Reviewed-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Fix parsing of tfdt when using sample descriptors.Jacob Trimble2018-04-05
| | | | | Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: parse multiple iTunes cover imagesTimo Teräs2018-04-01
| | | | | | | | | Multiple cover images are supported by having multiple data atoms inside the covr atom. AtomicParsley and mutagen amongst others support and document this construct. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Move +1 in check to avoid hypothetical overflow in ↵Michael Niedermayer2018-03-26
| | | | | | add_ctts_entry() Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Check STSC and remove invalid entriesMichael Niedermayer2018-03-20
| | | | | | | | | | | Fixes assertion failure Fixes: crbug 822547, crbug 822666 and crbug 823009 Affects: aark15sd_9A62E2FA.mp4 Found-by: ClusterFuzz Reviewed-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Fix integer overflows related to sample_durationMichael Niedermayer2018-03-12
| | | | | | | | | | Fixes: runtime error: signed integer overflow: -9166684017437101870 + -2495066639299164439 cannot be represented in type Fixes: Chromium bug 791349 Reported-by: Matt Wolenetz <wolenetz@google.com> Reviewed-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/mov.c: Use the correct offset to shift timestamp when seeking.Sasi Inguva2018-03-10
| | | | | | | | Fixes seek for files with empty edits and files with negative ctts (dts_shift > 0). Added fate samples and tests. Signed-off-by: Sasi Inguva <isasi@isasi.mtv.corp.google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: print the projection type when reporting it as unsupportedJames Almer2018-03-09
| | | | | Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: Fix stts_data memory allocationXiaohan Wang2018-03-09
| | | | | | | | | In this loop, |i| is the "index". And the memory allocated should be at least the current "count", which is |i + 1|. BUG=801821 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Fix integer overflow in mov_get_stsc_samples()Michael Niedermayer2018-03-07
| | | | | | | | Fixes: runtime error: signed integer overflow: 5 * -2147483647 cannot be represented in type 'int' Fixes: Chromium bug 817338 Reviewed-by: Matt Wolenetz <wolenetz@google.com> Reported-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Initialize a potential gap in ctts_data in mov_build_indexMatt Wolenetz2018-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | | mov_read_ctts ignores ctts entries having count <= 0. Generally, the aggregate of all ctts entries' count fields resulting from mov_read_ctts can be less than the corresponding sample_count. mov_build_index attempts to normalize any existing ctts_data counts to be 1, to make a 1-1 mapping of a ctts_data entry to a sample. That 1-1 mapping left a tail of uninitialized ctts_data entries when the aggregate, normalized ctts_count < sample_count. Even more generally, later usage of ctts_data may depend on the entire ctts_allocated_size having been initialized. This change memsets the entire allocation of the normalized ctts_data in mov_build_index, to prevent use of uninitialized data later. BUG=816787 Change-Id: I7fd7db255e3aeed076ee32c90cb2df211741c052 Reviewed-on: https://chromium-review.googlesource.com/947110 Reviewed-by: Xiaohan Wang <xhwang@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Add manu/modl to mov_read_udta_string.Tianqiang Liu2018-03-03
| | | | | | Documentation: http://mp4ra.org/atoms.html Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* ffmpeg: Fix memset size on ctts_data in mov_read_trun() (round 2)Xiaohan Wang2018-03-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | The allocated size of sc->ctts_data is (st->nb_index_entries + entries) * sizeof(*sc->ctts_data). The size to memset at offset sc->ctts_data + sc->ctts_count should be (st->nb_index_entries + entries - sc->ctts_count) * sizeof(*sc->ctts_data)) The current code missed |entries| I believe, which was introduced in https://patchwork.ffmpeg.org/patch/5541/. However, after offline discussion, it seems the original code is much more clear to read (before https://patchwork.ffmpeg.org/patch/5541/). Hence this CL revert the memset logic to it's previous state by remembering the |old_ctts_allocated_size|, and only memset the newly allocated entries. BUG=812567 Change-Id: Ibe94c7138e5818bfaae76866bfa6619a9b8a2b6b Reviewed-on: https://chromium-review.googlesource.com/934925 Reviewed-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Fix ctts_index calculationXiaohan Wang2018-02-10
| | | | | | | | An index should never be equal to the count. Hence we must make sure *ctts_index < ctts_count. Reviewed-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>