1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-27 15:41:54 +02:00
Commit Graph

863 Commits

Author SHA1 Message Date
Diego Biurrun
67deba8a41 Use avpriv_report_missing_feature() where appropriate 2016-11-08 17:54:34 +01:00
James Almer
70c6a1bcf0 avformat/matroskadec: fix DiscardPadding element parsing
If the value is negative then it means padding at the start of the packet
instead of at the end.

Based on a patch by Hendrik Leppkes.

Reviewed-by: James Zern <jzern-at-google.com@ffmpeg.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-08 13:43:53 -03:00
James Almer
0ad71ed6f9 avformat/matroskadec: fix BitsPerChannel element's default value
The element is currently ignored, so there's no effective functionality
change with this.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-18 23:55:32 -03:00
James Almer
f5cfc0cc54 avformat/matroskadec: clarify some Colour element defaults using enum values
This way it's more clear what the default values refer to, as
Undetermined/Unspecified is 0 for some, 2 for others.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-18 23:55:05 -03:00
James Almer
47ee6f1a59 avformat/matroskadec: support parsing Chroma Location elements
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-18 20:39:07 -03:00
Andreas Cadhalpun
eb751f06db matroskadec: fix NULL pointer dereference
The problem was introduced in commit 1273bc6.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-10-17 15:50:26 +02:00
James Almer
8b59ce0342 Partially revert "avformat/matroskadec: set aspect ratio only when DisplayWidth and DisplayHeight are in pixels"
The code works just fine regardless of unit, so only make sure DisplayUnit
is not "unknown".

Found-by: Nicolas George <george@nsup.org>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-16 14:19:05 -03:00
James Almer
bad8bbc26a avformat/matroskadec: set aspect ratio only when DisplayWidth and DisplayHeight are in pixels
A missing DisplayUnit element or one with the default value of 0 means
DisplayWidth and DisplayHeight should be interpreted as pixels.

The current code setting st->sample_aspect_ratio is wrong when DisplayUnit
is anything else.

Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-15 20:42:07 -03:00
James Almer
1273bc6d26 avformat/matroskadec: workaround the field_order bug in the Matroska muxer
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-13 14:22:07 -03:00
James Almer
a4044498f7 avformat/matroskadec: check for more reserved values on some Colour elements
Signed-off-by: James Almer <jamrial@gmail.com>
2016-10-06 13:49:29 -03: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
James Almer
29b6c2be29 avformat/matroskadec: set AVCodecParameters.field_order on progressive video
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-09-27 20:30:11 -03:00
Sophia Wang
8c83062acb avformat/matroskadec: retain error codes in matroska_resync() and matroska_read_packet()
Signed-off-by: Sophia Wang <skw@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-28 01:24:51 +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
Chris Cunningham
52ec4cc09b libavformat/matroskadec: Add test for seeking with codec delay.
Also cleanup parens for the skip_to_timecode check.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-30 01:02:41 +02:00
Chris Cunningham
d59820f6fe libavformat/matroskadec: fix unsigned overflow to improve seeking
When seeking a file where codec delay is greater than 0, the timecode
can become negative after offsetting by the codec delay. Failing to cast
to a signed int64 will cause the check against skip_to_timecode to evaluate
true for these negative values. This breaks the "skip_to" seek mechanism.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-23 10:32:28 +02:00
Anton Khirnov
40f74dc87a matroskadec: export CodecDelay 2016-07-03 09:13:29 +02:00
Michael Niedermayer
f573acc424 avformat/matroskadec: Call matroska_read_close() on header parsing error
Fixes memleak
Fixes Ticket5169

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-24 18:39:53 +02:00
James Almer
49b0246635 avformat/matroskadec: force 48kHz sample rate when rescaling Opus inital padding
Mkvtoolnix stores the sample rate of the original stream as reported by the
"OpusHead" stream header instead of 48kHz, the actual sample rate of the Opus
stream.
Ignoring the stored sample rate and forcing 48kHz preserves the correct initial
padding when remuxing such files.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-06-07 20:32:25 -03:00
Michael Niedermayer
b5bc436ebc avformat/matroskadec: Fix rounding error with codec_delay
Fixes Ticket5509

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-06 05:01:34 +02:00
Derek Buitenhuis
f3972b3b7d Merge commit '5f0226668124aa7ae4db501ba7f4ace4c770f3d1'
* commit '5f0226668124aa7ae4db501ba7f4ace4c770f3d1':
  matroska: Support interlaced content correctly

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-08 22:58:18 +01:00
Diego Biurrun
5afb94c817 Mark read-only tables as static 2016-05-05 10:48:34 +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
Luca Barbato
5f02266681 matroska: Support interlaced content correctly
The matroska specification now has two elements for it.
2016-03-31 18:03:21 +02:00
Luca Barbato
8b4b1c1eea matroska: Support V_QUICKTIME as written in the specification
Check if the size is written the first 4 bytes and read the next 4
as fourcc candidate, fallback checking the initial for 4 bytes.

"The CodecPrivate contains all additional data that is stored in the
'stsd' (sample description) atom in the QuickTime file after the
mandatory video descriptor structure (starting with the size and FourCC
fields)"

CC: libav-stable@libav.org
2016-03-15 16:06:35 +01:00
Neil Birkbeck
bbda13a771 lavf/matroskadec: Add early support for some of the new colour elements.
Adding early support for a subset of the proposed colour elements
according to the latest version of spec:
https://mailarchive.ietf.org/arch/search/?email_list=cellar&gbt=1&index=hIKLhMdgTMTEwUTeA4ct38h0tmE

I've left out elements for pix_fmt related things as there still
seems to be some discussion around these, and the max_cll/max_fall
are currently not propagated as there is not yet side data for them.

The new elements are exposed under strict experimental mode.

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-04 23:11:51 +01:00
Mats Peterson
6aac43f180 lavf/matroskadec: Process QuickTime palette per track
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-27 02:03:02 +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
Luca Barbato
f273f7fb25 mkv: Force the full parsing of mp3
Some muxer might or might not fit incomplete mp3 frames in
their packets.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-02-19 17:35:33 +01:00
Mats Peterson
535d09a510 lavf/matroskadec: Get sample size from private data
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-16 11:44:46 +01:00
Mats Peterson
adef8ee794 lavf/matroskadec: Use av_realloc() in get_qt_codec()
Use av_realloc() rather than av_malloc() when normalizing noncompliant
private data in get_qt_codec().

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-12 14:53:25 +01:00
Mats Peterson
71f73ee325 lavf/matroskadec: Normalize noncompliant A_QUICKTIME/V_QUICKTIME private data
This patch adds a new static function get_qt_codec() that takes care of
the initial retrieval of the fourcc and codec ID for A_QUICKTIME and
V_QUICKTIME. It also normalizes noncompliant private data found in some
older files that incorrectly starts with the fourcc by expanding/shifting
the data by 4 bytes, and storing the data size at the start. This is
necessary in order for the rest of the code in the A_QUICKTIME and
V_QUICKTIME blocks (and most likely other code as well) to correctly
parse the private data.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-11 01:35:34 +01:00
Mats Peterson
6f1466dc52 lavf/matroskadec: A_QUICKTIME and fourcc 0x00000000
In many older QuickTime files, the audio format, or "fourcc", is
0x00000000. The QuickTime File Format Specification states the following
regarding this situation:

"This format descriptor should not be used, but may be found in some
files. Samples are assumed to be stored in either 'raw ' or 'twos'
format, depending on the sample size field in the sound description."

MPlayer handles this logic by itself, but FFmpeg/FFplay currently does
not.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-08 14:52:53 +01:00
Mats Peterson
6a975cb07f lavf/matroskadec: correct codec_tag for "SMI" SVQ3 files
This corrects the codec_tag for some SVQ3 files

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-06 14:45:52 +01:00
Mats Peterson
7973603843 avformat/matroskadec: palettized QuickTime video in Matroska
Palettized QuickTime video in Matroska has hitherto not been recognized
whatsoever, and the "palette" used has been completely random.

The patch for matroskadec.c fixes this issue by adding a palette side
data packet in matroska_deliver_packet(), much in the same way as it's
done in mov.c.

