[xiph-commits] r3718 - liboggz/trunk/src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Tue Sep 16 02:33:49 PDT 2008


Author: conrad
Date: 2008-09-16 02:33:49 -0700 (Tue, 16 Sep 2008)
New Revision: 3718

Modified:
   liboggz/trunk/src/liboggz/metric_internal.c
   liboggz/trunk/src/liboggz/oggz_auto.c
   liboggz/trunk/src/liboggz/oggz_private.h
   liboggz/trunk/src/liboggz/oggz_read.c
   liboggz/trunk/src/liboggz/oggz_write.c
Log:
Parse BOS page before calling first page reader callback.
Fixes ticket:416, "oggz-chop writes wrong granulerate in fisbone"
by correcting the library behaviour.
  - Rename internal oggz_auto_get_granulerate() to oggz_auto_read_bos_packet()
  - Add internal oggz_auto_read_bos_page()
  - Use oggz_auto_read_bos_page() when a new bos page is encountered, before
    calling the user's page reader callback
  - Correct the granulerate denominator reported by oggz_get_granulerate,
    removing the internal OGGZ_AUTO_MULT scaling


Modified: liboggz/trunk/src/liboggz/metric_internal.c
===================================================================
--- liboggz/trunk/src/liboggz/metric_internal.c	2008-09-16 09:31:48 UTC (rev 3717)
+++ liboggz/trunk/src/liboggz/metric_internal.c	2008-09-16 09:33:49 UTC (rev 3718)
@@ -158,7 +158,7 @@
   if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
 
   *granulerate_n = stream->granulerate_n;
-  *granulerate_d = stream->granulerate_d;
+  *granulerate_d = stream->granulerate_d / OGGZ_AUTO_MULT;
 
   return 0;
 }

Modified: liboggz/trunk/src/liboggz/oggz_auto.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_auto.c	2008-09-16 09:31:48 UTC (rev 3717)
+++ liboggz/trunk/src/liboggz/oggz_auto.c	2008-09-16 09:33:49 UTC (rev 3718)
@@ -63,8 +63,6 @@
 #define INT32_BE_AT(x) _be_32((*(ogg_int32_t *)(x)))
 #define INT64_LE_AT(x) _le_64((*(ogg_int64_t *)(x)))
 
-#define OGGZ_AUTO_MULT 1000Ull
-
 static int
 oggz_stream_set_numheaders (OGGZ * oggz, long serialno, int numheaders)
 {
@@ -1111,14 +1109,30 @@
 }
 
 int
-oggz_auto_get_granulerate (OGGZ * oggz, ogg_packet * op, long serialno, 
-                void * user_data)
+oggz_auto_read_bos_page (OGGZ * oggz, ogg_page * og, long serialno,
+                         void * user_data)
 {
   int content = 0;
 
   content = oggz_stream_get_content(oggz, serialno);
   if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) {
     return 0;
+  } else if (content == OGGZ_CONTENT_SKELETON && !ogg_page_bos(og)) {
+    return auto_fisbone(oggz, serialno, og->body, og->body_len, user_data);
+  } else {
+    return oggz_auto_codec_ident[content].reader(oggz, serialno, og->body, og->body_len, user_data);
+  }
+}
+
+int
+oggz_auto_read_bos_packet (OGGZ * oggz, ogg_packet * op, long serialno, 
+                           void * user_data)
+{
+  int content = 0;
+
+  content = oggz_stream_get_content(oggz, serialno);
+  if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) {
+    return 0;
   } else if (content == OGGZ_CONTENT_SKELETON && !op->b_o_s) {
     return auto_fisbone(oggz, serialno, op->packet, op->bytes, user_data);
   } else {

Modified: liboggz/trunk/src/liboggz/oggz_private.h
===================================================================
--- liboggz/trunk/src/liboggz/oggz_private.h	2008-09-16 09:31:48 UTC (rev 3717)
+++ liboggz/trunk/src/liboggz/oggz_private.h	2008-09-16 09:33:49 UTC (rev 3718)
@@ -44,6 +44,8 @@
 #include "oggz_vector.h"
 #include "oggz_dlist.h"
 
+#define OGGZ_AUTO_MULT 1000Ull
+
 typedef struct _OGGZ OGGZ;
 typedef struct _OggzComment OggzComment;
 typedef struct _OggzIO OggzIO;
@@ -283,7 +285,10 @@
 /* oggz_auto */
  
 int
-oggz_auto_get_granulerate (OGGZ * oggz, ogg_packet * op, long serialno, 
+oggz_auto_read_bos_page (OGGZ * oggz, ogg_page * og, long serialno,
+                         void * user_data);
+int
+oggz_auto_read_bos_packet (OGGZ * oggz, ogg_packet * op, long serialno, 
                            void * user_data);
 
 int

Modified: liboggz/trunk/src/liboggz/oggz_read.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_read.c	2008-09-16 09:31:48 UTC (rev 3717)
+++ liboggz/trunk/src/liboggz/oggz_read.c	2008-09-16 09:33:49 UTC (rev 3718)
@@ -414,7 +414,7 @@
             (oggz->flags & OGGZ_AUTO)
           ) 
           {
-            oggz_auto_get_granulerate (oggz, op, serialno, NULL);
+            oggz_auto_read_bos_packet (oggz, op, serialno, NULL);
           }
 
           /* attempt to determine granulepos for this packet */
@@ -524,6 +524,10 @@
 
       /* identify stream type */
       oggz_auto_identify_page (oggz, &og, serialno);
+
+      /* read bos data */
+      if (oggz->flags & OGGZ_AUTO)
+        oggz_auto_read_bos_page (oggz, &og, serialno, NULL);
     }
     else if (oggz_stream_get_content(oggz, serialno) == OGGZ_CONTENT_ANXDATA)
     {

Modified: liboggz/trunk/src/liboggz/oggz_write.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_write.c	2008-09-16 09:31:48 UTC (rev 3717)
+++ liboggz/trunk/src/liboggz/oggz_write.c	2008-09-16 09:33:49 UTC (rev 3718)
@@ -290,7 +290,7 @@
   /* OK -- Update stream's memory of packet details */
 
   if (!stream->metric && (oggz->flags & OGGZ_AUTO)) {
-    oggz_auto_get_granulerate (oggz, op, serialno, NULL);
+    oggz_auto_read_bos_packet (oggz, op, serialno, NULL);
   }
 
   stream->b_o_s = 0; /* The stream is henceforth no longer at bos */



More information about the commits mailing list