Commit Graph

172 Commits

Author SHA1 Message Date
James Almer 41e349c24a avformat/mov: add support for tile HEIF still images
Export each tile as its own stream, and the grid information as a Stream Group
of type TILE_GRID.
This also enables exporting other stream items like thumbnails, which may be
present in non tiled HEIF images too. For those, the primary stream will be
tagged with the default disposition.

Based on a patch by Swaraj Hota

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-26 12:21:12 -03:00
James Almer fe637161db avformat/mov: add support for Immersive Audio Model and Formats in ISOBMFF
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:24:19 -03:00
James Almer 9ba327e70f avformat/mov: make MOVStreamContext refcounted
This will be useful in the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:24:19 -03:00
Damiano Galassi 112d3618ca avformat/mov: add support for 'amve' ambient viewing environment box
As defined in ISOBMFF (ISO/IEC 14496-12) document.

Co-Authored-By: Cosmin Stejerean <cosmin@cosmin.at>
2024-02-04 13:36:25 -03:00
James Almer b94b3eac0e avformat/mov: use a more descriptive name for variables of type HEIFItem
Other HEIF related structs will be introduced, so lets be more specific about what
this one defines.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-03 23:08:42 -03:00
James Almer f6b7b473d4 avformat/mov: ignore item boxes for animated heif
Fixes a regression since d9fed9df2a, where the single animated stream would
be exported twice as two independent streams.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-01 11:19:15 -03:00
James Almer d9fed9df2a avformat/mov: improve HEIF parsing
Parse iprp and iinf boxes and its child boxes to get the actual codec used
(AV1 for avif, HEVC for heic), and properly export extradata and other
properties in a generic way.
The avif tests reference files are updated as the extradata is now exported.

Based on a patch by Swaraj Hota

Co-authored-by: Swaraj Hota <swarajhota353@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-01-15 15:10:15 -03:00
James Almer 0405f71e19 avformat/mov: rename avif fields to heif
They are no longer avif specific.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-01-10 18:26:53 -03:00
Vignesh Venkatasubramanian via ffmpeg-devel a0821345eb avformat/mov: Add support for demuxing still HEIC images
They are similar to AVIF images (both use the HEIF container).
The only additional work needed is to parse the hvcC box and put
it in the extradata.

With this patch applied, ffmpeg (when built with an HEVC decoder)
is able to decode the files in
https://github.com/nokiatech/heif/tree/gh-pages/content/images

Also add a couple of fate tests with samples from
https://github.com/nokiatech/heif_conformance/tree/master/conformance_files

Partially fixes trac ticket #6521.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-01-09 16:44:14 -03:00
Zhao Zhili a8d9da4c8b avformat/mov: add interleaved_read option
For badly interleaved files, interleave packets from multiple tracks
at the demuxer level can trigger seeking back and forth, which can be
dramatically slow depending on the protocol. Demuxer level interleave
can be useless sometimes, e.g., reading mp4 via http and then
transcoding/remux to DASH. Disable this option when you don't need the
demuxer level interleave, and want to avoid the IO penalizes.

Co-authored-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-09-14 18:49:51 +08:00
Zhao Zhili d04dbf48fc avformat/mov: fix ISO/IEC 23003-5 support
Missing floating-point formats support.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-03-15 00:12:59 +08:00
Martin Storsjö 431f6260ac mov: Reduce the verbosity of the warning about fragmented MP4 vs advanced edit lists
Only warn if the advanced_editlist option is enabled (it is enabled
by default though) so we don't print one warning for each track, and
demote the warning to AV_LOG_LEVEL_VERBOSE; this message does get
generated whenever parsing a fragmented MP4 file, regardless of
whether the file actually uses multiple edits or not.

Later when parsing the mov structures, the demuxer does warn if
the file did contain multiple edits which would require the
advanced_editlist option enabled for decoding correctly.

Adjust the warning message for the case when the file seemed like it
actually would have needed handling of advanced edit lists, to
reflect the fact that it doesn't help to try set the option as
it has been automatically disabled.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-01-31 14:29:08 +02:00
Wang Yaqiang 0744782de3 avformat/mov: get the correct fragment stsd_id when decrypting the sample
When determining whether a packet should be decrypted,
should use the stsd_id of the fragment where the current packet is located.

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Wang Yaqiang <wangyaqiang03@kuaishou.com>
2022-09-21 13:58:40 +08:00
Zhao Zhili 1af7797d21 avformat/mov: fix encryption index in the case of multiple trun
frag_stream_info->index_entry isn't the first sample/trun index.
cenc.frag_index_entry_base failed to catch the case since
current_index > 0.

