summaryrefslogtreecommitdiff
path: root/libavformat/mov.c
Commit message (Collapse)AuthorAge
* lavf/mov: Allow reading very large files.Pablo Montilla2017-09-28
| | | | | | | The Sample count in the time-to-sample table is defined as 32-bit unsigned integer by the QT specification. Fixes ticket #6700.
* Merge commit 'b446f0e98f85e2e931b476e52b319f1c49244660'James Almer2017-09-28
|\ | | | | | | | | | | | | | | | | * commit 'b446f0e98f85e2e931b476e52b319f1c49244660': mov: Do not try to parse multiple stsd for the same track See 8b43ee4054af799e388d380b379a13a60849c1b5 Merged-by: James Almer <jamrial@gmail.com>
| * mov: Do not try to parse multiple stsd for the same trackLuca Barbato2017-02-15
| | | | | | | | | | | | | | Bug-Id: 1017 CC: libav-stable@libav.org Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit '53ea595eec984e3109310e8bb7ff4b5786d91057'James Almer2017-09-27
|\| | | | | | | | | | | | | | | | | * commit '53ea595eec984e3109310e8bb7ff4b5786d91057': mov: Rework stsc index validation See e26e6240b6700c5e8c16d0f092f1ad46805a723c. Merged-by: James Almer <jamrial@gmail.com>
| * mov: Rework stsc index validationVittorio Giovara2017-02-10
| | | | | | | | | | In order to avoid potential integer overflow change the comparison and make sure to use the same unsigned type for both elements.
| * Use bitstream_init8() where appropriateDiego Biurrun2017-02-07
| |
* | Merge commit '708e84cda1bdbffb92847f3d6ccf6fbeb26d9948'James Almer2017-09-26
|\| | | | | | | | | | | | | * commit '708e84cda1bdbffb92847f3d6ccf6fbeb26d9948': mov: Avoid memcmp of uninitialised data Merged-by: James Almer <jamrial@gmail.com>
| * mov: Avoid memcmp of uninitialised dataMark Thompson2017-01-30
| | | | | | | | | | | | | | | | | | The string codec name need not be as long as the value we are comparing it to, so memcmp may make decisions derived from uninitialised data that valgrind then complains about (though the overall result of the function will always be the same). Use strncmp instead, which will stop at the first zero byte and therefore not encounter this issue.
| * mov: Convert to the new bitstream readerAlexandra Hájková2017-01-13
| |
| * Use correct printf conversion specifiers for POSIX integer typesDiego Biurrun2016-12-23
| |
* | avformat/mov: Fix DoS in read_tfra()Michael Niedermayer2017-09-07
| | | | | | | | | | | | | | | | Fixes: Missing EOF check in loop No testcase Found-by: Xiaohei and Wangchu from Alibaba Security Team Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: prevent duplication of first fragment's ctts_dataDaniel Glöckner2017-09-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MP4 files with fragments might have the first moof box that is mentioned in a fragment index before the first mdat box. Since it is then already parsed by mov_read_header, we have to make sure that mov_switch_root will not parse it again when seeking by setting the headers_read flag in the index. Parsing it a second time would cause the ctts_data array to receive a second copy of the information from the trun box, leading to wrong PTS values for the second and following fragments in presence of B-frames. Fixes ticket 6560. Signed-off-by: Daniel Glöckner <daniel-gl@gmx.net> Reviewed-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: Bail when invalid sample data is present.Dale Curtis2017-09-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ctts data in ffmpeg relies on the index entries array to be 1:1 with samples... yet sc->sample_count can be read directly from the 'stsz' box and index entries are only generated if a chunk count has been read from 'stco' box. Ensure that if sc->sample_count > 0, sc->chunk_count is too as a basic sanity check. Additionally we need to check that after the index is built we have the right number of entries, so we also check in mov_read_trun() that sc->sample_count == st->nb_index_entries. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: Fix trampling of ctts during seeks when sidx support is enabled.Dale Curtis2017-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When sidx box support is enabled, the code will skip reading all trun boxes (each containing ctts entries for samples inthat box). If seeks are attempted before all ctts values are known, the old code would dump ctts entries into the wrong location. These are then used to compute pts values which leads to out of order and incorrectly timestamped packets. This patch fixes ctts processing by always using the index returned by av_add_index_entry() as the ctts_data index. When the index gains new entries old values are reshuffled as appropriate. This approach makes sense since the mov demuxer is already relying on the mapping of AVIndex entries to samples for correct demuxing. As a result of this all ctts entries are now 1-count. A followup change will be submitted to remove support for > 1 count entries which will simplify seeking. Notes for future improvement: Probably there are other boxes (stts, stsc, etc) that are impacted by this issue... this patch only attempts to fix ctts since it completely breaks packet timestamping. This patch continues using an array for the ctts data, which is not the most ideal given the rearrangement that needs to happen (via memmove as new entries are read in). Ideally AVIndex and the ctts data would be set-type structures so addition is always worst case O(lg(n)) instead of the O(n^2) that exists now; this slowdown is noticeable during seeks. Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: Fix signed integer overflows with total_sizeVitaly Buka2017-08-23
| | | | | | | | | | | | | | | | Signed integer overflow is undefined behavior. Detected with clang and -fsanitize=signed-integer-overflow Signed-off-by: Vitaly Buka <vitalybuka@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | libavformat/mov: Fix inserting frames before current_frame.Jacob Trimble2017-08-18
| | | | | | | | | | | | | | | | | | | | When using streaming input, it may be possible to see frames that appear before the current_frame. When these frames are inserted into the index, the current_frame needs to be updated so it is still pointing at the same frame. Signed-off-by: Jacob Trimble <modmaker@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: Fix memory leak when reading DDTS box.Nikolas Bowe2017-08-16
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: add support for reading VP Codec Configuration BoxJames Almer2017-06-11
| | | | | | | | | | | | | | As defined in "VP Codec ISO Media File Format Binding v1.0" https://github.com/webmproject/vp9-dash/blob/master/VPCodecISOMediaFileFormatBinding.md Signed-off-by: James Almer <jamrial@gmail.com>
* | lavf/mov.c: offset index timestamps by the minimum pts to make first pts zeroSasi Inguva2017-06-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the videos starts with B frame, then the minimum composition time as computed by stts + ctts will be non-zero. Hence we need to shift the DTS, so that the first pts is zero. This was the intention of that code-block. However it was subtracting by the wrong amount. For example, for one of the videos in the bug nonFormatted.mp4 we have stts: sample_count duration 960 1001 ctts: sample_count duration 1 3003 2 0 1 3003 .... The resulting composition times are : 3003, 1001, 2002, 6006, ... The minimum composition time or PTS is 1001, which should be used to offset DTS. However the code block was wrongly using ctts[0] which is 3003. Hence the PTS was negative. This change computes the minimum pts encountered while fixing the index, and then subtracts it from all the timestamps after the edit list fixes are applied. Samples files available from: https://bugs.chromium.org/p/chromium/issues/detail?id=721451 https://bugs.chromium.org/p/chromium/issues/detail?id=723537 fate-suite/h264/twofields_packet.mp4 is a similar file starting with 2 B frames. Before this change the PTS of first two B-frames was -6006 and -3003, and I am guessing one of them got dropped when being decoded and remuxed to the framecrc before, and now it is not being dropped. Signed-off-by: Sasi Inguva <isasi@google.com>
* | avformat/mov: add support for reading Content Light Level BoxJames Almer2017-05-27
| | | | | | | | | | | | | | | | As defined in "VP Codec ISO Media File Format Binding v1.0" https://github.com/webmproject/vp9-dash/blob/master/VPCodecISOMediaFileFormatBinding.md Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* | avformat/mov: add support for reading Mastering Display Metadata BoxJames Almer2017-05-27
| | | | | | | | | | | | | | | | As defined in "VP Codec ISO Media File Format Binding v1.0" https://github.com/webmproject/vp9-dash/blob/master/VPCodecISOMediaFileFormatBinding.md Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* | lavf/mov: make invalid m{d,v}hd time_scale default to 1 instead of erroring outMatthieu Bouron2017-05-20
| | | | | | | | | | | | | | Some samples have their metadata track time_scale incorrectly set to 0 and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71 prevents playback of those samples. Setting the time_scale to 1 fixes playback.
* | Merge commit '46191a2da16f751e53d93646ae1388d421d12bee'Clément Bœsch2017-04-29
|\| | | | | | | | | | | | | * commit '46191a2da16f751e53d93646ae1388d421d12bee': mov: fix a possible invalid read in mov_read_mac_string() Merged-by: Clément Bœsch <u@pkh.me>
| * mov: fix a possible invalid read in mov_read_mac_string()Anton Khirnov2016-12-19
| | | | | | | | | | | | | | | | | | | | When the input string is too large, so the second condition in if () fails, the code will erroneously execute the else branch, indexing the mac_to_unicode table with a negative index. CC: libav-stable@libav.org Bug-Id: 1000 Found-By: Kamil Frankowicz
| * mov: Export spherical informationVittorio Giovara2016-12-07
| | | | | | | | | | | | | | This implements Spherical Video V1 and V2, as described in the spatial-media collection by Google. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * mov: Use av_stream_add_side_data() for displaymatrix side dataJames Almer2016-11-23
| | | | | | | | | | Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * mov: Fix identity matrix boolean logicVittorio Giovara2016-11-16
| | | | | | | | | | | | | | | | This prevented the code from correctly exporting the rotation matrix which caused a few samples to be displayed wrong. Introduced in ecd2ec69ce10e13f6ede353d2def7c. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * mov: Read multiple stsd from DVVittorio Giovara2016-11-08
| | | | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * hevc: Support extradata changes from multiple stsdVittorio Giovara2016-11-08
| | | | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * mov: Evaluate the movie display matrixVittorio Giovara2016-11-01
| | | | | | | | | | | | | | | | | | | | | | 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>
| * Use ISO C printf conversion specifiers where appropriateDiego Biurrun2016-10-28
| |
* | lavf/mov: Only copy extradata if it exists.Carl Eugen Hoyos2017-04-19
| | | | | | | | Avoids undefined call of memcpy(ptr, NULL, 0);
* | avformat/mo: Add experimental demuxing support for Opus in ISO BMFF (MP4).Matthew Gregan2017-04-11
| | | | | | | | | | | | | | Based on the draft spec at http://vfrmaniac.fushizen.eu/contents/opus_in_isobmff.html Signed-off-by: Matthew Gregan <kinetik@flim.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | libavformat/mov: Fix memory leak, need to free the chapter tracks arrayThierry Foucu2017-04-06
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: Check creation_time for overflowMichael Niedermayer2017-04-04
| | | | | | | | | | | | | | | | Fixes integer overflow Fixes: 701640 Found-by: Found-by: Thomas Guilbert <tguilbert@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavf/mov.c: Add -advanced_editlist option for mov format.Sasi Inguva2017-03-31
| | | | | | | | | | | | | | Adding an MOV format option to turn on/off the editlist supporting code, introduced in https://github.com/FFmpeg/FFmpeg/commit/ca6cae73db207f17a0d5507609de12842d8f0ca3 Signed-off-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: Init ref_sc / ref_st to NULLMichael Niedermayer2017-03-30
| | | | | | | | | | | | | | | | | | This is more robust in case some change or corner case causes them to be dereferenced before being set Fixes CID1396274, CID1396275 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Fix all -Wformat warnings raised by DJGPPClément Bœsch2017-03-29
| |
* | lavf: use av_fourcc2str() where appropriateClément Bœsch2017-03-29
| |
* | avformat, ffmpeg: deprecate old rotation APIwm42017-03-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old "API" that signaled rotation as a metadata value has been replaced by DISPLAYMATRIX side data quite a while ago. There is no reason to make muxers/demuxers/API users support both. In addition, the metadata API is dangerous, as user tags could "leak" into it, creating unintended features or bugs. ffmpeg CLI has to be updated to use the new API. In particular, we must not allow to leak the "rotate" tag into the muxer. Some muxers will catch this properly (like mov), but others (like mkv) can add it as generic tag. Note applications, which use libavformat and assume the old rotate API, will interpret such "rotate" user tags as rotate metadata (which it is not), and incorrectly rotate the video. The ffmpeg/ffplay tools drop the use of the old API for muxing and demuxing, as all muxers/demuxers support the new API. This will mean that the tools will not mistakenly interpret per-track "rotate" user tags as rotate metadata. It will _not_ be treated as regression. Unfortunately, hacks have been added, that allow the user to override rotation by setting metadata explicitly, e.g. via -metadata:s:v:0 rotate=0 See references to trac #4560. fate-filter-meta-4560-rotate0 tests this. It's easier to adjust the hack for supporting it than arguing for its removal, so ffmpeg CLI now explicitly catches this case, and essentially replaces the "rotate" value with a display matrix side data. (It would be easier for both user and implementation to create an explicit option for rotation.) When the code under FF_API_OLD_ROTATE_API is disabled, one FATE reference file has to be updated (because "rotate" is not exported anymore). Tested-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mov: stop using deprecated codec flagsJames Almer2017-03-25
| | | | | | | | Signed-off-by: James Almer <jamrial@gmail.com>
* | Merge commit '1263b2039eb5aaf1522e9de9f07c787ab30a5f50'Clément Bœsch2017-03-24
|\| | | | | | | | | | | | | * commit '1263b2039eb5aaf1522e9de9f07c787ab30a5f50': Adjust printf conversion specifiers to match variable signedness Merged-by: Clément Bœsch <u@pkh.me>
| * Adjust printf conversion specifiers to match variable signednessDiego Biurrun2016-10-28
| |
* | Merge commit 'ca1e5eea0c7b72a6e30aa6488cfeced3a4853521'Clément Bœsch2017-03-24
|\| | | | | | | | | | | | | * commit 'ca1e5eea0c7b72a6e30aa6488cfeced3a4853521': Remove some pointless TRACE level debug code Merged-by: Clément Bœsch <u@pkh.me>
| * Remove some pointless TRACE level debug codeDiego Biurrun2016-10-27
| | | | | | | | This also kills some warnings with certain compiler options.
* | Merge commit '4b07ebf1eb13561492f7e3c30a67f34415016b3e'Clément Bœsch2017-03-24
|\| | | | | | | | | | | | | | | | | | | | | * commit '4b07ebf1eb13561492f7e3c30a67f34415016b3e': mov: Update colr values Mostly noop, see a3cab3d43387add8914c1c471fc99d733227d81b Only the use of av_color_{primaries,transfer,space}_name() is merged. Merged-by: Clément Bœsch <u@pkh.me>
| * mov: Update colr valuesVittorio Giovara2016-10-21
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'James Almer2017-03-21
|\| | | | | | | | | | | | | * commit '83548fe894cdb455cc127f754d09905b6d23c173': lavf: fix usage of AVIOContext.seekable Merged-by: James Almer <jamrial@gmail.com>
| * lavf: fix usage of AVIOContext.seekableAnton Khirnov2016-09-30
| | | | | | | | | | | | | | | | 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.
| * mov: Remove old b-frame/video delay heuristicDerek Buitenhuis2016-08-29
| | | | | | | | | | | | | | | | 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>