Bug 449159 - changes to liboggz required for seeking support
--- a/media/liboggz/README_MOZILLA
+++ b/media/liboggz/README_MOZILLA
@@ -1,4 +1,9 @@
-The source from this directory was copied from the liboggz-0.9.7 source
-distribution using the update.sh script. The only changes made were
-those applied by update.sh and the addition/upate of Makefile.in files
-for the Mozilla build system.
+The source from this directory was copied from the liboggz-0.9.7
+source distribution using the update.sh script. The only changes made
+were those applied by update.sh, which applies a patch from
+seek.patch, and the addition/upate of Makefile.in files for the
+Mozilla build system.
+
+The seek.patch address a bug in liboggz when a seek call returns an
+error. It also addresses an issue where the guess for the seek
+position can exceed the file size. These will be upstreamed to liboggz.
new file mode 100644
--- /dev/null
+++ b/media/liboggz/seek.patch
@@ -0,0 +1,62 @@
+diff --git a/mozilla/media/liboggz/src/liboggz/oggz_seek.c b/mozilla/media/liboggz/src/liboggz/oggz_seek.c
+index f933d4d..23ffb57 100644
+--- a/mozilla/media/liboggz/src/liboggz/oggz_seek.c
++++ b/mozilla/media/liboggz/src/liboggz/oggz_seek.c
+@@ -486,16 +486,18 @@ oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target,
+ serialno = ogg_page_serialno (og);
+ granule_at = ogg_page_granulepos (og);
+ unit_at = oggz_get_unit (oggz, serialno, granule_at);
+
+ break;
+ #else
+ do {
+ offset_at = oggz_get_prev_start_page(oggz, og, &granule_at, &serialno);
++ if (offset_at == -1)
++ return -1;
+ unit_at = oggz_get_unit(oggz, serialno, granule_at);
+ } while (unit_at > unit_target);
+ return offset_at;
+ #endif
+ } else if (unit_at == unit_target) {
+ #ifdef DEBUG
+ printf (" scan: (%lld) == (%lld)\n", unit_at, unit_target);
+ #endif
+@@ -552,16 +554,19 @@ oggz_seek_guess (ogg_int64_t unit_at, ogg_int64_t unit_target,
+ printf ("oggz_seek_guess: unit_end <= unit_begin (ERROR)\n");
+ #endif
+ offset_guess = -1;
+ } else {
+ offset_guess = guess (unit_at, unit_target, unit_begin, unit_end,
+ offset_begin, offset_end);
+ }
+
++ if (offset_end != -1 && guess >= offset_end)
++ offset_guess = offset_begin + (offset_end - offset_begin)/2;
++
+ #ifdef DEBUG
+ printf ("oggz_seek_guess: guessed %" PRI_OGGZ_OFF_T "d\n", offset_guess);
+ #endif
+
+ return offset_guess;
+ }
+
+ static oggz_off_t
+@@ -759,16 +764,18 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
+ } else {
+ break;
+ }
+ }
+
+ found:
+ do {
+ offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno);
++ if (offset_at == -1)
++ break;
+ unit_at = oggz_get_unit (oggz, serialno, granule_at);
+ } while (unit_at > unit_target);
+
+ if (offset_at < 0) {
+ oggz_reset (oggz, offset_orig, -1, SEEK_SET);
+ return -1;
+ }
+
--- a/media/liboggz/src/liboggz/oggz_seek.c
+++ b/media/liboggz/src/liboggz/oggz_seek.c
@@ -486,16 +486,18 @@ oggz_scan_for_page (OGGZ * oggz, ogg_pag
serialno = ogg_page_serialno (og);
granule_at = ogg_page_granulepos (og);
unit_at = oggz_get_unit (oggz, serialno, granule_at);
break;
#else
do {
offset_at = oggz_get_prev_start_page(oggz, og, &granule_at, &serialno);
+ if (offset_at == -1)
+ return -1;
unit_at = oggz_get_unit(oggz, serialno, granule_at);
} while (unit_at > unit_target);
return offset_at;
#endif
} else if (unit_at == unit_target) {
#ifdef DEBUG
printf (" scan: (%lld) == (%lld)\n", unit_at, unit_target);
#endif
@@ -552,16 +554,19 @@ oggz_seek_guess (ogg_int64_t unit_at, og
printf ("oggz_seek_guess: unit_end <= unit_begin (ERROR)\n");
#endif
offset_guess = -1;
} else {
offset_guess = guess (unit_at, unit_target, unit_begin, unit_end,
offset_begin, offset_end);
}
+ if (offset_end != -1 && guess >= offset_end)
+ offset_guess = offset_begin + (offset_end - offset_begin)/2;
+
#ifdef DEBUG
printf ("oggz_seek_guess: guessed %" PRI_OGGZ_OFF_T "d\n", offset_guess);
#endif
return offset_guess;
}
static oggz_off_t
@@ -759,16 +764,18 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t
} else {
break;
}
}
found:
do {
offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno);
+ if (offset_at == -1)
+ break;
unit_at = oggz_get_unit (oggz, serialno, granule_at);
} while (unit_at > unit_target);
if (offset_at < 0) {
oggz_reset (oggz, offset_orig, -1, SEEK_SET);
return -1;
}
--- a/media/liboggz/update.sh
+++ b/media/liboggz/update.sh
@@ -36,8 +36,9 @@ cp $1/src/liboggz/oggz_stream_private.h
cp $1/src/liboggz/oggz_vector.h ./src/liboggz/oggz_vector.h
cp $1/src/liboggz/oggz_auto.h ./src/liboggz/oggz_auto.h
sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_io.c >./src/liboggz/oggz_io.c
sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_vector.c >./src/liboggz/oggz_vector.c
sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/oggz_seek.c >./src/liboggz/oggz_seek.c
cp $1/src/liboggz/oggz_dlist.h ./src/liboggz/oggz_dlist.h
sed s/\#include\ \"config.h\"/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \"config.h\"\\n\#endif/g $1/src/liboggz/metric_internal.c >./src/liboggz/metric_internal.c
cp $1/AUTHORS ./AUTHORS
+patch -p4 <seek.patch
\ No newline at end of file