Video samples for testing are available at
https://drive.google.com/open?id=0B3_pEBoLs0faWElmM2FnLTZYNlk.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-28 02:47:58 +01:00
Hendrik Leppkes
5242cc878a Merge commit 'febfb49a70e82f5ac46dc7ea34dabd4d56b19b31'
* commit 'febfb49a70e82f5ac46dc7ea34dabd4d56b19b31':
  matroskadec: Fix sample_aspect_ratio for stereo matroska content

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-18 14:49:56 +01:00
Carl Eugen Hoyos
7c1c453ce9 lavf/matroskadec: Set codec_tag also for audio codecs.
This was already done for "A_MS/ACM" mkv files and it is done
for mov files but was not done for A_QUICKTIME" mkv files.
2015-12-12 18:21:45 +01:00
Aaron Colwell
febfb49a70 matroskadec: Fix sample_aspect_ratio for stereo matroska content
matroskaenc applies divisors to the display width/height when generating
stereo content. This patch adds the corresponding multipliers to matroskadec
so that the original sample aspect ratio can be recovered.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-12-07 11:27:42 -05:00
Hendrik Leppkes
0ecec7449c Merge commit 'a0fa6d06b848f26b16ba12f0a9a4a85b93ab8022'
* commit 'a0fa6d06b848f26b16ba12f0a9a4a85b93ab8022':
  matroska: Warn when metadata references a non-existent element

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-07 14:51:23 +01:00
Clément Bœsch
43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
Aaron Colwell
ec83efd4d3 avformat/matroskadec: Fix sample_aspect_ratio for stereo matroska content
matroskaenc.c applies divisors to the display width/height when generating
stereo content. This patch adds the corresponding multipliers to matroskadec.c
so that the original sample aspect ratio can be recovered.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
2015-12-02 11:09:07 +01:00
Luca Barbato
a0fa6d06b8 matroska: Warn when metadata references a non-existent element
Avoid some confusion when the information is not present.

Bug-Id: 902
2015-11-28 17:02:15 +01:00
Michael Niedermayer
a5034b324c avformat/matroskadec: Check subtitle stream before dereferencing
Unrecognized streams are not allocated
Fixes: flicker-1.color1.vp91447030769.08.webm

Found-by: Chris Cunningham <chcunningham@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-17 19:02:28 +01:00
Hendrik Leppkes
c2f861ca42 Replace remaining occurances of av_free_packet with av_packet_unref 2015-10-27 14:35:30 +01:00
Hendrik Leppkes
7f5af80ba4 Merge commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457'
* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457':
  avpacket: Replace av_free_packet with av_packet_unref

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-27 14:28:56 +01:00
Luca Barbato
ce70f28a17 avpacket: Replace av_free_packet with av_packet_unref
`av_packet_unref` matches the AVFrame ref-counted API and can be used as
a drop in replacement.

Deprecate `av_free_packet`.
2015-10-26 18:00:55 +01:00
Rodger Combs
4f7d9b7706 lavf/matroskadec: drop indexes that appear broken
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-09 04:43:49 +02:00
Hendrik Leppkes
b01891a9f0 Merge commit '948f3c19a8bd069768ca411212aaf8c1ed96b10d'
* commit '948f3c19a8bd069768ca411212aaf8c1ed96b10d':
  lavc: Make AVPacket.duration int64, and deprecate convergence_duration

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-29 15:22:52 +02:00
wm4
948f3c19a8 lavc: Make AVPacket.duration int64, and deprecate convergence_duration
Note that convergence_duration had another meaning, one which was in
practice never used. The only real use for it was a 64 bit replacement
for the duration field. It's better just to make duration 64 bits, and
to get rid of it.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-29 14:33:00 +02:00
Rodger Combs
cf2719abee lavf/matroska: ignore ChapCountry ID for now
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-20 20:08:01 +02:00
Rodger Combs
b4b2717ffe lavf/matroskadec: Fully parse and repack MP3 packets
Fixes https://trac.ffmpeg.org/ticket/4776

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-16 11:46:33 +02:00
Michael Niedermayer
29d147c94d Merge commit '059a934806d61f7af9ab3fd9f74994b838ea5eba'
* commit '059a934806d61f7af9ab3fd9f74994b838ea5eba':
  lavc: Consistently prefix input buffer defines

Conflicts:
	doc/examples/decoding_encoding.c
	libavcodec/4xm.c
	libavcodec/aac_adtstoasc_bsf.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.h
	libavcodec/asvenc.c
	libavcodec/avcodec.h
	libavcodec/avpacket.c
	libavcodec/dvdec.c
	libavcodec/ffv1enc.c
	libavcodec/g2meet.c
	libavcodec/gif.c
	libavcodec/h264.c
	libavcodec/h264_mp4toannexb_bsf.c
	libavcodec/huffyuvdec.c
	libavcodec/huffyuvenc.c
	libavcodec/jpeglsenc.c
	libavcodec/libxvid.c
	libavcodec/mdec.c
	libavcodec/motionpixels.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/noise_bsf.c
	libavcodec/nuv.c
	libavcodec/nvenc.c
	libavcodec/options.c
	libavcodec/parser.c
	libavcodec/pngenc.c
	libavcodec/proresenc_kostya.c
	libavcodec/qsvdec.c
	libavcodec/svq1enc.c
	libavcodec/tiffenc.c
	libavcodec/truemotion2.c
	libavcodec/utils.c
	libavcodec/utvideoenc.c
	libavcodec/vc1dec.c
	libavcodec/wmalosslessdec.c
	libavformat/adxdec.c
	libavformat/aiffdec.c
	libavformat/apc.c
	libavformat/apetag.c
	libavformat/avidec.c
	libavformat/bink.c
	libavformat/cafdec.c
	libavformat/flvdec.c
	libavformat/id3v2.c
	libavformat/isom.c
	libavformat/matroskadec.c
	libavformat/mov.c
	libavformat/mpc.c
	libavformat/mpc8.c
	libavformat/mpegts.c
	libavformat/mvi.c
	libavformat/mxfdec.c
	libavformat/mxg.c
	libavformat/nutdec.c
	libavformat/oggdec.c
	libavformat/oggparsecelt.c
	libavformat/oggparseflac.c
	libavformat/oggparseopus.c
	libavformat/oggparsespeex.c
	libavformat/omadec.c
	libavformat/rawdec.c
	libavformat/riffdec.c
	libavformat/rl2.c
	libavformat/rmdec.c
	libavformat/rtpdec_latm.c
	libavformat/rtpdec_mpeg4.c
	libavformat/rtpdec_qdm2.c
	libavformat/rtpdec_svq3.c
	libavformat/sierravmd.c
	libavformat/smacker.c
	libavformat/smush.c
	libavformat/spdifenc.c
	libavformat/takdec.c
	libavformat/tta.c
	libavformat/utils.c
	libavformat/vqf.c
	libavformat/westwood_vqa.c
	libavformat/xmv.c
	libavformat/xwma.c
	libavformat/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 23:15:19 +02:00
Vittorio Giovara
059a934806 lavc: Consistently prefix input buffer defines
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:59 +01:00
Michael Niedermayer
ba77fb61f7 Merge commit 'd80811c94e068085aab797f9ba35790529126f85'
* commit 'd80811c94e068085aab797f9ba35790529126f85':
  riff: Use the correct logging context

Conflicts:
	libavformat/asfdec_o.c
	libavformat/avidec.c
	libavformat/dxa.c
	libavformat/matroskadec.c
	libavformat/mov.c
	libavformat/riff.h
	libavformat/riffdec.c
	libavformat/wavdec.c
	libavformat/wtvdec.c
	libavformat/xwma.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-12 15:22:37 +02:00
Luca Barbato
d80811c94e riff: Use the correct logging context 2015-07-11 18:45:44 +02:00
Michael Niedermayer
2f8c81637c avformat/matroskadec: Fix undefined shift in read_sint()
Fixes: asan_heap-oob_17212bc_2243_cov_594210248_h264_TTA.mkv

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-01 12:00:43 +02:00
Andreas Cadhalpun
92e79a2f7b matroskadec: validate audio channels and bitdepth
In the TTA extradata re-construction the values are written with
avio_wl16 and if they don't fit into uint16_t, this triggers an
av_assert2 in avio_w8.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-06-16 21:46:04 +02:00
Andreas Cadhalpun
5b76c82fd7 matroskadec: check audio sample rate
And default to 8000 if it is invalid.

An invalid sample rate can trigger av_assert2 in av_rescale_rnd.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-06-16 21:45:45 +02:00
wm4
7e240f9581 matroskadec: verify seekhead IDs
Some files have SeekHead elements with broken IDs. They mismatch with
the ID of the destination element. These files are written by
"IDMmkvlib0.1" (as identified by the MuxingApp and WritingApp elements),
and the SeekHead IDs are actually endian-swapped.

This confuses the SeekHead logic of the demuxer. It will read some
elements twice, because the SeekHead ID is used to identify and remember
already read elements. With the file at hand, the stream list was
duplicated by reading the Tracks element twice.

