Commit graph

844 commits

Author SHA1 Message Date
Mathieu Duponchelle ee99cd7037 qtmux: Fix leak
gst_qt_mux_can_renegotiate () gets called everywhere following
that pattern:

return gst_qt_mux_can_renegotiate (ref(self));

This means the reference must be released both in the success
and failure cases, it was only done in the success case.
2018-04-13 22:49:43 +02:00
Edward Hervey 2662f58cc9 qtdemux: Fix comparision for extra caption atom
We want to make sure we have *enough* data for the potential 2nd
caption atom.

CID #1434161
2018-04-11 08:51:32 +02:00
Edward Hervey 8213fc2edf qtdemux: Handle bogus caption samples
Corrupted files could potentially have multiple cdat/cdt2 atoms in
a sample entry, which is unclear how to handle.

Ignore repeated ones.

CID #1434162
CID #1434159
2018-04-11 08:45:06 +02:00
Edward Hervey 7229bfd068 qtmux: Add comments and doc about prefill mode 2018-04-09 15:25:50 +02:00
Edward Hervey cc0c27850a qtmux: Refactor pad re-negotiation code
It was similar for all pads

https://bugzilla.gnome.org/show_bug.cgi?id=606643
2018-04-09 15:25:50 +02:00
Edward Hervey 2869edeea2 qtdemux: Detect and expose CEA 608/708 Closed Caption tracks
https://bugzilla.gnome.org/show_bug.cgi?id=606643
2018-04-09 15:25:50 +02:00
Edward Hervey d7038b9bb0 qtdemux: Handle variant of vorbis in mp4
Comes from gpac apparently. The codec_data uses the same packing
mechanism as matroska.

https://bugzilla.gnome.org/show_bug.cgi?id=738244
2018-03-22 15:22:33 +01:00
Edward Hervey 60bc77cc35 qtdemux: Check sample count is valid in PIFF parsing
The value stored in cenc_aux_sample_count wasn't in sync with the
parsing code that followed which checks whether all entries are
valid and present.

Only write the actual sample count when we know for sure.

CID #1427087
2018-03-22 15:22:24 +01:00
Sebastian Dröge 850e678813 qtdemux: Fix seeking on streams with frame reordering
The samples table is sorted by DTS, not PTS. As such we can only get the
correct result when using a binary search on it, if we search for the
DTS.
Also if we only ever search for the frame, where the following frame is
the first one with a PTS after the search position, we will generally
stop searching too early if frames are reordered.

In forwards playback this is not really a problem (after the decoder
reordered the frames, clipping is happening), in reverse playback
it means that we can output one or more frames too few as we stop too
early and the decoder would never receive it.

https://bugzilla.gnome.org/show_bug.cgi?id=782118
2018-03-20 12:08:28 +02:00
Edward Hervey 192b447e0b qtdemux: Fix comment typo in previous commit 2018-02-09 11:26:56 +01:00
Edward Hervey e16be12e37 qtdemux: More 'meta' atom parsing fixes
Turns out everybody is doing it their own way, so peek into the
meta atom itself to figure out which spec it is following
2018-02-09 11:22:38 +01:00
Sebastian Dröge e7177059e9 qtmux: Add support for muxing svmi atom for stereoscopic video information
https://bugzilla.gnome.org/show_bug.cgi?id=793120
2018-02-09 11:05:02 +02:00
Edward Hervey 4fd8635983 qtdemux: Minor cleanup
Just move variables to the blocks where they are used.

