Commit Graph

465 Commits

Author SHA1 Message Date
Harry Mallon
7031a7beae avformat/mxfdec: Read color metadata from MXF
Reads color_primaries, color_trc and color_space from mxf
headers. ULs are from https://registry.smpte-ra.org/ site.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-08-06 12:52:34 +02:00
Andreas Rheinhardt
28ce651c6d avformat/mxfdec: Fix memleak upon repeating tags
When parsing MXF encountering some tags leads to allocations. And when
these tags were encountered repeatedly, this could lead to memleaks,
because the pointer to the old data got simply overwritten with a
pointer to the new data (or to NULL on allocation failure). This has
been fixed.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 03:23:07 +02:00
Andreas Rheinhardt
78f21cab18 avformat/mxfdec: Fix memleak when parsing tag fails
The MXF demuxer uses an array of pointers to different structures of
metadata (all containing a common initial sequence containing a type
field to distinguish them) and some of these structures contain pointers
to separately allocated subelements. If an error happens while reading
and creating the tags, the semi-finished new tag is freed using the
function to free these tags. But this function doesn't free the already
allocated subelements, because the type has not been set yet. This commit
changes this.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 03:22:06 +02:00
Andreas Rheinhardt
49e78548c3 avformat/mxfdec: Fix memleak when adding element to array fails
Said array contains pointers to other structs and both the designated
new element as well as other stuff contained in it (e.g. strings) leak
if the new element can't be added to the array.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 03:21:37 +02:00
Michael Niedermayer
0aa2768cb2 avformat/mxfdec: free duplicated utf16 strings
Fixes: memleak
Fixes: 23415/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5124814510751744

Suggested-by: Marton Balint <cus@passwd.hu>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-06-14 21:22:47 +02:00
Limin Wang
ab7bcfb80c avformat/mxfdec: reindent code
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-05 08:20:45 +08:00
Andreas Rheinhardt
8d019dbc5b avformat/mxfdec: Correct confusing struct tag
Don't use typedef struct MXFTrack {...} MXFTimecodeComponent, in
particular given the fact that MXFTrack is a type of its own.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-03-30 07:27:02 +02:00
Limin Wang
750a81ba99 avformat/mxfdec: use av_asprintf()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-03-23 23:37:19 +01:00
Marton Balint
27a8146990 avformat/mxf: get rid of samples per frame array usage
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-03-14 22:25:25 +01:00
Michael Niedermayer
13816a1d08 avformat/mxfdec: Clear metadata_sets_count in mxf_read_close()
This avoids problems if the function is called twice

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-01 17:17:04 +01:00
Michael Niedermayer
9802599ad0 avformat/mxfdec: cleanup on "essence prior to first PartitionPack"
Fixes: memleak
Fixes: 18473/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5738557074833408

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-08 14:48:01 +01:00
Marton Balint
6ee40dcb64 avformat/mxfdec: do not ignore bad size errors
The return value was unintentionally lost after
00a2652df3.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-22 21:38:41 +02:00
Marton Balint
3dee6c0997 avformat/mxfdec: fix and enhance RIP KLV length checks
KLV length is BER encoded (variable size), but the code assumed the encoding to
always use 4 bytes.

Fixes parsing Random Index Pack in samples/MXF/issue2160/PW0805A0V01.4C5B5636.EFA330.mxf.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-04-28 21:55:28 +02:00
Marton Balint
fc15e8306f avformat/mxfdec: take into account run-in in find_partition_by_offset
Also rename the function to find_partition_by_absolute_offset to make it clear
offset is absolute.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-04-28 21:55:28 +02:00
Marton Balint
5b6960f955 avformat/mxfdec: guess wrapping of tracks by other tracks with the same body sid
This affects the following samples:

samples/ffmpeg-bugs/roundup/issue1775/av_seek_frame_failure.mxf
samples/ffmpeg-bugs/trac/ticket1957/16ch.mxf
samples/ffmpeg-bugs/trac/ticket5016/r0.mxf
samples/ffmpeg-bugs/trac/ticket5016/r1.mxf
samples/ffmpeg-bugs/trac/ticket5316/hq.MXF
samples/ffmpeg-bugs/trac/ticket5316/hqx.MXF