Fix this by rejecting invalid EBML IDs in SeekHead entries. (This fix is
relatively specific to the broken file at hand, and doesn't protect
against some other cases of broken SeekHead, such as valid but
mismatching target element IDs.)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-12 19:30:11 +02:00
Michael Niedermayer
e5397513b9 Merge commit '8fc11abe1fea4f211cc7dbd58a173d1221627d90'
* commit '8fc11abe1fea4f211cc7dbd58a173d1221627d90':
  mkv: Print unsupported mov tags when found

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-13 22:04:02 +02:00
Michael Niedermayer
171af59d58 avformat/matroskadec: Cleanup error handling for bz2 & zlib
Fixes CID703652

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-12 18:34:26 +02:00
Vittorio Giovara
8fc11abe1f mkv: Print unsupported mov tags when found 2015-05-12 15:28:31 +01:00
Michael Niedermayer
17b26308a2 avformat/matroskadec: Use size_t for the variable holding a strlen() value.
Should make no difference but is more correct

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-11 04:05:20 +02:00
Michael Niedermayer
5d309d3091 avformat/matroskadec: Use tracks[k]->stream instead of s->streams[k]
The later is not correct

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-04 15:49:58 +02:00
Andreas Cadhalpun
e54540655f matroskadec: check s->streams[k] before using it
This fixes a segmentation fault.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-04 15:48:55 +02:00
Andreas Cadhalpun
eb9fb508b0 matroskadec: use uint64_t instead of int for index_scale
index_scale is set to matroska->time_scale of type uint64_t.

When index_scale is int, the assignment can overflow and e.g. result
in index_scale = 0. This causes a floating point exception due to the
division by index_scale.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-04 00:16:00 +02:00
Michael Niedermayer
c187217287 avformat/matroskadec: Mark static tables as const
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-02 13:27:45 +02:00
Michael Niedermayer
0cab0931dc avformat/matroskadec: remove now duplicate doctype check
See: b8d7f3186e
See: d9fe6b926c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-19 16:47:12 +02:00
Thomas Guillem
b8d7f3186e matroskadec: fix crash when parsing invalid mkv
CC: libav-stable@libav.org

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-04-18 16:49:25 +02:00
Michael Niedermayer
f98cad8759 Merge commit 'b8d7f3186e86234f6255f5e8ee9e98573b4d9a6e'
* commit 'b8d7f3186e86234f6255f5e8ee9e98573b4d9a6e':
  matroskadec: fix crash when parsing invalid mkv

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-18 21:13:25 +02:00
Michael Niedermayer
8e1717cf12 Merge commit 'c4d37cd9ef6e374bb888f6273259b10fac5bd909'
* commit 'c4d37cd9ef6e374bb888f6273259b10fac5bd909':
  matroskadec: export cover art correctly

Conflicts:
	libavformat/matroskadec.c

See: 511585ce7f
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-08 20:37:24 +02:00
wm4
c4d37cd9ef matroskadec: export cover art correctly
Generally, libavformat exports cover art pictures as video streams with
1 packet and AV_DISPOSITION_ATTACHED_PIC set. Only matroskadec exported
it as attachment with codec_id set to AV_CODEC_ID_MJPEG.

Obviously, this should be consistent, so change the Matroska demuxer to
export a AV_DISPOSITION_ATTACHED_PIC pseudo video stream.

Matroska muxing is probably incorrect too. I know that it can create
broken files with an audio track and just 1 video frame when e.g.
remuxing mp3 with APIC to mkv. But for now this commit does not change
anything about muxing, and also continues to write attachments with
AV_CODEC_ID_MJPEG should the muxer application have special knowledge
that the Matroska is broken in this way.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-04-08 12:36:53 +02:00
Vignesh Venkatasubramanian
2171b7c58e matroskadec: Add support for parsing live header files
This patch adds support for parsing live files (produced by
-f webm_chunk) which contains only the headers but no packets. This
is only used when using -f webm_dash_manifest. There will be a
follow up patch which adds live support to WebM DASH Manifest
muxer.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-05 00:39:29 +02:00
wm4
511585ce7f matroskadec: export cover art correctly
Generally, libavformat exports cover art pictures as video streams with
1 packet and AV_DISPOSITION_ATTACHED_PIC set. Only matroskadec exported
it as attachment with codec_id set to AV_CODEC_ID_MJPEG.

Obviously, this should be consistent, so change the Matroska demuxer to
export a AV_DISPOSITION_ATTACHED_PIC pseudo video stream.

Matroska muxing is probably incorrect too. I know that it can create
broken files with an audio track and just 1 video frame when e.g.
remuxing mp3 with APIC to mkv. But for now this commit does not change
anything about muxing, and also continues to write attachments with
AV_CODEC_ID_MJPEG should the muxer application have special knowledge
that the Matroska is broken in this way.

Fixes trac #4423.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-04 02:25:56 +02:00
Michael Niedermayer
b0112019f9 Merge commit '6bdae41d3ef74a0865e8f87896e649f93b2f39bd'
* commit '6bdae41d3ef74a0865e8f87896e649f93b2f39bd':
  matroskadec: Check memory allocations

Conflicts:
	libavformat/matroskadec.c

See: 3e2a5b33f0
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-12 23:51:44 +01:00
Vittorio Giovara
6bdae41d3e matroskadec: Check memory allocations
CC: libav-stable@libav.org
2015-03-12 17:48:14 +00:00
Michael Niedermayer
a0fe1a25fa Merge commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e'
* commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e':
  avformat: Don't anonymously typedef structs

Conflicts:
	libavformat/adtsenc.c
	libavformat/aiffenc.c
	libavformat/avidec.c
	libavformat/gif.c
	libavformat/iff.c
	libavformat/img2dec.c
	libavformat/jvdec.c
	libavformat/matroskadec.c
	libavformat/udp.c
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 21:07:40 +01:00
Diego Biurrun
daf8cf358a avformat: Don't anonymously typedef structs 2015-02-14 10:13:47 -08:00
wm4
7862325f80 avformat/matroskadec: fix IGNIDX handling
Just because the user requested the seek index to be ignored, we can't
just skip essential headers. At least tags are often located at the end
of the file, and the old code simply ignored the seekhead for all
elements, not just the cue index. Also, it looks like it used the index
even if IGNIDX was set if the cue index was located in the beginning of
the file.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-12 17:08:51 +01:00
wm4
cac2295b21 matroska: redo seekhead handling
In particular, this reads chained seekheads. This makes seeking faster
in files which have the index indirectly linked through 2 seekheads.

As a side-effect, this warns when reading level-1 (toplevel) elements
multiple times (other than seekheads, clusters, and void/crc). Such
elements are not valid and likely break everything.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-12 13:51:41 +01:00
wm4
6938a095cb matroska: don't complain about unknown elements
Matroska is an extensible format - unknown elements must be expected. It
shouldn't complain about such elements to the user either; it'll just
generate noise. The "error_recognition & AV_EF_EXPLODE" is completely,
wrong why would it explode on valid files?

It's still useful for debugging, so the message is left in place with a
higher log level.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-09 21:33:33 +01:00
Michael Niedermayer
fc3cdb00d0 avformat/matroskadec: Fix number suffixes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-01 20:00:10 +01:00
Michael Niedermayer
a1062e1437 avformat/matroskadec: Use av_malloc_array() for index_entries
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-25 00:26:53 +01:00
Michael Niedermayer
c1cdce5dcb avformat/matroskadec: Check av_mallocz() return values
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-25 00:26:39 +01:00
Michael Niedermayer
6e70e4aca5 avformat/matroskadec: Use av_freep() to avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-06 15:07:50 +01:00
Thomas Volkert
00d7555f34 wavdec: RIFX file format support
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-18 00:10:35 +01:00
Xiaohan Wang
490a3ebf36 matroskadec: Fix read-after-free in matroska_read_seek()
In matroska_read_seek(), |tracks| is assigned at the begining of the
function. However, functions like matroska_parse_cues() could reallocate
the tracks and invalidate |tracks|.

This assigns |tracks| only before using it, so that it will not get
invalidated elsewhere.

Bug-Id: chromium/427266
2014-12-15 15:46:34 +01:00
Michael Niedermayer
72c984432e avformat/matroskadec: request a sample with recursive seek heads
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-07 22:45:34 +01:00
wm4
6551acab68 avformat/matroskadec: fix handling of recursive SeekHead elements
When matroska_execute_seekhead() is called, it goes through the list of
seekhead entries and attempts to read elements not read yet. When doing
this, the parser can find further SeekHead elements, and will extend the
matroska->seekhead list. This can lead to a (practically) infinite loop
with certain broken files. (Maybe it can happen even with valid files.
The demuxer doesn't seem to check correctly whether an element has
already been read.)

Fix this by ignoring elements that were added to the seekhead field
during executing seekhead entries.

This does not fix the possible situation when multiple SeekHead elements
after the file header (i.e. occur after the "before_pos" file position)
point to the same elements. These elements will probably be parsed
multiple times, likely leading to bugs.

Fixes ticket #4162.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-07 22:30:56 +01:00
Matthew Oliver
0167fa0060 msvc: Fix compilation errors due to header include order.
Ensures that the header include order is such that winsock2.h is always
included before windows.h or that windows.h does not include winsock.h.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-27 12:40:18 +01:00
Xiaohan Wang
33301f0017 Fix read-after-free in matroska_read_seek().
In matroska_read_seek(), |tracks| is assigned at the begining of the function.
However, functions like matroska_parse_cues() could reallocate the tracks so
that |tracks| can get invalidated.

