Commit Graph

660 Commits

Author SHA1 Message Date
Andreas Cadhalpun ff100c9dd9 matroskadec: fix NULL pointer dereference in webm_dash_manifest_read_header
The code assumes that s->streams[0] is valid.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-11-08 20:17:31 +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
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
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
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