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

conrad at svn.annodex.net conrad at svn.annodex.net
Wed Jan 23 20:55:22 PST 2008


Author: conrad
Date: 2008-01-23 20:55:20 -0800 (Wed, 23 Jan 2008)
New Revision: 3377

Modified:
   liboggz/trunk/src/liboggz/oggz.c
   liboggz/trunk/src/liboggz/oggz_auto.c
   liboggz/trunk/src/liboggz/oggz_byteorder.h
   liboggz/trunk/src/liboggz/oggz_private.h
   liboggz/trunk/src/liboggz/oggz_stream.c
Log:
implement numheaders for all codecs (esp. those with variable extra_headers,
ie. speex, flac, skeleton)


Modified: liboggz/trunk/src/liboggz/oggz.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz.c	2008-01-24 04:42:28 UTC (rev 3376)
+++ liboggz/trunk/src/liboggz/oggz.c	2008-01-24 04:55:20 UTC (rev 3377)
@@ -324,7 +324,7 @@
   oggz_comments_init (stream);
 
   stream->content = OGGZ_CONTENT_UNKNOWN;
-  stream->nr_headers = 0;
+  stream->numheaders = 3; /* Default to 3 headers for Ogg logical bitstreams */
   stream->preroll = 0;
   stream->granulerate_n = 1;
   stream->granulerate_d = 1;

Modified: liboggz/trunk/src/liboggz/oggz_auto.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_auto.c	2008-01-24 04:42:28 UTC (rev 3376)
+++ liboggz/trunk/src/liboggz/oggz_auto.c	2008-01-24 04:55:20 UTC (rev 3377)
@@ -38,7 +38,6 @@
 
 #include "config.h"
 
-#if OGGZ_CONFIG_READ
 #include <stdlib.h>
 #include <string.h>
 
@@ -56,6 +55,7 @@
 			    ogg_int64_t granule_rate_numerator,
 			    ogg_int64_t granule_rate_denominator);
 
+#define INT16_BE_AT(x) _be_16((*(ogg_int32_t *)(x)))
 #define INT32_LE_AT(x) _le_32((*(ogg_int32_t *)(x)))
 #define INT32_BE_AT(x) _be_32((*(ogg_int32_t *)(x)))
 #define INT64_LE_AT(x) _le_64((*(ogg_int64_t *)(x)))
@@ -63,10 +63,26 @@
 #define OGGZ_AUTO_MULT 1000Ull
 
 static int
+oggz_stream_set_numheaders (OGGZ * oggz, long serialno, int numheaders)
+{
+  oggz_stream_t * stream;
+
+  if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
+
+  stream = oggz_get_stream (oggz, serialno);
+  if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
+
+  stream->numheaders = numheaders;
+
+  return 0;
+}
+
+static int
 auto_speex (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
 {
   unsigned char * header = op->packet;
   ogg_int64_t granule_rate = 0;
+  int numheaders;
 
   if (op->bytes < 68) return 0;
 
@@ -77,6 +93,9 @@
 
   oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT);
 
+  numheaders = (ogg_int64_t) INT32_LE_AT(&header[68]) + 2;
+  oggz_stream_set_numheaders (oggz, serialno, numheaders);
+
   return 1;
 }
 
@@ -95,6 +114,8 @@
 
   oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT);
 
+  oggz_stream_set_numheaders (oggz, serialno, 3);
+
   return 1;
 }
 
@@ -147,6 +168,8 @@
 			OGGZ_AUTO_MULT * (ogg_int64_t)fps_denominator);
   oggz_set_granuleshift (oggz, serialno, keyframe_shift);
 
+  oggz_stream_set_numheaders (oggz, serialno, 3);
+
   return 1;
 }
 
@@ -195,6 +218,8 @@
     
   oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT);
 
+  oggz_stream_set_numheaders (oggz, serialno, 3);
+
   return 1;
 }
 
