Commit Graph

408 Commits

Author SHA1 Message Date
Marton Balint cf5ffe0183 avformat/mxfdec: do not allow more partitions than INT_MAX/2
Some math (e.g: partition binary search) overflows if we have that many
parititions.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-09 20:37:49 +01:00
Marton Balint 90756e67a0 avformat/mxfdec: use binary search in mxf_absolute_bodysid_offset
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-09 20:37:49 +01:00
Marton Balint 3aaf97e773 avformat/mxfdec: fix opAtom audio demuxing
Consider edit rate when determining edit_units_per_packet and also make sure
that checks are done in edit rate time base and not in stream time base.

Fixes some errors reported with the sample in ticket #5863.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-09 20:37:49 +01:00
Marton Balint f50741147c avformat/mxfdec: always use a stream which matches the first index table when seeking
Obviously this is still not perfect, but better then it was. Using the first
index table and mxf->current_edit_unit is still hardcoded in many places, so
this change has hopefully the less chance of breaking anything that works
now.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint e8e1c22f21 avformat/mxfdec: compute sample_count after seek from index for audio streams
This fixes audio timestamps if the audio streams are not frame wrapped with the
video.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint 0827c78e98 avformat/mxfdec: use body_offset of the partitions in mxf_absolute_bodysid_offset
Use body_offset of the partitions to search for the partition with the given
offset in the essence. This makes the function find the correct partition for
non frame-wrapped essences as well, where only the essence data is part of the
the edit unit byte count, not the KLV-s.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint 5b36379eb6 avformat/mxfdec: set index_duration from the track using the index
Also use original_duration as index_duration is in edit units.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint c46e430c5b avformat/mxfdec: fix sorting of index segments
Fixes ticket #5320.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint 9492bb58ee avformat/mxfdec: use both body_sid and track_number to find the track of a packet
In order to do that we have to parse the EssenceContainerData and assign the
proper body_sid and index_sid to the tracks from the corresponding source
packages.

This fixes packets returned in the wrong stream for some OP1-b files.

Based on a patch by Alex Mogurenko from https://github.com/da8eat/FFmpeg

Reference: http://mogurenko.com/2018/01/02/mxf-op1b-ffmpeg-part1/

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint 9ec3e61fc3 avformat/mxfdec: use full UMID to resolve source package
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint 5c2fd59700 avformat/mxfdec: use the first system item if available for calculating essence_offset
Also add an additional system item key.

Fixes parsing of ffmpeg-bugs/trac/ticket2817/warehouse.mxf

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint e9b0e42e77 avformat/mxfdec: fix essence_offset calculation
The reference point for a KAG is the first byte of the key of a Partition Pack.

Fixes ticket #2817.
Fixes ticket #5317.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint d54a04b69b avformat/mxfdec: fix indentation
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-03-01 22:03:53 +01:00
Marton Balint 5a93a85fd0 avformat/mxfdec: fix last packet timestamps
The current edit unit cannot be reliably determined for the last packet of a
video stream, because we can't query the start offset of the next edit unit
from the index. This caused missing timestamps for the last video packet.

Therefore from now on, we allow setting the PTS even if we are not sure of the
current edit unit if mxf_set_current_edit_unit returned a specific failure, and
the assumed current edit unit is the last.

Fixes last packet timestamp of:
ffprobe -fflags nofillin -show_packets tests/data/lavf/lavf.mxf -select_streams v

Signed-off-by: Marton Balint <cus@passwd.hu>
2017-12-03 21:06:47 +01:00
Carl Eugen Hoyos 4590d073cc lavf/mxfdec: Search all components of material track for source package.
Fixes ticket #5925.

Reviewed-by: Marton
2017-10-03 23:29:20 +02:00
James Almer 318778de9e Merge commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3'
* commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3':
  Mark some arrays that never change as const.

Merged-by: James Almer <jamrial@gmail.com>
2017-09-26 16:02:40 -03:00
Marton Balint 01911b9b3c avformat/mxfdec: use the common packet pts setter function for opatom files
Fixes ticket #6631.

Signed-off-by: Marton Balint <cus@passwd.hu>
2017-09-23 19:07:54 +02:00
Marton Balint 7f80b065a6 avformat/mxfdec: factorize packet pts setter function
Signed-off-by: Marton Balint <cus@passwd.hu>
2017-09-23 19:07:54 +02:00
孙浩(晓黑) 9d00fb9d70 avformat/mxfdec: Fix Sign error in mxf_read_primer_pack()
Fixes: 20170829B.mxf

Co-Author: 张洪亮(望初)" <wangchu.zhl@alibaba-inc.com>
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-01 01:48:39 +02:00
孙浩(晓黑) 900f39692c avformat/mxfdec: Fix DoS issues in mxf_read_index_entry_array()
Fixes: 20170829A.mxf

Co-Author: 张洪亮(望初)" <wangchu.zhl@alibaba-inc.com>
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-01 01:48:35 +02:00
James Almer 4de591e6fb Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'
* commit '83548fe894cdb455cc127f754d09905b6d23c173':
  lavf: fix usage of AVIOContext.seekable

Merged-by: James Almer <jamrial@gmail.com>
2017-03-21 17:02:30 -03:00
Anton Khirnov fd9212f2ed Mark some arrays that never change as const. 2017-02-01 10:42:59 +01:00
Andreas Cadhalpun fdb8c455b6 mxfdec: fix NULL pointer dereference in mxf_read_packet_old
Metadata streams have priv_data set to NULL.