That function is massive, could do with some splitting up for
readability :(
2018-02-09 09:00:46 +01:00
Edward Hervey 357d77cf55 qtdemux: Cope with difference between QTFF and ISO BMFF specs
The 'meta' atom is defined differently in QTFF and BMFF, so try
to guess which spec the current stream applies to by looking
at the major file type.
2018-02-09 09:00:46 +01:00
Edward Hervey b415358c7e isomp4: Make 'hdlr' atom dump more flexible
The smallest possible is 24 (and not 25) bytes.

The last "name" field can according to QTFF specifications not be present
at all. The parser will handle this fine and so will the rest of
the qtdemux code.
2018-02-09 09:00:46 +01:00
Justin Kim ad8a6cb639 qtmux: send stream warning when refusing video caps
If codec_data is changed, the stream is no longer valid.
Rather than keeping running when refusing new caps,
this patch send a warning  to the bus.

Also fix up splitmuxsink to ignore this warning while changing caps.

https://bugzilla.gnome.org/show_bug.cgi?id=790000
2018-02-01 10:12:46 +00:00
Edward Hervey 0c56a80333 isomp4: Add gmhd/gmin debugging
* gmhd is a container, mark it as such so we can see/dump
  what is contained within
* Add dumping for the Base Media Information atom (gmin)
2018-01-31 19:12:48 +01:00
Edward Hervey 0511c4c225 qtdemux_dump: Demote verbose logging to TRACE level 2018-01-31 11:38:35 +01:00
Edward Hervey 40be9f4f85 qtdemux: Re-enable full debug logging of stsz entries
No idea why it was disabled (was the case since 2007)
2018-01-31 11:23:07 +01:00
Seungha Yang 75241cfa6b qtdemux: Remove white space at end of line
https://bugzilla.gnome.org/show_bug.cgi?id=791483
2018-01-29 18:42:47 +00:00
Seungha Yang 1551759cec qtdemux: Apply qtdemux debug category to gstisoff
.. instead of the use of default debug category.
And, make new header to declare the debug category

https://bugzilla.gnome.org/show_bug.cgi?id=791483
2018-01-29 18:40:02 +00:00
Alicia Boya García ac46d5c2a3 qtdemux: Add more prose to the comment of gst_qtdemux_find_sample()
https://bugzilla.gnome.org/show_bug.cgi?id=792910
2018-01-25 20:40:46 +00:00
Vivia Nikolaidou 379059b1c7 qtmux: Make sure timecode uses the same timescale as video
Don't blindly derive it from the frame rate, but try to get the per-pad
configured timescale first (if it exists)

https://bugzilla.gnome.org/show_bug.cgi?id=792680
2018-01-23 16:40:36 +02:00
Sebastian Dröge c71cd08d0e qtmux: Allow configuring trak timescale per pad/trak
It generally makes not much sense to configure it for all pads/traks at
once as this value is usually different for each of them. As such, add a
new property on the pads in addition to the existing property on the
whole muxer.

https://bugzilla.gnome.org/show_bug.cgi?id=792649
2018-01-23 16:40:23 +02:00
Edward Hervey 6e21faffe7 qtdemux: Push a GAP event if there's a second *or more*
And not "more than a second"
2017-12-13 12:06:49 +01:00
Edward Hervey 2e45926a96 qtdemux: Don't push GAP event if first buffer is within 1s
If we saw empty segments, we previously unconditionally pushed a
GAP event downstream regardless of the duration of that empty
segment.

In order to avoid issues with initial negotiation of downstream elements
(which would negotiate to something before receiving any data due to
that initial GAP event), check if there's at least a second of difference
(like we do for other GAP-related checks in qtdemux) before
deciding to push a GAP event downstream.
2017-12-13 11:35:37 +01:00
Edward Hervey 5c341f0980 qtdemux: Don't set pared=True on underspecified audio/mpeg
This *really* needs to go through a parser to figure out what the
exact content type is.
2017-12-13 10:21:17 +01:00
Florian Zwoch b4ca81591c qtdemux: fix debug log for 'hvcC' codec_data
https://bugzilla.gnome.org/show_bug.cgi?id=784749
2017-12-02 13:46:29 +00:00
Jan Schmidt a260eb80fb qtmux: Always update reserved-duration-remaining
If a reserved-max-duration is set, we should always track
and update the reserved-duration-remaining estimate, even
if we're not sending periodic moov updates downstream for
full robust muxing.
2017-11-25 00:56:11 +11:00
Edward Hervey 22ab222dbc qtdemux: Run gst-indent 2017-11-23 08:00:58 +01:00
Edward Hervey d08e155ec8 qtdemux: Check presence of bitrate tags
Check whether the tag was present before printing it out

CID #1418501
2017-11-23 07:57:44 +01:00
Jan Schmidt 3ba556a54d qtdemux: Use new GST_SEQNUM_INVALID constant 2017-11-18 02:33:01 +11:00
Jun Xie 7c8aeff262 qtdemux: reset reused QtDemuxStream while parsing a new 'trak'
if QtDemuxStream is reused, then we need to reset it.

https://bugzilla.gnome.org/show_bug.cgi?id=788759
2017-11-17 11:49:24 +02:00
Seungha Yang 8aa5c59b5f isomp4: Add official fourcc for VP8 codec
fourcc for VP8 codec is "vp08" defined by spec. To follow it,
add it to demux and change legacy VP8 fourcc "VP80" to "vp08" in mux.
Also, enable sync table in case of VP8 codec.
See also https://www.webmproject.org/vp9/mp4/

https://bugzilla.gnome.org/show_bug.cgi?id=790026
2017-11-13 10:08:14 -05:00
Seungha Yang 93f19b19d2 isomp4: Add support VP9 codec
Add fourcc for VP9 codec and support it by qtdemux and qtmux
See also https://www.webmproject.org/vp9/mp4/

https://bugzilla.gnome.org/show_bug.cgi?id=790026
2017-11-13 10:08:14 -05:00
Ashish Kumar 1aed3948a8 gst-plugins-good: atoms_recovery: Handled buffer mapping failure
https://bugzilla.gnome.org/show_bug.cgi?id=789413
2017-10-24 22:04:27 -07:00
Thiago Santos 923b83a48c atomsrecovery: read from mdat only what is on headers
It is possible that the mdat has more data than what was stored in the
headers file. If we put that to the output the file will have bogus data
at the end and some players will complain.

https://bugzilla.gnome.org/show_bug.cgi?id=784258
2017-10-24 21:33:25 -07:00
Thiago Santos 69605b6c61 isomp4: atomsrecovery: handle common and large atom headers
Do not assume all files are large files. Check and use the short or
extended atom size field only if needed.

https://bugzilla.gnome.org/show_bug.cgi?id=784258
2017-10-24 21:33:25 -07:00
Sebastian Dröge 728a1629cf qtdemux: Fix compiler warning
qtdemux.c: In function ‘gst_qtdemux_configure_stream’:
qtdemux.c:7764:34: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
     if ((stream->n_samples == 1) && (stream->first_duration == 0)
         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-10-10 18:04:50 +03:00
Nael Ouedraogo 5874bafa4f qtdemux: fix assert when moof containing one sample
Avoid computing frame rate when a stream contain moof with only one
sample, to avoid an assert. The moof is considered as still picture.

The same is already done for one sample given in the moov.

https://bugzilla.gnome.org/show_bug.cgi?id=782217
2017-10-10 18:03:42 +03:00
Jan Schmidt d191584531 qtmux: Allow MPEG layer 1/2, AC3 and Opus in qtmux
qtmux is supposed to be the muxer that allows all formats,
with others (mp4mux and friends) being profile-restricted.
2017-09-06 23:55:38 +10:00
Michael Olbrich 61429a78a8 qtdemux: allow larger files
For really long files such as contiguous recordings of a whole day, the
50MB limit is not sufficient.

https://bugzilla.gnome.org/show_bug.cgi?id=781458
2017-08-10 16:17:56 +03:00
Sebastian Dröge 7d89e73336 qtdemux: Fix offsets for reading lpcm specific fields
We were reading at the completely wrong positions, 16 bytes later in the
data.

Also add support for high-aligned samples.
2017-08-10 16:13:05 +03:00
Mark Nauwelaerts 7bd439efb5 qtdemux: preferably send open-ended segment rather than repeated segment events 2017-07-19 18:35:58 +02:00
Mark Nauwelaerts 854f85acb4 qtdemux: fix seeking in fragmented file without mfra random access info
... which no longer worked due to unconditionally clearing sample info and
ending up in inconsistent state.  Let's tread a bit more carefully and also
allow for the old seek handling that resorts to scanning if no mfra info
is available.
2017-07-19 18:35:49 +02:00
Sebastian Dröge c0318f3d60 qtdemux: Fix parsing of RLE depth
Regression introduced by 86b427dc70

https://bugzilla.gnome.org/show_bug.cgi?id=784812
2017-07-13 12:47:27 +03:00
Mark Nauwelaerts f9f1a03653 qtmux: robustify time tracking for sparse subtitle stream 2017-07-01 18:59:14 +02:00
Mark Nauwelaerts d1d149ce82 qtmux: correctly track chunk size of subtitle stream
... thereby ensuring correct chunk offset tracking for all streams.
2017-07-01 18:59:07 +02:00
Mark Nauwelaerts 83987b5037 qtdemux: specify '_swr' atom as a container atom
... so it is parsed as an mp4 style metadata atom as written by muxer
2017-06-28 20:00:44 +02:00
Mark Nauwelaerts dbcb99ac1d qtmux: initialize mdhd language code as undefined 2017-06-28 20:00:44 +02:00
Mark Nauwelaerts 949902f1e2 qtmux: correctly calculate overall first_ts to ensure stream sync
... by minding and compensating for the dts_adjustment that may have
been introduced in the PTS timeline.
2017-06-24 17:36:54 +02:00
Tim-Philipp Müller 3a0fe9c2f5 qtmux: add support for muxing PNG
Demuxer already supported it.
2017-06-15 23:31:24 +01:00
Sebastian Dröge deb9c62cd9 qtmux: Un-merge the last two stsc entries after serializing
The last entry will most likely get new samples added to it in "robust"
muxing mode, changing the samples_per_chunk and thus making it wrong to
keep the last two entries merged. It will run into an assertion later
when adding a new sample to the chunk.

Thanks to gdiener@cardinalpeak.com for the analysis of the bug and
proposal for a solution.
2017-06-15 11:50:44 +03:00
Jimmy Ohn 55e0b18186 qtdemux: remove not needed code
remove not needed code about res variable.

https://bugzilla.gnome.org/show_bug.cgi?id=783422
2017-06-06 11:02:59 +02:00
Edward Hervey 4f713717de isomp4: Safely ignore [skip] atoms
Instead of warning about them
2017-05-18 18:12:15 +02:00
Nicolas Dufresne b68d936ae0 Remove plugin specific static build option
Static and dynamic plugins now have the same interface. The standard
--enable-static/--enable-shared toggle are sufficient.
2017-05-16 14:41:19 -04:00
Vivia Nikolaidou 5f7fe63fea qtmux: Do not check timecode data for mp4 container
Timecode trak is only supported for mov right now, not for mp4. That
code would otherwise create an invalid trak if the muxed video contained
timecode metadata.

https://bugzilla.gnome.org/show_bug.cgi?id=782684
2017-05-16 15:16:58 +03:00
Sebastian Dröge 347e814074 qtmux: When accepting renegotiation, just return TRUE and change nothing
We only accept new caps if they are basically the same. We don't want to
reset anything as if the caps are new, otherwise various state could get
out of sync with the current run.
2017-05-11 20:01:15 +02:00
Sebastian Dröge 10f4693163 qtmux: In prefill mode, only pad buffers with > 0 sized memories as needed
Adding a 0-byte memory has not much effect.

Also add some debug output.
2017-05-11 19:21:22 +02:00
Sebastian Dröge 63492ee141 qtmux: Lateness is in QT timescale, diff in GstClockTime
Print the right one in debug output to get meaningful numbers.
2017-05-10 15:58:41 +02:00
Sebastian Dröge 163b62fc25 qtmux: Error out if a gap edit list has to be written in prefill mode
We don't have any space reserved for this in the moov and the
pre-finalized moov would have broken A/V synchronization. Error out here
now
2017-05-10 14:31:40 +02:00
Sebastian Dröge c0f505e80e qtmux: Calculate with reserved moov size instead of last moov size
We have some padding added after the initial moov, so a bigger updated
moov can be handled to some degree and is expected. Previously we just
ignored the padding and errored out in cases when the padding would've
just been enough.
2017-05-10 11:42:09 +02:00
Sebastian Dröge 419f53259f qtmux: Error out directly if sending filler data results in a flow error
CID 1405994
2017-05-10 11:12:23 +02:00
Sebastian Dröge 3fcfe774e6 qtmux: In prefill mode, handle the case when only the first chunk was ever used 2017-05-09 16:02:43 +02:00
Sebastian Dröge 55f949676e qtmux: Add new prefill recording mode
This sets up a moov with the correct sample positions beforehand and
only works with constant framerate, I-frame only streams.

Currently only support for ProRes and raw audio is implemented but
adding new codecs is just a matter of defining appropriate maximum frame
sizes.

https://bugzilla.gnome.org/show_bug.cgi?id=781447
2017-05-09 14:17:04 +02:00
Sebastian Dröge f0163a016c qtmux: Error out on discontinuities/gaps when muxing raw audio
When muxing raw audio, we have no way of storing timestamps but are just
storing a continuous stream of audio samples. If the difference between
the expected and the real timestamp becomes to big, we should error out
instead of silently creating files with wrong A/V sync.

https://bugzilla.gnome.org/show_bug.cgi?id=780679
2017-05-09 14:16:51 +02:00
Seungha Yang 66448be77f qtdemux: Fix crash on mss stream caused by invalid stsd entry access
Since mss has no moov, default stsd entry should be created with media-caps.

https://bugzilla.gnome.org/show_bug.cgi?id=782042
2017-05-02 14:20:02 +03:00
Sebastian Dröge 875fc630d5 qtdemux: Don't crash in debug output if stream==NULL
That case is correctly handled below but not in the debug output.

https://bugzilla.gnome.org/show_bug.cgi?id=781270
2017-04-27 12:56:27 +03:00
Sebastian Dröge a593e4966e qtdemux: Don't perform seeks with inconsistent seek values
If gst_segment_do_seek() fails, we shouldn't try seeking on that
resulting segment but just error out. Crashes further down the line
otherwise.
2017-04-25 17:12:30 +03:00
Jürgen Sachs 7c658c3c04 qtdemux: reset sample_description_id to default
Fixes stream where sample_description_id is specified in the tfhd

https://bugzilla.gnome.org/show_bug.cgi?id=778337
2017-04-21 06:45:10 +02:00
Edward Hervey 58e3033747 qtdemux: Reset adapter in more discontinuity cases
In push mode we process as much as possible in the adapter. When we receive
a DISCONT buffer which we can't match to an actual sample (based on the existing
sample table) and there is still data remaining in the incoming adapter,there is
one of two cases happening:
1) We are doing reverse playback, in which case we should flush out all pending
  data
