Commit Graph

136 Commits

Author SHA1 Message Date
Tomas Härdin d8531a1c18 mxfdec: Handle small EditUnitByteCount
These are common with audio atoms. Without this the demuxer would read two
bytes at a time for a mono 16-bit file.
2012-01-24 11:36:39 +01:00
Michael Niedermayer feb997577b Merge remote-tracking branch 'qatar/master'
* qatar/master: (25 commits)
  riff: fix invalid av_freep() calls on EOF in ff_read_riff_info
  pam: Fix a typo that broke writing and reading PAM files.
  mxfdec: fix memleak on av_realloc failures
  mxfdec: Do not parse slices or DeltaEntryArrays.
  mxfdec: hybrid demuxing/seeking solution
  mxfdec: Add Avid's essence element key.
  mfxdec: Separate mxf_essence_container_uls for audio and video.
  mxfdec: Compute packet offsets properly.
  mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack.
  mxfdec: use av_dlog() for 'no corresponding source package found'
  mxfdec: Make mxf->partitions sorted by offset.
  mxfdec: parse ThisPartition
  mxfdec: Speed up metadata and index parsing.
  mxfdec: Make sure DataDefinition is consistent between material track and source track.
  mxfdec: add EssenceContainer UL found in 0001GL00.MXF.A1.mxf_opatom.mxf
  mxfdec: Add hack that adjusts the n_delta calculation when system items are present.
  mxfdec: Parse IndexTableSegments and convert them into AVIndexEntry arrays.
  mxfdec: Move FooterPartition to MXFContext and make sure it is never zero.
  mxfdec: check return value of avio_seek
  mxfdec: skip to end of structural sets
  ...

Conflicts:
	configure
	libavcodec/pnm.c
	libavformat/mxfdec.c
	libavformat/riff.c
	libavformat/rtsp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-23 01:05:20 +01:00
Janne Grunau 20ea14d0f8 mxfdec: fix memleak on av_realloc failures 2012-01-22 14:47:11 +01:00
Tomas Härdin fc85729458 mxfdec: Do not parse slices or DeltaEntryArrays.
The most recent demuxing/seeking code does not need them.
2012-01-22 14:40:54 +01:00
Janne Grunau f028d4d1c3 mxfdec: hybrid demuxing/seeking solution
This uses the old demuxing code for OP1a and separate demuxing code for OPAtom.
Timestamp output is added to the old demuxing code.

The seeking code is made to seek to the start of the desired EditUnit only,
from which the normal demuxing code takes over (if OP1a). This means we
do not use delta entries or slices, only StreamOffsets. OPAtom seeking
basically works like before.

This also makes D-10 seeking behave the same way as OP1a and OPAtom. In other
words, we allow seeking before the start or past the end for D-10 too.

Based on several patches by Tomas Härdin <tomas.hardin@codemill.se> and
Reimar Döffinger <Reimar.Doeffinger@gmx.de>.

Changed av_calloc to av_mallocz, added overflow checks.
2012-01-22 14:40:53 +01:00
Tomas Härdin 1f5f8b2654 mxfdec: Add Avid's essence element key.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:53 +01:00
Carl Eugen Hoyos 44deb9f68d mfxdec: Separate mxf_essence_container_uls for audio and video.
It is a really bad idea to assign a video codec id
when we have set codec_type to audio and vice versa.

Prevents detection of mp2 in mxf as mpeg2video.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:53 +01:00
Tomas Härdin 3cb33fbe91 mxfdec: Compute packet offsets properly.
This replaces the old essence_offset code.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:53 +01:00
Tomas Härdin f4187945a0 mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:53 +01:00
Tomas Härdin 21cc4b3327 mxfdec: use av_dlog() for 'no corresponding source package found'
This is not an error and expected behavior for OPAtom files.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:53 +01:00
Tomas Härdin c77a5460b1 mxfdec: Make mxf->partitions sorted by offset.
This also zeroes new entries for good measure (used by future patches).

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:53 +01:00
Tomas Härdin be78e3f6ec mxfdec: parse ThisPartition
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:53 +01:00
Tomas Härdin 775d3b4ab1 mxfdec: Speed up metadata and index parsing.
Specifically, this means parsing as before until we run into essence.
At that point we seek to the footer and parse until EOF. After that we start
seeking backward to the previous partition and parse that until we run into
essence or the next partition. This procedure is repeated until we encounter
the last partition we parsed in the forward direction.