Reviewed-by: Josh de Kock <josh@itanimul.li>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-11-23 00:40:52 +01:00
Andreas Cadhalpun 0efb610611 mxfdec: fix NULL pointer dereference
Metadata streams have priv_data set to NULL.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-11-05 18:56:41 +01:00
Michael Niedermayer fecb3e82a4 avformat/mxfdec: Check size to avoid integer overflow in mxf_read_utf16_string()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-21 20:06:29 +02:00
Michael Niedermayer c495f4ffde avformat/mxfdec: Fix mixed declaration and code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-21 20:06:29 +02:00
Mark Reid 6902e1c7fa libavformat/mxfdec: add metadata streams for external referenced sourclips
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-21 02:04:19 +02:00
Mark Reid 263f8fd7e5 libavformat/mxfdec: don't assume first stream index to be primary
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-21 02:04:16 +02:00
Mark Reid 3b82be9e3b libavformat/mxfdec: export track name metadata
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-21 02:04:01 +02:00
Tobias Rapp e3196b6862 avformat/mxfdec: Detect field_order based on video_line_map
Read video_line_map from MXF generic picture essence descriptor and use
it to derive the coded field order. Use field_dominance to derive the
display field order from coded field order. If field_dominance is not
available the default value "1" is used as defined in SMPTE S377-1.

Fixes field_order detection for a bunch of DV/DVCPRO files. The heuristic
for deriving coded field order from video_line_map is inspired by
MediaInfo.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-21 02:00:56 +02:00
Anton Khirnov 83548fe894 lavf: fix usage of AVIOContext.seekable
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.
2016-09-30 16:54:33 +02:00
Mark Reid d8d4333217 avformat/mxfdec: use first valid sourceclip found if material track has multiple components
This commit fixes a issue with mxf footage having multiple
components on a material track.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-21 01:29:20 +02:00
Marton Balint 13b90ff2c1 avformat: fix decoded creation_time timestamps
Use proper ISO 8601 timestamps which also signal that they are in UTC.

This changes the format of creation_time and modification_date metadata values
from 2016-06-01 22:30:00 to 2016-01-01T22:30:00.000000Z

Fixes ticket #5673.

Signed-off-by: Marton Balint <cus@passwd.hu>
2016-08-28 15:55:32 +02:00
Anton Khirnov 5ebef79abe Fix instances of broken indentation found by gcc 6 2016-07-31 08:19:27 +02:00
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Marton Balint 4bee44007a avformat/mxfdec: check if source_package is NULL
Fixes ticket #5554.

Reviewed-by: Tomas Härdin <tomas.hardin@codemill.se>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-06-13 22:43:22 +02:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Derek Buitenhuis 6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +01:00
Lou Logan 06eef96b69 fix some a/an typos
Signed-off-by: Lou Logan <lou@lrcd.com>
2016-03-28 14:13:17 -08:00
Carl Eugen Hoyos f1a3677c0f lavf/mxfdec: Fix Canopus essence element size. 2016-03-14 16:37:48 +01:00
Carl Eugen Hoyos ac1974652b lavf/mxfdec: Support Canopus codecs.
Fixes ticket #5316.
2016-03-10 09:59:35 +01:00
Anton Khirnov 9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Marton Balint 97795ba6c3 lavf/mxfdec: fix seeking before the first keyframe
Regression since 53f2ef2c4a.
Fixes ticket #5017.

Signed-off-by: Marton Balint <cus@passwd.hu>
2015-12-08 02:14:44 +01:00
Anshul Maheshwari 162754c1e0 Remove Redundant Entry of MPEG2 Video Desc
Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-07 01:28:48 +01:00
Carl Eugen Hoyos ec494e6c83 lavf/mxfdec: Set width to actual coded_width for AVCI50.
Fixes ticket #5029.
Reported and analyzed by videolan trac user HenkDemper in vlc ticket #15762.
2015-11-29 21:08:38 +01:00
Andreas Cadhalpun 047bf82c18 mxfdec: check edit_rate also for physical_track
Previously only the edit_rate of material_track was checked.
If it's negative, it causes assertion failures in av_rescale_rnd.

Reviewed-by: Tim Nicholson <nichot20-at-yahoo.com@ffmpeg.org>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-11-18 23:54:24 +01:00
Alexis Ballier 12628e3369 libavformat/mxfdec.c: Report dark metadata keys only when they match no parser at all, not everytime they fail to match one.
Reviewed-by: Tomas Härdin <tomas.hardin@codemill.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-22 00:53:35 +02:00
Alexis Ballier 94ec82f14a libavformat/mxfdec.c: cosmetics: Add missing space after '?' in log message.
Reviewed-by: Tomas Härdin <tomas.hardin@codemill.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-22 00:53:35 +02:00
Arnaud Bienner 0cdba4ac68 lavf/mxfdec: Support more codecs in mxf_picture_essence_container_uls[].
Signed-off-by: Carl Eugen Hoyos <cehoyos@ag.or.at>
2015-09-05 00:11:14 +02:00
Carl Eugen Hoyos f7361dbcf4 lavc/mxfdec: Support more mxf files with codec_ul.
Fixes decoding for the sample from ticket #4820.
2015-09-04 23:50:34 +02:00