2) We have leftover data from the previous incoming buffer... which we can't do
  anything about.

For the second case, make sure we flush out the remaining data so that we can start
parsing again from scratch.

https://bugzilla.gnome.org/show_bug.cgi?id=781319
2017-04-17 13:10:06 +02:00
Seungha Yang 3b9ea4b85f qtdemux: Fix leak on QtDemuxStreamStsdEntry
Fix unit test failure

https://bugzilla.gnome.org/show_bug.cgi?id=781362
2017-04-16 23:37:55 +01:00
Sebastian Dröge e51c08b0a2 qtmux: Fix timescale of timecode tracks
They should have ideally the same timescale of the video track, which we
can't guarantee here as in theory timecode configuration and video
framerate could be different. However we should set a correct timescale
based on the framerate given in the timecode configuration, and not just
use the framerate numerator.
2017-04-14 13:38:53 +03:00
Edward Hervey c6e9c67f63 qtdemux: Properly reset demuxer when all streams are EOS
Make sure offset and neededbytes are properly resetted when all
streams are EOS in push-mode.

Avoids cases when some data might still be pushed by upstream (because
it didn't yet see the resulting GST_FLOW_EOS yet) and qtdemux gets
completely lost.

https://bugzilla.gnome.org/show_bug.cgi?id=781266
2017-04-13 13:26:36 +02:00
Edward Hervey 7077425c3d qtmux: Don't forget to update pad->last_buf
buf is the current pad->last_buf value. If ever it gets copied/unreffed,
we need to make sure to write back the new  pointer to the last_buf
variable.

Fixes using wrong pointer values in the case of decrasing DTS value
2017-04-12 13:26:59 +02:00
Jürgen Sachs 9684c88c60 qtdemux: fix: sample description index override in tfhd not evaluated
https://bugzilla.gnome.org/show_bug.cgi?id=778337
2017-04-12 11:04:46 +02:00
Edward Hervey 26f9869668 qtdemux: Add out-of-bound check
Make sure we don't read invalid memory
2017-04-12 11:03:24 +02:00
Thiago Santos 9ac3861a9b qtdemux: move parsing of tkhd out of stsd entry loop
It needs only to be read once.
2017-04-11 23:42:56 -07:00
Thiago Santos cf6733a55e qtdemux: check for a different stsd entry before pushing a sample
Before pushing a sample, check if there was a change in the current
stsd entry. This patch also assumes that the first stsd entry is
used as default for the first sample. It might cause an uneeded
caps renegotiation when this isn't the case.
2017-04-11 23:42:56 -07:00
Thiago Santos 86b427dc70 qtdemux: parse all stsd entries
stsd can have multiple format entries, parse them all.

This is required to play DVB DASH profile that uses multiple entries
to identify the different available bitrates/options on dash streams

The stream format-specific data is not stored into QtDemuxStreamStsdEntry
2017-04-11 23:42:55 -07:00
Thiago Santos 54e252e095 qtdemux: rework stsd sample entries access
Instead of using the stsd as a base pointer, use the actual stsd
entry as the stsd can have multiple entries. This is rarely used
for file playback but is a possible profile with in DVB DASH specs.

This still doesn't support stsd with multiple entries but makes it
easier to do so.
2017-04-11 14:13:56 -07:00
Thiago Santos bd32bcc36c qtdemux: get stsd child by index instead of type
There might be multiple children with the same type
2017-04-11 14:13:56 -07:00
Sebastian Dröge d6b145df5f qtmux: Fix last_dts tracking for raw audio and similar formats
Accumulate the durations directly and don't scale yet another time by
the number of samples.
2017-04-10 15:55:54 +03:00
Sebastian Dröge 6f3737f0c5 qtmux: Simplify buffer refcounting in add_buffer() and remove unneeded NULL checks 2017-04-04 15:24:45 +03:00
Sebastian Dröge 6b889bea69 qtmux: Select the best pad based on the cached last_buf if any
last_buf is the one we're going to write next, not buf. As such we
should check timestamps against that one if there is one to select the
earliest pad.

Also remember the currently selected pad in the very beginning when
storing the first last_buf.

This both solves some edge cases where not the correct next pad was
selected corresponding to the target interleave.
2017-04-04 15:24:45 +03:00
Sebastian Dröge eb307baff4 qtmux: Error out immediately if a timecode is to be written but downstream return not-OK 2017-04-04 15:24:45 +03:00
Edward Hervey 1e4cdc6d6f qtdemux: Update variables before early exit
This is an update of d78d589627

We still exit as early as possible in case of non-ok/non-unlinked combined
flow, but we first make sure that we update the internal position variables.

This ensures that if upstreams "ignores" the flow return (and carries on pushing),
we don't end up processing data with completely bogus variables/positions.
2017-04-03 11:37:52 +02:00
Sebastian Dröge 2b50a338c3 qtdemux: In gap mode, consider the mdat offset when calculating the remaining mdat size
The mdat generally does not start at offset 0, we have to include the
size of the moof and whatever else was in front of the mdat.
2017-03-27 21:52:51 +03:00
Sebastian Dröge ea4e9fc2d4 atomsrecovery: Error out when fseek() fails instead of silently ignoring
CID 1403262
2017-03-27 11:43:57 +03:00
Sebastian Dröge e66d75ec87 qtmux: Remove some unused variables 2017-03-23 17:53:54 +02:00
Sebastian Dröge ebdaca603c qtmux: Remove a couple of unneeded levels of indentation 2017-03-23 15:02:03 +02:00
Enrique Ocaña González 28a57d0586 qtdemux: distinguish TFDT with value 0 from no TFDT at all
TFDTs with time 0 are being ignored since commit 1fc3d42f. They're
mistaken with the case of not having TFDT, but those two cases
must be distinguished in some way.

This patch passes an extra boolean flag when the TFDT is present.
This is now the condition being evaluated, instead of checking for
0 time.

https://bugzilla.gnome.org/show_bug.cgi?id=780410
2017-03-23 08:28:53 +11:00
Sebastian Dröge 9c121b09a5 qtmux: Reset current chunk after writing out timecode
If we have multiple tracks with timecodes, or it's not the first track
that has timecodes, or not the first buffer, we already started a chunk
for media data. We now need to "close" that chunk because we wrote data
for the timecode track and a new chunk has to be started for the
original track the next time it has data.
2017-03-22 19:16:33 +02:00
Sebastian Dröge cb6aab8685 qtmux: Do timecode handling per track, not per muxer instance
There could be multiple video tracks with timecodes.
2017-03-22 18:53:19 +02:00
Jan Schmidt d76bd1913f qtdemux: matroskademux: Ignore repeated seek events
Similar to what was done in adaptivedemux, ignore seek
events we've already handled - such as when they are received
on every srcpad of files with lots of streams.
2017-03-22 00:40:01 +11:00
Sebastian Dröge a56a01f15f dashdemux: Update mdatleft from overall mdatsize and offset when observing a gap
Otherwise mdatleft will have a value calculated from the initial
mdatsize minus the parts of the stream that we saw, which is not
including all the parts of the stream that might've been skipped.
2017-03-21 14:56:55 +02:00
Thiago Santos b434ba86f1 atomsrecovery: also handle extra atoms after 'mdia' in a 'trak'
Take into account the atoms at the end of the 'trak' atom when
recovering it. So that its size (already computed and added in the trak
size) isn't making offsets wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=771478
2017-03-14 20:27:48 -07:00
Thiago Santos 7e39dec391 qtmux: avoid fallthrough to moovrecovery failure section
Return before that to preserve our successfull results, otherwise no
moov recovery information would be written

https://bugzilla.gnome.org/show_bug.cgi?id=771478
2017-03-14 20:27:48 -07:00
Thiago Santos 4d9b17ad77 atomsrecovery: expect more atom types at the headers
Skip more atoms at the header until it finds the 'mdat' to continue the
moov recovery

https://bugzilla.gnome.org/show_bug.cgi?id=771478
2017-03-14 20:27:48 -07:00
Emeric Grange 534be3313c qtmux: add CineForm support
https://bugzilla.gnome.org/show_bug.cgi?id=780024
2017-03-14 18:03:34 +02:00
Sebastian Dröge 6cb8c802f4 qtmux: Only create new chunks if we have more than a single stream
There's no point in creating multiple chunks otherwise, it only wastes
some bytes for storing the chunk offsets.
2017-03-14 15:09:44 +02:00
Emeric Grange 7bdcd57980 qtdemux: add S16L support
https://bugzilla.gnome.org/show_bug.cgi?id=780022
2017-03-14 14:55:44 +02:00
Wim Taymans 16f3fd6782 qtmux: init fourcc
Initialize the fourcc to 0 so that we can detect failure later.
2017-03-10 11:24:14 +01:00
Sebastian Dröge 98583dc944 qtmux: Free EDTS instead of just clearing it and setting it to NULL 2017-03-08 16:01:02 +02:00
Sebastian Dröge 0e62a0603d qtmux: Fix some memory leaks related to timecode tracks 2017-03-08 15:27:32 +02:00
Jan Schmidt c82ced1868 qtdemux: Don't lose crypto info on a new moof
We parse the next moof in advance of having pushed
all samples from the previous one in some cases, and
we'll still need the crypto info from the previous
fragment so keep around any unused crypto info entries
when adding new ones
2017-03-04 00:35:32 +11:00
Sebastian Dröge 7709920ca3 qtmux: Update modification times when sending the moov
https://bugzilla.gnome.org/show_bug.cgi?id=779422
2017-03-02 20:33:30 +02:00
Sebastian Dröge ce2070c092 qtdemux: Protect against NULL pointer dereference for streams without caps
CID 1363332
2017-02-28 15:20:31 +02:00
Sebastian Dröge 4c30cbfe22 qtdemux: Fix compilation with gcc 7
qtdemux.c: In function ‘qtdemux_parse_samples’:
qtdemux.c:8450:39: error: ‘*’ in boolean context, suggest ‘&&’ instead [-Werror=int-in-bool-context]
         if (stream->samples_per_frame * stream->bytes_per_frame) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
2017-02-27 21:02:51 +02:00
Jan Schmidt 488e8edba4 Revert "qtdemux: Always snap to the start of the keyframe"
This reverts commit 107902ec51.

This commit intended to ensure that keyframe seeks land at the
start timestamp of a keyframe, rather than in the middle of one,
but they cause trouble on files with sparse streams, or with
JPEG 'cover art' tracks that have only one or a few JPEG samples
with very long durations.

That's still desirable for doing seamless cutting of videos,
but needs a rethink for implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=778690
2017-02-17 13:19:58 +11:00
Jan Schmidt 2987e66f22 qtmux: Add a comment about how atom_trak_set_elst_entry() works 2017-02-09 11:29:43 +11:00
Tim-Philipp Müller c7aa449e58 qtdemux: demote some log messages to TRACE level
Don't spam debug log with uninteresting stuff.
2017-02-09 11:17:02 +11:00
Sebastian Dröge 1426a55a83 qtmux: Clear edit lists every time we recalculate them
We recalculate them, so any old information has to be forgotten.
Otherwise we write invalid edit lists when writing headers multiple
times.

https://bugzilla.gnome.org/show_bug.cgi?id=778330
2017-02-08 17:26:21 +02:00
Tim-Philipp Müller 19c9600ea6 qtdemux: sanity check number of segments in edit list
Fixes crash with fuzzed file.

https://bugzilla.gnome.org/show_bug.cgi?id=777940
2017-01-31 20:46:41 +00:00
Seungha Yang 7a6752a7e0 qtdemux: Skip seeking query if upstream format is time
Don't need to querying byte-format seeking for time-format
upstream case

https://bugzilla.gnome.org/show_bug.cgi?id=776715
2017-01-31 17:09:29 +01:00
Seungha Yang d3f5aa2689 qtdemux: Use upstream's StreamFlags if there are
When multiple demuxer's are used, upstream might want to indicate
default streams using GST_STREAM_FLAG_{SELECT, UNSELECT}

https://bugzilla.gnome.org/show_bug.cgi?id=775440
2017-01-31 16:20:42 +01:00
Vivia Nikolaidou af47e93b97 qtmux: Timecode track fixes for STSD entry
The n_frames field (frames per second) should follow the nominal frame
rate for drop-frame timecodes.

Also, the trak's timescale (and duration, accordingly) should follow the
STSD entry's timescale and frame duration (fps_n and fps_d accordingly),
not the other way around.

https://bugzilla.gnome.org/show_bug.cgi?id=777832
2017-01-27 16:41:34 +02:00
Brendan Shanks a9056a8a7e qtmux: Fix debug typo and remove misleading warning
https://bugzilla.gnome.org/show_bug.cgi?id=777362
2017-01-26 15:05:24 +02:00
Sebastian Dröge d1ce68e840 qtmux: Only write 4 byte zero padding to the Video Sample Description in MOV
For MP4 this is not defined, and it actually breaks things for MSE in
Chrome if we do this. For MOV this is required by some broken software
but the official specification says it's optional:
https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html

https://bugzilla.gnome.org/show_bug.cgi?id=777540
2017-01-24 17:59:59 +02:00
Sebastian Dröge 1ffef8bf60 qtdemux: Increment current stts index whenever we finished one stts entry
Otherwise we could read more chunks than there are available, doing an
out of bounds read and potentially crash.

https://bugzilla.gnome.org/show_bug.cgi?id=777469
2017-01-19 13:46:58 +02:00
Sebastian Dröge db1757503d Revert "qtdemux: Increment current stts index in all code paths after reading one chunk"
This reverts commit 99d5d7570d. It broke
playback of various valid files.
2017-01-19 13:25:53 +02:00
Sebastian Dröge 99d5d7570d qtdemux: Increment current stts index in all code paths after reading one chunk
Otherwise we could read more chunks than there are available, doing an
out of bounds read and potentially crash.

https://bugzilla.gnome.org/show_bug.cgi?id=777469
2017-01-19 12:25:41 +02:00
David Warman 642331fd7f qtdemux: avoid XMP tag parsing fatal error.
qtdemux_handle_xmp_taglist() requires a writable taglist,
but qtdemux->tag_list can become non-writable, specifically
after sending global tags (qtdemux.c:958), which adds a
second reference.  Ensure the list is made writable before
calling (make_writable will copy the list if necessary).

https://bugzilla.gnome.org/show_bug.cgi?id=766177
2017-01-17 23:26:02 -03:00
Thiago Santos 5bb7ca8a62 qtdemux: rework taglist handling
Keep taglist around during element existance to avoid having to
create it at different places before usage. Makes code simpler to handle.

https://bugzilla.gnome.org/show_bug.cgi?id=766177
2017-01-17 22:41:43 -03:00
Aurélien Zanelli 6769dce5c1 qtmux: add 4444 and 4444xq variants to video/x-prores pad template caps
They are handled since commit 7b565475bf
(qt: Add support for ProRes 4444 XQ).

https://bugzilla.gnome.org/show_bug.cgi?id=777377
2017-01-17 12:52:05 +02:00
Georg Lippitsch d71c06c8fe qtmux: Don't write Sync Sample Atom for ProRes
https://bugzilla.gnome.org/show_bug.cgi?id=777331
2017-01-16 19:29:08 +02:00
Tim-Philipp Müller 5404304fac qtdemux: boldly assume that first 'covr' image is the front cover 2017-01-14 15:16:53 +00:00
Tim-Philipp Müller 59fd44a56f qtdemux: extract cover art images into GST_TAG_IMAGE not PREVIEW_IMAGE
These are usually much bigger than icon size and required by
iTunes to be certain fairly large sizes. In qtmux it is also
the IMAGE tags which we write out as 'covr' atoms.
2017-01-14 15:13:39 +00:00
Jan Schmidt b0e38ed374 qtmux: Don't reset request pad numbering across uses
When reset, don't restart request pad numberings, as
request pads can survive across state changes. Only
restart at 0 if all request pads are handed back first.

https://bugzilla.gnome.org/show_bug.cgi?id=777174
2017-01-13 10:37:21 +11:00
Aurélien Zanelli 52d1355d87 qtmux: simplify video/x-h264 caps handling
'stream-format' and 'alignment' are defined in pad template caps so
there is no need to check them again here. Also remove bitrate parsing from
caps as bitrate in caps doesn't make sense but from tags, which is
actually the case.

https://bugzilla.gnome.org/show_bug.cgi?id=777181
2017-01-12 19:16:57 +02:00
Aurélien Zanelli 4c6a69fdff qtmux: add basic HEVC/H.265 muxing support
https://bugzilla.gnome.org/show_bug.cgi?id=736752
2017-01-12 19:16:23 +02:00
Georg Lippitsch fcdba65302 qtmux: Calculate clean aperture size
Calculate clean aperture dimensions by first guessing
display aspect ratio based on pixel aspect ratio and
frame size.

https://bugzilla.gnome.org/show_bug.cgi?id=777100
2017-01-12 19:09:22 +02:00
Sebastian Dröge e12c94065d qtmux: Write tapt atom for MOV files if PAR not 1/1
Needed for QuickTime 7 to properly play files.

Also write the clap atom for MOV files always, not only when ProRes is
used as a video codec. It's mandatory for MOV.

https://bugzilla.gnome.org/show_bug.cgi?id=777100
2017-01-12 19:09:22 +02:00
Andre McCurdy 29433495d6 qtdemux: free seqh after calling qtdemux_parse_svq3_stsd_data()
The seqh buffer allocated in qtdemux_parse_svq3_stsd_data() needs to
be freed by the caller after use.

https://bugzilla.gnome.org/show_bug.cgi?id=777157

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
2017-01-12 11:10:50 +02:00
Edward Hervey 4a279f4499 isomp4: Don't spam debug log with knonw/padding atoms
Only output WARNING messages for atoms we don't know how to handle
instead of for padding/known atoms we don't need to do any processing
on

https://bugzilla.gnome.org/show_bug.cgi?id=777095
2017-01-10 16:03:00 +01:00
Jan Schmidt 12ad37fdb3 qtmux: Write tfdt atom into fragmented files.
The DASH spec requires that tfdt atoms be present, so
write one out. ISO/IEC 23009-1:2014 6.3.4.2

https://bugzilla.gnome.org/show_bug.cgi?id=708221
2017-01-08 01:23:52 +11:00
Jan Schmidt 1fc3d42f8a qtdemux: Don't reset output timestamps when no tfdt
If a fragmented stream doesn't have a tfdt, don't
reset the output timestamps at each fragment boundary
by erroneously using the default value of 0. Introduced
by commit 69fc48

https://bugzilla.gnome.org/show_bug.cgi?id=754230
2017-01-07 23:57:35 +11:00
Thibault Saunier 9d1942f286 meson: Install presets files 2017-01-05 09:49:21 -03:00
Jan Schmidt 107902ec51 qtdemux: Always snap to the start of the keyframe
When performing a key-unit seek, always snap to the start ts
of the keyframe buffer we landed on so that the keyframe is
entirely within the resulting outgoing segment. That seems
the most sensible result, since the user requested snapping
to the keyframe position.
2017-01-03 01:34:02 +11:00
Jan Schmidt f415730fdf qtdemux: Omit cslg_shift when snapping seeks
Segments times and seek requests are stored and handled
in raw 'PTS' time, without the cslg_shift - which only applies
to outgoing samples. Omit the cslg_shift portion when
extracting PTS to compare for internal seek snaps.

If the cslg_shift is included, then keyframe+snap-before seeks
generate a segment start/stop time that already includes the
cslg_shift, and it's then added a 2nd time, causing the
first buffer(s) to have timestamps that are out of segment.
2017-01-03 01:34:02 +11:00
Jan Schmidt db0eddb10f qtmux: Remove bogus check in atom_stsc_add_new_entry()
Remove an old check from atom_stsc_add_new_entry() that
extends the last entry in the STSC if the samples per chunk
matches, as the new interleave merging logic requires that
the final entry by updateable. There's already code
below which simply merges the final entry into the previous
one when needed, so rely on that instead.

Fixes asserts like:

ERROR:atoms.c:2940:atom_stsc_update_entry: assertion failed:
(atom_array_index (&stsc->entries, len - 1).first_chunk == first_chunk)
2017-01-03 01:34:02 +11:00
Seungha Yang 65c5d6d080 qtdemux: Fix key_time in gst_qtdemux_adjust_seek()
time in segment should be PTS based (not DTS).

https://bugzilla.gnome.org/show_bug.cgi?id=765498
2017-01-03 01:34:02 +11:00
Mark Nauwelaerts 867ce71922 qtdemux: implement pull mode SNAP flag seeking 2016-12-29 12:48:56 +01:00
Sebastian Dröge 76c007dd25 qtdemux: Check if we have enough data available when parsing edit lists
Also consume the data entry by entry to get complicated indexing out of
the code.

https://bugzilla.gnome.org/show_bug.cgi?id=776107
2016-12-14 21:48:24 +02:00
Sebastian Dröge 35748dc8f2 qtdemux: Check that the XiTh size is big enough
https://bugzilla.gnome.org/show_bug.cgi?id=775794
2016-12-14 10:17:41 +02:00
Heekyoung Seo f7c033f4ec qtdemux: Check node length of video sample description
Add check for node length of video sample description and its fields and
for the XiTh atom.

Also unify the code a bit.

https://bugzilla.gnome.org/show_bug.cgi?id=775794
2016-12-14 10:17:41 +02:00
Heekyoung Seo a5bfaf8a79 qtdemux: Enable xvid/mp2 codec support
Add support for xvid video and mp2 audio, add m2v1 fourcc.

https://bugzilla.gnome.org/show_bug.cgi?id=775794
2016-12-14 10:17:23 +02:00
Edward Hervey 50bb6630f5 qtdemux: Sanitize unknown codec caps
We might have non-printable characters in the unknown fourcc, replace
them with '_', in the same way we do it for unknown tags.
2016-12-02 08:52:06 +01:00
Sebastian Dröge 6939399e96 qtdemux: Increase inflate buffer in bigger steps
1024 bytes is quite small, let's do 4096 bytes (or one page).
Also remove redundant if, we're always in that case when getting here.
2016-12-01 14:44:26 +02:00
Sebastian Dröge b79655d3c9 qtdemux: Ensure that size of the pasp atom is as much as we need
https://bugzilla.gnome.org/show_bug.cgi?id=775455
2016-12-01 14:30:49 +02:00