mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 495336 - liboggz oggz_get_next_page() and oggz_read_get_next_page() wrong r=doublec sr=roc a=blocking1.9.1+
This commit is contained in:
parent
1559de55e2
commit
73e0202e9d
@ -17,7 +17,7 @@ function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
var v = document.getElementById('v');
|
||||
ok(Math.round(v.duration*1000) == 3833, "Check duration of video: " + v.duration);
|
||||
is(Math.round(v.duration*1000), 3966, "Check duration of video: " + v.duration);
|
||||
completed = true;
|
||||
clearTimeout(timeout);
|
||||
SimpleTest.finish();
|
||||
|
@ -13,4 +13,6 @@ endian.patch is applied to fix bug 452698.
|
||||
|
||||
bounded_seek.patch is applied to fix bug 469408.
|
||||
|
||||
key_frame_seek.patch fixes buf 463358.
|
||||
key_frame_seek.patch fixes bug 463358.
|
||||
|
||||
offset_next.patch fixes bug 495366.
|
||||
|
184
media/liboggz/offset_next.patch
Normal file
184
media/liboggz/offset_next.patch
Normal file
@ -0,0 +1,184 @@
|
||||
diff --git a/media/liboggz/src/liboggz/oggz_read.c b/media/liboggz/src/liboggz/oggz_read.c
|
||||
--- a/media/liboggz/src/liboggz/oggz_read.c
|
||||
+++ b/media/liboggz/src/liboggz/oggz_read.c
|
||||
@@ -180,61 +180,47 @@ oggz_set_read_page (OGGZ * oggz, long se
|
||||
* returns >= 0 if found; return value is offset of page start
|
||||
* returns -1 on error
|
||||
* returns -2 if EOF was encountered
|
||||
*/
|
||||
static oggz_off_t
|
||||
oggz_read_get_next_page (OGGZ * oggz, ogg_page * og)
|
||||
{
|
||||
OggzReader * reader = &oggz->x.reader;
|
||||
- long bytes = 0, more;
|
||||
- oggz_off_t page_offset = 0, ret;
|
||||
+ long more = 0, page_offset = 0;
|
||||
int found = 0;
|
||||
|
||||
/* Increment oggz->offset by length of the last page processed */
|
||||
oggz->offset += reader->current_page_bytes;
|
||||
|
||||
do {
|
||||
more = ogg_sync_pageseek (&reader->ogg_sync, og);
|
||||
|
||||
if (more == 0) {
|
||||
/* No page available */
|
||||
- page_offset = 0;
|
||||
+ reader->current_page_bytes = 0;
|
||||
return -2;
|
||||
} else if (more < 0) {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: skipped %ld bytes\n", -more);
|
||||
#endif
|
||||
page_offset += (-more);
|
||||
- oggz->offset += (-more);
|
||||
} else {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: page has %ld bytes\n", more);
|
||||
#endif
|
||||
reader->current_page_bytes = more;
|
||||
found = 1;
|
||||
}
|
||||
|
||||
} while (!found);
|
||||
|
||||
-#if 0 /* This is now done by the increment at the top of the file */
|
||||
- /* Calculate the byte offset of the page which was found */
|
||||
- if (bytes > 0) {
|
||||
- oggz->offset = oggz_io_tell (oggz) - bytes + page_offset;
|
||||
- ret = oggz->offset;
|
||||
- } else {
|
||||
- /* didn't need to do any reading -- accumulate the page_offset */
|
||||
- ret = oggz->offset + page_offset;
|
||||
- oggz->offset += page_offset + more;
|
||||
- }
|
||||
+ oggz->offset += page_offset;
|
||||
|
||||
- return ret;
|
||||
-#else
|
||||
return oggz->offset;
|
||||
-#endif
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ogg_packet packet;
|
||||
ogg_int64_t calced_granulepos;
|
||||
oggz_stream_t * stream;
|
||||
OggzReader * reader;
|
||||
OGGZ * oggz;
|
||||
diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c
|
||||
--- a/media/liboggz/src/liboggz/oggz_seek.c
|
||||
+++ b/media/liboggz/src/liboggz/oggz_seek.c
|
||||
@@ -119,16 +119,18 @@ oggz_seek_raw (OGGZ * oggz, oggz_off_t o
|
||||
offset_at = oggz_io_tell (oggz);
|
||||
|
||||
oggz->offset = offset_at;
|
||||
|
||||
ogg_sync_reset (&reader->ogg_sync);
|
||||
|
||||
oggz_vector_foreach(oggz->streams, oggz_seek_reset_stream);
|
||||
|
||||
+ reader->current_page_bytes = 0;
|
||||
+
|
||||
return offset_at;
|
||||
}
|
||||
|
||||
static int
|
||||
oggz_stream_reset (void * data)
|
||||
{
|
||||
oggz_stream_t * stream = (oggz_stream_t *) data;
|
||||
|
||||
@@ -200,74 +202,70 @@ oggz_purge (OGGZ * oggz)
|
||||
* returns -2 if EOF was encountered
|
||||
*/
|
||||
static oggz_off_t
|
||||
oggz_get_next_page (OGGZ * oggz, ogg_page * og)
|
||||
{
|
||||
OggzReader * reader = &oggz->x.reader;
|
||||
char * buffer;
|
||||
long bytes = 0, more;
|
||||
- oggz_off_t page_offset = 0, ret;
|
||||
+ oggz_off_t page_offset = 0;
|
||||
int found = 0;
|
||||
|
||||
+ /* Increment oggz->offset by length of the last page processed */
|
||||
+ oggz->offset += reader->current_page_bytes;
|
||||
+
|
||||
do {
|
||||
more = ogg_sync_pageseek (&reader->ogg_sync, og);
|
||||
|
||||
if (more == 0) {
|
||||
- page_offset = 0;
|
||||
-
|
||||
buffer = ogg_sync_buffer (&reader->ogg_sync, CHUNKSIZE);
|
||||
if ((bytes = (long) oggz_io_read (oggz, buffer, CHUNKSIZE)) == 0) {
|
||||
- if (oggz->file && feof (oggz->file)) {
|
||||
+ if (oggz->file && feof (oggz->file)) {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
- printf ("get_next_page: feof (oggz->file), returning -2\n");
|
||||
+ printf ("get_next_page: feof (oggz->file), returning -2\n");
|
||||
#endif
|
||||
- clearerr (oggz->file);
|
||||
- return -2;
|
||||
- }
|
||||
+ clearerr (oggz->file);
|
||||
+ reader->current_page_bytes = 0;
|
||||
+ return -2;
|
||||
+ }
|
||||
}
|
||||
if (bytes == OGGZ_ERR_SYSTEM) {
|
||||
- /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/
|
||||
- return -1;
|
||||
+ reader->current_page_bytes = 0;
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
if (bytes == 0) {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
- printf ("get_next_page: bytes == 0, returning -2\n");
|
||||
+ printf ("get_next_page: bytes == 0, returning -2\n");
|
||||
#endif
|
||||
- return -2;
|
||||
+ reader->current_page_bytes = 0;
|
||||
+ return -2;
|
||||
}
|
||||
|
||||
ogg_sync_wrote(&reader->ogg_sync, bytes);
|
||||
|
||||
} else if (more < 0) {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: skipped %ld bytes\n", -more);
|
||||
#endif
|
||||
- page_offset -= more;
|
||||
+ page_offset += (-more);
|
||||
} else {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: page has %ld bytes\n", more);
|
||||
#endif
|
||||
+ reader->current_page_bytes = more;
|
||||
found = 1;
|
||||
}
|
||||
|
||||
} while (!found);
|
||||
|
||||
- /* Calculate the byte offset of the page which was found */
|
||||
- if (bytes > 0) {
|
||||
- oggz->offset = oggz_tell_raw (oggz) - bytes + page_offset;
|
||||
- } else {
|
||||
- /* didn't need to do any reading -- accumulate the page_offset */
|
||||
- oggz->offset += page_offset;
|
||||
- }
|
||||
-
|
||||
- ret = oggz->offset + more;
|
||||
+ oggz->offset += page_offset;
|
||||
|
||||
- return ret;
|
||||
+ return oggz->offset;
|
||||
}
|
||||
|
||||
static oggz_off_t
|
||||
oggz_get_next_start_page (OGGZ * oggz, ogg_page * og)
|
||||
{
|
||||
oggz_off_t page_offset;
|
||||
int found = 0;
|
||||
|
@ -185,8 +185,7 @@ static oggz_off_t
|
||||
oggz_read_get_next_page (OGGZ * oggz, ogg_page * og)
|
||||
{
|
||||
OggzReader * reader = &oggz->x.reader;
|
||||
long bytes = 0, more;
|
||||
oggz_off_t page_offset = 0, ret;
|
||||
long more = 0, page_offset = 0;
|
||||
int found = 0;
|
||||
|
||||
/* Increment oggz->offset by length of the last page processed */
|
||||
@ -197,14 +196,13 @@ oggz_read_get_next_page (OGGZ * oggz, ogg_page * og)
|
||||
|
||||
if (more == 0) {
|
||||
/* No page available */
|
||||
page_offset = 0;
|
||||
reader->current_page_bytes = 0;
|
||||
return -2;
|
||||
} else if (more < 0) {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: skipped %ld bytes\n", -more);
|
||||
#endif
|
||||
page_offset += (-more);
|
||||
oggz->offset += (-more);
|
||||
} else {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: page has %ld bytes\n", more);
|
||||
@ -215,21 +213,9 @@ oggz_read_get_next_page (OGGZ * oggz, ogg_page * og)
|
||||
|
||||
} while (!found);
|
||||
|
||||
#if 0 /* This is now done by the increment at the top of the file */
|
||||
/* Calculate the byte offset of the page which was found */
|
||||
if (bytes > 0) {
|
||||
oggz->offset = oggz_io_tell (oggz) - bytes + page_offset;
|
||||
ret = oggz->offset;
|
||||
} else {
|
||||
/* didn't need to do any reading -- accumulate the page_offset */
|
||||
ret = oggz->offset + page_offset;
|
||||
oggz->offset += page_offset + more;
|
||||
}
|
||||
oggz->offset += page_offset;
|
||||
|
||||
return ret;
|
||||
#else
|
||||
return oggz->offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -124,6 +124,8 @@ oggz_seek_raw (OGGZ * oggz, oggz_off_t offset, int whence)
|
||||
|
||||
oggz_vector_foreach(oggz->streams, oggz_seek_reset_stream);
|
||||
|
||||
reader->current_page_bytes = 0;
|
||||
|
||||
return offset_at;
|
||||
}
|
||||
|
||||
@ -205,35 +207,38 @@ oggz_get_next_page (OGGZ * oggz, ogg_page * og)
|
||||
OggzReader * reader = &oggz->x.reader;
|
||||
char * buffer;
|
||||
long bytes = 0, more;
|
||||
oggz_off_t page_offset = 0, ret;
|
||||
oggz_off_t page_offset = 0;
|
||||
int found = 0;
|
||||
|
||||
/* Increment oggz->offset by length of the last page processed */
|
||||
oggz->offset += reader->current_page_bytes;
|
||||
|
||||
do {
|
||||
more = ogg_sync_pageseek (&reader->ogg_sync, og);
|
||||
|
||||
if (more == 0) {
|
||||
page_offset = 0;
|
||||
|
||||
buffer = ogg_sync_buffer (&reader->ogg_sync, CHUNKSIZE);
|
||||
if ((bytes = (long) oggz_io_read (oggz, buffer, CHUNKSIZE)) == 0) {
|
||||
if (oggz->file && feof (oggz->file)) {
|
||||
if (oggz->file && feof (oggz->file)) {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: feof (oggz->file), returning -2\n");
|
||||
printf ("get_next_page: feof (oggz->file), returning -2\n");
|
||||
#endif
|
||||
clearerr (oggz->file);
|
||||
return -2;
|
||||
}
|
||||
clearerr (oggz->file);
|
||||
reader->current_page_bytes = 0;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if (bytes == OGGZ_ERR_SYSTEM) {
|
||||
/*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/
|
||||
return -1;
|
||||
reader->current_page_bytes = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bytes == 0) {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: bytes == 0, returning -2\n");
|
||||
printf ("get_next_page: bytes == 0, returning -2\n");
|
||||
#endif
|
||||
return -2;
|
||||
reader->current_page_bytes = 0;
|
||||
return -2;
|
||||
}
|
||||
|
||||
ogg_sync_wrote(&reader->ogg_sync, bytes);
|
||||
@ -242,27 +247,20 @@ oggz_get_next_page (OGGZ * oggz, ogg_page * og)
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: skipped %ld bytes\n", -more);
|
||||
#endif
|
||||
page_offset -= more;
|
||||
page_offset += (-more);
|
||||
} else {
|
||||
#ifdef DEBUG_VERBOSE
|
||||
printf ("get_next_page: page has %ld bytes\n", more);
|
||||
#endif
|
||||
reader->current_page_bytes = more;
|
||||
found = 1;
|
||||
}
|
||||
|
||||
} while (!found);
|
||||
|
||||
/* Calculate the byte offset of the page which was found */
|
||||
if (bytes > 0) {
|
||||
oggz->offset = oggz_tell_raw (oggz) - bytes + page_offset;
|
||||
} else {
|
||||
/* didn't need to do any reading -- accumulate the page_offset */
|
||||
oggz->offset += page_offset;
|
||||
}
|
||||
|
||||
ret = oggz->offset + more;
|
||||
oggz->offset += page_offset;
|
||||
|
||||
return ret;
|
||||
return oggz->offset;
|
||||
}
|
||||
|
||||
static oggz_off_t
|
||||
|
@ -48,3 +48,4 @@ patch -p3 <wince.patch
|
||||
patch -p3 <endian.patch
|
||||
patch -p3 <bounded_seek.patch
|
||||
patch -p3 <key_frame_seek.patch
|
||||
patch -p3 <offset_next.patch
|
||||
|
Loading…
x
Reference in New Issue
Block a user