This CL assigns |tracks| only before we use it so that it won't be invalidated.

BUG=427266
TEST=Test case in associated bug passes now.

Change-Id: I9c7065fe8f4311ca846076281df2282d190ed344

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-08 01:33:13 +01:00
Michael Niedermayer
a52cb42ba6 avformat/matroskadec: use gmtime_r() for thread saftey
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-02 19:19:07 +01:00
Michael Niedermayer
f0390638e0 avformat/matroskadec: Check the return code from strftime()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-26 17:07:29 +01:00
Michael Niedermayer
3ae818f6ab Merge commit 'e0caa1eb4e518111a81801db0d2ccdd2733ba94b'
* commit 'e0caa1eb4e518111a81801db0d2ccdd2733ba94b':
  matroskadec: check return values

Conflicts:
	libavformat/matroskadec.c

See: 1116491c53
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-25 04:37:27 +02:00
Vittorio Giovara
e0caa1eb4e matroskadec: check return values
CC: libav-stable@libav.org
Bug-Id: CID 733712
2014-10-24 23:48:51 +01:00
Vittorio Giovara
3c1199c3c4 matroskadec: fix leak on error
CC: libav-stable@libav.org
Bug-Id: CID 1026767
2014-10-24 23:43:25 +01:00
Michael Niedermayer
a39201818f avformat/matroskadec: Fix cluster parsing loop which gathers seek information
Fixes Ticket2263
Fixes Ticket3934

Reviewed-by: Rodger Combs <rodger.combs@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-22 13:40:28 +02:00
Vignesh Venkatasubramanian
233f3ad869 lavf/webm_dash: Allow filenames without directories
Fix basename computation code to allow just file names without any
directories in the path.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-10 00:46:37 +02:00
Michael Niedermayer
be695ee389 avformat/matroskadec: do not trust the default duration to be the real 1/timebase if its less than 5fps
Fixes Ticket3980

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-08 20:39:37 +02:00
Vignesh Venkatasubramanian
b1071db3df lavf/webm_dash: Fix incorrect bandwidth computation
Fix incorrect bandwidth computation in some cases. When the cue end
descriptor is null (i.e.) start_time_ns == -1, existing bandwidth
computed (if any) should be returned rather than returning 0.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-01 20:47:18 +02:00
Vignesh Venkatasubramanian
8acb76567a lavf/webm_dash: fix hardcode in cues_end computation
Fix an incorrect hard code in cues_end computation. Updating the fate
test reference files related to the fix as well. The earlier computation
was clearly wrong as the cues_end field was greater than the file size
itself in some cases.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-01 20:47:11 +02:00
Clément Bœsch
c7d8dbad14 avformat: remove FF_API_ASS_SSA dead code 2014-09-09 21:34:23 +02:00
Michael Niedermayer
37520a91ac avformat: drop redundant MATROSKA_VIDEO_STEREO_MODE_COUNT identifier
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-29 01:26:52 +02:00
Michael Niedermayer
fcc3909908 Merge commit 'd4ae8ac92f619507aadd021bb67b517d39d3a36f'
* commit 'd4ae8ac92f619507aadd021bb67b517d39d3a36f':
  matroskadec: parse stereo mode on decoding

Conflicts:
	Changelog
	libavformat/matroska.c
	libavformat/matroskadec.c

See: 4c509fe305 and others
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-28 23:48:23 +02:00
Michael Niedermayer
56cc754c76 Merge commit 'f2583bc86eb5d7decc639fc9a36edc93e6003eef'
* commit 'f2583bc86eb5d7decc639fc9a36edc93e6003eef':
  matroska: list supported extensions

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-28 22:12:36 +02:00
Vittorio Giovara
d4ae8ac92f matroskadec: parse stereo mode on decoding
Convert the Matroska stereo format to the Stereo3D format, and add a
Stereo3D side data to the stream.

Bump the doctype version supported.

Bug-Id: 728 / https://bugs.debian.org/757185
2014-08-28 12:33:26 -04:00
Vittorio Giovara
f2583bc86e matroska: list supported extensions 2014-08-28 12:33:25 -04:00
Vignesh Venkatasubramanian
080acf7771 lavf/matroskadec: Ensure cues_end is initialized
Ensure that cues_start and cues_end are always initialized and
the webm_dash_manifest_cues function returns appropriate error if
they are not computed correctly.

This fixes coverity defect CID1231991.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-25 18:25:39 +02:00
Reimar Döffinger
a0941c8a2b Use new av_dict_set_int helper function.
Get rid of the many, slightly differing, implementations
of basically the same thing.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2014-08-16 14:31:41 +02:00
Michael Niedermayer
81a663f49e Drop remaining unneeded != NULL
Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-15 22:47:45 +02:00
Michael Niedermayer
60dbed6067 Merge commit '4b1f5e5090abed6c618c8ba380cd7d28d140f867'
* commit '4b1f5e5090abed6c618c8ba380cd7d28d140f867':
  cosmetics: Write NULL pointer inequality checks more compactly

Conflicts:
	libavcodec/dvdsubdec.c
	libavcodec/h263dec.c
	libavcodec/libxvid.c
	libavcodec/rv10.c
	libavcodec/utils.c
	libavformat/format.c
	libavformat/matroskadec.c
	libavformat/segment.c
	libavutil/opt.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-15 21:26:12 +02:00
Michael Niedermayer
fb33bff990 Merge commit 'f929ab0569ff31ed5a59b0b0adb7ce09df3fca39'
* commit 'f929ab0569ff31ed5a59b0b0adb7ce09df3fca39':
  cosmetics: Write NULL pointer equality checks more compactly

Conflicts:
	cmdutils.c
	ffmpeg_opt.c
	ffplay.c
	libavcodec/dvbsub.c
	libavcodec/dvdsubdec.c
	libavcodec/dvdsubenc.c
	libavcodec/dxa.c
	libavcodec/libxvid_rc.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/rv10.c
	libavcodec/tiffenc.c
	libavcodec/utils.c
	libavcodec/vc1dec.c
	libavcodec/zmbv.c
	libavdevice/v4l2.c
	libavformat/matroskadec.c
	libavformat/movenc.c
	libavformat/sdp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-15 21:00:50 +02:00
Gabriel Dume
4b1f5e5090 cosmetics: Write NULL pointer inequality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 05:34:13 -07:00
Gabriel Dume
f929ab0569 cosmetics: Write NULL pointer equality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 03:18:18 -07:00
Justin Jacobs
87dc8b3af9 avformat/matroskadec: Check avpriv_new_chapter() for failure
Fixes null pointer dereference

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-08 21:16:30 +02:00
James Almer
d34ec64a22 replace calls to url_feof() with avio_feof()
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-08 00:48:38 +02:00
Michael Niedermayer
92de445034 Merge commit 'fa38573cd9ce4ab727f86f57c03b113cfd4c9d0a'
* commit 'fa38573cd9ce4ab727f86f57c03b113cfd4c9d0a':
  matroska: Register mime types

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-29 21:18:11 +02:00
Luca Barbato
fa38573cd9 matroska: Register mime types 2014-07-29 17:47:32 +02:00
Michael Niedermayer
e240d01c12 avformat/matroskadec: fix declaration after statement
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-16 00:06:15 +02:00
Vignesh Venkatasubramanian
5a20656946 lavf/matroska: Add functions for WebM DASH Manifest
Add functions and logic to matroskadec for use by the WebM DASH Manifest
XML Muxer. The actual muxer is added in a future patch.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-15 23:56:17 +02:00
Michael Niedermayer
98569d8963 matroskadec: Fix a double negation typo
This typo has existed since this code was added in c16582579.
Newer versions of clang pointed out that this comparison always
was true (since the result of the negation is either 0 or 1, while
AVDISCARD_ALL has the value 48).

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-07-02 20:15:42 +03:00
Diego Biurrun
73953df71a Replace av_malloc() and memset(0) by av_mallocz() 2014-06-22 18:43:11 +02:00
Michael Niedermayer
b3dfebd641 avformat/matroskadec: fix off by 1 error in matroska_read_seek()
Fixes out of array read

Fixes: vp9-opus-crash.webm

Found-by: Dale Curtis <dalecurtis@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-30 13:55:03 +02:00
Michael Niedermayer
579e2b2874 Merge commit '23f741f79327e31be7b2a75ebb2e02111e06e52f'
* commit '23f741f79327e31be7b2a75ebb2e02111e06e52f':
  matroskadec: parse the channel layout mask for FLAC

Conflicts:
	libavformat/oggparsevorbis.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 13:02:19 +02:00
