Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: chromium/patches/to_upstream/12_ogg_seek_to_zero.patch

Issue 9290059: Initial commit of all previous Chrome build scripts. (Closed) Base URL: http://git.chromium.org/chromium/third_party/ffmpeg.git@master
Patch Set: Drop deprecated subfolder. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698