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

giles at motherfish-iii.xiph.org giles at motherfish-iii.xiph.org
Sun Sep 26 12:29:25 PDT 2004


Author: giles
Date: 2004-09-26 12:29:24 -0700 (Sun, 26 Sep 2004)
New Revision: 7880

Modified:
   trunk/theora/include/theora/theora.h
   trunk/theora/lib/toplevel.c
Log:
Add convience calls for header and keyframe packet detection.


Modified: trunk/theora/include/theora/theora.h
===================================================================
--- trunk/theora/include/theora/theora.h	2004-09-25 07:08:31 UTC (rev 7879)
+++ trunk/theora/include/theora/theora.h	2004-09-26 19:29:24 UTC (rev 7880)
@@ -304,6 +304,26 @@
 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
 
 /**
+ * Report whether a theora packet is a header or not
+ * This function does no verification beyond checking the header
+ * flag bit so it should not be used for bitstream identification;
+ * use theora_decode_header() for that.
+ * \param op An ogg_packet containing encoded theora data.
+ * \retval 1 The packet is a header packet
+ * \retval 0 The packet is not a header packet (and so contains frame data)
+ */
+extern int theora_packet_isheader(ogg_packet *op);
+
+/**
+ * Report whether a theora packet is a keyframe or not
+ * \param op An ogg_packet containing encoded theora data.
+ * \retval 1 The packet contains a keyframe image
+ * \retval 0 The packet is contains an interframe delta
+ * \retval -1 the packet is not an image data packet at all
+ */
+extern int theora_packet_iskeyframe(ogg_packet *op);
+
+/**
  * Convert a granulepos to an absolute frame number. The granulepos is
  * interpreted in the context of a given theora_state handle.
  * \param th A previously initialized theora_state handle (encode or decode)

Modified: trunk/theora/lib/toplevel.c
===================================================================
--- trunk/theora/lib/toplevel.c	2004-09-25 07:08:31 UTC (rev 7879)
+++ trunk/theora/lib/toplevel.c	2004-09-26 19:29:24 UTC (rev 7880)
@@ -419,6 +419,19 @@
   return(-1);
 }
 
+/* check for header flag */
+int theora_packet_isheader(ogg_packet *op)
+{
+  return (op->packet[0] & 0x80) ? 1 : 0;
+}
+
+/* check for keyframe */
+int theora_packet_iskeyframe(ogg_packet *op)
+{
+  if (op->packet[0] & 0x80) return -1; /* not a data packet */
+  return (op->packet[0] & 0x40) ? 0 : 1; /* inter or intra */
+}
+
 /* 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