Michael Niedermayer
1c0ce2d4e0 Merge commit '4efdadc8ec50332c812e8a95e8c67f5a260e7cb0'
* commit '4efdadc8ec50332c812e8a95e8c67f5a260e7cb0':
  matroskadec: export just the STREAMINFO block as FLAC extradata

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 12:49:28 +02:00
Michael Niedermayer
69de229bb8 Merge commit '6df478bf891b9fc5626e4a0b993899f310ba0a1c'
* commit '6df478bf891b9fc5626e4a0b993899f310ba0a1c':
  matroskadec: split parsing tracks into a separate function

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 12:41:35 +02:00
Anton Khirnov
23f741f793 matroskadec: parse the channel layout mask for FLAC
It is commonly stored in a vorbiscomment block in codec private data.
2014-05-28 07:50:32 +02:00
Anton Khirnov
4efdadc8ec matroskadec: export just the STREAMINFO block as FLAC extradata
It contains all information that is used by the decoder and the other
FLAC-capable demuxers (flacdec, ogg) export only STREAMINFO as well.
2014-05-28 07:49:15 +02:00
Anton Khirnov
6df478bf89 matroskadec: split parsing tracks into a separate function 2014-05-28 07:48:59 +02:00
Michael Niedermayer
8bf90562f6 Merge commit 'eb3b5501e8b85bfea09d533314cb6920efc42639'
* commit 'eb3b5501e8b85bfea09d533314cb6920efc42639':
  matroskadec: read the CodecDelay element

Conflicts:
	libavformat/matroska.h
	libavformat/matroskadec.c

See: d6f86d74ed
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-01 04:29:40 +02:00
Anton Khirnov
eb3b5501e8 matroskadec: read the CodecDelay element 2014-04-30 21:00:01 +02:00
Carl Eugen Hoyos
ade5851be0 Try mov tags if the fourcc in V_MS/VFW mkv files cannot be found in bmp tags.
Fixes decoding of broken mkv files containing ProRes video from ticket #3434.
2014-04-27 12:52:34 +02:00
Carl Eugen Hoyos
6c18200c2f Only insert the icpf atom in ProRes mkv packets if it isn't already present.
The patch allows to read broken mkv files containing ProRes as written by
the Haali muxer.
Fixes a part of ticket #3434.
2014-04-17 14:46:11 +02:00
Carl Eugen Hoyos
3d5c859fa6 Set Matroska private data when muxing Prores.
The specification requires the mov code point to be written as "fourcc".
2014-04-06 23:35:17 +02:00
Michael Niedermayer
28ee7757f5 Merge commit 'd92024f18fa3d69937cb2575f3a8bf973df02430'
* commit 'd92024f18fa3d69937cb2575f3a8bf973df02430':
  lavf: more correct printf format specifiers

Conflicts:
	libavformat/asfdec.c
	libavformat/cafdec.c
	libavformat/dxa.c
	libavformat/framecrcenc.c
	libavformat/hnm.c
	libavformat/iff.c
	libavformat/mov.c
	libavformat/mxfdec.c
	libavformat/rmdec.c
	libavformat/rpl.c
	libavformat/smacker.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-11 21:05:34 +01:00
Diego Biurrun
d92024f18f lavf: more correct printf format specifiers 2014-03-11 13:13:41 +01:00
Michael Niedermayer
fabf69f37a Merge commit 'f69befe5eefef12172a6479dd9cef3c01bddec7a'
* commit 'f69befe5eefef12172a6479dd9cef3c01bddec7a':
  matroskadec: cosmetics: Fix "attachement" vs. "attachment" typo

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-08 00:13:20 +01:00
Michael Niedermayer
b3d9ab1829 Merge commit '84cfce9f99805a144df684417e166c1ae6f95421'
* commit '84cfce9f99805a144df684417e166c1ae6f95421':
  matroskadec: K&R formatting cosmetics

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-07 23:52:44 +01:00
Diego Biurrun
f69befe5ee matroskadec: cosmetics: Fix "attachement" vs. "attachment" typo 2014-03-07 13:54:18 +01:00
Keiji Costantini
84cfce9f99 matroskadec: K&R formatting cosmetics
Also sort #includes into canonical order.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-03-07 13:39:07 +01:00
Carl Eugen Hoyos
96fc2908f0 Read bits_per_coded_sample from V_MS/VFW/FOURCC mkv files.
Fixes ticket #3425.
2014-02-26 00:02:51 +01:00
Michael Niedermayer
9d13432a90 avformat/matroskadec: identify SMI as SVQ3
Fixes part of Ticket3256

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-19 20:13:38 +01:00
Michael Niedermayer
48218580e1 avformat/matroskadec: support QDM2 as generated by mkvtoolnix-6.7.0
Fixes part of Ticket3256

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-19 18:48:49 +01:00
Michael Niedermayer
5800b08572 avformat/matroskadec: support SVQ3 as generated by mkvtoolnix-6.6.0
Fixes part of Ticket3256

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-19 18:48:11 +01:00
Carl Eugen Hoyos
1132937077 Do not read mkv audio bit_depth if bits_per_coded_sample is already set.
This allows decoding broken mkv files containing G.726 audio.
2014-01-15 23:37:47 +01:00
Michael Niedermayer
a1ed1c2193 avformat/matroskadec: check generic audio deinterleaver sub_packet_size against frame_size
Fixes use of uninitialized memory
Fixes: msan_uninit-mem_7f67d052a530_7517_nosound.mkv
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-10 23:45:43 +01:00
James Almer
2c759d7018 matroskadec: Export the MuxingApp element value as metadata
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-03 04:09:00 +01:00
James Almer
0d944ee343 matroskadec: Fix bug when parsing realaudio codec parameters
flavor can be 0.

This fixes tract ticket #3214

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-25 13:36:25 +01:00
Alex Sukhanov
251c96a70b avformat/matroskadec: Fix start_time
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-24 18:59:46 +01:00
Aurelien Jacobs
8b516f154a matroskadec: use correct compression parameters for current track CodecPrivate
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2013-11-21 20:54:55 +01:00
Anton Khirnov
30be1ea33e matroskadec: pad EBML_BIN data.
It might be passed to code requiring padding, such as lzo decompression.

Fixes invalid reads.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org
2013-11-21 20:54:30 +01:00
Jan Gerber
8cc59ec881 lavf/matroskadec ReferenceBlock is a signed integer
according to the Matroska Specification
ReferenceBlock is a signed integer too.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-16 01:24:40 +01:00
Jan Gerber
f4b1ca99ff lavf/matroska*: DiscardPadding is a signed integer
according to the Matriska Specification
 http://matroska.org/technical/specs/index.html
DiscardPadding is a signed integer.

Tested-by: Jan Gerber <j@v2v.cc>
Tested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-16 00:49:23 +01:00
Michael Niedermayer
cddd15ba5c avformat/matroska: simplify signed int access code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-15 21:38:23 +01:00
Jan Gerber
d03eea36b2 lavf/matroska*: add support for signed integers
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-15 21:38:12 +01:00
Michael Niedermayer
0fbeeb9399 Merge commit '959bea13ce3498a5bddf8a415a061a7bb5a8b075'
* commit '959bea13ce3498a5bddf8a415a061a7bb5a8b075':
  matroskadec: Support HEVC demuxing

Conflicts:
	Changelog
	libavformat/matroskadec.c
	libavformat/version.h

See: 16b6839de6
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-01 17:57:57 +01:00
Yusuke Nakamura
959bea13ce matroskadec: Support HEVC demuxing 2013-10-31 20:20:49 +01:00
Yusuke Nakamura
16b6839de6 lavf/matroskadec: Support HEVC demuxing.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-16 00:17:28 +02:00
Vignesh Venkatasubramanian
d6f86d74ed matroskadec: Demux support for SeekPreRoll and CodecDelay
Adds support for demuxing SeekPreRoll and CodecDelay container
elements.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-14 21:06:59 +02:00
Paul B Mahol
a807c68253 avformat: use ff_alloc_extradata()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-10-13 20:13:38 +00:00
Michael Niedermayer
6853e40106 avformat/matroskadec: only set r_frame_rate if the value is within reasonable limits
Fixes Ticket2451

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-06 00:22:08 +02:00
Michael Niedermayer
57070d9892 Merge commit '668643b9239c70b777aea322eab411ebc960d9a0'
* commit '668643b9239c70b777aea322eab411ebc960d9a0':
  matroskadec: check av_strdup() when setting defaults

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-25 09:39:24 +02:00
Anton Khirnov
668643b923 matroskadec: check av_strdup() when setting defaults 2013-09-24 17:11:50 +02:00
James Almer
56f17407bc matroska: Add the CueDuration element
Use it only on subtitle CuePoints.
With proper demuxer/splitter support this should improve the display
of subtitles right after seeking to a given point in the stream.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-21 14:33:01 +02:00
Monty Montgomery
f6622f9610 avformat/matroskadec: correct spurious keyframe warnings in webm
Minor change to fix for Trac #1003 to avoid squawking about files
with valid keyframes that aren't marked (as opposed to frames that are
marked as keyframes and aren't).

