aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-06-06 04:23:16 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-06-06 05:01:34 +0200
commitb5bc436ebc57ec60d87f86008a1888fbfb4099bc (patch)
treefbf0860370cb79f9ea43bf5eba56263f47e484b0 /libavformat/matroskadec.c
parentbacc4b6e8173fa944c24f297435dc507a60efb10 (diff)
downloadffmpeg-b5bc436ebc57ec60d87f86008a1888fbfb4099bc.tar.gz
avformat/matroskadec: Fix rounding error with codec_delay
Fixes Ticket5509 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1ef2001465..3270009409 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -219,6 +219,7 @@ typedef struct MatroskaTrack {
MatroskaTrackOperation operation;
EbmlList encodings;
uint64_t codec_delay;
+ uint64_t codec_delay_in_track_tb;
AVStream *stream;
int64_t end_timecode;
@@ -2239,7 +2240,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
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,
+ track->codec_delay_in_track_tb = av_rescale_q(track->codec_delay,
(AVRational){ 1, 1000000000 },
st->time_base);
@@ -2351,7 +2352,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->codec_delay > 0) {
st->codecpar->initial_padding = av_rescale_q(track->codec_delay,
- st->time_base,
+ (AVRational){1, 1000000000},
(AVRational){1, st->codecpar->sample_rate});
}
if (track->seek_preroll > 0) {
@@ -3132,7 +3133,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 - track->codec_delay;
+ timecode = cluster_time + block_time - track->codec_delay_in_track_tb;
if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE &&
timecode < track->end_timecode)
is_keyframe = 0; /* overlapping subtitles are not key frame */