Path: blob/master/thirdparty/libtheora/theora/theora.h
9912 views
/********************************************************************1* *2* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *3* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *4* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *5* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *6* *7* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *8* by the Xiph.Org Foundation https://www.xiph.org/ *9* *10********************************************************************1112function:1314********************************************************************/1516#ifndef OGG_THEORA_HEADER17#define OGG_THEORA_HEADER1819#ifdef __cplusplus20extern "C"21{22#endif /* __cplusplus */2324#include <stddef.h> /* for size_t */2526#include <ogg/ogg.h>2728/** \file29* The libtheora pre-1.0 legacy C API.30*31* \ingroup oldfuncs32*33* \section intro Introduction34*35* This is the documentation for the libtheora legacy C API, declared in36* the theora.h header, which describes the old interface used before37* the 1.0 release. This API was widely deployed for several years and38* remains supported, but for new code we recommend the cleaner API39* declared in theoradec.h and theoraenc.h.40*41* libtheora is the reference implementation for42* <a href="https://www.theora.org/">Theora</a>, a free video codec.43* Theora is derived from On2's VP3 codec with improved integration with44* Ogg multimedia formats by <a href="https://www.xiph.org/">Xiph.Org</a>.45*46* \section overview Overview47*48* This library will both decode and encode theora packets to/from raw YUV49* frames. In either case, the packets will most likely either come from or50* need to be embedded in an Ogg stream. Use51* <a href="https://www.xiph.org/ogg/">libogg</a> or52* <a href="http://www.annodex.net/software/liboggz/index.html">liboggz</a>53* to extract/package these packets.54*55* \section decoding Decoding Process56*57* Decoding can be separated into the following steps:58* -# initialise theora_info and theora_comment structures using59* theora_info_init() and theora_comment_init():60\verbatim61theora_info info;62theora_comment comment;6364theora_info_init(&info);65theora_comment_init(&comment);66\endverbatim67* -# retrieve header packets from Ogg stream (there should be 3) and decode68* into theora_info and theora_comment structures using69* theora_decode_header(). See \ref identification for more information on70* identifying which packets are theora packets.71\verbatim72int i;73for (i = 0; i < 3; i++)74{75(get a theora packet "op" from the Ogg stream)76theora_decode_header(&info, &comment, op);77}78\endverbatim79* -# initialise the decoder based on the information retrieved into the80* theora_info struct by theora_decode_header(). You will need a81* theora_state struct.82\verbatim83theora_state state;8485theora_decode_init(&state, &info);86\endverbatim87* -# pass in packets and retrieve decoded frames! See the yuv_buffer88* documentation for information on how to retrieve raw YUV data.89\verbatim90yuf_buffer buffer;91while (last packet was not e_o_s) {92(get a theora packet "op" from the Ogg stream)93theora_decode_packetin(&state, op);94theora_decode_YUVout(&state, &buffer);95}96\endverbatim97*98*99* \subsection identification Identifying Theora Packets100*101* All streams inside an Ogg file have a unique serial_no attached to the102* stream. Typically, you will want to103* - retrieve the serial_no for each b_o_s (beginning of stream) page104* encountered within the Ogg file;105* - test the first (only) packet on that page to determine if it is a theora106* packet;107* - once you have found a theora b_o_s page then use the retrieved serial_no108* to identify future packets belonging to the same theora stream.109*110* Note that you \e cannot use theora_packet_isheader() to determine if a111* packet is a theora packet or not, as this function does not perform any112* checking beyond whether a header bit is present. Instead, use the113* theora_decode_header() function and check the return value; or examine the114* header bytes at the beginning of the Ogg page.115*/116117118/** \defgroup oldfuncs Legacy pre-1.0 C API */119/* @{ */120121/**122* A YUV buffer for passing uncompressed frames to and from the codec.123* This holds a Y'CbCr frame in planar format. The CbCr planes can be124* subsampled and have their own separate dimensions and row stride125* offsets. Note that the strides may be negative in some126* configurations. For theora the width and height of the largest plane127* must be a multiple of 16. The actual meaningful picture size and128* offset are stored in the theora_info structure; frames returned by129* the decoder may need to be cropped for display.130*131* All samples are 8 bits. Within each plane samples are ordered by132* row from the top of the frame to the bottom. Within each row samples133* are ordered from left to right.134*135* During decode, the yuv_buffer struct is allocated by the user, but all136* fields (including luma and chroma pointers) are filled by the library.137* These pointers address library-internal memory and their contents should138* not be modified.139*140* Conversely, during encode the user allocates the struct and fills out all141* fields. The user also manages the data addressed by the luma and chroma142* pointers. See the encoder_example.c and dump_video.c example files in143* theora/examples/ for more information.144*/145typedef struct {146int y_width; /**< Width of the Y' luminance plane */147int y_height; /**< Height of the luminance plane */148int y_stride; /**< Offset in bytes between successive rows */149150int uv_width; /**< Width of the Cb and Cr chroma planes */151int uv_height; /**< Height of the chroma planes */152int uv_stride; /**< Offset between successive chroma rows */153unsigned char *y; /**< Pointer to start of luminance data */154unsigned char *u; /**< Pointer to start of Cb data */155unsigned char *v; /**< Pointer to start of Cr data */156157} yuv_buffer;158159/**160* A Colorspace.161*/162typedef enum {163OC_CS_UNSPECIFIED, /**< The colorspace is unknown or unspecified */164OC_CS_ITU_REC_470M, /**< This is the best option for 'NTSC' content */165OC_CS_ITU_REC_470BG, /**< This is the best option for 'PAL' content */166OC_CS_NSPACES /**< This marks the end of the defined colorspaces */167} theora_colorspace;168169/**170* A Chroma subsampling171*172* These enumerate the available chroma subsampling options supported173* by the theora format. See Section 4.4 of the specification for174* exact definitions.175*/176typedef enum {177OC_PF_420, /**< Chroma subsampling by 2 in each direction (4:2:0) */178OC_PF_RSVD, /**< Reserved value */179OC_PF_422, /**< Horizonatal chroma subsampling by 2 (4:2:2) */180OC_PF_444 /**< No chroma subsampling at all (4:4:4) */181} theora_pixelformat;182183/**184* Theora bitstream info.185* Contains the basic playback parameters for a stream,186* corresponding to the initial 'info' header packet.187*188* Encoded theora frames must be a multiple of 16 in width and height.189* To handle other frame sizes, a crop rectangle is specified in190* frame_height and frame_width, offset_x and * offset_y. The offset191* and size should still be a multiple of 2 to avoid chroma sampling192* shifts. Offset values in this structure are measured from the193* upper left of the image.194*195* Frame rate, in frames per second, is stored as a rational196* fraction. Aspect ratio is also stored as a rational fraction, and197* refers to the aspect ratio of the frame pixels, not of the198* overall frame itself.199*200* See <a href="http://svn.xiph.org/trunk/theora/examples/encoder_example.c">201* examples/encoder_example.c</a> for usage examples of the202* other parameters and good default settings for the encoder parameters.203*/204typedef struct {205ogg_uint32_t width; /**< encoded frame width */206ogg_uint32_t height; /**< encoded frame height */207ogg_uint32_t frame_width; /**< display frame width */208ogg_uint32_t frame_height; /**< display frame height */209ogg_uint32_t offset_x; /**< horizontal offset of the displayed frame */210ogg_uint32_t offset_y; /**< vertical offset of the displayed frame */211ogg_uint32_t fps_numerator; /**< frame rate numerator **/212ogg_uint32_t fps_denominator; /**< frame rate denominator **/213ogg_uint32_t aspect_numerator; /**< pixel aspect ratio numerator */214ogg_uint32_t aspect_denominator; /**< pixel aspect ratio denominator */215theora_colorspace colorspace; /**< colorspace */216int target_bitrate; /**< nominal bitrate in bits per second */217int quality; /**< Nominal quality setting, 0-63 */218int quick_p; /**< Quick encode/decode */219220/* decode only */221unsigned char version_major;222unsigned char version_minor;223unsigned char version_subminor;224225void *codec_setup;226227/* encode only */228int dropframes_p;229int keyframe_auto_p;230ogg_uint32_t keyframe_frequency;231ogg_uint32_t keyframe_frequency_force; /* also used for decode init to232get granpos shift correct */233ogg_uint32_t keyframe_data_target_bitrate;234ogg_int32_t keyframe_auto_threshold;235ogg_uint32_t keyframe_mindistance;236ogg_int32_t noise_sensitivity;237ogg_int32_t sharpness;238239theora_pixelformat pixelformat; /**< chroma subsampling mode to expect */240241} theora_info;242243/** Codec internal state and context.244*/245typedef struct{246theora_info *i;247ogg_int64_t granulepos;248249void *internal_encode;250void *internal_decode;251252} theora_state;253254/**255* Comment header metadata.256*257* This structure holds the in-stream metadata corresponding to258* the 'comment' header packet.259*260* Meta data is stored as a series of (tag, value) pairs, in261* length-encoded string vectors. The first occurrence of the262* '=' character delimits the tag and value. A particular tag263* may occur more than once. The character set encoding for264* the strings is always UTF-8, but the tag names are limited265* to case-insensitive ASCII. See the spec for details.266*267* In filling in this structure, theora_decode_header() will268* null-terminate the user_comment strings for safety. However,269* the bitstream format itself treats them as 8-bit clean,270* and so the length array should be treated as authoritative271* for their length.272*/273typedef struct theora_comment{274char **user_comments; /**< An array of comment string vectors */275int *comment_lengths; /**< An array of corresponding string vector lengths in bytes */276int comments; /**< The total number of comment string vectors */277char *vendor; /**< The vendor string identifying the encoder, null terminated */278279} theora_comment;280281282/**\name theora_control() codes */283/* \anchor decctlcodes_old284* These are the available request codes for theora_control()285* when called with a decoder instance.286* By convention decoder control codes are odd, to distinguish287* them from \ref encctlcodes_old "encoder control codes" which288* are even.289*290* Note that since the 1.0 release, both the legacy and the final291* implementation accept all the same control codes, but only the292* final API declares the newer codes.293*294* Keep any experimental or vendor-specific values above \c 0x8000.*/295296/*@{*/297298/**Get the maximum post-processing level.299* The decoder supports a post-processing filter that can improve300* the appearance of the decoded images. This returns the highest301* level setting for this post-processor, corresponding to maximum302* improvement and computational expense.303*/304#define TH_DECCTL_GET_PPLEVEL_MAX (1)305306/**Set the post-processing level.307* Sets the level of post-processing to use when decoding the308* compressed stream. This must be a value between zero (off)309* and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX.310*/311#define TH_DECCTL_SET_PPLEVEL (3)312313/**Sets the maximum distance between key frames.314* This can be changed during an encode, but will be bounded by315* <tt>1<<th_info#keyframe_granule_shift</tt>.316* If it is set before encoding begins, th_info#keyframe_granule_shift will317* be enlarged appropriately.318*319* \param[in] buf <tt>ogg_uint32_t</tt>: The maximum distance between key320* frames.321* \param[out] buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.322* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.323* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.324* \retval OC_IMPL Not supported by this implementation.*/325#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)326327/**Set the granule position.328* Call this after a seek, to update the internal granulepos329* in the decoder, to insure that subsequent frames are marked330* properly. If you track timestamps yourself and do not use331* the granule position returned by the decoder, then you do332* not need to use this control.333*/334#define TH_DECCTL_SET_GRANPOS (5)335336/**\anchor encctlcodes_old */337338/**Sets the quantization parameters to use.339* The parameters are copied, not stored by reference, so they can be freed340* after this call.341* <tt>NULL</tt> may be specified to revert to the default parameters.342*343* \param[in] buf #th_quant_info344* \retval OC_FAULT \a theora_state is <tt>NULL</tt>.345* \retval OC_EINVAL Encoding has already begun, the quantization parameters346* are not acceptable to this version of the encoder,347* \a buf is <tt>NULL</tt> and \a buf_sz is not zero,348* or \a buf is non-<tt>NULL</tt> and \a buf_sz is349* not <tt>sizeof(#th_quant_info)</tt>.350* \retval OC_IMPL Not supported by this implementation.*/351#define TH_ENCCTL_SET_QUANT_PARAMS (2)352353/**Disables any encoder features that would prevent lossless transcoding back354* to VP3.355* This primarily means disabling block-level QI values and not using 4MV mode356* when any of the luma blocks in a macro block are not coded.357* It also includes using the VP3 quantization tables and Huffman codes; if you358* set them explicitly after calling this function, the resulting stream will359* not be VP3-compatible.360* If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source361* material, or when using a picture region smaller than the full frame (e.g.362* a non-multiple-of-16 width or height), then non-VP3 bitstream features will363* still be disabled, but the stream will still not be VP3-compatible, as VP3364* was not capable of encoding such formats.365* If you call this after encoding has already begun, then the quantization366* tables and codebooks cannot be changed, but the frame-level features will367* be enabled or disabled as requested.368*369* \param[in] buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,370* or 0 to disable it (the default).371* \param[out] buf <tt>int</tt>: 1 if all bitstream features required for372* VP3-compatibility could be set, and 0 otherwise.373* The latter will be returned if the pixel format is not374* 4:2:0, the picture region is smaller than the full frame,375* or if encoding has begun, preventing the quantization376* tables and codebooks from being set.377* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.378* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.379* \retval OC_IMPL Not supported by this implementation.*/380#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)381382/**Gets the maximum speed level.383* Higher speed levels favor quicker encoding over better quality per bit.384* Depending on the encoding mode, and the internal algorithms used, quality385* may actually improve, but in this case bitrate will also likely increase.386* In any case, overall rate/distortion performance will probably decrease.387* The maximum value, and the meaning of each value, may change depending on388* the current encoding mode (VBR vs. CQI, etc.).389*390* \param[out] buf int: The maximum encoding speed level.391* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.392* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.393* \retval OC_IMPL Not supported by this implementation in the current394* encoding mode.*/395#define TH_ENCCTL_GET_SPLEVEL_MAX (12)396397/**Sets the speed level.398* By default a speed value of 1 is used.399*400* \param[in] buf int: The new encoding speed level.401* 0 is slowest, larger values use less CPU.402* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.403* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>, or the404* encoding speed level is out of bounds.405* The maximum encoding speed level may be406* implementation- and encoding mode-specific, and can be407* obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.408* \retval OC_IMPL Not supported by this implementation in the current409* encoding mode.*/410#define TH_ENCCTL_SET_SPLEVEL (14)411412/*@}*/413414#define OC_FAULT -1 /**< General failure */415#define OC_EINVAL -10 /**< Library encountered invalid internal data */416#define OC_DISABLED -11 /**< Requested action is disabled */417#define OC_BADHEADER -20 /**< Header packet was corrupt/invalid */418#define OC_NOTFORMAT -21 /**< Packet is not a theora packet */419#define OC_VERSION -22 /**< Bitstream version is not handled */420#define OC_IMPL -23 /**< Feature or action not implemented */421#define OC_BADPACKET -24 /**< Packet is corrupt */422#define OC_NEWPACKET -25 /**< Packet is an (ignorable) unhandled extension */423#define OC_DUPFRAME 1 /**< Packet is a dropped frame */424425/**426* Retrieve a human-readable string to identify the encoder vendor and version.427* \returns A version string.428*/429extern const char *theora_version_string(void);430431/**432* Retrieve a 32-bit version number.433* This number is composed of a 16-bit major version, 8-bit minor version434* and 8 bit sub-version, composed as follows:435<pre>436(VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)437</pre>438* \returns The version number.439*/440extern ogg_uint32_t theora_version_number(void);441442/**443* Initialize the theora encoder.444* \param th The theora_state handle to initialize for encoding.445* \param ti A theora_info struct filled with the desired encoding parameters.446* \retval 0 Success447*/448extern int theora_encode_init(theora_state *th, theora_info *ti);449450/**451* Submit a YUV buffer to the theora encoder.452* \param t A theora_state handle previously initialized for encoding.453* \param yuv A buffer of YUV data to encode. Note that both the yuv_buffer454* struct and the luma/chroma buffers within should be allocated by455* the user.456* \retval OC_EINVAL Encoder is not ready, or is finished.457* \retval -1 The size of the given frame differs from those previously input458* \retval 0 Success459*/460extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);461462/**463* Request the next packet of encoded video.464* The encoded data is placed in a user-provided ogg_packet structure.465* \param t A theora_state handle previously initialized for encoding.466* \param last_p whether this is the last packet the encoder should produce.467* \param op An ogg_packet structure to fill. libtheora will set all468* elements of this structure, including a pointer to encoded469* data. The memory for the encoded data is owned by libtheora.470* \retval 0 No internal storage exists OR no packet is ready471* \retval -1 The encoding process has completed472* \retval 1 Success473*/474extern int theora_encode_packetout( theora_state *t, int last_p,475ogg_packet *op);476477/**478* Request a packet containing the initial header.479* A pointer to the header data is placed in a user-provided ogg_packet480* structure.481* \param t A theora_state handle previously initialized for encoding.482* \param op An ogg_packet structure to fill. libtheora will set all483* elements of this structure, including a pointer to the header484* data. The memory for the header data is owned by libtheora.485* \retval 0 Success486*/487extern int theora_encode_header(theora_state *t, ogg_packet *op);488489/**490* Request a comment header packet from provided metadata.491* A pointer to the comment data is placed in a user-provided ogg_packet492* structure.493* \param tc A theora_comment structure filled with the desired metadata494* \param op An ogg_packet structure to fill. libtheora will set all495* elements of this structure, including a pointer to the encoded496* comment data. The memory for the comment data is owned by497* the application, and must be freed by it using _ogg_free().498* On some systems (such as Windows when using dynamic linking), this499* may mean the free is executed in a different module from the500* malloc, which will crash; there is no way to free this memory on501* such systems.502* \retval 0 Success503*/504extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);505506/**507* Request a packet containing the codebook tables for the stream.508* A pointer to the codebook data is placed in a user-provided ogg_packet509* structure.510* \param t A theora_state handle previously initialized for encoding.511* \param op An ogg_packet structure to fill. libtheora will set all512* elements of this structure, including a pointer to the codebook513* data. The memory for the header data is owned by libtheora.514* \retval 0 Success515*/516extern int theora_encode_tables(theora_state *t, ogg_packet *op);517518/**519* Decode an Ogg packet, with the expectation that the packet contains520* an initial header, comment data or codebook tables.521*522* \param ci A theora_info structure to fill. This must have been previously523* initialized with theora_info_init(). If \a op contains an initial524* header, theora_decode_header() will fill \a ci with the525* parsed header values. If \a op contains codebook tables,526* theora_decode_header() will parse these and attach an internal527* representation to \a ci->codec_setup.528* \param cc A theora_comment structure to fill. If \a op contains comment529* data, theora_decode_header() will fill \a cc with the parsed530* comments.531* \param op An ogg_packet structure which you expect contains an initial532* header, comment data or codebook tables.533*534* \retval OC_BADHEADER \a op is NULL; OR the first byte of \a op->packet535* has the signature of an initial packet, but op is536* not a b_o_s packet; OR this packet has the signature537* of an initial header packet, but an initial header538* packet has already been seen; OR this packet has the539* signature of a comment packet, but the initial header540* has not yet been seen; OR this packet has the signature541* of a comment packet, but contains invalid data; OR542* this packet has the signature of codebook tables,543* but the initial header or comments have not yet544* been seen; OR this packet has the signature of codebook545* tables, but contains invalid data;546* OR the stream being decoded has a compatible version547* but this packet does not have the signature of a548* theora initial header, comments, or codebook packet549* \retval OC_VERSION The packet data of \a op is an initial header with550* a version which is incompatible with this version of551* libtheora.552* \retval OC_NEWPACKET the stream being decoded has an incompatible (future)553* version and contains an unknown signature.554* \retval 0 Success555*556* \note The normal usage is that theora_decode_header() be called on the557* first three packets of a theora logical bitstream in succession.558*/559extern int theora_decode_header(theora_info *ci, theora_comment *cc,560ogg_packet *op);561562/**563* Initialize a theora_state handle for decoding.564* \param th The theora_state handle to initialize.565* \param c A theora_info struct filled with the desired decoding parameters.566* This is of course usually obtained from a previous call to567* theora_decode_header().568* \retval 0 Success569*/570extern int theora_decode_init(theora_state *th, theora_info *c);571572/**573* Input a packet containing encoded data into the theora decoder.574* \param th A theora_state handle previously initialized for decoding.575* \param op An ogg_packet containing encoded theora data.576* \retval 0 Success577* \retval OC_BADPACKET \a op does not contain encoded video data578*/579extern int theora_decode_packetin(theora_state *th,ogg_packet *op);580581/**582* Output the next available frame of decoded YUV data.583* \param th A theora_state handle previously initialized for decoding.584* \param yuv A yuv_buffer in which libtheora should place the decoded data.585* Note that the buffer struct itself is allocated by the user, but586* that the luma and chroma pointers will be filled in by the587* library. Also note that these luma and chroma regions should be588* considered read-only by the user.589* \retval 0 Success590*/591extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);592593/**594* Report whether a theora packet is a header or not595* This function does no verification beyond checking the header596* flag bit so it should not be used for bitstream identification;597* use theora_decode_header() for that.598*599* \param op An ogg_packet containing encoded theora data.600* \retval 1 The packet is a header packet601* \retval 0 The packet is not a header packet (and so contains frame data)602*603* Thus function was added in the 1.0alpha4 release.604*/605extern int theora_packet_isheader(ogg_packet *op);606607/**608* Report whether a theora packet is a keyframe or not609*610* \param op An ogg_packet containing encoded theora data.611* \retval 1 The packet contains a keyframe image612* \retval 0 The packet is contains an interframe delta613* \retval -1 The packet is not an image data packet at all614*615* Thus function was added in the 1.0alpha4 release.616*/617extern int theora_packet_iskeyframe(ogg_packet *op);618619/**620* Report the granulepos shift radix621*622* When embedded in Ogg, Theora uses a two-part granulepos,623* splitting the 64-bit field into two pieces. The more-significant624* section represents the frame count at the last keyframe,625* and the less-significant section represents the count of626* frames since the last keyframe. In this way the overall627* field is still non-decreasing with time, but usefully encodes628* a pointer to the last keyframe, which is necessary for629* correctly restarting decode after a seek.630*631* This function reports the number of bits used to represent632* the distance to the last keyframe, and thus how the granulepos633* field must be shifted or masked to obtain the two parts.634*635* Since libtheora returns compressed data in an ogg_packet636* structure, this may be generally useful even if the Theora637* packets are not being used in an Ogg container.638*639* \param ti A previously initialized theora_info struct640* \returns The bit shift dividing the two granulepos fields641*642* This function was added in the 1.0alpha5 release.643*/644int theora_granule_shift(theora_info *ti);645646/**647* Convert a granulepos to an absolute frame index, starting at 0.648* The granulepos is interpreted in the context of a given theora_state handle.649*650* Note that while the granulepos encodes the frame count (i.e. starting651* from 1) this call returns the frame index, starting from zero. Thus652* One can calculate the presentation time by multiplying the index by653* the rate.654*655* \param th A previously initialized theora_state handle (encode or decode)656* \param granulepos The granulepos to convert.657* \returns The frame index corresponding to \a granulepos.658* \retval -1 The given granulepos is undefined (i.e. negative)659*660* Thus function was added in the 1.0alpha4 release.661*/662extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);663664/**665* Convert a granulepos to absolute time in seconds. The granulepos is666* interpreted in the context of a given theora_state handle, and gives667* the end time of a frame's presentation as used in Ogg mux ordering.668*669* \param th A previously initialized theora_state handle (encode or decode)670* \param granulepos The granulepos to convert.671* \returns The absolute time in seconds corresponding to \a granulepos.672* This is the "end time" for the frame, or the latest time it should673* be displayed.674* It is not the presentation time.675* \retval -1. The given granulepos is undefined (i.e. negative).676*/677extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);678679/**680* Initialize a theora_info structure. All values within the given theora_info681* structure are initialized, and space is allocated within libtheora for682* internal codec setup data.683* \param c A theora_info struct to initialize.684*/685extern void theora_info_init(theora_info *c);686687/**688* Clear a theora_info structure. All values within the given theora_info689* structure are cleared, and associated internal codec setup data is freed.690* \param c A theora_info struct to initialize.691*/692extern void theora_info_clear(theora_info *c);693694/**695* Free all internal data associated with a theora_state handle.696* \param t A theora_state handle.697*/698extern void theora_clear(theora_state *t);699700/**701* Initialize an allocated theora_comment structure702* \param tc An allocated theora_comment structure703**/704extern void theora_comment_init(theora_comment *tc);705706/**707* Add a comment to an initialized theora_comment structure708* \param tc A previously initialized theora comment structure709* \param comment A null-terminated string encoding the comment in the form710* "TAG=the value"711*712* Neither theora_comment_add() nor theora_comment_add_tag() support713* comments containing null values, although the bitstream format714* supports this. To add such comments you will need to manipulate715* the theora_comment structure directly.716**/717718extern void theora_comment_add(theora_comment *tc, char *comment);719720/**721* Add a comment to an initialized theora_comment structure.722* \param tc A previously initialized theora comment structure723* \param tag A null-terminated string containing the tag724* associated with the comment.725* \param value The corresponding value as a null-terminated string726*727* Neither theora_comment_add() nor theora_comment_add_tag() support728* comments containing null values, although the bitstream format729* supports this. To add such comments you will need to manipulate730* the theora_comment structure directly.731**/732extern void theora_comment_add_tag(theora_comment *tc,733char *tag, char *value);734735/**736* Look up a comment value by tag.737* \param tc Tn initialized theora_comment structure738* \param tag The tag to look up739* \param count The instance of the tag. The same tag can appear multiple740* times, each with a distinct and ordered value, so an index741* is required to retrieve them all.742* \returns A pointer to the queried tag's value743* \retval NULL No matching tag is found744*745* \note Use theora_comment_query_count() to get the legal range for the746* count parameter.747**/748749extern char *theora_comment_query(theora_comment *tc, char *tag, int count);750751/** Look up the number of instances of a tag.752* \param tc An initialized theora_comment structure753* \param tag The tag to look up754* \returns The number on instances of a particular tag.755*756* Call this first when querying for a specific tag and then iterate757* over the number of instances with separate calls to758* theora_comment_query() to retrieve all instances in order.759**/760extern int theora_comment_query_count(theora_comment *tc, char *tag);761762/**763* Clear an allocated theora_comment struct so that it can be freed.764* \param tc An allocated theora_comment structure.765**/766extern void theora_comment_clear(theora_comment *tc);767768/**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 available773* control codes" for details.774* \param buf The parameters for this control code.775* \param buf_sz The size of the parameter buffer.*/776extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);777778/* @} */ /* end oldfuncs doxygen group */779780#ifdef __cplusplus781}782#endif /* __cplusplus */783784#endif /* OGG_THEORA_HEADER */785786787