Change correctly surpresses the spurious warnings, while still complaining
about (and handling) the genuinely broken file attached to bug #1003.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-20 03:45:02 +02:00
Paul B Mahol
3e2a5b33f0 avformat/matroskadec: use av_malloc_array() and check for allocation error
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-19 22:28:25 +00:00
Michael Niedermayer
2c8d876dea Merge commit '569d18aa9dc989c37bb4d4b968026fe5afa6fff9'
* commit '569d18aa9dc989c37bb4d4b968026fe5afa6fff9':
  matroskadec: Verify realaudio codec parameters

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-17 15:25:45 +02:00
Martin Storsjö
569d18aa9d matroskadec: Verify realaudio codec parameters
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-09-17 11:22:30 +03:00
James Almer
5ab7b3b948 matroskadec: Mute "Unknown entry" log messages for CueRelativePosition entries
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-15 12:57:19 +02:00
Michael Niedermayer
e529082369 avformat/matroskadec: use av_realloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-11 13:34:25 +02:00
Michael Niedermayer
32805f8521 avformat/matroskadec: ebml_parse_elem() should not deallocate priorly existing lists on failure
This reverts a hunk from "avformat: Use av_reallocp_array() where suitable"

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-11 12:15:08 +02:00
Michael Niedermayer
cbe47b1e84 Merge commit 'f369b9356c4606cd4d713d60f7db5de119d901fa'
* commit 'f369b9356c4606cd4d713d60f7db5de119d901fa':
  avformat: Use av_reallocp_array() where suitable

Conflicts:
	libavformat/asfenc.c
	libavformat/gxfenc.c
	libavformat/mov.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-11 11:23:40 +02:00
Vignesh Venkatasubramanian
7b0a839b0b opus/matroska: Adding support for End Trimming in demuxer/decoder
Implementing support for end trimming Opus in Matroska by making
use of the DiscardPadding value from the container and discarding
the samples accordingly.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-10 23:11:15 +02:00
Alexandra Khirnova
f369b9356c avformat: Use av_reallocp_array() where suitable
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2013-09-10 12:38:32 +02:00
Michael Niedermayer
233ab0f02a Merge commit '5bcd3ae5b167fb74215520b01d5d810e0c8986ab'
* commit '5bcd3ae5b167fb74215520b01d5d810e0c8986ab':
  matroskadec: Check that .lang was allocated and set before reading it

Conflicts:
	libavformat/matroskadec.c

See: 01fd1aa0ad
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-04 12:07:06 +02:00
Martin Storsjö
5bcd3ae5b1 matroskadec: Check that .lang was allocated and set before reading it
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-09-03 22:57:15 +03:00
Matthew Heaney
818ebe930f avformat/matroskadec: add WebVTT support
WebM files now support inband text tracks, as described in the
following specification:

http://wiki.webmproject.org/webm-metadata/temporal-metadata/webvtt-in-webm

The Matroska demuxer now detects the presence of WebVTT tracks,
synthesizing WebVTT packets (having codec id AV_CODEC_ID_WEBVTT) and
pushing them downstream in the normal way.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-19 22:34:57 +02:00
Michael Niedermayer
338f8b2eaf avformat/matroskadec: check out_samplerate before using it in av_rescale()
Prevent assertion failure with damaged input

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-18 02:34:48 +02:00
James Almer
af248fa117 matroskadec: Improve TTA duration calculation
Calculate the duration as accurately as possible to improve decoding of samples
where the last frame is smaller than the rest.

Example:
Take lossless-audio/luckynight-partial.tak from the FATE suit and convert it
to TTA muxed into matroska:

ffmpeg -i $(SAMPLES)/lossless-audio/luckynight-partial.tak -c:a tta lucky.mka

The framemd5 output for lucky.mka without this patch:

0,          0,          0,    46080,   184320, 7c3751ddd571d2903c3cf0ab4b3e3d0a
0,      46080,      46080,    46080,   184320, 6b70c782ba1da3f933fde2daa4f96b73
0,      92160,      92160,    46080,   184320, dcf70d89c54b9a4f0b302d4ec4fb302d
0,     138240,     138240,    46080,   184320, 48713ca38b388d2ea4abf5b86ed1226f
0,     184320,     184320,    46080,   184320, 12188a23648e7ebfb07cd6fe9197b2ea
0,     230400,     230400,    46080,   184320, 49653ab8186a5d4a044ed284671a26e0
0,     276480,     276480,    46080,   184320, 5e82c6a7fe58c7ea612c03a0a2927dd4
0,     322560,     322560,    46080,   184320, 83dc449dbd9eab5f2e8ad2b4403d6a21
0,     368640,     368640,    46080,   184320, bdd6b92c23d30978d4e802d305b0fc49

With this patch:

0,          0,          0,    46080,   184320, 7c3751ddd571d2903c3cf0ab4b3e3d0a
0,      46080,      46080,    46080,   184320, 6b70c782ba1da3f933fde2daa4f96b73
0,      92160,      92160,    46080,   184320, dcf70d89c54b9a4f0b302d4ec4fb302d
0,     138240,     138240,    46080,   184320, 48713ca38b388d2ea4abf5b86ed1226f
0,     184320,     184320,    46080,   184320, 12188a23648e7ebfb07cd6fe9197b2ea
0,     230400,     230400,    46080,   184320, 49653ab8186a5d4a044ed284671a26e0
0,     276480,     276480,    46080,   184320, 5e82c6a7fe58c7ea612c03a0a2927dd4
0,     322560,     322560,    46080,   184320, 83dc449dbd9eab5f2e8ad2b4403d6a21
0,     368640,     368640,    46080,   184320, bdd6b92c23d30978d4e802d305b0fc49
0,     414720,     414720,     4230,    16920, b50b440c5bbcecb8e9fbece643447593

The duration without this patch was calculated as 418950000000, which is bigger
than uint32_t and as such stored as 2338172288.
With this patch the duration is correctly calculated as 418950.

Signed-off-by: James Almer <jamrial@gmail.com>
Approved-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-18 02:34:39 +02:00
Michael Niedermayer
62cf5c114a avformat/matroskadec: make sipr_bit_rate static const
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-04 21:18:49 +02:00
Michael Niedermayer
6158a3bcdf avformat/matroskadec: Detect conflicting sample rate/default_duration
Fixes Ticket2508

Thanks-to: Moritz Bunkus
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-15 17:13:45 +02:00
Michael Niedermayer
045e371cf1 Merge commit '8835c554ff506992c47f6e347c74216ae073f0fa'
* commit '8835c554ff506992c47f6e347c74216ae073f0fa':
  matroskadec: introduce resync function.

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-11 09:16:13 +02:00
Sean McGovern
8835c554ff matroskadec: introduce resync function.
This allows handling matroska files with errors.
Fixes test4.mkv and test7.mkv from the official Matroska test suite,
and by extension Bugzilla #62.

Based on a patch by Reimar Doffinger <Reimar.Doeffinger@gmx.de>

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2013-06-10 20:51:35 +02:00
Paul B Mahol
9644fc95be matroskadec: move ALAC extradata creation bellow AAC one
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-06-08 17:39:51 +00:00
Michael Niedermayer
2fe4b6210c matroskadec: fix memleak of pkt_data
Fixes: CID1026767
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-03 16:08:38 +02:00
Michael Niedermayer
0722b4d08c matroskadec: favor av_freep()
av_freep() is safer as it zeros the pointer

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-03 16:05:09 +02:00
Michael Niedermayer
3ed3aaab32 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  smacker: assign video frame PTS
  matroskadec: export full wavpack blocks.

Conflicts:
	libavcodec/wavpack.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-28 11:58:46 +02:00
Anton Khirnov
9b6f47c448 matroskadec: export full wavpack blocks.
This allows us to get rid of demuxer-specific hacks in the decoder and
will allow streamcopy from matroska once we have a wavpack muxer.
2013-05-28 08:14:35 +02:00
Michael Niedermayer
91db8ff203 Merge commit '564b7e0c0095768cd20001b28154d69462be54e7'
* commit '564b7e0c0095768cd20001b28154d69462be54e7':
  matroskadec: silently skip CodecState element.
  smacker: fix off-by-one error in palette expanding code

Conflicts:
	libavformat/smacker.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-28 08:04:02 +02:00
