Browse code

avformat/oggenc: fix page duration calculation when granule differs from timestamp

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>

James Almer authored on 2016/07/08 10:41:55
Showing 1 changed files
... ...
@@ -193,7 +193,7 @@ static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
193 193
         return AVERROR(ENOMEM);
194 194
     l->page = oggstream->page;
195 195
 
196
-    oggstream->page.start_granule = oggstream->page.granule;
196
+    oggstream->page.start_granule = ogg_granule_to_timestamp(oggstream, oggstream->page.granule);
197 197
     oggstream->page_count++;
198 198
     ogg_reset_cur_page(oggstream);
199 199
 
... ...
@@ -265,8 +265,8 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
265 265
 
266 266
             int64_t start = av_rescale_q(page->start_granule, st->time_base,
267 267
                                          AV_TIME_BASE_Q);
268
-            int64_t next  = av_rescale_q(page->granule, st->time_base,
269
-                                         AV_TIME_BASE_Q);
268
+            int64_t next  = av_rescale_q(ogg_granule_to_timestamp(oggstream, page->granule),
269
+                                         st->time_base, AV_TIME_BASE_Q);
270 270
 
271 271
             if (page->segments_count == 255) {
272 272
                 ogg_buffer_page(s, oggstream);