The end result of all this is that large essence containers are not needlessly
parsed. This speeds up parsing large files a lot.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:52 +01:00
Tomas Härdin 0999151962 mxfdec: Make sure DataDefinition is consistent between material track and source track.
This fixes 0001GL.MXF.V1.mxf_opatom.mxf and 0001GL00.MXF.A1.mxf_opatom.mxf
getting two streams each due to both using the same SourcePackageID.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:52 +01:00
Tomas Härdin 0ac5e6a8c4 mxfdec: add EssenceContainer UL found in 0001GL00.MXF.A1.mxf_opatom.mxf
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:52 +01:00
Tomas Härdin edb5085647 mxfdec: Add hack that adjusts the n_delta calculation when system items are present.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:52 +01:00
Janne Grunau 682b6db706 mxfdec: Parse IndexTableSegments and convert them into AVIndexEntry arrays.
Based on patch from Tomas Härdin <tomas.hardin@codemill.se>
and work by Georg Lippitsch <georg.lippitsch@gmx.at>

Changed av_calloc to av_mallocz and added overflow checks.
2012-01-22 14:40:52 +01:00
Tomas Härdin 83ab10f6e9 mxfdec: Move FooterPartition to MXFContext and make sure it is never zero.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:52 +01:00
Joakim Plate 3359246d9a mxfdec: check return value of avio_seek
Avoid modifying state if avio_seek fails.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:52 +01:00
Philip de Nier 0662eea6b0 mxfdec: skip to end of structural sets
This fixes reading of partition packs. The code stops reading after the
operational pattern and should skip the array of essence container
labels that follow.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2012-01-22 14:40:52 +01:00
Tomas Härdin d32b3f40c7 mxfdec: parse MXF partitions 2012-01-22 14:40:51 +01:00
Tomas Härdin 1de5154dfb mxfdec: Consider OPAtom files that don't have exactly one EC to be OP1a
This fixes demuxing of 2011_DCPTEST_24FPS.V.mxf.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-17 20:55:19 +01:00
Reimar Döffinger 203f94fd7c mxfdec: Add missing free.
Should fix valgrind FATE.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2012-01-16 19:21:24 +01:00
Michael Niedermayer 4a4c4278b7 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  fate: split ADPCM and DPCM test references into separate files.
  mov, mxfdec: Employ more meaningful return values.
  lavc: Relax API strictness in avcodec_decode_audio3 with a custom get_buffer()
  wavpack: fix clipping for 32-bit lossy mode
  vb: Use bytestream2 functions