Anton Khirnov
564b7e0c00 matroskadec: silently skip CodecState element.
mkvmerge apparrently uses it for mpeg1/2 video, but it contains the same
information as CodecPrivate, so it can be ignored.
2013-05-27 21:25:53 +02:00
Michael Niedermayer
4758e32a6c matroska_read_seek: Fix used streams for subtitle index compensation
Might fix Ticket1907 (I have no testcase so i cant test)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-26 13:14:01 +02:00
Michael Niedermayer
729fa55b8f avformat/matroskadec: fix integer overflow
Fixes fate-mkv with ekopath 4

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-19 23:38:01 +02:00
Reimar Döffinger
762d4335ae matroska: set "done" only during resync fail.
Fixes playback of test7.mkv validation test file.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2013-05-07 05:30:19 +02:00
Michael Niedermayer
f083b4c338 Merge commit 'e0f8be6413b6a8d334d6052e610af32935c310af'
* commit 'e0f8be6413b6a8d334d6052e610af32935c310af':
  avformat: Add AVPROBE_SCORE_EXTENSION define and use where appropriate

Conflicts:
	libavformat/ac3dec.c
	libavformat/avformat.h
	libavformat/avs.c
	libavformat/m4vdec.c
	libavformat/mov.c
	libavformat/mp3dec.c
	libavformat/mpeg.c
	libavformat/mpegvideodec.c
	libavformat/psxstr.c
	libavformat/pva.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-05 12:31:03 +02:00
Diego Biurrun
e0f8be6413 avformat: Add AVPROBE_SCORE_EXTENSION define and use where appropriate 2013-05-04 21:43:06 +02:00
Clément Bœsch
7c1a002c78 subtitles: introduce ASS codec id and use it.
Currently, we have a AV_CODEC_ID_SSA, which matches the way the ASS/SSA
markup is muxed in a standalone .ass/.ssa file. This means the AVPacket
data starts with a "Dialogue:" string, followed by a timing information
(start and end of the event as string) and a trailing CRLF after each
line. One packet can contain several lines. We'll refer to this layout
as "SSA" or "SSA lines".

In matroska, this markup is not stored as such: it has no "Dialogue:"
prefix, it contains a ReadOrder field, the timing information is not in
the payload, and it doesn't contain the trailing CRLF. See [1] for more
info. We'll refer to this layout as "ASS".

Since we have only one common codec for both formats, the matroska
demuxer is constructing an AVPacket following the "SSA lines" format.
This causes several problems, so it was decided to change this into
clean ASS packets.

Some insight about what is changed or unchanged in this commit:

  CODECS
  ------

  - the decoding process still writes "SSA lines" markup inside the ass
    fields of the subtitles rectangles (sub->rects[n]->ass), which is
    still the current common way of representing decoded subtitles
    markup. It is meant to change later.

  - new ASS codec id: AV_CODEC_ID_ASS (which is different from the
    legacy AV_CODEC_ID_SSA)

  - lavc/assdec: the "ass" decoder is renamed into "ssa" (instead of
    "ass") for consistency with the codec id and allows to add a real
    ass decoder. This ass decoder receives clean ASS lines (so it starts
    with a ReadOrder, is followed by the Layer, etc). We make sure this
    is decoded properly in a new ass-line rectangle of the decoded
    subtitles (the ssa decoder OTOH is doing a simple straightforward
    copy). Using the packet timing instead of data string makes sure the
    ass-line now contains the appropriate timing.

  - lavc/assenc: just like the ass decoder, the "ssa" encoder is renamed
    into "ssa" (instead of "ass") for consistency with the codec id, and
    allows to add a real "ass" encoder.

    One important thing about this encoder is that it only supports one
    ass rectangle: we could have put several dialogue events in the
    AVPacket (separated by a \0 for instance) but this would have cause
    trouble for the muxer which needs not only the start time, but also
    the duration: typically, you have merged events with the same start
    time (stored in the AVPacket->pts) but a different duration. At the
    moment, only the matroska do the merge with the SSA-line codec.

    We will need to make sure all the decoders in the future can't add
    more than one rectangle (and only one Dialogue line in it
    obviously).

  FORMATS
  -------

  - lavf/assenc: the .ass/.ssa muxer can take both SSA and ASS packets.
    In the case of ASS packets as input, it adds the timing based on the
    AVPacket pts and duration, and mux it with "Dialogue:", trailing
    CRLF, etc.

  - lavf/assdec: unchanged; it currently still only outputs SSA-lines
    packets.

  - lavf/mkv: the demuxer can now output ASS packets without the need of
    any "SSA-lines" reconstruction hack. It will become the default at
    next libavformat bump, and the SSA support will be dropped from the
    demuxer. The muxer can take ASS packets since it's muxed normally,
    and still supports the old SSA packets. All the SSA support and
    hacks in Matroska code will be dropped at next lavf bump.

[1]: http://www.matroska.org/technical/specs/subtitles/ssa.html
2013-04-18 23:23:59 +02:00
Michael Niedermayer
3b93bea9e3 matroskadec: Check EBML lace sizes.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-04 15:51:04 +02:00
Michael Niedermayer
115c3bc41f matroskadec: Check for overflows in xiph lace decoding
This also detects errors earlier

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-04 15:17:57 +02:00
Michael Niedermayer
14de77d677 matroskadec: fix return code for too long xiph laces
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-04 15:13:53 +02:00
Michael Niedermayer
e7389ed5d0 Merge commit 'bcc94328980e6c56546792ab08b0756abdce310b'
* commit 'bcc94328980e6c56546792ab08b0756abdce310b':
  opt: check the return values of av_get_token for ENOMEM.
  doc: Fix best_nb_channells typo
  matroska: pass the lace size to the matroska_parse_rm_audio

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-04 13:00:59 +02:00
Michael Niedermayer
534b292102 Merge commit '8a96df7b70be509dae9ceec82d2c10a20361356d'
* commit '8a96df7b70be509dae9ceec82d2c10a20361356d':
  matroska: fix a corner case in ebml-lace parsing

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-04 12:46:47 +02:00
Michael Niedermayer
f51ce34e5e matroskadec: fix display_width/height = 0 handling
Fixes Ticket2424

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-03 23:45:32 +02:00
Luca Barbato
25a80a931a matroska: pass the lace size to the matroska_parse_rm_audio
Each lace must be independent according to the specification.

Fix heap-buffer-overflow in matroska_parse_block for
corrupted real media in mkv files.

Stricter check than fc43c19a56

CC: libav-stable@libav.org
2013-04-03 12:34:38 +02:00
Luca Barbato
8a96df7b70 matroska: fix a corner case in ebml-lace parsing
Make sure we notice when the lace_size[n] is a negative value.

CC: libav-stable@libav.org
2013-04-03 12:33:15 +02:00
Dale Curtis
fc43c19a56 matroska: Update the available size after lace parsing
Fix heap-buffer-overflow in matroska_parse_block for
corrupted real media in mkv files.

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-04-03 12:33:01 +02:00
Dale Curtis
81e85bc95c Fix heap-buffer-overflow in matroska_parse_block
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-27 23:51:44 +01:00
Michael Niedermayer
ac75e0c755 matroskadec: switch to av_assert
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-22 18:04:17 +01:00
Frank Galligan
b853103fe0 matroskadec: Add support for parsing Matroska ContentEncKeyID
This patch adds the enums for the ContentEncryption elements.
This patch also adds support for parsing the ContentEncKeyID. The
ContentEncKeyID is then base64 encoded and stored in the stream's
metadata.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-20 21:29:55 +01:00
Michael Niedermayer
fdda9b440c matroska_parse_frame: fix memleak
Fixes CID991856
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-19 14:33:47 +01:00
Michael Niedermayer
70c0ae915d matroskadec: avoid integer overflow
Found-by: wm4
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-15 13:48:04 +01:00
Luca Barbato
37cb3b180a matroskadec: request a read buffer for the wav header
Solve an infiniloop.

CC: libav-stable@libav.org
2013-03-12 18:58:06 +01:00
Anton Khirnov
85a5bc054c lavf: remove disabled FF_API_R_FRAME_RATE cruft 2013-03-11 18:23:50 +01:00
Michael Niedermayer
2653e12520 Merge commit '1afddbe59e96af75f1c07605afc95615569f388f'
* commit '1afddbe59e96af75f1c07605afc95615569f388f':
  avpacket: use AVBuffer to allow refcounting the packets.

Conflicts:
	libavcodec/avpacket.c
	libavcodec/utils.c
	libavdevice/v4l2.c
	libavformat/avidec.c
	libavformat/flacdec.c
	libavformat/id3v2.c
	libavformat/matroskaenc.c
	libavformat/mux.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-08 19:12:03 +01:00
Anton Khirnov
1afddbe59e avpacket: use AVBuffer to allow refcounting the packets.
This will allow us to avoid copying the packets in many cases.