Fix ticket #9807.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-08-16 18:47:40 +08:00
Vignesh Venkatasubramanian d931554f66 avformat/mov: Rework the AVIF parser to handle multiple items
Stores the item ids of all the items found in the file and
processes the primary item at the end of the meta box. This patch
does not change any behavior. It sets up the code for parsing
alpha channel (and possibly images with 'grid') in follow up
patches.

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Zern <jzern@google.com>
2022-08-09 13:15:55 -07:00
Vignesh Venkatasubramanian be4d1caad4 avformat/mov: Only read the primary item for AVIF
Update the still AVIF parser to only read the primary item. With this
patch, AVIF still images with exif/icc/alpha channel will no longer
fail to parse.

For example, this patch enables parsing of files in:
https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft

Adding two fate tests:
1) demuxing of still image with 1 item - this test will pass regardless
   of this patch.
2) demuxing of still image with 2 items - this test will fail without
   this patch and will pass with patch applied.

Partially fixes trac ticket #7621

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Zern <jzern@google.com>
2022-06-29 12:16:40 -07:00
Vignesh Venkatasubramanian 499e245b85 avformat/mov: Add support for still image AVIF parsing
This patch supports AVIF still images conforming to the
final specification that have exactly one item (i.e. no alpha channel).
The iloc box is parsed and the mov index populated.

Partially fixes #7621.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
2022-04-23 13:26:34 +05:30
Marton Balint 8dd5bb7280 avformat/mov: fix timecode with high frame rate content
60 fps content have "Number of Frames" set to 30 in the tmcd atom, but the
frame duration / timescale reflects the original video frame rate.

Therefore we multiply the frame count with the quotient of the rounded timecode
frame rate and the "Number of Frames" per second to get a frame count in the original
(higher) frame rate.

Note that the frames part in the timecode will be in high frame rate which will
make the timecode different to e.g. MediaInfo which seems to show the 30 fps
timecode even for 120 fps content.

Regression since 428b4aacb1.

Fixes ticket #9710.
Fixes ticket #9492.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-04-22 22:54:56 +02:00
Clément Bœsch ab77b878f1 avformat/mov: fix seeking with HEVC open GOP files
This was tested with medias recorded from an iPhone XR and an iPhone 13.

Here is how a typical stream looks like in coding order:

    ┌────────┬─────┬─────┬──────────┐
    │ sample | PTS | DTS | keyframe |
    ├────────┼─────┼─────┼──────────┤
    ┊        ┊     ┊     ┊          ┊
    │   53   │ 560 │ 510 │    No    │
    │   54   │ 540 │ 520 │    No    │
    │   55   │ 530 │ 530 │    No    │
    │   56   │ 550 │ 540 │    No    │
    │   57   │ 600 │ 550 │    Yes   │
    │ * 58   │ 580 │ 560 │    No    │
    │ * 59   │ 570 │ 570 │    No    │
    │ * 60   │ 590 │ 580 │    No    │
    │   61   │ 640 │ 590 │    No    │
    │   62   │ 620 │ 600 │    No    │
    ┊        ┊     ┊     ┊          ┊

In composition/display order:

    ┌────────┬─────┬─────┬──────────┐
    │ sample | PTS | DTS | keyframe |
    ├────────┼─────┼─────┼──────────┤
    ┊        ┊     ┊     ┊          ┊
    │   55   │ 530 │ 530 │    No    │
    │   54   │ 540 │ 520 │    No    │
    │   56   │ 550 │ 540 │    No    │
    │   53   │ 560 │ 510 │    No    │
    │ * 59   │ 570 │ 570 │    No    │
    │ * 58   │ 580 │ 560 │    No    │
    │ * 60   │ 590 │ 580 │    No    │
    │   57   │ 600 │ 550 │    Yes   │
    │   63   │ 610 │ 610 │    No    │
    │   62   │ 620 │ 600 │    No    │
    ┊        ┊     ┊     ┊          ┊

