[xiph-commits] r9505 - in trunk/theora: include/theora lib

giles at svn.xiph.org giles at svn.xiph.org
Wed Jun 22 04:41:00 PDT 2005


Author: giles
Date: 2005-06-22 04:40:55 -0700 (Wed, 22 Jun 2005)
New Revision: 9505

Modified:
   trunk/theora/include/theora/theora.h
   trunk/theora/lib/toplevel.c
Log:
Add a theora_granule_shift() utility function to extract the shift from 
the theora_info struct. This is convenient for those wanting to inspect 
the granulepos themselves who are still using libtheora.


Modified: trunk/theora/include/theora/theora.h
===================================================================
--- trunk/theora/include/theora/theora.h	2005-06-22 00:36:54 UTC (rev 9504)
+++ trunk/theora/include/theora/theora.h	2005-06-22 11:40:55 UTC (rev 9505)
@@ -387,6 +387,33 @@
 extern int theora_packet_iskeyframe(ogg_packet *op);
 
 /**
+ * Report the granulepos shift radix
+ *
+ * When embedded in Ogg, Theora uses a two-part granulepos, 
+ * splitting the 64-bit field into two pieces. The more-significant
+ * section represents the frame count at the last keyframe,
+ * and the less-significant section represents the count of
+ * frames since the last keyframe. In this way the overall
+ * field is still non-decreasing with time, but usefully encodes
+ * a pointer to the last keyframe, which is necessary for
+ * correctly restarting decode after a seek. 
+ *
+ * This function reports the number of bits used to represent
+ * the distance to the last keyframe, and thus how the granulepos
+ * field must be shifted or masked to obtain the two parts.
+ * 
+ * Since libtheora returns compressed data in an ogg_packet
+ * structure, this may be generally useful even if the Theora
+ * packets are not being used in an Ogg container. 
+ *
+ * \param ti A previously initialized theora_info struct
+ * \returns The bit shift dividing the two granulepos fields
+ *
+ * This function was added inthe 1.0alpha5 release.
+ */
+int theora_granule_shift(theora_info *ti);
+
+/**
  * Convert a granulepos to an absolute frame number. The granulepos is
  * interpreted in the context of a given theora_state handle.
  *

Modified: trunk/theora/lib/toplevel.c
===================================================================
--- trunk/theora/lib/toplevel.c	2005-06-22 00:36:54 UTC (rev 9504)
+++ trunk/theora/lib/toplevel.c	2005-06-22 11:40:55 UTC (rev 9505)
@@ -440,6 +440,12 @@
   return (op->packet[0] & 0x40) ? 0 : 1; /* inter or intra */
 }
 
+/* returns the shift radix used to split the granulepos into two fields */
+int theora_granule_shift(theora_info *ti)
+{
+  return _ilog(ti->keyframe_frequency_force - 1);
+}
+
 /* returns frame number of current packet in given logical stream */
 ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos){
   CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);



More information about the commits mailing list