Commit Graph

173 Commits

Author SHA1 Message Date
Reimar Döffinger dd5e1fc22e mxfdec: fix memleak on read error/EOF.
This also matches the rest of the demuxer which will return
partial packets.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2012-04-20 20:58:45 +02:00
Matthieu Bouron cbda76c7c6 mxfdec: Add missing break in frame layout parsing
Reviewed-by: Tomas Härdin <tomas.hardin@codemill.se>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-19 15:08:22 +02:00
Tomas Härdin a61fada380 mxfdec: Fix regression on files from Pinnacle Thunder
The reason for this is that such files have IndexTableSegments which when parsed
cover EditUnit ranges like this:

 [0,1)
 [249,250)
 [249,377)
 [0,249)

where each interval is [IndexStartPosition,IndexStartPosition+IndexDuration).
This would be reduced to a sparse index like:

 [0,1), [249,250)

instead of the full range:

 [0,249), [249,377)

See TimeCode_HD.mxf, UMID =
060a2b340101010101010410130000000004001aa0e59175025b2a5600da4101.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-04 17:43:17 +02:00
Michael Niedermayer 3b370abf16 mxfdec: fix off by one error.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-26 15:05:02 +02:00
Michael Niedermayer 33f39c02aa mxfdec: pass correct context to av_timecode_init()
fixes null ptr dereference
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-26 03:13:54 +02:00
Tomas Härdin 393b81f093 mxfdec: Only parse next partition pack if parsing forward
This fixes ticket #1099.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-20 13:45:19 +01:00
Tomas Härdin eb74e9ea10 mxfdec: Let pkt->pts = mxf->current_edit_unit if intra-only
We can't do this in general since we could be reading a file with B-frames while
lacking an index.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-18 19:57:01 +01:00
Joseph Artsimovich 84b9b4aa18 Fix frame height vs field height confusion in MXF decoding.
Reviewed-by: Tomas Härdin <tomas.hardin@codemill.se>
Reveiwed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-11 17:39:52 +01:00
Matthieu Bouron ad029c24a6 mxfdec: add timecode to metadata
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-11 08:12:46 +01:00
Tomas Härdin f6daa9f4f6 mxfdec: Add intra_only flag to MXFTrack
This allows future assumptions to be made without affecting non-intra files.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-08 00:39:56 +01:00
Tomas Härdin 8c7721e709 mxfdec: Fix Avid AirSpeed files being misinterpreted as OP1a
The "ECs != 1 -> OP1a" assumption was wrong. Luckily, the file that triggered
that behavior had two ECs, not zero. Hence distinguishing between them is
simple in this case.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-08 00:39:56 +01:00
Tomas Härdin bf2290a80c mxfdec: Truncate packets that extend past the next edit unit
This fixes rare cases where OPAtom may be treated as OP1a, causing all essence
to be read into RAM.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-08 00:39:56 +01:00
Philip de Nier 34210e8df1 mxfdec: set pixel format for cdci picture formats
The properties of the CDCI Descriptor are insufficient to specify
the pixel format for uncompressed picture data. SMPTE 377-1 and
RP224v10 have defined a set of picture coding labels to indicate what
formatting was used.

This patch uses 2 labels to detect UYVY422 or YUYV422 pixel formats.

It defaults to UYVY422 for 8-bit 4:2:2 pictures to support files
that were created before the coding labels were introduced ~2008

The codec pix_fmt default was changed from 0 (PIX_FMT_YUV420P) to
-1 (PIX_FMT_NONE)

Reviewed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-02-28 20:24:01 +01:00
Philip de Nier c2d11a8b86 mxfdec: detect uncomp pictures using essence container ul
This supports detection of uncompressed picture in files that
didn't include a Picture Coding Label. The lables weren't
available until SMPTE 377-1 and RP224v10

Reviewed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-02-28 20:22:53 +01:00
Philip de Nier 3592bd509c mxfdec: set track edit rate num/den in expected order
This matches the order used for the index table edit rate.

