Browse Source

avformat/matroskadec: Fix rounding error with codec_delay

Fixes Ticket5509

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n3.1
Michael Niedermayer 9 years ago
parent
commit
b5bc436ebc
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      libavformat/matroskadec.c

+ 4
- 3
libavformat/matroskadec.c View File

@@ -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 */


Loading…
Cancel
Save