зеркало из https://github.com/mozilla/pjs.git
169 строки
4.4 KiB
Diff
169 строки
4.4 KiB
Diff
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
|
|
@@ -176,43 +176,46 @@ 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 more;
|
|
+ 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 */
|
|
+ reader->current_page_bytes = 0;
|
|
return -2;
|
|
} else if (more < 0) {
|
|
#ifdef DEBUG_VERBOSE
|
|
printf ("get_next_page: skipped %ld bytes\n", -more);
|
|
#endif
|
|
- oggz->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);
|
|
|
|
+ oggz->offset += page_offset;
|
|
+
|
|
return oggz->offset;
|
|
}
|
|
|
|
typedef struct {
|
|
ogg_packet packet;
|
|
ogg_int64_t calced_granulepos;
|
|
oggz_stream_t * stream;
|
|
OggzReader * reader;
|
|
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
|
|
@@ -115,16 +115,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;
|
|
|
|
@@ -196,74 +198,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;
|
|
|