| OLD | NEW |
| (Empty) | |
| 1 diff -wurp -N orig/libavformat/oggdec.c ffmpeg/libavformat/oggdec.c |
| 2 --- orig/libavformat/oggdec.c 2011-07-12 20:48:31.175020888 -0700 |
| 3 +++ ffmpeg/libavformat/oggdec.c 2011-07-12 20:48:31.225013975 -0700 |
| 4 @@ -618,6 +618,8 @@ static int64_t ogg_read_timestamp(AVForm |
| 5 AVIOContext *bc = s->pb; |
| 6 int64_t pts = AV_NOPTS_VALUE; |
| 7 int i = -1; |
| 8 + int packet = 0; |
| 9 + int64_t start_pos = *pos_arg; |
| 10 avio_seek(bc, *pos_arg, SEEK_SET); |
| 11 ogg_reset(ogg); |
| 12 |
| 13 @@ -627,6 +629,12 @@ static int64_t ogg_read_timestamp(AVForm |
| 14 pts = ogg_calc_pts(s, i, NULL); |
| 15 if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY)) |
| 16 pts = AV_NOPTS_VALUE; |
| 17 + |
| 18 + // This is for the special case for the first packet in the stream. |
| 19 + if (pts == AV_NOPTS_VALUE && start_pos <= s->data_offset && !packet
) { |
| 20 + pts = 0; |
| 21 + } |
| 22 + ++packet; |
| 23 } |
| 24 if (pts != AV_NOPTS_VALUE) |
| 25 break; |
| 26 @@ -641,6 +649,10 @@ static int ogg_read_seek(AVFormatContext |
| 27 struct ogg *ogg = s->priv_data; |
| 28 struct ogg_stream *os = ogg->streams + stream_index; |
| 29 int ret; |
| 30 + int64_t seek_pos; |
| 31 + int64_t pos_arg; |
| 32 + int64_t seek_pts; |
| 33 + int i; |
| 34 |
| 35 // Try seeking to a keyframe first. If this fails (very possible), |
| 36 // av_seek_frame will fall back to ignoring keyframes |
| 37 @@ -652,6 +664,22 @@ static int ogg_read_seek(AVFormatContext |
| 38 os = ogg->streams + stream_index; |
| 39 if (ret < 0) |
| 40 os->keyframe_seek = 0; |
| 41 + |
| 42 + // Save the position seeked to. |
| 43 + pos_arg = seek_pos = url_ftell(s->pb); |
| 44 + seek_pts = ogg_read_timestamp(s, stream_index, &pos_arg, url_fsize(s->pb)); |
| 45 + os = ogg->streams + stream_index; |
| 46 + |
| 47 + // Since we have seeked to the beginning then reset lastpts and lastdts to
0. |
| 48 + if (!seek_pts) { |
| 49 + for (i = 0; i < ogg->nstreams; i++){ |
| 50 + struct ogg_stream *stream = ogg->streams + i; |
| 51 + stream->lastpts = 0; |
| 52 + stream->lastdts = 0; |
| 53 + } |
| 54 + os->keyframe_seek = 0; |
| 55 + } |
| 56 + url_fseek(s->pb, seek_pos, SEEK_SET); |
| 57 return ret; |
| 58 } |
| 59 |
| OLD | NEW |