Conflicts:
	libavcodec/utils.c
	libavcodec/vb.c
	libavformat/mxfdec.c
	tests/fate/dpcm.mak

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-16 01:33:35 +01:00
Daniel Huang bcd5d979aa mov, mxfdec: Employ more meaningful return values.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-01-15 22:00:11 +01:00
Jean First d92d2af81f mxfdec: change av_log formatting %lx to PRIx64 and %li to PRIi64
Signed-off-by: Jean First <jeanfirst@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-01 21:15:46 +01:00
Tomas Härdin 6547fd9264 mxfdec: consider QuantizationBits between 17 and 24 to be pcm_s24*
This fixes playback of BRD38772509.mxf.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2011-12-21 16:28:42 +01:00
Tomas Härdin cc1dda851b mxfdec: Don't crash in mxf_packet_timestamps() if current_edit_unit overflows 2011-12-21 14:18:08 +01:00
Tomas Härdin 0cd21ddaed mxfdec: Zero nb_ptses in mxf_compute_ptses_fake_index()
This fixes SIGSEGV on files with both CBR and VBR index segments (zzuf6.mxf).
2011-12-21 14:18:08 +01:00
Tomas Härdin 46d65fb8a5 mxfdec: Sanity check PreviousPartition
Without this certain files could get the demuxer stuck in a loop
2011-12-21 14:17:44 +01:00
Tomas Härdin e7839602f4 mxfdec: Never seek back in local sets and KLVs
Specially crafted files can lead the parsing code to take too long.
We fix a lot of these problems by not allowing local tags to extend past the
end of the set and not allowing other KLVs to be read past the end of
themselves.
2011-12-21 14:17:29 +01:00
Tomas Härdin 184f479096 mxfdec: Move the current_partition check inside mxf_read_header()
This fixes SIGSEGV on files where this is actually the case, such as zzuf4.mxf
2011-12-21 14:16:03 +01:00
Tomas Härdin 4ae7d45170 mxfdec: Fix infinite loop in mxf_packet_timestamps()
This can happen if an index table segment has a very large IndexStartPosition.
zzuf3.mxf is an example of such a file.
2011-12-21 14:16:03 +01:00
Tomas Härdin 2116e4ba91 mxfdec: Check url_feof() in mxf_read_local_tags()
This fixes the infinite loop with zzuf2.mxf
2011-12-21 14:15:51 +01:00
Tomas Härdin 5e5e69d078 mxfdec: Check for NULL component
This fixes SIGSEGV with zzuf1.mxf
2011-12-21 13:48:39 +01:00
Tomas Härdin 5b718009b2 mxfdec: Sanity-check SampleRate
This avoids a SIGFPE if SampleRate is missing or set to naughty values.
2011-12-20 11:34:48 +01:00
Tomas Härdin 1888bd1b6d mxfdec: Make sure mxf->nb_index_tables > 0 in mxf_packet_timestamps()
Only the OPAtom demuxing logic is guaranteed to have index tables, meaning OP1a
files that lack an index would cause SIGSEGV.
2011-12-20 11:32:59 +01:00
Tomas Härdin 54cbbdd25a mxfdec: Remove unused variables 2011-12-20 09:59:29 +01:00
Tomas Härdin 6e9081f4d8 mxfdec: Make sure x < index_table->nb_ptses
Without this the demuxer will SIGSEGV on files with IndexEntryCount < IndexDuration
2011-12-20 09:58:37 +01:00
Tomas Härdin 085249a379 mxfdec: Ignore the last entry in Avid's index table segments
The last entry is the total size of the essence container.
Previously a TemporalOffset error would be logged, even though segments like
these are expected.
2011-12-20 09:18:44 +01:00
Tomas Härdin 0e764cf541 mxfdec: Don't parse slices or DeltaEntryArrays
The most recent demuxing/seeking code doesn't need them
2011-12-16 11:54:08 +01:00
Tomas Härdin f98726551c mxfdec: Remove dead/useless code 2011-12-16 11:54:07 +01:00
Tomas Härdin 2eba8da675 mxfdec: Hybrid demuxing/seeking solution
This uses the old demuxing code for OP1a and separate demuxing code for OPAtom.
Timestamp output is added to the old demuxing code.
The seeking code is made to seek to the start of the desired EditUnit only,
from which the normal demuxing code takes over (if OP1a). This means we don't
use delta entries or slices, only StreamOffsets.
OPAtom seeking basically works like before.
This also makes D-10 seeking behave the same way as OP1a and OPAtom. In other
words, we allow seeking before the start or past the end for D-10 too.
This fixes ticket #746.
2011-12-16 11:54:03 +01:00
Tomas Härdin 36c305f9db mxfdec: Add mxf_edit_unit_absolute_offset()
This maps an EditUnit in an index table to the corresponding absolute offset
in the file.
2011-12-16 11:48:02 +01:00
Tomas Härdin b56adc7842 mxfdec: Replace zero IndexDurations with st->duration
The mxf_d10 muxer outputs files with zero IndexDurations..
2011-12-16 11:48:02 +01:00
Tomas Härdin 2212e040b7 mxfdec: Add "fake" index to MXFIndexTable to assist seeking
This changes mxf_compute_ptses() to be used for MXFIndexTable, and also adds
code for computing the fake index to it.
This also temporarily disables PTS computation. A future patch will restore it.
2011-12-16 11:45:40 +01:00
Tomas Härdin 8ce41721a4 mxfdec: Add MXFIndexTables
This structs collects MXFIndexTableSegments belonging to one IndexSID and some
other bits of useful information.
2011-12-16 11:32:52 +01:00
Tomas Härdin 31029e30fa mxfdec: Move mxf_read_packet*() near the bottom of the file
This simplifies future commits.
2011-12-16 11:32:52 +01:00
Tomas Härdin 7d531e83b6 mxfdec: Set DTS and PTS on video packets
This involves computing DTS/PTS from the index tables.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-12 18:34:37 +01:00
Tomas Härdin 8a2cb2abbf mxfdec: Only sort IndexTableSegments once
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-12 18:34:37 +01:00