Sample/frame 58, 59 and 60 are B-frames which actually depends on the
key frame (57). Here the key frame is not an IDR but a "CRA" (Clean
Random Access).

Initially, I thought I could rely on the sdtp box (independent and
disposable samples), but unfortunately:

    sdtp[54] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[55] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[56] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[57] is_leading:0 sample_depends_on:2 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[58] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[59] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[60] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[61] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[62] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0

The information that might have been useful here would have been
is_leading, but all the samples are set to 0 so this was unusable.

Instead, we need to rely on sgpd/sbgp tables. In my case the video track
contained 3 sgpd tables with the following grouping types: tscl, sync
and tsas. In the sync table we have the following 2 entries (only):

    sgpd.sync[1]: sync nal_unit_type:0x14
    sgpd.sync[2]: sync nal_unit_type:0x15

(The count starts at 1 because 0 carries the undefined semantic, we'll
see that later in the reference table).

The NAL unit types presented here correspond to:

    libavcodec/hevc.h:    HEVC_NAL_IDR_N_LP       = 20,
    libavcodec/hevc.h:    HEVC_NAL_CRA_NUT        = 21,

In parallel, the sbgp sync table contains the following:

    ┌────┬───────┬─────┐
    │ id │ count │ gdi │
    ├────┼───────┼─────┤
    │  0 │   1   │  1  │
    │  1 │   56  │  0  │
    │  2 │   1   │  2  │
    │  3 │   59  │  0  │
    │  4 │   1   │  2  │
    │  5 │   59  │  0  │
    │  6 │   1   │  2  │
    │  7 │   59  │  0  │
    │  8 │   1   │  2  │
    │  9 │   59  │  0  │
    │ 10 │   1   │  2  │
    │ 11 │   11  │  0  │
    └────┴───────┴─────┘

The gdi column (group description index) directly refers to the index in
the sgpd.sync table. This means the first frame is an IDR, then we have
batches of undefined frames interlaced with CRA frames. No IDR ever
appears again (tried on a 30+ seconds sample).

With that information, we can build an heuristic using the presentation
order.

A few things needed to be introduced in this commit:

1. min_sample_duration is extracted from the stts: we need the minimal
   step between sample in order to PTS-step backward to a valid point
2. In order to avoid a loop over the ctts table systematically during a
   seek, we build an expanded list of sample offsets which will be used
   to translate from DTS to PTS
3. An open_key_samples index to keep track of all the non-IDR key
   frames; for now it only supports HEVC CRA frames. We should probably
   add BLA frames as well, but I don't have any sample so I prefered to
   leave that for later

It is entirely possible I missed something obvious in my approach, but I
couldn't come up with a better solution. Also, as mentioned in the diff,
we could optimize is_open_key_sample(), but the linear scaling overhead
should be fine for now since it only happens in seek events.

Fixing this issue prevents sending broken packets to the decoder. With
FFmpeg hevc decoder the frames are skipped, with VideoToolbox the frames
are glitching.
2022-03-04 15:50:51 +01:00
Clément Bœsch e05e4398c3 avformat/mov: add parsing for the sgpd sync box
sgpd means Sample Group Description Box.

For now, only the sync grouping type is parsed, but the function can
easily be adjusted to support other flavours.

The sbgp (Sample to Group Box) sync_group table built in previous commit
contains references to this table through the group_description_index
field.
2022-03-04 15:50:51 +01:00
Clément Bœsch eb947471b2 avformat/mov: add support for sync group in sbgp box 2022-03-04 15:50:51 +01:00
Gyan Doshi 9cfc7a2440 avformat/mov: add option max_stts_delta
Very high stts sample deltas may occasionally be intended but usually
they are written in error or used to store a negative value for dts correction
when treated as signed 32-bit integers.

This option lets the user set an upper limit, beyond which the delta is clamped to 1.
Values greater than the limit if negative when cast to int32 are used to adjust onward dts.

Unit is the track time scale. Default is UINT_MAX - 48000*10 which
allows upto a 10 second dts correction for 48 kHz audio streams while
accommodating 99.9% of uint32 range.

Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-31 14:44:20 +05:30
Gyan Doshi 203b0e3561 avformat/mov: make STTS duration unsigned int
As per 8.6.1.2.2 of ISO/IEC 14496-12:2015(E), STTS sample offsets
are to be always stored as uint32_t. So far, they have been signed ints
which led to desync in files with very large offsets.

