[xiph-commits] r3163 - liboggz/trunk/src/liboggz
shans at svn.annodex.net
shans at svn.annodex.net
Thu Jul 19 01:00:08 PDT 2007
Author: shans
Date: 2007-07-19 01:00:07 -0700 (Thu, 19 Jul 2007)
New Revision: 3163
Modified:
liboggz/trunk/src/liboggz/oggz_seek.c
liboggz/trunk/src/liboggz/oggz_vector.c
liboggz/trunk/src/liboggz/oggz_vector.h
Log:
Some improvements to seeking algorithm
Modified: liboggz/trunk/src/liboggz/oggz_seek.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_seek.c 2007-07-19 05:11:15 UTC (rev 3162)
+++ liboggz/trunk/src/liboggz/oggz_seek.c 2007-07-19 08:00:07 UTC (rev 3163)
@@ -97,19 +97,18 @@
*/
int
-oggz_seek_reset_stream(void *data) {
- ((oggz_stream_t *)data)->last_granulepos = -1;
+oggz_seek_reset_stream(void *data, void *arg) {
+ ((oggz_stream_t *)data)->last_granulepos = (int)arg;
return 0;
}
static oggz_off_t
oggz_seek_raw (OGGZ * oggz, oggz_off_t offset, int whence)
{
- OggzReader * reader = &oggz->x.reader;
- oggz_off_t offset_at;
+ OggzReader * reader = &oggz->x.reader;
+ oggz_off_t offset_at;
+ int i;
- oggz_vector_foreach(oggz->streams, oggz_seek_reset_stream);
-
if (oggz_io_seek (oggz, offset, whence) == -1) {
return -1;
}
@@ -120,6 +119,8 @@
ogg_sync_reset (&reader->ogg_sync);
+ oggz_vector_foreach1(oggz->streams, oggz_seek_reset_stream, -1);
+
return offset_at;
}
@@ -285,8 +286,9 @@
* !ogg_page_continued : page contains start of a packet
* ogg_page_packets > 1: page contains start of a packet
*/
- if (page_offset <= 0 || !ogg_page_continued (og) ||
- ogg_page_packets (og) > 1)
+ /*if (page_offset <= 0 || !ogg_page_continued (og) ||
+ ogg_page_packets (og) > 1)*/
+ if (page_offset <= 0 || ogg_page_granulepos(og) > -1)
found = 1;
}
while (!found);
@@ -377,8 +379,8 @@
offset_at = oggz_reset (oggz, found_offset, unit_at, SEEK_SET);
#ifdef DEBUG
- printf ("get_prev_start_page: [C] offset_at: @%" PRI_OGGZ_OFF "d\t"
- "found_offset: @%" PRO_OGGZ_OFF "d\tunit_at: %lld\n",
+ printf ("get_prev_start_page: [C] offset_at: @%" PRI_OGGZ_OFF_T "d\t"
+ "found_offset: @%" PRI_OGGZ_OFF_T "d\tunit_at: %lld\n",
offset_at, found_offset, unit_at);
#endif
@@ -484,6 +486,10 @@
break;
#else
+ do {
+ offset_at = oggz_get_prev_start_page(oggz, og, &granule_at, &serialno);
+ unit_at = oggz_get_unit(oggz, serialno, granule_at);
+ } while (unit_at > unit_target);
return offset_at;
#endif
} else if (unit_at == unit_target) {
@@ -753,10 +759,11 @@
}
found:
- offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno);
+ do {
+ offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno);
+ unit_at = oggz_get_unit (oggz, serialno, granule_at);
+ } while (unit_at > unit_target);
- unit_at = oggz_get_unit (oggz, serialno, granule_at);
-
if (offset_at < 0) {
oggz_reset (oggz, offset_orig, -1, SEEK_SET);
return -1;
Modified: liboggz/trunk/src/liboggz/oggz_vector.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_vector.c 2007-07-19 05:11:15 UTC (rev 3162)
+++ liboggz/trunk/src/liboggz/oggz_vector.c 2007-07-19 08:00:07 UTC (rev 3163)
@@ -39,6 +39,7 @@
#include "oggz_macros.h"
typedef int (*OggzFunc) (void * data);
+typedef int (*OggzFunc1) (void * data, void * arg);
typedef int (*OggzFindFunc) (void * data, long serialno);
typedef int (*OggzCmpFunc) (const void * a, const void * b, void * user_data);
@@ -196,6 +197,18 @@
return 0;
}
+int
+oggz_vector_foreach1 (OggzVector * vector, OggzFunc1 func, void *arg)
+{
+ int i;
+
+ for (i = 0; i < vector->nr_elements; i++) {
+ func (vector->data[i].p, arg);
+ }
+
+ return 0;
+}
+
static void
_array_swap (oggz_data_t v[], int i, int j)
{
Modified: liboggz/trunk/src/liboggz/oggz_vector.h
===================================================================
--- liboggz/trunk/src/liboggz/oggz_vector.h 2007-07-19 05:11:15 UTC (rev 3162)
+++ liboggz/trunk/src/liboggz/oggz_vector.h 2007-07-19 08:00:07 UTC (rev 3163)
@@ -36,6 +36,7 @@
typedef void OggzVector;
typedef int (*OggzFunc) (void * data);
+typedef int (*OggzFunc1) (void * data, void *arg);
typedef int (*OggzFindFunc) (void * data, long serialno);
typedef int (*OggzCmpFunc) (const void * a, const void * b, void * user_data);
@@ -64,6 +65,9 @@
oggz_vector_foreach (OggzVector * vector, OggzFunc func);
int
+oggz_vector_foreach1 (OggzVector * vector, OggzFunc1 func, void *arg);
+
+int
oggz_vector_size (OggzVector * vector);
/**
More information about the commits
mailing list