[xiph-commits] r3320 - in liboggz/trunk: include/oggz src/liboggz
shans at svn.annodex.net
shans at svn.annodex.net
Wed Jan 2 04:18:27 PST 2008
Author: shans
Date: 2008-01-02 04:18:25 -0800 (Wed, 02 Jan 2008)
New Revision: 3320
Modified:
liboggz/trunk/include/oggz/oggz_constants.h
liboggz/trunk/src/liboggz/Makefile.am
liboggz/trunk/src/liboggz/oggz.c
liboggz/trunk/src/liboggz/oggz_private.h
liboggz/trunk/src/liboggz/oggz_read.c
Log:
Some code for creating skeleton packets on oggz_read, when the
OGGZ_CONSTRUCT_SKELETON flag is set. Note that this doesn't completely
work and isn't used by anything yet. If you want a preview, switch on
the debugging hack line in oggz.c.
Modified: liboggz/trunk/include/oggz/oggz_constants.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_constants.h 2008-01-01 12:47:04 UTC (rev 3319)
+++ liboggz/trunk/include/oggz/oggz_constants.h 2008-01-02 12:18:25 UTC (rev 3320)
@@ -70,8 +70,21 @@
/**
* Suffix
*/
- OGGZ_SUFFIX = 0x80
+ OGGZ_SUFFIX = 0x80,
+ /**
+ * Construct skeleton packets if none are present in the stream. This
+ * operates as a filter both on reading existing streams and on writing
+ * new streams.
+ */
+ OGGZ_CONSTRUCT_SKELETON = 0x100,
+
+ /**
+ * Correct skeleton packets if they are present (but incorrect) in the
+ * stream. This operates as a filter both on reading existing streams and
+ * on writing new streams.
+ */
+ OGGZ_CORRECT_SKELETON = 0x200
};
enum OggzStopCtl {
Modified: liboggz/trunk/src/liboggz/Makefile.am
===================================================================
--- liboggz/trunk/src/liboggz/Makefile.am 2008-01-01 12:47:04 UTC (rev 3319)
+++ liboggz/trunk/src/liboggz/Makefile.am 2008-01-02 12:18:25 UTC (rev 3320)
@@ -19,6 +19,7 @@
oggz_table.c \
oggz_vector.c oggz_vector.h \
oggz_dlist.c oggz_dlist.h \
+ oggz_skeleton.c oggz_skeleton.h \
metric_internal.c
liboggz_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
Modified: liboggz/trunk/src/liboggz/oggz.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz.c 2008-01-01 12:47:04 UTC (rev 3319)
+++ liboggz/trunk/src/liboggz/oggz.c 2008-01-02 12:18:25 UTC (rev 3320)
@@ -82,6 +82,14 @@
if (oggz == NULL) return NULL;
oggz->flags = flags;
+ /** DEBUGGING HACK SGS **/
+ // oggz->flags |= OGGZ_CONSTRUCT_SKELETON;
+ /** END DEBUGGING HACK **/
+
+ /* need auto-identify to construct skeleton */
+ if (oggz->flags & OGGZ_CONSTRUCT_SKELETON) {
+ oggz->flags |= OGGZ_AUTO;
+ }
oggz->file = NULL;
oggz->io = NULL;
@@ -101,8 +109,17 @@
oggz->order = NULL;
oggz->order_user_data = NULL;
- oggz->packet_buffer = oggz_dlist_new ();
+ if (oggz->flags & OGGZ_AUTO) {
+ oggz->packet_buffer = oggz_dlist_new ();
+ }
+ if (oggz->flags & OGGZ_CONSTRUCT_SKELETON) {
+ oggz->bos_buffer = oggz_dlist_new ();
+ }
+
+ oggz->non_bos_encountered = 0;
+ oggz->skeleton_seen = 0;
+
if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) {
oggz_write_init (oggz);
} else if (OGGZ_CONFIG_READ) {
@@ -316,6 +333,19 @@
{
oggz_stream_t * stream;
+ /*
+ * if we're trying to construct a skeleton and we have encountered an
+ * out-of-order bos packet then we can't really continue as we've already
+ * output the skeleton EOS
+ */
+ if
+ (
+ oggz->non_bos_encountered == 1 && (oggz->flags & OGGZ_CONSTRUCT_SKELETON)
+ )
+ {
+ return NULL;
+ }
+
stream = oggz_malloc (sizeof (oggz_stream_t));
if (stream == NULL) return NULL;
Modified: liboggz/trunk/src/liboggz/oggz_private.h
===================================================================
--- liboggz/trunk/src/liboggz/oggz_private.h 2008-01-01 12:47:04 UTC (rev 3319)
+++ liboggz/trunk/src/liboggz/oggz_private.h 2008-01-02 12:18:25 UTC (rev 3320)
@@ -230,6 +230,10 @@
OggzVector * streams;
int all_at_eos; /* all streams are at eos */
+ int non_bos_encountered; /* a non-bos packet has been seen */
+ int skeleton_seen;
+ long skeleton_serialno;
+ int skeleton_packetno;
OggzMetric metric;
void * metric_user_data;
@@ -244,6 +248,7 @@
} x;
OggzDList * packet_buffer;
+ OggzDList * bos_buffer;
};
OGGZ * oggz_read_init (OGGZ * oggz);
Modified: liboggz/trunk/src/liboggz/oggz_read.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_read.c 2008-01-01 12:47:04 UTC (rev 3319)
+++ liboggz/trunk/src/liboggz/oggz_read.c 2008-01-02 12:18:25 UTC (rev 3320)
@@ -59,6 +59,7 @@
#include "oggz_compat.h"
#include "oggz_private.h"
+#include "oggz_skeleton.h"
/* #define DEBUG */
/* #define DEBUG_VERBOSE */
@@ -328,6 +329,31 @@
return DLIST_ITER_CONTINUE;
}
+OggzDListIterResponse
+oggz_read_create_fisbone(void *elem) {
+
+ OggzBufferedPacket *p = (OggzBufferedPacket *)elem;
+
+ int packets;
+
+ ogg_packet *op = oggz_skeleton_create_fisbone(p->serialno, p->stream->content,
+ p->stream->granulerate_n, p->stream->granulerate_d,
+ p->stream->basegranule, p->stream->granuleshift,
+ &packets, (p->oggz->skeleton_packetno)++);
+
+ if (p->stream->read_packet) {
+ p->stream->read_packet(p->oggz, op, p->oggz->skeleton_serialno,
+ p->stream->read_user_data);
+ } else if (p->reader->read_packet) {
+ p->reader->read_packet(p->oggz, op, p->oggz->skeleton_serialno,
+ p->reader->read_user_data);
+ }
+
+ oggz_skeleton_destroy_packet(op);
+
+ return DLIST_ITER_CONTINUE;
+}
+
static int
oggz_read_sync (OGGZ * oggz)
{
@@ -363,11 +389,13 @@
if (stream == NULL) {
/* new stream ... check bos etc. */
+ assert(!"there should be no new streams here!\n");
if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
/* error -- could not add stream */
return -7;
}
}
+
os = &stream->ogg_stream;
result = ogg_stream_packetout(os, op);
@@ -401,7 +429,7 @@
granulepos = op->granulepos;
content = oggz_stream_get_content(oggz, serialno);
-
+
/*
* if we have no metrics for this stream yet, then generate them
*/
@@ -442,7 +470,46 @@
if (stream->packetno == 1) {
oggz_auto_read_comments (oggz, stream, serialno, op);
}
-
+
+ /*
+ * don't emit BOS packets until there's a non-BOS packet or
+ * until a Skeleton BOS has been seen
+ */
+ if (oggz->flags & OGGZ_CONSTRUCT_SKELETON) {
+
+ if (content == OGGZ_CONTENT_SKELETON) {
+ oggz->skeleton_seen = 1;
+ oggz->skeleton_serialno = serialno;
+ }
+
+ if (!(oggz->non_bos_encountered || oggz->skeleton_seen)) {
+ OggzBufferedPacket *p = oggz_read_new_pbuffer_entry(
+ oggz, &packet, reader->current_granulepos,
+ serialno, stream, reader);
+ oggz_dlist_append(oggz->bos_buffer, p);
+ continue;
+ }
+
+ if (!oggz_dlist_is_empty(oggz->bos_buffer)) {
+ ogg_packet *op = oggz_skeleton_create_bos(0, 1000, 0, 1000);
+ if (stream->read_packet) {
+ cb_ret = stream->read_packet (oggz, op, serialno,
+ stream->read_user_data);
+ } else if (reader->read_packet) {
+ cb_ret = reader->read_packet (oggz, op, serialno,
+ reader->read_user_data);
+ }
+ oggz_skeleton_destroy_packet(op);
+ oggz_dlist_iter(oggz->bos_buffer, oggz_read_deliver_packet);
+ oggz->skeleton_packetno = 1;
+ oggz_dlist_iter(oggz->bos_buffer, oggz_read_create_fisbone);
+ oggz_dlist_delete(oggz->bos_buffer);
+ oggz->bos_buffer = oggz_dlist_new();
+
+ }
+
+ }
+
if (oggz->flags & OGGZ_AUTO) {
/*
@@ -513,13 +580,16 @@
stream = oggz_get_stream (oggz, serialno);
+ if (stream != NULL) {
+ oggz->non_bos_encountered = 1;
+ }
+
if (stream == NULL) {
/* new stream ... check bos etc. */
if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
/* error -- could not add stream */
return -7;
}
-
/* identify stream type */
oggz_auto_identify(oggz, &og, serialno);
}
More information about the commits
mailing list