This breaks ABI.
2013-03-08 07:33:45 +01:00
Vignesh Venkatasubramanian
003be0a9c3 Removing network.h from matroskadec.c
Removing accidentally added include file.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-14 23:59:41 +01:00
Vignesh Venkatasubramanian
ce6a8e5947 Adding AlphaMode element to Matroska Parser
Adding support for parsing AlphaMode element in the Track header
and export that information as a metadata tag. This flag indicates
presence of alpha channel data in BlockAdditional element.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-14 21:34:47 +01:00
Michael Niedermayer
a08ebf04b1 matroskadec: simplify additional_id writing code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-14 00:55:25 +01:00
Vignesh Venkatasubramanian
30c5c45b12 Adding support for parsing BlockAdditional
Matroska specification lists support for BlockAdditional element
which is not supported by ffmpeg's matroska parser. This patch
adds grammar definitions for parsing that element (and few other
related elements) and then puts the data in AVPacket.side_data
with new AVPacketSideDataType AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-14 00:46:28 +01:00
Michael Niedermayer
7c00d853a6 matroskadec: support seek to non keyframes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-07 21:48:48 +01:00
Paul B Mahol
dd5689a3bd matroskadec: export codec bits_per_coded_sample
Fixes -codec copy with TTA from matroska to matroska.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-01-24 12:15:12 +00:00
Michael Niedermayer
6fc0648932 Merge commit '7b8c5b263bc680eff5710bee5994de39d47fc15e'
* commit '7b8c5b263bc680eff5710bee5994de39d47fc15e':
  vc1dec: prevent a crash due missing pred_flag parameter
  matroska: Fix use after free

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-11 13:01:07 +01:00
Dale Curtis
ae3d416369 matroska: Fix use after free
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-01-11 00:12:08 +01:00
Michael Niedermayer
d0b450457b matroskadec: fix ffio_init_context() usage
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-04 13:01:30 +01:00
Michael Niedermayer
5e1bacf2d4 matroskadec: reset size when freeing data.
Fixes null pointer dereference

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-04 03:50:09 +01:00
Michael Niedermayer
0efcf16a3e replace av_log(0, by av_log(NULL,
The first parameter is a pointer and NULL is more correct

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-23 18:10:02 +01:00
Michael Niedermayer
c2ca0163af matroskadec: check h in generic rm packet shuffler
Fixes crash

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-11 01:19:44 +01:00
Michael Niedermayer
c63e76ba35 ebml_read_binary: use fast_padded_malloc()
Fixes out of array accesses

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-09 23:35:58 +01:00
Michael Niedermayer
2581d9bcbb Merge remote-tracking branch 'qatar/master'
* qatar/master:
  doc: add apidoc target for doxygen API documentation
  matroskadec: do not use avpacket internals

Conflicts:
	doc/Makefile
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-03 14:48:51 +01:00
Anton Khirnov
34871beb5e matroskadec: do not use avpacket internals 2012-11-02 18:28:56 +01:00
Michael Niedermayer
aa604e8e33 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  avutil: Make LZO decoder code configure-time selectable
  avutil: Move memcpy_backptr() to mem.c
  configure: detect parisc64 automatically
  configure: detect ppc64 automatically
  configure: detect mips64 automatically
  configure: generalise 64-bit test
  smoothstreamingenc: Don't assume streams start from timestamp 0

Conflicts:
	configure
	libavutil/Makefile
	libavutil/lzo.c
	libavutil/lzo.h
	libavutil/mem.c
	libavutil/mem.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-25 13:15:58 +02:00
Diego Biurrun
2a91ada828 avutil: Make LZO decoder code configure-time selectable 2012-10-25 11:49:49 +02:00
Michael Niedermayer
2c5b92fe90 matroskadec: fix double negation typo
Fixes CID602563
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-20 16:58:33 +02:00
Michael Niedermayer
1116491c53 matroska_parse_rm_audio: check for malloc failure
Fixes CID733712
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-20 16:55:45 +02:00
Michael Niedermayer
9270a2b374 Merge commit '4c995fafd861f537360b3717901cdbed6a6844e7'
* commit '4c995fafd861f537360b3717901cdbed6a6844e7':
  configure: simplify get_version() function
  build: support asan and tsan toolchain shortcuts
  rmdec: Move SIPR code shared with Matroska demuxer to a separate file

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-16 13:20:46 +02:00
Diego Biurrun
7e68c91e24 rmdec: Move SIPR code shared with Matroska demuxer to a separate file 2012-10-15 13:34:07 +02:00
Michael Niedermayer
406cdddbdd Merge remote-tracking branch 'qatar/master'
* qatar/master:
  libx264: add forgotten ;
  matroskadec: fix a sanity check.
  matroskadec: only return corrupt packets that actually contain data
  lavf: zero data/size of the packet passed to read_packet().
  ARM: use 2-operand syntax for ADD Rd, PC in Apple PIC code
  ARM: align PIC offset pools to 4 bytes
  ARM: swap source operands in some add instructions
  configure: update tms470 detection for latest version
  lavf probe: prevent codec probe with no data at all seen
  motion_est: fix use of inline on extern functions

Conflicts:
	libavcodec/motion_est_template.c
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-21 14:44:32 +02:00
Anton Khirnov
87b017a298 matroskadec: fix a sanity check. 2012-09-21 09:15:07 +02:00
Anton Khirnov
bdb939ad73 matroskadec: only return corrupt packets that actually contain data
Fixes bug 372.
2012-09-21 09:15:01 +02:00
Michael Niedermayer
a6ec1e49f6 matroskadec: matroska_parse_rm_audio: remove unused parameter
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 23:43:20 +02:00
Michael Niedermayer
5864ce13d1 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  mp3dec: read Xing frame TOC index
  mp3dec: use named constants for Xing header flags
  libx264: add support for nal-hrd, required for Blu-ray streams.
  mov: support random access point grouping
  matroskadec: properly support BlockDuration

Conflicts:
	libavcodec/libx264.c
	libavformat/isom.h
	libavformat/matroskadec.c
	libavformat/mov.c
	libavformat/mp3dec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 21:46:35 +02:00
Michael Niedermayer
8c51ea5489 Merge commit 'c831ebf61629d219ebcaa9f02d262e67aad09d83'
* commit 'c831ebf61629d219ebcaa9f02d262e67aad09d83':
  matroskadec: split frame parsing
  matroskadec: split laces parsing

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 20:39:47 +02:00
Michael Niedermayer
b8044972c4 Merge commit '117d8c6d1f1c187ffc6098d9618457e00534e013'
* commit '117d8c6d1f1c187ffc6098d9618457e00534e013':
  matroska: implement support for ProRes
  matroska: implement support for ALAC

Conflicts:
	libavformat/matroskaenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 19:43:38 +02:00
Michael Niedermayer
0da50055eb matroskadec: fix typo
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 19:12:07 +02:00
Michael Niedermayer
6902c3acb0 Merge commit '870e75524aa0d00ebcd1d15589c8d29b84af1565'
* commit '870e75524aa0d00ebcd1d15589c8d29b84af1565':
  matroskadec: validate lace_size when parsed

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 19:11:46 +02:00
Michael Niedermayer
a16c512374 Merge commit 'c9a39cec70603f662f4c326b21b11c4f0112079a'
* commit 'c9a39cec70603f662f4c326b21b11c4f0112079a':
  matroskadec: return meaningful errors in matroska_decode_buffer
  matroskadec: fix incorrect unsigned->signed conversion

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 13:40:47 +02:00
Michael Niedermayer
1df2e3c707 Merge commit '8d4dd55c37b14ecea596f3477b35bf6c20688d8b'
* commit '8d4dd55c37b14ecea596f3477b35bf6c20688d8b':
  matroskadec: refactor matroska_decode_buffer

Conflicts:
	libavformat/matroskadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 13:32:43 +02:00
Michael Niedermayer
61ced71d79 Merge commit '581281e242609a222233a2e5538b89dfb88fb18e'
* commit '581281e242609a222233a2e5538b89dfb88fb18e':
  matroskadec: check realloc in lzo encoding
  matroska: honor error_recognition on unknown doctypes
  tiffdec: Add support for GRAY16LE.
  tiffenc: Add support for little endian RGB48 and GRAY16
  mpeg4: support frame parameter changes with frame-mt
  mpegvideo: check ff_find_unused_picture() return value for errors
  mpegvideo: release frame buffers before freeing them
  configure: msvc: default to 'lib' as 'ar' tool
  build: support some non-standard ar variants

Conflicts:
	libavcodec/h263dec.c
	libavcodec/mpegvideo.c
	libavcodec/tiff.c
	libavcodec/tiffenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-20 03:20:29 +02:00
Luca Barbato
c831ebf616 matroskadec: split frame parsing 2012-09-19 20:34:14 +02:00
Luca Barbato
117d8c6d1f matroska: implement support for ProRes
Support Matroska native formatting.

On demuxing prepend a Frame container atom (32bit big endian encoded
frame size and 'icpf' string).
On muxing remove it.
2012-09-19 20:34:14 +02:00
Luca Barbato
870e75524a matroskadec: validate lace_size when parsed
Stricter validation, explicitly exit on misparsing and some error
forwarding from the ebml parsing functions used.
2012-09-19 20:34:14 +02:00