@@ -203,6 +228,7 @@
 {
   unsigned char * header = op->packet;
   ogg_int64_t granule_rate = 0;
+  int numheaders;
 
   if (op->bytes < 51) return 0;
 
@@ -214,6 +240,9 @@
 
   oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT);
 
+  numheaders = INT16_BE_AT(&header[7]);
+  oggz_stream_set_numheaders (oggz, serialno, numheaders);
+
   return 1;
 }
 
@@ -236,6 +265,8 @@
 
   oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT);
 
+  oggz_stream_set_numheaders (oggz, serialno, 3);
+
   return 1;
 }
 
@@ -265,6 +296,8 @@
 			OGGZ_AUTO_MULT * granule_rate_denominator);
   oggz_set_granuleshift (oggz, serialno, granuleshift);
 
+  oggz_stream_set_numheaders (oggz, serialno, 3);
+
   return 1;
 }
 
@@ -274,7 +307,7 @@
   unsigned char * header = op->packet;
   long fisbone_serialno; /* The serialno referred to in this fisbone */
   ogg_int64_t granule_rate_numerator = 0, granule_rate_denominator = 0;
-  int granuleshift;
+  int granuleshift, numheaders;
 
   if (op->bytes < 48) return 0;
 
@@ -297,6 +330,10 @@
 			granule_rate_numerator,
 			OGGZ_AUTO_MULT * granule_rate_denominator);
   oggz_set_granuleshift (oggz, fisbone_serialno, granuleshift);
+
+  /* Increment the number of headers for this stream */
+  numheaders = oggz_stream_get_numheaders (oggz, serialno);
+  oggz_stream_set_numheaders (oggz, serialno, numheaders+1);
 				
   return 1;
 }
@@ -310,6 +347,9 @@
   }
   
   oggz_set_granulerate (oggz, serialno, 0, 1);
+
+  /* For skeleton, numheaders will get incremented as each header is seen */
+  oggz_stream_set_numheaders (oggz, serialno, 1);
   
   return 1;
 }
@@ -1004,4 +1044,3 @@
   return 0;
 }
 
-#endif /* OGGZ_CONFIG_READ */

Modified: liboggz/trunk/src/liboggz/oggz_byteorder.h
===================================================================
--- liboggz/trunk/src/liboggz/oggz_byteorder.h	2008-01-24 04:42:28 UTC (rev 3376)
+++ liboggz/trunk/src/liboggz/oggz_byteorder.h	2008-01-24 04:55:20 UTC (rev 3377)
@@ -61,7 +61,6 @@
    return ret;
 }
 
-#ifdef _UNUSED_
 static  unsigned short
 _be_16 (unsigned short s)
 {
@@ -72,7 +71,6 @@
 #endif
   return ret;
 }
-#endif /* _UNUSED_ */
 
 static  ogg_uint32_t
 _be_32 (ogg_uint32_t i)

Modified: liboggz/trunk/src/liboggz/oggz_private.h
===================================================================
--- liboggz/trunk/src/liboggz/oggz_private.h	2008-01-24 04:42:28 UTC (rev 3376)
+++ liboggz/trunk/src/liboggz/oggz_private.h	2008-01-24 04:55:20 UTC (rev 3377)
@@ -80,7 +80,7 @@
 
   /** STATIC INFO */
   int content;
-  int nr_headers;
+  int numheaders;
   int preroll;
   ogg_int64_t granulerate_n;
   ogg_int64_t granulerate_d;

Modified: liboggz/trunk/src/liboggz/oggz_stream.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_stream.c	2008-01-24 04:42:28 UTC (rev 3376)
+++ liboggz/trunk/src/liboggz/oggz_stream.c	2008-01-24 04:55:20 UTC (rev 3377)
@@ -83,7 +83,6 @@
   stream = oggz_get_stream (oggz, serialno);
   if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
 
-  /*return stream->numheaders;*/
-  return 3;
+  return stream->numheaders;
 }
 



More information about the commits mailing list