Commit b5bc436e authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/matroskadec: Fix rounding error with codec_delay

Fixes Ticket5509
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent bacc4b6e
...@@ -219,6 +219,7 @@ typedef struct MatroskaTrack { ...@@ -219,6 +219,7 @@ typedef struct MatroskaTrack {
MatroskaTrackOperation operation; MatroskaTrackOperation operation;
EbmlList encodings; EbmlList encodings;
uint64_t codec_delay; uint64_t codec_delay;
uint64_t codec_delay_in_track_tb;
AVStream *stream; AVStream *stream;
int64_t end_timecode; int64_t end_timecode;
...@@ -2239,7 +2240,7 @@ static int matroska_parse_tracks(AVFormatContext *s) ...@@ -2239,7 +2240,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
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 */ /* 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 }, (AVRational){ 1, 1000000000 },
st->time_base); st->time_base);
...@@ -2351,7 +2352,7 @@ static int matroska_parse_tracks(AVFormatContext *s) ...@@ -2351,7 +2352,7 @@ static int matroska_parse_tracks(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->codecpar->initial_padding = av_rescale_q(track->codec_delay, st->codecpar->initial_padding = av_rescale_q(track->codec_delay,
st->time_base, (AVRational){1, 1000000000},
(AVRational){1, st->codecpar->sample_rate}); (AVRational){1, st->codecpar->sample_rate});
} }
if (track->seek_preroll > 0) { if (track->seek_preroll > 0) {
...@@ -3132,7 +3133,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, ...@@ -3132,7 +3133,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 - track->codec_delay; timecode = cluster_time + block_time - track->codec_delay_in_track_tb;
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