[xiph-commits] r9000 - in experimental/derf/theora-exp: include/theora lib

tterribe at motherfish-iii.xiph.org tterribe at motherfish-iii.xiph.org
Tue Mar 1 08:50:15 PST 2005


Author: tterribe
Date: 2005-03-01 08:50:13 -0800 (Tue, 01 Mar 2005)
New Revision: 9000

Modified:
   experimental/derf/theora-exp/include/theora/theora.h
   experimental/derf/theora-exp/lib/internal.c
   experimental/derf/theora-exp/lib/state.c
Log:
Add functions introduced to the 1.0alpha4 API.

Modified: experimental/derf/theora-exp/include/theora/theora.h
===================================================================
--- experimental/derf/theora-exp/include/theora/theora.h	2005-03-01 16:40:57 UTC (rev 8999)
+++ experimental/derf/theora-exp/include/theora/theora.h	2005-03-01 16:50:13 UTC (rev 9000)
@@ -819,15 +819,41 @@
  * \endcode
  * \return the version number.*/
 extern ogg_uint32_t theora_version_number(void);
+/**Converts a granule position to an absolute frame number.
+ * The granule position is interpreted in the context of a given
+ *  #theora_enc_ctx or #theora_dec_ctx handle (either will suffice).
+ * \param _encdec  A previously allocated #theora_enc_ctx or #theora_dec_ctx
+ *                  handle.
+ * \param _granpos The granule position to convert.
+ * \returns The absolute frame number corresponding to \a _granpos.
+ * \retval -1 The given granule position was invalid (i.e. negative).*/
+extern ogg_int64_t theora_granule_frame(void *_encdec,ogg_int64_t _granpos);
 /**Converts a granule position to an absolute time in seconds.
  * The granule position is interpreted in the context of a given
  *  #theora_enc_ctx or #theora_dec_ctx handle (either will suffice).
- * \param _encdec     A previously allocated #theora_enc_ctx or #theora_dec_ctx
- *                     handle.
+ * \param _encdec  A previously allocated #theora_enc_ctx or #theora_dec_ctx
+ *                  handle.
  * \param _granpos The granule position to convert.
  * \return The absolute time in seconds corresponding to \a _granpos.
- * \retval -1 The given granule position is invalid (ie. negative).*/
+ * \retval -1 The given granule position was invalid (i.e. negative).*/
 extern double theora_granule_time(void *_encdec,ogg_int64_t _granpos);
+/**Determines whether a Theora packet is a header or not.
+ * This function does no verification beyond checking the packet type bit, so
+ *  it should not be used for bitstream identification; use
+ *  theora_decode_headerin() for that.
+ * \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
+ * \retval 1 The packet is a header packet
+ * \retval 0 The packet is a video data packet.*/
+extern int theora_packet_isheader(ogg_packet *_op);
+/**Determines whether a theora packet is a key frame or not.
+ * This function does no verification beyond checking the packet type and
+ *  key frame bits, so it should not be used for bitstream identification; use
+ *  theora_decode_headerin() for that.
+ * \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
+ * \retval 1  The packet contains a key frame.
+ * \retval 0  The packet contains a delta frame.
+ * \retval -1 The packet is not a video data packet.*/
+extern int theora_packet_iskeyframe(ogg_packet *_op);
 /*@}*/
 
 

Modified: experimental/derf/theora-exp/lib/internal.c
===================================================================
--- experimental/derf/theora-exp/lib/internal.c	2005-03-01 16:40:57 UTC (rev 8999)
+++ experimental/derf/theora-exp/lib/internal.c	2005-03-01 16:50:13 UTC (rev 9000)
@@ -349,3 +349,19 @@
 ogg_uint32_t theora_version_number(void){
   return (OC_VERSION_MAJOR<<16)+(OC_VERSION_MINOR<<8)+(OC_VERSION_SUB);
 }
+
+/*Determines the packet type.
+  Note that this correctly interprets a 0-byte packet as a video data packet.
+  Return: 1 for a header packet, 0 for a data packet.*/
+int theora_packet_isheader(ogg_packet *_op){
+  return _op->bytes>0?_op->packet[0]>>7:0;
+}
+
+/*Determines the frame type of a video data packet.
+  Note that this correctly interprets a 0-byte packet as a delta frame.
+  Return: 1 for a key frame, 0 for a delta frame, and -1 for a header
+           packet.*/
+int theora_packet_iskeyframe(ogg_packet *_op){
+  return _op->bytes<=0?0:_op->packet[0]&0x80?-1:!(_op->packet[0]&0x40);
+}
+

Modified: experimental/derf/theora-exp/lib/state.c
===================================================================
--- experimental/derf/theora-exp/lib/state.c	2005-03-01 16:40:57 UTC (rev 8999)
+++ experimental/derf/theora-exp/lib/state.c	2005-03-01 16:50:13 UTC (rev 9000)
@@ -1122,6 +1122,19 @@
 
 
 
+ogg_int64_t theora_granule_frame(void *_encdec,ogg_int64_t _granpos){
+  oc_theora_state *state;
+  state=(oc_theora_state *)_encdec;
+  if(_granpos>=0){
+    ogg_int64_t iframe;
+    ogg_int64_t pframe;
+    iframe=_granpos>>state->info.keyframe_granule_shift;
+    pframe=_granpos-(iframe<<state->info.keyframe_granule_shift);
+    return iframe+pframe;
+  }
+  return -1;
+}
+
 double theora_granule_time(void *_encdec,ogg_int64_t _granpos){
   oc_theora_state *state;
   state=(oc_theora_state *)_encdec;
@@ -1133,5 +1146,5 @@
     return (iframe+pframe)*(
      (double)state->info.fps_denominator/state->info.fps_numerator);
   }
-  return(-1);
+  return -1;
 }



More information about the commits mailing list