diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-04 21:01:38 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-04 21:01:38 +0200 |
commit | c36fd16aaa0bf67b2af254ef8324dc8d8ee9fca7 (patch) | |
tree | bdf26777cde02f7b770ad5d5a3ada936ce50ed73 | |
parent | 8c5897632a326c1d797f0bd45f97e0c83683412c (diff) | |
parent | 82cebc0e0544dce507749dd9b1c2983f083de836 (diff) | |
download | ffmpeg-c36fd16aaa0bf67b2af254ef8324dc8d8ee9fca7.tar.gz |
Merge commit '82cebc0e0544dce507749dd9b1c2983f083de836' into release/2.2
* commit '82cebc0e0544dce507749dd9b1c2983f083de836':
matroskadec: read the CodecDelay element
Conflicts:
libavformat/matroska.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/matroskadec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 8c0ccb0a02..4726e94d8e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -44,6 +44,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" #include "libavutil/lzo.h" +#include "libavutil/mathematics.h" #include "libavutil/dict.h" #if CONFIG_ZLIB #include <zlib.h> @@ -164,12 +165,12 @@ typedef struct { uint64_t default_duration; uint64_t flag_default; uint64_t flag_forced; - uint64_t codec_delay; uint64_t seek_preroll; MatroskaTrackVideo video; MatroskaTrackAudio audio; MatroskaTrackOperation operation; EbmlList encodings; + uint64_t codec_delay; AVStream *stream; int64_t end_timecode; @@ -404,6 +405,7 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_TRACKTYPE, EBML_UINT, 0, offsetof(MatroskaTrack,type) }, { MATROSKA_ID_CODECID, EBML_STR, 0, offsetof(MatroskaTrack,codec_id) }, { 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_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack,default_duration) }, { MATROSKA_ID_TRACKTIMECODESCALE, EBML_FLOAT,0, offsetof(MatroskaTrack,time_scale), {.f=1.0} }, @@ -414,7 +416,6 @@ static EbmlSyntax matroska_track[] = { { 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_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_TRACKFLAGENABLED, EBML_NONE }, { MATROSKA_ID_TRACKFLAGLACING, EBML_NONE }, @@ -1852,6 +1853,11 @@ static int matroska_read_header(AVFormatContext *s) track->time_scale = 1.0; avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 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; if (strcmp(track->language, "und")) @@ -1934,7 +1940,7 @@ static int matroska_read_header(AVFormatContext *s) st->need_parsing = AVSTREAM_PARSE_HEADERS; if (track->codec_delay > 0) { st->codec->delay = av_rescale_q(track->codec_delay, - (AVRational){1, 1000000000}, + st->time_base, (AVRational){1, st->codec->sample_rate}); } if (track->seek_preroll > 0) { @@ -2615,7 +2621,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, if (cluster_time != (uint64_t)-1 && (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 && timecode < track->end_timecode) is_keyframe = 0; /* overlapping subtitles are not key frame */ |