Reviewed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-02-28 20:20:51 +01:00
Michael Niedermayer 8c6ebab747 Merge remote-tracking branch 'qatar/master'
* qatar/master: (26 commits)
  eac3dec: replace undefined 1<<31 with INT32_MIN in noise generation
  yadif: specify array size outside DECLARE_ALIGNED
  prores: specify array size outside DECLARE_ALIGNED brackets.
  WavPack demuxer: set packet duration
  tta: use skip_bits_long()
  mxfdec: Ignore the last entry in Avid's index table segments
  mxfdec: Sanity-check SampleRate
  mxfdec: Handle small EditUnitByteCount
  mxfdec: Consider OPAtom files that do not have exactly one EC to be OP1a
  mxfdec: Don't crash in mxf_packet_timestamps() if current_edit_unit overflows
  mxfdec: Zero nb_ptses in mxf_compute_ptses_fake_index()
  mxfdec: Sanity check PreviousPartition
  mxfdec: Never seek back in local sets and KLVs
  mxfdec: Move the current_partition check inside mxf_read_header()
  mxfdec: Fix infinite loop in mxf_packet_timestamps()
  mxfdec: Check eof_reached in mxf_read_local_tags()
  mxfdec: Check for NULL component
  mxfdec: Make sure mxf->nb_index_tables > 0 in mxf_packet_timestamps()
  mxfdec: Make sure x < index_table->nb_ptses
  build: Add missing directories to DIRS declarations.
  ...

Conflicts:
	doc/build_system.txt
	doc/fate.texi
	libavfilter/x86/yadif_template.c
	libavformat/mxfdec.c
	libavutil/Makefile
	tests/fate/audio.mak
	tests/fate/prores.mak
	tests/fate/screen.mak
	tests/fate/video.mak
	tests/ref/fate/bethsoft-vid
	tests/ref/fate/cscd
	tests/ref/fate/dfa4
	tests/ref/fate/nuv
	tests/ref/fate/vp8-sign-bias
	tests/ref/fate/wmv8-drm
	tests/ref/lavf/gxf

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-02-10 01:20:07 +01:00
Tomas Härdin e24167aae6 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.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 13:26:02 +01:00
Tomas Härdin d6b81ff949 mxfdec: Sanity-check SampleRate
This avoids a SIGFPE if SampleRate is missing or set to naughty values.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 13:00:05 +01:00
Tomas Härdin c65642d351 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.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:59:41 +01:00
Tomas Härdin 240ddbce56 mxfdec: Consider OPAtom files that do not have exactly one EC to be OP1a
This fixes demuxing of 2011_DCPTEST_24FPS.V.mxf.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:55:44 +01:00
Tomas Härdin 9123950be0 mxfdec: Don't crash in mxf_packet_timestamps() if current_edit_unit overflows
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:54:14 +01:00
Tomas Härdin d00257e96a mxfdec: Zero nb_ptses in mxf_compute_ptses_fake_index()
This fixes SIGSEGV on files with both CBR and VBR index segments (zzuf6.mxf).

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:54:13 +01:00
Tomas Härdin df2a85085e mxfdec: Sanity check PreviousPartition
Without this certain files could get the demuxer stuck in a loop.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:54:05 +01:00
Tomas Härdin 11800c8c89 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.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:46:12 +01:00
Tomas Härdin 687e2fdebd mxfdec: Move the current_partition check inside mxf_read_header()
This fixes SIGSEGV on files where this is the case, such as zzuf4.mxf.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:43:47 +01:00
Tomas Härdin e352c96c17 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.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:42:59 +01:00
Tomas Härdin 0373ec635d mxfdec: Check eof_reached in mxf_read_local_tags()
This fixes an infinite loop with zzuf2.mxf.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:41:50 +01:00
Tomas Härdin effe3b9575 mxfdec: Check for NULL component
This fixes a SIGSEGV with zzuf1.mxf.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:41:50 +01:00
Tomas Härdin 29fc8f50cd 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.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:41:42 +01:00
Tomas Härdin a3923482f2 mxfdec: Make sure x < index_table->nb_ptses
Avoids a SIGSEGV on files with IndexEntryCount < IndexDuration.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-02-09 12:40:34 +01:00
Michael Niedermayer e37f161e66 Merge remote-tracking branch 'qatar/master'
* qatar/master: (71 commits)
  movenc: Allow writing to a non-seekable output if using empty moov
  movenc: Support adding isml (smooth streaming live) metadata
  libavcodec: Don't crash in avcodec_encode_audio if time_base isn't set
  sunrast: Document the different Sun Raster file format types.
  sunrast: Add a check for experimental type.
  libspeexenc: use AVSampleFormat instead of deprecated/removed SampleFormat
  lavf: remove disabled FF_API_SET_PTS_INFO cruft
  lavf: remove disabled FF_API_OLD_INTERRUPT_CB cruft
  lavf: remove disabled FF_API_REORDER_PRIVATE cruft
  lavf: remove disabled FF_API_SEEK_PUBLIC cruft
  lavf: remove disabled FF_API_STREAM_COPY cruft
  lavf: remove disabled FF_API_PRELOAD cruft
  lavf: remove disabled FF_API_NEW_STREAM cruft
  lavf: remove disabled FF_API_RTSP_URL_OPTIONS cruft
  lavf: remove disabled FF_API_MUXRATE cruft
  lavf: remove disabled FF_API_FILESIZE cruft
  lavf: remove disabled FF_API_TIMESTAMP cruft
  lavf: remove disabled FF_API_LOOP_OUTPUT cruft
  lavf: remove disabled FF_API_LOOP_INPUT cruft
  lavf: remove disabled FF_API_AVSTREAM_QUALITY cruft
  ...

Conflicts:
	doc/APIchanges
	libavcodec/8bps.c
	libavcodec/avcodec.h
	libavcodec/libx264.c
	libavcodec/mjpegbdec.c
	libavcodec/options.c
	libavcodec/sunrast.c
	libavcodec/utils.c
	libavcodec/version.h
	libavcodec/x86/h264_deblock.asm
	libavdevice/libdc1394.c
	libavdevice/v4l2.c
	libavformat/avformat.h
	libavformat/avio.c
	libavformat/avio.h
	libavformat/aviobuf.c
	libavformat/dv.c
	libavformat/mov.c
	libavformat/utils.c
	libavformat/version.h
	libavformat/wtv.c
	libavutil/Makefile
	libavutil/file.c
	libswscale/x86/input.asm
	libswscale/x86/swscale_mmx.c
	libswscale/x86/swscale_template.c
	tests/ref/lavf/ffm

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-28 07:53:34 +01:00
Anton Khirnov 6e9651d106 lavf: remove AVFormatParameters from AVFormatContext.read_header signature 2012-01-27 10:51:57 +01:00
Michael Niedermayer 01fcbdf9ce Merge remote-tracking branch 'qatar/master'
* qatar/master:
  smacker: Sanity check huffman tables found in the headers.
  smacker: remove dead store
  qdm2: Check data block size for bytes to bits overflow.
  mxfdec: Fix files with essence containers larger than 2 GiB.
  mxfdec: Employ correct printf conversion specifiers for POSIX int types.
  vc1: always read the bfraction element for interlaced fields
  fate: add XWD image regression test
  lavf: prevent infinite loops while flushing in avformat_find_stream_info
  matroskadec: Pad AAC extradata.
  ismindex: Fix build on mingw

Conflicts:
	libavformat/mxfdec.c
	libavformat/utils.c
	tests/lavf-regression.sh

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-27 02:09:58 +01:00
Tomas Härdin 62271c4c9a mxfdec: Fix files with essence containers larger than 2 GiB.
For such files, accumulating into an int would cause an overflow.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-01-26 15:47:50 +01:00
Jean First 4fbd3e89e7 mxfdec: Employ correct printf conversion specifiers for POSIX int types.
Signed-off-by: Jean First <jeanfirst@gmail.com>
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-01-26 15:31:55 +01:00
Tomas Härdin b720915be1 mxfdec: Fix files > 2 GiB
Accumulating into an int would cause overflow for files with essence
containers larger than 2 GiB.
2012-01-24 12:42:32 +01:00
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
Janne Grunau 50a3f9a4bd mxfdec: fix memleak on mxf_read_close() 2012-01-23 17:29:58 +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