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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chromium/patches/to_upstream/12_ogg_seek_to_zero.patch
diff --git a/chromium/patches/to_upstream/12_ogg_seek_to_zero.patch b/chromium/patches/to_upstream/12_ogg_seek_to_zero.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c714064e70585060a415357e5e5695dc4b5ea8d3
--- /dev/null
+++ b/chromium/patches/to_upstream/12_ogg_seek_to_zero.patch
@@ -0,0 +1,59 @@
+diff -wurp -N orig/libavformat/oggdec.c ffmpeg/libavformat/oggdec.c
+--- orig/libavformat/oggdec.c 2011-07-12 20:48:31.175020888 -0700
++++ ffmpeg/libavformat/oggdec.c 2011-07-12 20:48:31.225013975 -0700
+@@ -618,6 +618,8 @@ static int64_t ogg_read_timestamp(AVForm
+ AVIOContext *bc = s->pb;
+ int64_t pts = AV_NOPTS_VALUE;
+ int i = -1;
++ int packet = 0;
++ int64_t start_pos = *pos_arg;
+ avio_seek(bc, *pos_arg, SEEK_SET);
+ ogg_reset(ogg);
+
+@@ -627,6 +629,12 @@ static int64_t ogg_read_timestamp(AVForm
+ pts = ogg_calc_pts(s, i, NULL);
+ if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY))
+ pts = AV_NOPTS_VALUE;
++
++ // 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;
++ }
++ ++packet;
+ }
+ if (pts != AV_NOPTS_VALUE)
+ break;
+@@ -641,6 +649,10 @@ static int ogg_read_seek(AVFormatContext
+ struct ogg *ogg = s->priv_data;
+ struct ogg_stream *os = ogg->streams + stream_index;
+ int ret;
++ int64_t seek_pos;
++ int64_t pos_arg;
++ int64_t seek_pts;
++ int i;
+
+ // Try seeking to a keyframe first. If this fails (very possible),
+ // av_seek_frame will fall back to ignoring keyframes
+@@ -652,6 +664,22 @@ static int ogg_read_seek(AVFormatContext
+ os = ogg->streams + stream_index;
+ if (ret < 0)
+ os->keyframe_seek = 0;
++
++ // Save the position seeked to.
++ pos_arg = seek_pos = url_ftell(s->pb);
++ seek_pts = ogg_read_timestamp(s, stream_index, &pos_arg, url_fsize(s->pb));
++ os = ogg->streams + stream_index;
++
++ // Since we have seeked to the beginning then reset lastpts and lastdts to 0.
++ if (!seek_pts) {
++ for (i = 0; i < ogg->nstreams; i++){
++ struct ogg_stream *stream = ogg->streams + i;
++ stream->lastpts = 0;
++ stream->lastdts = 0;
++ }
++ os->keyframe_seek = 0;
++ }
++ url_fseek(s->pb, seek_pos, SEEK_SET);
+ return ret;
+ }
+

Powered by Google App Engine
This is Rietveld 408576698