The MOVStts struct was used to store CTTS offsets as well. These can be
negative in version 1. So a new struct MOVCtts was created and all
declarations for CTTS usage changed to MOVCtts.
2021-11-22 15:18:42 +05:30
Nachiket Tarate ef0f5d1be6 libavformat/mov: add support for 'cens', 'cbc1' and 'cbcs' encryption schemes specified in Common Encryption (CENC) standard
correct implementation of 'cenc' encryption scheme to support
decryption of partial cipher blocks at the end of subsamples

https://www.iso.org/standard/68042.html

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2021-10-13 11:23:44 +08:00
Jan Ekström 7a446b1179 avformat/{isom,mov,movenc}: add support for CMAF DASH roles
This information is coded in a standard MP4 KindBox and utilizes the
scheme and values as per the DASH role scheme defined in MPEG-DASH.
Other schemes are technically allowed, but where multiple schemes
define the same concepts, the DASH scheme should be utilized.

Such flagging is additionally utilized by the DASH-IF CMAF ingest
specification, enabling an encoder to inform the following component
of the roles of the incoming media streams.

A test is added for this functionality in a similar manner to the
matroska test.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-10-04 17:55:27 +03:00
Jan Ekström e41bd075dd avformat/movenc: add support for TTML muxing
Includes basic support for both the ISMV ('dfxp') and MP4 ('stpp')
methods. This initial version also foregoes fragmentation support
in case the built-in sample squashing is to be utilized, as this
eases the initial review.

Additionally, add basic tests for both muxing modes in MP4.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-08-25 09:26:46 +03:00
Gyan Doshi 071930de72 avformat/mov: add option to use tfdt for fragment timestamps. 2021-06-02 10:46:04 +05:30
Vesselin Bontchev 03fb314acf Add support for playing Audible AAXC (.aaxc) files [PATCH v4]
The AAXC container format is the same as the (already supported) Audible
AAX format but it uses a different encryption scheme.

Note: audible_key and audible_iv values are variable (per file) and are
externally fed.

It is possible to extend https://github.com/mkb79/Audible to derive the
audible_key and audible_key values.

Relevant code:

def decrypt_voucher(deviceSerialNumber, customerId, deviceType, asin, voucher):
    buf = (deviceType + deviceSerialNumber + customerId + asin).encode("ascii")
    digest = hashlib.sha256(buf).digest()
    key = digest[0:16]
    iv = digest[16:]

    # decrypt "voucher" using AES in CBC mode with no padding
    cipher = AES.new(key, AES.MODE_CBC, iv)
    plaintext = cipher.decrypt(voucher).rstrip(b"\x00")  # improve this!
    return json.loads(plaintext)

The decrypted "voucher" has the required audible_key and audible_iv
values.

Update (Nov-2020): This patch has now been tested by multiple folks -
details at the following URL:

https://github.com/mkb79/Audible/issues/3

Signed-off-by: Vesselin Bontchev <vesselin.bontchev@yandex.com>
2020-11-05 21:40:20 +05:30
Derek Buitenhuis 97fa669a6f avformat/mov: Only read the mfra size once during sidx parsing
On files with more than one sidx box, like live fragmented MP4
files, it was previously re-reading and seeking on every singl
sidx box, leading to extremely poor performance on larger files,
especially over the network.

Only do it on the first one, and stash its result.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-09-03 19:04:29 +01:00
John Stebbins 9f4054a0cb libavformat/mov: fix multiple trun per traf
dts would start over at the beginning of each trun when they should be
computed contiguously for each trun in a traf

