[FFmpeg-cvslog] avformat/matroskadec: Fix rounding error with codec_delay

Michael Niedermayer git at videolan.org
Mon Jun 6 05:33:10 CEST 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Mon Jun  6 04:23:16 2016 +0200| [b5bc436ebc57ec60d87f86008a1888fbfb4099bc] | committer: Michael Niedermayer

avformat/matroskadec: Fix rounding error with codec_delay

Fixes Ticket5509

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5bc436ebc57ec60d87f86008a1888fbfb4099bc
---

 libavformat/matroskadec.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1ef2001..3270009 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 */



More information about the ffmpeg-cvslog mailing list