1 /********************************************************************
3 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
11 ********************************************************************
14 last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $
16 ********************************************************************/
24 #endif /* __cplusplus */
26 #include <stddef.h> /* for size_t */
31 * The libtheora pre-1.0 legacy C API.
35 * \section intro Introduction
37 * This is the documentation for the libtheora legacy C API, declared in
38 * the theora.h header, which describes the old interface used before
39 * the 1.0 release. This API was widely deployed for several years and
40 * remains supported, but for new code we recommend the cleaner API
41 * declared in theoradec.h and theoraenc.h.
43 * libtheora is the reference implementation for
44 * <a href="http://www.theora.org/">Theora</a>, a free video codec.
45 * Theora is derived from On2's VP3 codec with improved integration with
46 * Ogg multimedia formats by <a href="http://www.xiph.org/">Xiph.Org</a>.
48 * \section overview Overview
50 * This library will both decode and encode theora packets to/from raw YUV
51 * frames. In either case, the packets will most likely either come from or
52 * need to be embedded in an Ogg stream. Use
53 * <a href="http://xiph.org/ogg/">libogg</a> or
54 * <a href="http://www.annodex.net/software/liboggz/index.html">liboggz</a>
55 * to extract/package these packets.
57 * \section decoding Decoding Process
59 * Decoding can be separated into the following steps:
60 * -# initialise theora_info and theora_comment structures using
61 * theora_info_init() and theora_comment_init():
64 theora_comment comment;
66 theora_info_init(&info);
67 theora_comment_init(&comment);
69 * -# retrieve header packets from Ogg stream (there should be 3) and decode
70 * into theora_info and theora_comment structures using
71 * theora_decode_header(). See \ref identification for more information on
72 * identifying which packets are theora packets.
75 for (i = 0; i < 3; i++)
77 (get a theora packet "op" from the Ogg stream)
78 theora_decode_header(&info, &comment, op);
81 * -# initialise the decoder based on the information retrieved into the
82 * theora_info struct by theora_decode_header(). You will need a
83 * theora_state struct.
87 theora_decode_init(&state, &info);
89 * -# pass in packets and retrieve decoded frames! See the yuv_buffer
90 * documentation for information on how to retrieve raw YUV data.
93 while (last packet was not e_o_s) {
94 (get a theora packet "op" from the Ogg stream)
95 theora_decode_packetin(&state, op);
96 theora_decode_YUVout(&state, &buffer);
101 * \subsection identification Identifying Theora Packets
103 * All streams inside an Ogg file have a unique serial_no attached to the
104 * stream. Typically, you will want to
105 * - retrieve the serial_no for each b_o_s (beginning of stream) page
106 * encountered within the Ogg file;
107 * - test the first (only) packet on that page to determine if it is a theora
109 * - once you have found a theora b_o_s page then use the retrieved serial_no
110 * to identify future packets belonging to the same theora stream.
112 * Note that you \e cannot use theora_packet_isheader() to determine if a
113 * packet is a theora packet or not, as this function does not perform any
114 * checking beyond whether a header bit is present. Instead, use the
115 * theora_decode_header() function and check the return value; or examine the
116 * header bytes at the beginning of the Ogg page.
120 /** \defgroup oldfuncs Legacy pre-1.0 C API */
124 * A YUV buffer for passing uncompressed frames to and from the codec.
125 * This holds a Y'CbCr frame in planar format. The CbCr planes can be
126 * subsampled and have their own separate dimensions and row stride
127 * offsets. Note that the strides may be negative in some
128 * configurations. For theora the width and height of the largest plane
129 * must be a multiple of 16. The actual meaningful picture size and
130 * offset are stored in the theora_info structure; frames returned by
131 * the decoder may need to be cropped for display.
133 * All samples are 8 bits. Within each plane samples are ordered by
134 * row from the top of the frame to the bottom. Within each row samples
135 * are ordered from left to right.
137 * During decode, the yuv_buffer struct is allocated by the user, but all
138 * fields (including luma and chroma pointers) are filled by the library.
139 * These pointers address library-internal memory and their contents should
142 * Conversely, during encode the user allocates the struct and fills out all
143 * fields. The user also manages the data addressed by the luma and chroma
144 * pointers. See the encoder_example.c and dump_video.c example files in
145 * theora/examples/ for more information.
148 int y_width; /**< Width of the Y' luminance plane */
149 int y_height; /**< Height of the luminance plane */
150 int y_stride; /**< Offset in bytes between successive rows */
152 int uv_width; /**< Width of the Cb and Cr chroma planes */
153 int uv_height; /**< Height of the chroma planes */
154 int uv_stride; /**< Offset between successive chroma rows */
155 unsigned char *y; /**< Pointer to start of luminance data */
156 unsigned char *u; /**< Pointer to start of Cb data */
157 unsigned char *v; /**< Pointer to start of Cr data */
165 OC_CS_UNSPECIFIED, /**< The colorspace is unknown or unspecified */
166 OC_CS_ITU_REC_470M, /**< This is the best option for 'NTSC' content */
167 OC_CS_ITU_REC_470BG, /**< This is the best option for 'PAL' content */
168 OC_CS_NSPACES /**< This marks the end of the defined colorspaces */
172 * A Chroma subsampling
174 * These enumerate the available chroma subsampling options supported
175 * by the theora format. See Section 4.4 of the specification for
179 OC_PF_420, /**< Chroma subsampling by 2 in each direction (4:2:0) */
180 OC_PF_RSVD, /**< Reserved value */
181 OC_PF_422, /**< Horizonatal chroma subsampling by 2 (4:2:2) */
182 OC_PF_444, /**< No chroma subsampling at all (4:4:4) */
183 } theora_pixelformat;
186 * Theora bitstream info.
187 * Contains the basic playback parameters for a stream,
188 * corresponding to the initial 'info' header packet.
190 * Encoded theora frames must be a multiple of 16 in width and height.
191 * To handle other frame sizes, a crop rectangle is specified in
192 * frame_height and frame_width, offset_x and * offset_y. The offset
193 * and size should still be a multiple of 2 to avoid chroma sampling
194 * shifts. Offset values in this structure are measured from the
195 * upper left of the image.
197 * Frame rate, in frames per second, is stored as a rational
198 * fraction. Aspect ratio is also stored as a rational fraction, and
199 * refers to the aspect ratio of the frame pixels, not of the
200 * overall frame itself.
202 * See <a href="http://svn.xiph.org/trunk/theora/examples/encoder_example.c">
203 * examples/encoder_example.c</a> for usage examples of the
204 * other paramters and good default settings for the encoder parameters.
207 ogg_uint32_t width; /**< encoded frame width */
208 ogg_uint32_t height; /**< encoded frame height */
209 ogg_uint32_t frame_width; /**< display frame width */
210 ogg_uint32_t frame_height; /**< display frame height */
211 ogg_uint32_t offset_x; /**< horizontal offset of the displayed frame */
212 ogg_uint32_t offset_y; /**< vertical offset of the displayed frame */
213 ogg_uint32_t fps_numerator; /**< frame rate numerator **/
214 ogg_uint32_t fps_denominator; /**< frame rate denominator **/
215 ogg_uint32_t aspect_numerator; /**< pixel aspect ratio numerator */
216 ogg_uint32_t aspect_denominator; /**< pixel aspect ratio denominator */
217 theora_colorspace colorspace; /**< colorspace */
218 int target_bitrate; /**< nominal bitrate in bits per second */
219 int quality; /**< Nominal quality setting, 0-63 */
220 int quick_p; /**< Quick encode/decode */
223 unsigned char version_major;
224 unsigned char version_minor;
225 unsigned char version_subminor;
232 ogg_uint32_t keyframe_frequency;
233 ogg_uint32_t keyframe_frequency_force; /* also used for decode init to
234 get granpos shift correct */
235 ogg_uint32_t keyframe_data_target_bitrate;
236 ogg_int32_t keyframe_auto_threshold;
237 ogg_uint32_t keyframe_mindistance;
238 ogg_int32_t noise_sensitivity;
239 ogg_int32_t sharpness;
241 theora_pixelformat pixelformat; /**< chroma subsampling mode to expect */
245 /** Codec internal state and context.
249 ogg_int64_t granulepos;
251 void *internal_encode;
252 void *internal_decode;
257 * Comment header metadata.
259 * This structure holds the in-stream metadata corresponding to
260 * the 'comment' header packet.
262 * Meta data is stored as a series of (tag, value) pairs, in
263 * length-encoded string vectors. The first occurence of the
264 * '=' character delimits the tag and value. A particular tag
265 * may occur more than once. The character set encoding for
266 * the strings is always UTF-8, but the tag names are limited
267 * to case-insensitive ASCII. See the spec for details.
269 * In filling in this structure, theora_decode_header() will
270 * null-terminate the user_comment strings for safety. However,
271 * the bitstream format itself treats them as 8-bit clean,
272 * and so the length array should be treated as authoritative
275 typedef struct theora_comment{
276 char **user_comments; /**< An array of comment string vectors */
277 int *comment_lengths; /**< An array of corresponding string vector lengths in bytes */
278 int comments; /**< The total number of comment string vectors */
279 char *vendor; /**< The vendor string identifying the encoder, null terminated */
284 /**\name theora_control() codes */
285 /* \anchor decctlcodes_old
286 * These are the available request codes for theora_control()
287 * when called with a decoder instance.
288 * By convention decoder control codes are odd, to distinguish
289 * them from \ref encctlcodes_old "encoder control codes" which
292 * Note that since the 1.0 release, both the legacy and the final
293 * implementation accept all the same control codes, but only the
294 * final API declares the newer codes.
296 * Keep any experimental or vendor-specific values above \c 0x8000.*/
300 /**Get the maximum post-processing level.
301 * The decoder supports a post-processing filter that can improve
302 * the appearance of the decoded images. This returns the highest
303 * level setting for this post-processor, corresponding to maximum
304 * improvement and computational expense.
306 #define TH_DECCTL_GET_PPLEVEL_MAX (1)
308 /**Set the post-processing level.
309 * Sets the level of post-processing to use when decoding the
310 * compressed stream. This must be a value between zero (off)
311 * and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX.
313 #define TH_DECCTL_SET_PPLEVEL (3)
315 /**Sets the maximum distance between key frames.
316 * This can be changed during an encode, but will be bounded by
317 * <tt>1<<th_info#keyframe_granule_shift</tt>.
318 * If it is set before encoding begins, th_info#keyframe_granule_shift will
319 * be enlarged appropriately.
321 * \param[in] buf <tt>ogg_uint32_t</tt>: The maximum distance between key
323 * \param[out] buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.
324 * \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
325 * \retval OC_EINVAL \a buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.
326 * \retval OC_IMPL Not supported by this implementation.*/
327 #define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
329 /**Set the granule position.
330 * Call this after a seek, to update the internal granulepos
331 * in the decoder, to insure that subsequent frames are marked
332 * properly. If you track timestamps yourself and do not use
333 * the granule postion returned by the decoder, then you do
334 * not need to use this control.
336 #define TH_DECCTL_SET_GRANPOS (5)
338 /**\anchor encctlcodes_old */
340 /**Sets the quantization parameters to use.
341 * The parameters are copied, not stored by reference, so they can be freed
343 * <tt>NULL</tt> may be specified to revert to the default parameters.
345 * \param[in] buf #th_quant_info
346 * \retval OC_FAULT \a theora_state is <tt>NULL</tt>.
347 * \retval OC_EINVAL Encoding has already begun, the quantization parameters
348 * are not acceptable to this version of the encoder,
349 * \a buf is <tt>NULL</tt> and \a buf_sz is not zero,
350 * or \a buf is non-<tt>NULL</tt> and \a buf_sz is
351 * not <tt>sizeof(#th_quant_info)</tt>.
352 * \retval OC_IMPL Not supported by this implementation.*/
353 #define TH_ENCCTL_SET_QUANT_PARAMS (2)
355 /**Disables any encoder features that would prevent lossless transcoding back
357 * This primarily means disabling block-level QI values and not using 4MV mode
358 * when any of the luma blocks in a macro block are not coded.
359 * It also includes using the VP3 quantization tables and Huffman codes; if you
360 * set them explicitly after calling this function, the resulting stream will
361 * not be VP3-compatible.
362 * If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source
363 * material, or when using a picture region smaller than the full frame (e.g.
364 * a non-multiple-of-16 width or height), then non-VP3 bitstream features will
365 * still be disabled, but the stream will still not be VP3-compatible, as VP3
366 * was not capable of encoding such formats.
367 * If you call this after encoding has already begun, then the quantization
368 * tables and codebooks cannot be changed, but the frame-level features will
369 * be enabled or disabled as requested.
371 * \param[in] buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,
372 * or 0 to disable it (the default).
373 * \param[out] buf <tt>int</tt>: 1 if all bitstream features required for
374 * VP3-compatibility could be set, and 0 otherwise.
375 * The latter will be returned if the pixel format is not
376 * 4:2:0, the picture region is smaller than the full frame,
377 * or if encoding has begun, preventing the quantization
378 * tables and codebooks from being set.
379 * \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
380 * \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.
381 * \retval OC_IMPL Not supported by this implementation.*/
382 #define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
384 /**Gets the maximum speed level.
385 * Higher speed levels favor quicker encoding over better quality per bit.
386 * Depending on the encoding mode, and the internal algorithms used, quality
387 * may actually improve, but in this case bitrate will also likely increase.
388 * In any case, overall rate/distortion performance will probably decrease.
389 * The maximum value, and the meaning of each value, may change depending on
390 * the current encoding mode (VBR vs. CQI, etc.).
392 * \param[out] buf int: The maximum encoding speed level.
393 * \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
394 * \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.
395 * \retval OC_IMPL Not supported by this implementation in the current
397 #define TH_ENCCTL_GET_SPLEVEL_MAX (12)
399 /**Sets the speed level.
400 * By default a speed value of 1 is used.
402 * \param[in] buf int: The new encoding speed level.
403 * 0 is slowest, larger values use less CPU.
404 * \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
405 * \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>, or the
406 * encoding speed level is out of bounds.
407 * The maximum encoding speed level may be
408 * implementation- and encoding mode-specific, and can be
409 * obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
410 * \retval OC_IMPL Not supported by this implementation in the current
412 #define TH_ENCCTL_SET_SPLEVEL (14)
416 #define OC_FAULT -1 /**< General failure */
417 #define OC_EINVAL -10 /**< Library encountered invalid internal data */
418 #define OC_DISABLED -11 /**< Requested action is disabled */
419 #define OC_BADHEADER -20 /**< Header packet was corrupt/invalid */
420 #define OC_NOTFORMAT -21 /**< Packet is not a theora packet */
421 #define OC_VERSION -22 /**< Bitstream version is not handled */
422 #define OC_IMPL -23 /**< Feature or action not implemented */
423 #define OC_BADPACKET -24 /**< Packet is corrupt */
424 #define OC_NEWPACKET -25 /**< Packet is an (ignorable) unhandled extension */
425 #define OC_DUPFRAME 1 /**< Packet is a dropped frame */
428 * Retrieve a human-readable string to identify the encoder vendor and version.
429 * \returns A version string.
431 extern const char *theora_version_string(void);
434 * Retrieve a 32-bit version number.
435 * This number is composed of a 16-bit major version, 8-bit minor version
436 * and 8 bit sub-version, composed as follows:
438 (VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)
440 * \returns The version number.
442 extern ogg_uint32_t theora_version_number(void);
445 * Initialize the theora encoder.
446 * \param th The theora_state handle to initialize for encoding.
447 * \param ti A theora_info struct filled with the desired encoding parameters.
450 extern int theora_encode_init(theora_state *th, theora_info *ti);
453 * Submit a YUV buffer to the theora encoder.
454 * \param t A theora_state handle previously initialized for encoding.
455 * \param yuv A buffer of YUV data to encode. Note that both the yuv_buffer
456 * struct and the luma/chroma buffers within should be allocated by
458 * \retval OC_EINVAL Encoder is not ready, or is finished.
459 * \retval -1 The size of the given frame differs from those previously input
462 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
465 * Request the next packet of encoded video.
466 * The encoded data is placed in a user-provided ogg_packet structure.
467 * \param t A theora_state handle previously initialized for encoding.
468 * \param last_p whether this is the last packet the encoder should produce.
469 * \param op An ogg_packet structure to fill. libtheora will set all
470 * elements of this structure, including a pointer to encoded
471 * data. The memory for the encoded data is owned by libtheora.
472 * \retval 0 No internal storage exists OR no packet is ready
473 * \retval -1 The encoding process has completed
476 extern int theora_encode_packetout( theora_state *t, int last_p,
480 * Request a packet containing the initial header.
481 * A pointer to the header data is placed in a user-provided ogg_packet
483 * \param t A theora_state handle previously initialized for encoding.
484 * \param op An ogg_packet structure to fill. libtheora will set all
485 * elements of this structure, including a pointer to the header
486 * data. The memory for the header data is owned by libtheora.
489 extern int theora_encode_header(theora_state *t, ogg_packet *op);
492 * Request a comment header packet from provided metadata.
493 * A pointer to the comment data is placed in a user-provided ogg_packet
495 * \param tc A theora_comment structure filled with the desired metadata
496 * \param op An ogg_packet structure to fill. libtheora will set all
497 * elements of this structure, including a pointer to the encoded
498 * comment data. The memory for the comment data is owned by
502 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
505 * Request a packet containing the codebook tables for the stream.
506 * A pointer to the codebook data is placed in a user-provided ogg_packet
508 * \param t A theora_state handle previously initialized for encoding.
509 * \param op An ogg_packet structure to fill. libtheora will set all
510 * elements of this structure, including a pointer to the codebook
511 * data. The memory for the header data is owned by libtheora.
514 extern int theora_encode_tables(theora_state *t, ogg_packet *op);
517 * Decode an Ogg packet, with the expectation that the packet contains
518 * an initial header, comment data or codebook tables.
520 * \param ci A theora_info structure to fill. This must have been previously
521 * initialized with theora_info_init(). If \a op contains an initial
522 * header, theora_decode_header() will fill \a ci with the
523 * parsed header values. If \a op contains codebook tables,
524 * theora_decode_header() will parse these and attach an internal
525 * representation to \a ci->codec_setup.
526 * \param cc A theora_comment structure to fill. If \a op contains comment
527 * data, theora_decode_header() will fill \a cc with the parsed
529 * \param op An ogg_packet structure which you expect contains an initial
530 * header, comment data or codebook tables.
532 * \retval OC_BADHEADER \a op is NULL; OR the first byte of \a op->packet
533 * has the signature of an initial packet, but op is
534 * not a b_o_s packet; OR this packet has the signature
535 * of an initial header packet, but an initial header
536 * packet has already been seen; OR this packet has the
537 * signature of a comment packet, but the initial header
538 * has not yet been seen; OR this packet has the signature
539 * of a comment packet, but contains invalid data; OR
540 * this packet has the signature of codebook tables,
541 * but the initial header or comments have not yet
542 * been seen; OR this packet has the signature of codebook
543 * tables, but contains invalid data;
544 * OR the stream being decoded has a compatible version
545 * but this packet does not have the signature of a
546 * theora initial header, comments, or codebook packet
547 * \retval OC_VERSION The packet data of \a op is an initial header with
548 * a version which is incompatible with this version of
550 * \retval OC_NEWPACKET the stream being decoded has an incompatible (future)
551 * version and contains an unknown signature.
554 * \note The normal usage is that theora_decode_header() be called on the
555 * first three packets of a theora logical bitstream in succession.
557 extern int theora_decode_header(theora_info *ci, theora_comment *cc,
561 * Initialize a theora_state handle for decoding.
562 * \param th The theora_state handle to initialize.
563 * \param c A theora_info struct filled with the desired decoding parameters.
564 * This is of course usually obtained from a previous call to
565 * theora_decode_header().
568 extern int theora_decode_init(theora_state *th, theora_info *c);
571 * Input a packet containing encoded data into the theora decoder.
572 * \param th A theora_state handle previously initialized for decoding.
573 * \param op An ogg_packet containing encoded theora data.
575 * \retval OC_BADPACKET \a op does not contain encoded video data
577 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
580 * Output the next available frame of decoded YUV data.
581 * \param th A theora_state handle previously initialized for decoding.
582 * \param yuv A yuv_buffer in which libtheora should place the decoded data.
583 * Note that the buffer struct itself is allocated by the user, but
584 * that the luma and chroma pointers will be filled in by the
585 * library. Also note that these luma and chroma regions should be
586 * considered read-only by the user.
589 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
592 * Report whether a theora packet is a header or not
593 * This function does no verification beyond checking the header
594 * flag bit so it should not be used for bitstream identification;
595 * use theora_decode_header() for that.
597 * \param op An ogg_packet containing encoded theora data.
598 * \retval 1 The packet is a header packet
599 * \retval 0 The packet is not a header packet (and so contains frame data)
601 * Thus function was added in the 1.0alpha4 release.
603 extern int theora_packet_isheader(ogg_packet *op);
606 * Report whether a theora packet is a keyframe or not
608 * \param op An ogg_packet containing encoded theora data.
609 * \retval 1 The packet contains a keyframe image
610 * \retval 0 The packet is contains an interframe delta
611 * \retval -1 The packet is not an image data packet at all
613 * Thus function was added in the 1.0alpha4 release.
615 extern int theora_packet_iskeyframe(ogg_packet *op);
618 * Report the granulepos shift radix
620 * When embedded in Ogg, Theora uses a two-part granulepos,
621 * splitting the 64-bit field into two pieces. The more-significant
622 * section represents the frame count at the last keyframe,
623 * and the less-significant section represents the count of
624 * frames since the last keyframe. In this way the overall
625 * field is still non-decreasing with time, but usefully encodes
626 * a pointer to the last keyframe, which is necessary for
627 * correctly restarting decode after a seek.
629 * This function reports the number of bits used to represent
630 * the distance to the last keyframe, and thus how the granulepos
631 * field must be shifted or masked to obtain the two parts.
633 * Since libtheora returns compressed data in an ogg_packet
634 * structure, this may be generally useful even if the Theora
635 * packets are not being used in an Ogg container.
637 * \param ti A previously initialized theora_info struct
638 * \returns The bit shift dividing the two granulepos fields
640 * This function was added in the 1.0alpha5 release.
642 int theora_granule_shift(theora_info *ti);
645 * Convert a granulepos to an absolute frame index, starting at 0.
646 * The granulepos is interpreted in the context of a given theora_state handle.
648 * Note that while the granulepos encodes the frame count (i.e. starting
649 * from 1) this call returns the frame index, starting from zero. Thus
650 * One can calculate the presentation time by multiplying the index by
653 * \param th A previously initialized theora_state handle (encode or decode)
654 * \param granulepos The granulepos to convert.
655 * \returns The frame index corresponding to \a granulepos.
656 * \retval -1 The given granulepos is undefined (i.e. negative)
658 * Thus function was added in the 1.0alpha4 release.
660 extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
663 * Convert a granulepos to absolute time in seconds. The granulepos is
664 * interpreted in the context of a given theora_state handle, and gives
665 * the end time of a frame's presentation as used in Ogg mux ordering.
667 * \param th A previously initialized theora_state handle (encode or decode)
668 * \param granulepos The granulepos to convert.
669 * \returns The absolute time in seconds corresponding to \a granulepos.
670 * This is the "end time" for the frame, or the latest time it should
672 * It is not the presentation time.
673 * \retval -1. The given granulepos is undefined (i.e. negative), or
674 * \retval -1. The function has been disabled because floating
675 * point support is not available.
677 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
680 * Initialize a theora_info structure. All values within the given theora_info
681 * structure are initialized, and space is allocated within libtheora for
682 * internal codec setup data.
683 * \param c A theora_info struct to initialize.
685 extern void theora_info_init(theora_info *c);
688 * Clear a theora_info structure. All values within the given theora_info
689 * structure are cleared, and associated internal codec setup data is freed.
690 * \param c A theora_info struct to initialize.
692 extern void theora_info_clear(theora_info *c);
695 * Free all internal data associated with a theora_state handle.
696 * \param t A theora_state handle.
698 extern void theora_clear(theora_state *t);
701 * Initialize an allocated theora_comment structure
702 * \param tc An allocated theora_comment structure
704 extern void theora_comment_init(theora_comment *tc);
707 * Add a comment to an initialized theora_comment structure
708 * \param tc A previously initialized theora comment structure
709 * \param comment A null-terminated string encoding the comment in the form
712 * Neither theora_comment_add() nor theora_comment_add_tag() support
713 * comments containing null values, although the bitstream format
714 * supports this. To add such comments you will need to manipulate
715 * the theora_comment structure directly.
718 extern void theora_comment_add(theora_comment *tc, char *comment);
721 * Add a comment to an initialized theora_comment structure.
722 * \param tc A previously initialized theora comment structure
723 * \param tag A null-terminated string containing the tag
724 * associated with the comment.
725 * \param value The corresponding value as a null-terminated string
727 * Neither theora_comment_add() nor theora_comment_add_tag() support
728 * comments containing null values, although the bitstream format
729 * supports this. To add such comments you will need to manipulate
730 * the theora_comment structure directly.
732 extern void theora_comment_add_tag(theora_comment *tc,
733 char *tag, char *value);
736 * Look up a comment value by tag.
737 * \param tc Tn initialized theora_comment structure
738 * \param tag The tag to look up
739 * \param count The instance of the tag. The same tag can appear multiple
740 * times, each with a distinct and ordered value, so an index
741 * is required to retrieve them all.
742 * \returns A pointer to the queried tag's value
743 * \retval NULL No matching tag is found
745 * \note Use theora_comment_query_count() to get the legal range for the
749 extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
751 /** Look up the number of instances of a tag.
752 * \param tc An initialized theora_comment structure
753 * \param tag The tag to look up
754 * \returns The number on instances of a particular tag.
756 * Call this first when querying for a specific tag and then interate
757 * over the number of instances with separate calls to
758 * theora_comment_query() to retrieve all instances in order.
760 extern int theora_comment_query_count(theora_comment *tc, char *tag);
763 * Clear an allocated theora_comment struct so that it can be freed.
764 * \param tc An allocated theora_comment structure.
766 extern void theora_comment_clear(theora_comment *tc);
768 /**Encoder control function.
769 * This is used to provide advanced control the encoding process.
770 * \param th A #theora_state handle.
771 * \param req The control code to process.
772 * See \ref encctlcodes_old "the list of available
773 * control codes" for details.
774 * \param buf The parameters for this control code.
775 * \param buf_sz The size of the parameter buffer.*/
776 extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);
778 /* @} */ /* end oldfuncs doxygen group */
782 #endif /* __cplusplus */
784 #endif /* _O_THEORA_H_ */