Fixes ticket 8070

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-11 18:15:58 +02:00
Matthieu Bouron 1921f866ec avformat/mov: parse sdtp atom and set the pkt disposable flag accordingly
Allows the creation of the sdtp atom while remuxing MP4 to MP4. This
atom is required by Apple devices (iPhone, Apple TV) in order to accept
2160p medias.
2019-10-12 14:36:15 +02:00
chcunningham 3ea87e5d9e avformat/mov.c: require tfhd to begin parsing trun
Detecting missing tfhd avoids re-using tfhd track info from the previous
moof. For files with multiple tracks, this may make a mess of the
avindex and fragindex, which can later trigger av_assert0 in
mov_read_trun().

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-08 12:00:59 +01:00
Justin Ruggles d2047c14c0 Use QT format for audio sample descriptors depending on stsd version.
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>
2018-09-09 19:52:53 +01:00
John Stebbins c9a992d931 lavf/mov: add AVCodecTag entry for GoPro metadata
This allows for validation of the track type

Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-08 19:08:34 -03:00
Carl Eugen Hoyos fa35ab80f3 lavf/isom: Make auxiliary_offsets consistently uint64_t.
Fixes a compilation warning if size_t != uint64_t:
libavformat/mov.c: In function ‘mov_read_saio’:
libavformat/mov.c:6207:45: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
         encryption_index->auxiliary_offsets = auxiliary_offsets;
                                             ^
2018-07-25 20:06:04 +02:00
Jacob Trimble e5ba5fab49 avformat/mov: Fix parsing of saio/siaz atoms in encrypted content.
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>
2018-04-21 00:45:31 +02:00
Jacob Trimble baf9c0bd99 avformat/mov: Remove old encryption info methods.
Signed-off-by: Jacob Trimble <modmaker@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-19 21:49:47 +02:00
Jacob Trimble f7221d8e67 avformat/mov: Increase support for common encryption.
- 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>
2018-04-19 03:15:32 +02:00
Sasi Inguva 43205df645 lavf/mov.c: Use the correct offset to shift timestamp when seeking.
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>
2018-03-10 17:55:50 +01:00
John Stebbins 00d454ed2c lavf/movenc: add sdtp (sample dependency) box
The sdtp is required by the AppleTV 4K in order to play 2160p60 video.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-02 19:14:34 +01:00
James Almer 4bb09bf5a0 Merge commit '604fbb3132e88727e496c96c92cfe02748c25a1a'
* commit '604fbb3132e88727e496c96c92cfe02748c25a1a':
  mov: Move code shared with CAF to a separate file

Merged-by: James Almer <jamrial@gmail.com>
2017-10-26 15:21:59 -03:00
John Stebbins 4a9d32baca mov: fix decode of fragments that overlap in time
When keyframe intervals of dash segments are not perfectly aligned,
fragments in the stream can overlap in time. The previous sorting by
timestamp causes packets to be read out of decode order and results
in decode errors.

Insert new "trun" index entries into index_entries in the order that
the trun are referenced by the sidx.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-10-23 12:41:04 +02:00
Pablo Montilla 1015982f45 lavf/mov: Allow reading very large files.
The Sample count in the time-to-sample table is defined as
32-bit unsigned integer by the QT specification.

Fixes ticket #6700.
2017-09-28 23:46:57 +02:00
James Almer b35f6d3aa3 Merge commit '53ea595eec984e3109310e8bb7ff4b5786d91057'
* commit '53ea595eec984e3109310e8bb7ff4b5786d91057':
  mov: Rework stsc index validation

See e26e6240b6.

Merged-by: James Almer <jamrial@gmail.com>
2017-09-27 20:43:17 -03:00
Dale Curtis 37e8edc9f5 avformat/mov: Fix trampling of ctts during seeks when sidx support is enabled.
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>
2017-08-24 11:02:22 +02:00
James Almer 24133973fc avformat/mov: add support for reading Content Light Level Box
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>
2017-05-27 16:14:24 -03:00
James Almer ab05bd6e6c avformat/mov: add support for reading Mastering Display Metadata Box
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>
2017-05-27 16:09:55 -03:00
Diego Biurrun 604fbb3132 mov: Move code shared with CAF to a separate file 2017-04-03 13:50:00 +02:00
Sasi Inguva ef71dc7948 lavf/mov.c: Add -advanced_editlist option for mov format.
Adding an MOV format option to turn on/off the editlist supporting code, introduced in ca6cae73db

Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-31 13:59:21 +02:00
Vittorio Giovara 53ea595eec mov: Rework stsc index validation
In order to avoid potential integer overflow change the comparison
and make sure to use the same unsigned type for both elements.
2017-02-10 16:26:16 -05:00