Some AVPacket->pos values are changed because for frame wrapped tracks we point
to the KLV offset and not the data.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-04-28 21:55:28 +02:00
Marton Balint
a5136426a7 avformat/mxfdec: rework mxf_essence_container_end
We find the last essence container much faster if we go through the partitions
backwards...

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-04-28 21:55:28 +02:00
Marton Balint
f9840cd2b5 avformat/mxfdec: use operational_pattern_ul instead of operational_pattern for metadata
This makes it more consistent with other metadata keys.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-04-14 21:54:35 +02:00
Marton Balint
6ed7df5b20 avformat/mxfdec: export operational pattern UL as file metadata
Can be useful for API users as ffmpeg/libavformat can't properly support some
operational patterns.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-04-11 21:17:57 +02:00
Carl Eugen Hoyos
4d8875ec23 lavf: Constify the probe function argument.
Reviewed-by: Lauri Kasanen
Reviewed-by: Tomas Härdin
2019-03-21 11:42:17 +01:00
Matthew McKenna
f95aee2b72 Add the Canon XF-HEVC UL to the picture essence container UL list 2019-03-08 14:14:15 +01:00
Marton Balint
02935c2c93 avformat/mxfdec: support subsecond precision of decoded timestamps
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-12-25 20:16:29 +01:00
Marton Balint
d0e43cf1a8 avformat/mxfdec: replace obsolete comment
We no longer use strftime directly but use av_timegm to get an int64_t timestamp.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-12-25 20:16:29 +01:00
Michael Niedermayer
8b53d1322f avformat/mxfdec: Do not process zero modified_date timestamp.
This causes windows to fail as the timestamp is outside its supported range
Fixes regression & fate

Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-12-22 22:28:52 +01:00
Paul B Mahol
e5a0013c4a avformat/mxfdec: fix error check in macro
Fixes #6750.
2018-12-13 23:51:53 +01:00
Paul B Mahol
3981f262ac avformat/mxfdec: fix indentation 2018-12-09 20:12:23 +01:00
Paul B Mahol
cc6208cde2 avformat/mxfdec: set codec_tag for prores codec 2018-12-07 20:08:37 +01:00
Baptiste Coudurier
ef23ed6fe9 lavf/mxfdec: demux s436m as eia608 subtitle track 2018-10-12 12:28:28 -07:00
Baptiste Coudurier
9b7ab57953 lavf/mxfenc: support creating s436m data tracks 2018-10-12 12:28:22 -07:00
Marton Balint
6aaf1b504c avformat/mxfdec: do not use sound essence descriptor quantization bits for bits_per_coded_sample
It refers to the uncompressed quantization, therefore is not correct for AAC.

Also change mxf_set_pts to work based on current edit unit if
bits_per_coded_sample is not available.

Fixes error messages in the sample of ticket #7366.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-09-05 22:41:09 +02:00
Marton Balint
a5c17cf43e avformat/mxfdec: drop invalid index table segments when sorting them
This way if an index table segment is present multiple times, we can always use
the proper one instead of the invalid one.

Fixes seeking in the sample of ticket #5671.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-24 09:06:55 +02:00
Baptiste Coudurier
b420fead53 avformat/mxfdec: only call mxf_free_metadataset when ctx_size is != 0, otherwise ctx == mxf 2018-07-19 08:25:24 -07:00
Marton Balint
e5ff2c0c06 avformat/mxfdec: only return stream indexes which have a corresponding track
Without this check some crafted files might crash because a packet might be
demuxed which have no corresponding mxf track.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-13 22:58:40 +02:00
Michael Niedermayer
bab0716c7f avformat/mxfdec: Fix av_log context
Fixes: out of array access
Fixes: mxf-crash-1c2e59bf07a34675bfb3ada5e1ec22fa9f38f923

Found-by: Paul Ch <paulcher@icloud.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-07-05 19:52:42 +02:00
Marton Balint
e37741d26a avformat/mxfdec: add support for opAtom without index
Clip wrapped code is capable of doing some magic for such files.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-04 21:52:21 +02:00
Marton Balint
5861bc9e75 avformat/mxfdec: guess constant byte count indexes based on track duration
For clip wrapped essences this should work. Also, since index_edit_rate can now
be different from track edit rate, remove overriding track edit rate.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-04 21:52:21 +02:00
Marton Balint
c6fff3d32f avformat/mxfdec: take into account index_edit_rate
Fixes samples/ffmpeg-bugs/roundup/issue591/02785736.mxf
Fixes samples/ffmpeg-bugs/trac/ticket1916/pcm_s24le_to_pcm_s16le.mxf

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-04 21:52:21 +02:00
Marton Balint
afd09131ff avformat/mxfdec: fix indentation and rename mxf_read_packet_old
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-04 21:52:21 +02:00
Marton Balint
00a2652df3 avformat/mxfdec: add support for clip wrapped essences
Also use common code with opAtom.

Fixes ticket #2776.
Partially fixes ticket #5671.
Fixes ticket #5866.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-07-04 21:52:21 +02:00
Marton Balint
404dc6bab5 avformat/mxfdec: avoid index_table->nb_ptses overflow in mxf_compute_ptses_fake_index
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
865e0c2d66 avformat/mxfdec: compute sample_count for all streams on seek
sample_count will be used for per-stream current_edit_unit.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
e7b1a83718 avformat/mxfdec: add support for returning the partition for mxf_edit_unit_absolute_offset and mxf_absolute_bodysid_offset
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
1cea0e73d2 avformat/mxfdec: make current_edit_unit a parameter of mxf_compute_samples
No change in functionality.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
ae64c68208 avformat/mxfdec: make edit_units_per_packet a track property
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
f217be2cb8 avformat/mxfdec: simply use the first essence element for non frame-wrapped partition essence offset
Also add the canopus essence element to the list of the recognized essence
element keys.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
6345770eeb avformat/mxfdec: compute both essence_offset and essence_length in mxf_compute_essence_containers
Also compute the correct essence_offset and essence_length for all clip wrapped
essences.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
459282389c avformat/mxfdec: extend mxf_handle_missing_index_segment for all clip wrapped essences
Also make sure we set a valid track index sid and a valid track edit rate in
order for the index to be useful.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
3cb19ba97e avformat/mxfdec: add some essence container uls from SMPTE draft
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
7ec90b168b avformat/mxfdec: add support for determining essence wrapping scheme
Some code is based on bmxlib-libmxf/mxf/mxf_utils.c.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
bfa0b50441 avformat/mxfdec: store next_klv in KLVPacket
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-24 20:42:35 +02:00
Marton Balint
2bd26dea66 avformat/mxfdec: add support for recognizing timed text streams
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-06-08 23:21:20 +02:00