Bug 481921. Don't crash when timestamps go backwards. r=wiking
authorMats Palmgren <matspal@gmail.com>
Mon, 18 May 2009 10:24:04 +1200
changeset 28474 c4a6d23c2ac90a2345838b0ad6e28460e9387e5b
parent 28473 1523d386e613dff968c65f37246482a9a8f64bb6
child 28475 b225f46f163843697a2cce193fb00ec4288150cf
push id7077
push userrocallahan@mozilla.com
push dateSun, 17 May 2009 22:31:55 +0000
treeherderautoland@773dc0ba39c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswiking
bugs481921
milestone1.9.2a1pre
Bug 481921. Don't crash when timestamps go backwards. r=wiking
media/liboggplay/README_MOZILLA
media/liboggplay/bug481921.patch
media/liboggplay/src/liboggplay/oggplay_callback_info.c
media/liboggplay/update.sh
--- a/media/liboggplay/README_MOZILLA
+++ b/media/liboggplay/README_MOZILLA
@@ -9,12 +9,14 @@ The git commit ID used was b4a7efa06d465
 
 The following local patches have been applied:
 
 bug485291_yuv_align: only use optimized YUV routines if video dimensions are a multiple of the
                      optimized routine's supported alignment.
 
 endian: pick up NSPR's little/big endian defines in oggplay's config.h.
 
+bug481921: fix a crash in oggplay_callback_info_prepare().
+
 trac466: Fix for infinite loop in liboggplay when running decoder on its own thread. Cherry picked from liboggplay git commit e6871f.
 
 bug492436: Fix for that bug cherry picked from liboggplay git commit 4b97ad.
 bug493140: Fix for offsets not being used.
new file mode 100644
--- /dev/null
+++ b/media/liboggplay/bug481921.patch
@@ -0,0 +1,32 @@
+diff --git a/media/liboggplay/src/liboggplay/oggplay_callback_info.c b/media/liboggplay/src/liboggplay/oggplay_callback_info.c
+--- a/media/liboggplay/src/liboggplay/oggplay_callback_info.c
++++ b/media/liboggplay/src/liboggplay/oggplay_callback_info.c
+@@ -133,21 +133,23 @@ oggplay_callback_info_prepare(OggPlay *m
+ 
+     track_info->available_records = count;
+     track_info->required_records = 0;
+ 
+     track_info->data_type = track->decoded_type;
+  
+     count = 0;
+     for (p = q; p != NULL; p = p->next) {
+-      track_info->records[count++] = p;
+-      if (p->presentation_time <= me->target + track->offset) {
+-        track_info->required_records++;
+-        p->has_been_presented = 1;
+-        //lpt = p->presentation_time;
++      if (!p->has_been_presented) {
++        track_info->records[count++] = p;
++        if (p->presentation_time <= me->target + track->offset) {
++          track_info->required_records++;
++          p->has_been_presented = 1;
++          //lpt = p->presentation_time;
++        }
+       }
+     }
+      
+     if (track_info->required_records > 0) {
+       /*
+        * if the StreamState is FIRST_DATA then update it to INITIALISED, 
+        * as we've marked the first data instance
+        */
--- a/media/liboggplay/src/liboggplay/oggplay_callback_info.c
+++ b/media/liboggplay/src/liboggplay/oggplay_callback_info.c
@@ -162,21 +162,23 @@ oggplay_callback_info_prepare(OggPlay *m
 
     track_info->available_records = count;
     track_info->required_records = 0;
 
     track_info->data_type = track->decoded_type;
  
     count = 0;
     for (p = q; p != NULL; p = p->next) {
-      track_info->records[count++] = p;
-      if (p->presentation_time <= me->target + track->offset) {
-        track_info->required_records++;
-        p->has_been_presented = 1;
-        //lpt = p->presentation_time;
+      if (!p->has_been_presented) {
+        track_info->records[count++] = p;
+        if (p->presentation_time <= me->target + track->offset) {
+          track_info->required_records++;
+          p->has_been_presented = 1;
+          //lpt = p->presentation_time;
+        }
       }
     }
      
     if (track_info->required_records > 0) {
       /*
        * if the StreamState is FIRST_DATA then update it to INITIALISED, 
        * as we've marked the first data instance
        */
--- a/media/liboggplay/update.sh
+++ b/media/liboggplay/update.sh
@@ -44,8 +44,9 @@ sed 's/#include <config.h>/#ifdef WIN32\
 #endif/g' ./src/liboggplay/oggplay_private.h1 >./src/liboggplay/oggplay_private.h
 rm ./src/liboggplay/oggplay_private.h1
 sed s/\#ifdef\ HAVE_INTTYPES_H/\#if\ HAVE_INTTYPES_H/g $1/src/liboggplay/oggplay_data.c >./src/liboggplay/oggplay_data.c
 patch -p3 < bug485291_yuv_align.patch
 patch -p3 < endian.patch
 patch -p3 < trac466.patch
 patch -p3 < bug492436.patch
 patch -p3 < bug493140.patch
+patch -p3 < bug481921.patch