[FFmpeg-devel] [PATCH] ogg: Fix seek to zero and packet pts after read through.

Michael Niedermayer michaelni at gmx.at
Wed Apr 25 10:14:03 CEST 2012


On Tue, Apr 24, 2012 at 07:42:31PM -0700, Dale Curtis wrote:
> On Tue, Apr 24, 2012 at 6:57 PM, Michael Niedermayer <michaelni at gmx.at>wrote:
> 
> >
> > i dont seem to have equally as much luck with that stream
> >
> > with the patch:
> > ret: 0         st: 0 flags:0 dts: 0.000000 pts: 0.000000 pos:   6183 size:
> >  4133
> > ret: 0         st: 1 flags:1 dts: 5833.897506 pts: 5833.897506 pos:  10360
> > size:    91
> > ret: 0         st: 1 flags:1 dts: 5833.920726 pts: 5833.920726 pos:  10479
> > size:    91
> > ret: 0         st: 0 flags:1 dts: 5833.920000 pts: 5833.920000 pos:  10598
> > size: 11769
> > ret: 0         st: 1 flags:1 dts: 5833.943946 pts: 5833.943946 pos:  22441
> > size:    94
> > ret: 0         st:-1 flags:0  ts:-1.000000
> > ret: 0         st: 0 flags:0 dts: 0.000000 pts: 0.000000 pos:   6183 size:
> >  4133
> > ret: 0         st: 1 flags:1 dts: 5833.897506 pts: 5833.897506 pos:  10360
> > size:    91
> > ret: 0         st: 1 flags:1 dts: 5833.920726 pts: 5833.920726 pos:  10479
> > size:    91
> > ret: 0         st: 0 flags:1 dts: 5833.920000 pts: 5833.920000 pos:  10598
> > size: 11769
> > ret: 0         st: 1 flags:1 dts: 5833.943946 pts: 5833.943946 pos:  22441
> > size:    94
> >
> > that looks consistent, giving the same both times but still its
> > wrong both times, the first packet ends up with 0 time stamps
> >
> >
> Strange, what are the numbers w/o the patch? The first read_frame shouldn't
> be affected by the patch since neither ogg_read_seek nor ogg_read_timestamp
> have been called by that point, right? I can't find any calls to them in
> any case.

without the patch:
ret: 0         st: 0 flags:0 dts: 0.000000 pts: 0.000000 pos:   6183 size:  4133
ret: 0         st: 1 flags:1 dts: 5833.897506 pts: 5833.897506 pos:  10360 size:    91
ret: 0         st: 1 flags:1 dts: 5833.920726 pts: 5833.920726 pos:  10479 size:    91
ret: 0         st: 0 flags:1 dts: 5833.920000 pts: 5833.920000 pos:  10598 size: 11769
ret: 0         st: 1 flags:1 dts: 5833.943946 pts: 5833.943946 pos:  22441 size:    94
ret: 0         st:-1 flags:0  ts:-1.000000
ret: 0         st: 0 flags:1 dts: 5833.920000 pts: 5833.920000 pos:  10598 size: 11769
ret: 0         st: 1 flags:1 dts: 5833.920000 pts: 5833.920000 pos:  22441 size:    94
ret: 0         st: 1 flags:1 dts: 5833.967166 pts: 5833.967166 pos:  22563 size:   101
ret: 0         st: 0 flags:0 dts: 5833.960000 pts: 5833.960000 pos:  22692 size:  7639
ret: 0         st: 1 flags:1 dts: 5833.990385 pts: 5833.990385 pos:  30388 size:    83

also if i apply the patch but replace the 0 by 1234*25 (see patch) i
get:
ret: 0         st: 0 flags:0 dts: 0.000000 pts: 0.000000 pos:   6183 size:  4133
ret: 0         st: 1 flags:1 dts: 5833.897506 pts: 5833.897506 pos:  10360 size:    91
ret: 0         st: 1 flags:1 dts: 5833.920726 pts: 5833.920726 pos:  10479 size:    91
ret: 0         st: 0 flags:1 dts: 5833.920000 pts: 5833.920000 pos:  10598 size: 11769
ret: 0         st: 1 flags:1 dts: 5833.943946 pts: 5833.943946 pos:  22441 size:    94
ret: 0         st:-1 flags:0  ts:-1.000000
ret: 0         st: 0 flags:0 dts: 1234.000000 pts: 1234.000000 pos:   6183 size:  4133
ret: 0         st: 1 flags:1 dts: 0.699546 pts: 0.699546 pos:  10360 size:    91
ret: 0         st: 1 flags:1 dts: 5833.920726 pts: 5833.920726 pos:  10479 size:    91
ret: 0         st: 0 flags:1 dts: 5833.920000 pts: 5833.920000 pos:  10598 size: 11769
ret: 0         st: 1 flags:1 dts: 5833.943946 pts: 5833.943946 pos:  22441 size:    94

the timestamps leak straight out and 0 and 1234 both are not good
at all


--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -681,7 +681,7 @@ static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,

             // This is for the special case for the first packet in the stream.
             if (pts == AV_NOPTS_VALUE && start_pos <= s->data_offset && !packet) {
-                pts = 0;
+                pts = 1234*25;
             }
             ++packet;
         }
@@ -725,11 +725,11 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index,
     os = ogg->streams + stream_index;

     // Since we have seeked to the beginning then reset lastpts and lastdts to 0.
-    if (!seek_pts) {
+    if (seek_pts == 1234*25) {
         for (i = 0; i < ogg->nstreams; i++){
             struct ogg_stream *stream = ogg->streams + i;
-            stream->lastpts = 0;
-            stream->lastdts = 0;
+            stream->lastpts = 1234*25;
+            stream->lastdts = 1234*25;
         }
         os->keyframe_seek = 0;
     }

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120425/53332ddf/attachment.asc>


More information about the ffmpeg-devel mailing list