Commit 8bf90562 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'eb3b5501'

* commit 'eb3b5501':
  matroskadec: read the CodecDelay element

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

See: d6f86d74Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents feaa31d3 eb3b5501
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "libavutil/intfloat.h" #include "libavutil/intfloat.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/lzo.h" #include "libavutil/lzo.h"
#include "libavutil/mathematics.h"
#include "libavcodec/bytestream.h" #include "libavcodec/bytestream.h"
#include "libavcodec/mpeg4audio.h" #include "libavcodec/mpeg4audio.h"
...@@ -170,12 +171,12 @@ typedef struct { ...@@ -170,12 +171,12 @@ typedef struct {
uint64_t default_duration; uint64_t default_duration;
uint64_t flag_default; uint64_t flag_default;
uint64_t flag_forced; uint64_t flag_forced;
uint64_t codec_delay;
uint64_t seek_preroll; uint64_t seek_preroll;
MatroskaTrackVideo video; MatroskaTrackVideo video;
MatroskaTrackAudio audio; MatroskaTrackAudio audio;
MatroskaTrackOperation operation; MatroskaTrackOperation operation;
EbmlList encodings; EbmlList encodings;
uint64_t codec_delay;
AVStream *stream; AVStream *stream;
int64_t end_timecode; int64_t end_timecode;
...@@ -410,6 +411,7 @@ static EbmlSyntax matroska_track[] = { ...@@ -410,6 +411,7 @@ static EbmlSyntax matroska_track[] = {
{ MATROSKA_ID_TRACKTYPE, EBML_UINT, 0, offsetof(MatroskaTrack, type) }, { MATROSKA_ID_TRACKTYPE, EBML_UINT, 0, offsetof(MatroskaTrack, type) },
{ MATROSKA_ID_CODECID, EBML_STR, 0, offsetof(MatroskaTrack, codec_id) }, { MATROSKA_ID_CODECID, EBML_STR, 0, offsetof(MatroskaTrack, codec_id) },
{ MATROSKA_ID_CODECPRIVATE, EBML_BIN, 0, offsetof(MatroskaTrack, codec_priv) }, { MATROSKA_ID_CODECPRIVATE, EBML_BIN, 0, offsetof(MatroskaTrack, codec_priv) },
{ MATROSKA_ID_CODECDELAY, EBML_UINT, 0, offsetof(MatroskaTrack, codec_delay) },
{ MATROSKA_ID_TRACKLANGUAGE, EBML_UTF8, 0, offsetof(MatroskaTrack, language), { .s = "eng" } }, { MATROSKA_ID_TRACKLANGUAGE, EBML_UTF8, 0, offsetof(MatroskaTrack, language), { .s = "eng" } },
{ MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack, default_duration) }, { MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack, default_duration) },
{ MATROSKA_ID_TRACKTIMECODESCALE, EBML_FLOAT, 0, offsetof(MatroskaTrack, time_scale), { .f = 1.0 } }, { MATROSKA_ID_TRACKTIMECODESCALE, EBML_FLOAT, 0, offsetof(MatroskaTrack, time_scale), { .f = 1.0 } },
...@@ -420,7 +422,6 @@ static EbmlSyntax matroska_track[] = { ...@@ -420,7 +422,6 @@ static EbmlSyntax matroska_track[] = {
{ MATROSKA_ID_TRACKOPERATION, EBML_NEST, 0, offsetof(MatroskaTrack, operation), { .n = matroska_track_operation } }, { MATROSKA_ID_TRACKOPERATION, EBML_NEST, 0, offsetof(MatroskaTrack, operation), { .n = matroska_track_operation } },
{ MATROSKA_ID_TRACKCONTENTENCODINGS, EBML_NEST, 0, 0, { .n = matroska_track_encodings } }, { MATROSKA_ID_TRACKCONTENTENCODINGS, EBML_NEST, 0, 0, { .n = matroska_track_encodings } },
{ MATROSKA_ID_TRACKMAXBLKADDID, EBML_UINT, 0, offsetof(MatroskaTrack, max_block_additional_id) }, { MATROSKA_ID_TRACKMAXBLKADDID, EBML_UINT, 0, offsetof(MatroskaTrack, max_block_additional_id) },
{ MATROSKA_ID_CODECDELAY, EBML_UINT, 0, offsetof(MatroskaTrack, codec_delay) },
{ MATROSKA_ID_SEEKPREROLL, EBML_UINT, 0, offsetof(MatroskaTrack, seek_preroll) }, { MATROSKA_ID_SEEKPREROLL, EBML_UINT, 0, offsetof(MatroskaTrack, seek_preroll) },
{ MATROSKA_ID_TRACKFLAGENABLED, EBML_NONE }, { MATROSKA_ID_TRACKFLAGENABLED, EBML_NONE },
{ MATROSKA_ID_TRACKFLAGLACING, EBML_NONE }, { MATROSKA_ID_TRACKFLAGLACING, EBML_NONE },
...@@ -1931,6 +1932,11 @@ static int matroska_read_header(AVFormatContext *s) ...@@ -1931,6 +1932,11 @@ static int matroska_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, matroska->time_scale * track->time_scale, avpriv_set_pts_info(st, 64, matroska->time_scale * track->time_scale,
1000 * 1000 * 1000); /* 64 bit pts in ns */ 1000 * 1000 * 1000); /* 64 bit pts in ns */
/* convert the delay from ns to the track timebase */
track->codec_delay = av_rescale_q(track->codec_delay,
(AVRational){ 1, 1000000000 },
st->time_base);
st->codec->codec_id = codec_id; st->codec->codec_id = codec_id;
if (strcmp(track->language, "und")) if (strcmp(track->language, "und"))
...@@ -2013,7 +2019,7 @@ static int matroska_read_header(AVFormatContext *s) ...@@ -2013,7 +2019,7 @@ static int matroska_read_header(AVFormatContext *s)
st->need_parsing = AVSTREAM_PARSE_HEADERS; st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->codec_delay > 0) { if (track->codec_delay > 0) {
st->codec->delay = av_rescale_q(track->codec_delay, st->codec->delay = av_rescale_q(track->codec_delay,
(AVRational){1, 1000000000}, st->time_base,
(AVRational){1, st->codec->sample_rate}); (AVRational){1, st->codec->sample_rate});
} }
if (track->seek_preroll > 0) { if (track->seek_preroll > 0) {
...@@ -2702,7 +2708,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, ...@@ -2702,7 +2708,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
if (cluster_time != (uint64_t) -1 && if (cluster_time != (uint64_t) -1 &&
(block_time >= 0 || cluster_time >= -block_time)) { (block_time >= 0 || cluster_time >= -block_time)) {
timecode = cluster_time + block_time; timecode = cluster_time + block_time - track->codec_delay;
if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE && if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE &&
timecode < track->end_timecode) timecode < track->end_timecode)
is_keyframe = 0; /* overlapping subtitles are not key frame */ is_keyframe = 0; /* overlapping subtitles are not key frame */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment