Path: blob/master/thirdparty/libtheora/theora/theoraenc.h
9903 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/**\file17* The <tt>libtheoraenc</tt> C encoding API.*/1819#if !defined(OGG_THEORA_THEORAENC_HEADER)20# define OGG_THEORA_THEORAENC_HEADER (1)21# include <stddef.h>22# include <ogg/ogg.h>23# include "codec.h"2425#if defined(__cplusplus)26extern "C" {27#endif28293031/**\name th_encode_ctl() codes32* \anchor encctlcodes33* These are the available request codes for th_encode_ctl().34* By convention, these are even, to distinguish them from the35* \ref decctlcodes "decoder control codes".36* Keep any experimental or vendor-specific values above \c 0x8000.*/37/*@{*/38/**Sets the Huffman tables to use.39* The tables are copied, not stored by reference, so they can be freed after40* this call.41* <tt>NULL</tt> may be specified to revert to the default tables.42*43* \param[in] _buf <tt>#th_huff_code[#TH_NHUFFMAN_TABLES][#TH_NDCT_TOKENS]</tt>44* \retval TH_EFAULT \a _enc is <tt>NULL</tt>.45* \retval TH_EINVAL Encoding has already begun or one or more of the given46* tables is not full or prefix-free, \a _buf is47* <tt>NULL</tt> and \a _buf_sz is not zero, or \a _buf is48* non-<tt>NULL</tt> and \a _buf_sz is not49* <tt>sizeof(#th_huff_code)*#TH_NHUFFMAN_TABLES*#TH_NDCT_TOKENS</tt>.50* \retval TH_EIMPL Not supported by this implementation.*/51#define TH_ENCCTL_SET_HUFFMAN_CODES (0)52/**Sets the quantization parameters to use.53* The parameters are copied, not stored by reference, so they can be freed54* after this call.55* <tt>NULL</tt> may be specified to revert to the default parameters.56*57* \param[in] _buf #th_quant_info58* \retval TH_EFAULT \a _enc is <tt>NULL</tt>.59* \retval TH_EINVAL Encoding has already begun, \a _buf is60* <tt>NULL</tt> and \a _buf_sz is not zero,61* or \a _buf is non-<tt>NULL</tt> and62* \a _buf_sz is not <tt>sizeof(#th_quant_info)</tt>.63* \retval TH_EIMPL Not supported by this implementation.*/64#define TH_ENCCTL_SET_QUANT_PARAMS (2)65/**Sets the maximum distance between key frames.66* This can be changed during an encode, but will be bounded by67* <tt>1<<th_info#keyframe_granule_shift</tt>.68* If it is set before encoding begins, th_info#keyframe_granule_shift will69* be enlarged appropriately.70*71* \param[in] _buf <tt>ogg_uint32_t</tt>: The maximum distance between key72* frames.73* \param[out] _buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.74* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.75* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.76* \retval TH_EIMPL Not supported by this implementation.*/77#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)78/**Disables any encoder features that would prevent lossless transcoding back79* to VP3.80* This primarily means disabling block-adaptive quantization and always coding81* all four luma blocks in a macro block when 4MV is used.82* It also includes using the VP3 quantization tables and Huffman codes; if you83* set them explicitly after calling this function, the resulting stream will84* not be VP3-compatible.85* If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source86* material, or when using a picture region smaller than the full frame (e.g.87* a non-multiple-of-16 width or height), then non-VP3 bitstream features will88* still be disabled, but the stream will still not be VP3-compatible, as VP389* was not capable of encoding such formats.90* If you call this after encoding has already begun, then the quantization91* tables and codebooks cannot be changed, but the frame-level features will92* be enabled or disabled as requested.93*94* \param[in] _buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,95* or 0 to disable it (the default).96* \param[out] _buf <tt>int</tt>: 1 if all bitstream features required for97* VP3-compatibility could be set, and 0 otherwise.98* The latter will be returned if the pixel format is not99* 4:2:0, the picture region is smaller than the full frame,100* or if encoding has begun, preventing the quantization101* tables and codebooks from being set.102* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.103* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.104* \retval TH_EIMPL Not supported by this implementation.*/105#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)106/**Gets the maximum speed level.107* Higher speed levels favor quicker encoding over better quality per bit.108* Depending on the encoding mode, and the internal algorithms used, quality109* may actually improve, but in this case bitrate will also likely increase.110* In any case, overall rate/distortion performance will probably decrease.111* The maximum value, and the meaning of each value, may change depending on112* the current encoding mode (VBR vs. constant quality, etc.).113*114* \param[out] _buf <tt>int</tt>: The maximum encoding speed level.115* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.116* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.117* \retval TH_EIMPL Not supported by this implementation in the current118* encoding mode.*/119#define TH_ENCCTL_GET_SPLEVEL_MAX (12)120/**Sets the speed level.121* The current speed level may be retrieved using #TH_ENCCTL_GET_SPLEVEL.122*123* \param[in] _buf <tt>int</tt>: The new encoding speed level.124* 0 is slowest, larger values use less CPU.125* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.126* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the127* encoding speed level is out of bounds.128* The maximum encoding speed level may be129* implementation- and encoding mode-specific, and can be130* obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.131* \retval TH_EIMPL Not supported by this implementation in the current132* encoding mode.*/133#define TH_ENCCTL_SET_SPLEVEL (14)134/**Gets the current speed level.135* The default speed level may vary according to encoder implementation, but if136* this control code is not supported (it returns #TH_EIMPL), the default may137* be assumed to be the slowest available speed (0).138* The maximum encoding speed level may be implementation- and encoding139* mode-specific, and can be obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.140*141* \param[out] _buf <tt>int</tt>: The current encoding speed level.142* 0 is slowest, larger values use less CPU.143* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.144* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.145* \retval TH_EIMPL Not supported by this implementation in the current146* encoding mode.*/147#define TH_ENCCTL_GET_SPLEVEL (16)148/**Sets the number of duplicates of the next frame to produce.149* Although libtheora can encode duplicate frames very cheaply, it costs some150* amount of CPU to detect them, and a run of duplicates cannot span a151* keyframe boundary.152* This control code tells the encoder to produce the specified number of extra153* duplicates of the next frame.154* This allows the encoder to make smarter keyframe placement decisions and155* rate control decisions, and reduces CPU usage as well, when compared to156* just submitting the same frame for encoding multiple times.157* This setting only applies to the next frame submitted for encoding.158* You MUST call th_encode_packetout() repeatedly until it returns 0, or the159* extra duplicate frames will be lost.160*161* \param[in] _buf <tt>int</tt>: The number of duplicates to produce.162* If this is negative or zero, no duplicates will be produced.163* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.164* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the165* number of duplicates is greater than or equal to the166* maximum keyframe interval.167* In the latter case, NO duplicate frames will be produced.168* You must ensure that the maximum keyframe interval is set169* larger than the maximum number of duplicates you will170* ever wish to insert prior to encoding.171* \retval TH_EIMPL Not supported by this implementation in the current172* encoding mode.*/173#define TH_ENCCTL_SET_DUP_COUNT (18)174/**Modifies the default bitrate management behavior.175* Use to allow or disallow frame dropping, and to enable or disable capping176* bit reservoir overflows and underflows.177* See \ref encctlcodes "the list of available flags".178* The flags are set by default to179* <tt>#TH_RATECTL_DROP_FRAMES|#TH_RATECTL_CAP_OVERFLOW</tt>.180*181* \param[in] _buf <tt>int</tt>: Any combination of182* \ref ratectlflags "the available flags":183* - #TH_RATECTL_DROP_FRAMES: Enable frame dropping.184* - #TH_RATECTL_CAP_OVERFLOW: Don't bank excess bits for later185* use.186* - #TH_RATECTL_CAP_UNDERFLOW: Don't try to make up shortfalls187* later.188* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.189* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt> or rate control190* is not enabled.191* \retval TH_EIMPL Not supported by this implementation in the current192* encoding mode.*/193#define TH_ENCCTL_SET_RATE_FLAGS (20)194/**Sets the size of the bitrate management bit reservoir as a function195* of number of frames.196* The reservoir size affects how quickly bitrate management reacts to197* instantaneous changes in the video complexity.198* Larger reservoirs react more slowly, and provide better overall quality, but199* require more buffering by a client, adding more latency to live streams.200* By default, libtheora sets the reservoir to the maximum distance between201* keyframes, subject to a minimum and maximum limit.202* This call may be used to increase or decrease the reservoir, increasing or203* decreasing the allowed temporary variance in bitrate.204* An implementation may impose some limits on the size of a reservoir it can205* handle, in which case the actual reservoir size may not be exactly what was206* requested.207* The actual value set will be returned.208*209* \param[in] _buf <tt>int</tt>: Requested size of the reservoir measured in210* frames.211* \param[out] _buf <tt>int</tt>: The actual size of the reservoir set.212* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.213* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or rate control214* is not enabled. The buffer has an implementation215* defined minimum and maximum size and the value in _buf216* will be adjusted to match the actual value set.217* \retval TH_EIMPL Not supported by this implementation in the current218* encoding mode.*/219#define TH_ENCCTL_SET_RATE_BUFFER (22)220/**Enable pass 1 of two-pass encoding mode and retrieve the first pass metrics.221* Pass 1 mode must be enabled before the first frame is encoded, and a target222* bitrate must have already been specified to the encoder.223* Although this does not have to be the exact rate that will be used in the224* second pass, closer values may produce better results.225* The first call returns the size of the two-pass header data, along with some226* placeholder content, and sets the encoder into pass 1 mode implicitly.227* This call sets the encoder to pass 1 mode implicitly.228* Then, a subsequent call must be made after each call to229* th_encode_ycbcr_in() to retrieve the metrics for that frame.230* An additional, final call must be made to retrieve the summary data,231* containing such information as the total number of frames, etc.232* This must be stored in place of the placeholder data that was returned233* in the first call, before the frame metrics data.234* All of this data must be presented back to the encoder during pass 2 using235* #TH_ENCCTL_2PASS_IN.236*237* \param[out] <tt>char *</tt>_buf: Returns a pointer to internal storage238* containing the two pass metrics data.239* This storage is only valid until the next call, or until the240* encoder context is freed, and must be copied by the241* application.242* \retval >=0 The number of bytes of metric data available in the243* returned buffer.244* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.245* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(char *)</tt>, no target246* bitrate has been set, or the first call was made after247* the first frame was submitted for encoding.248* \retval TH_EIMPL Not supported by this implementation.*/249#define TH_ENCCTL_2PASS_OUT (24)250/**Submits two-pass encoding metric data collected the first encoding pass to251* the second pass.252* The first call must be made before the first frame is encoded, and a target253* bitrate must have already been specified to the encoder.254* It sets the encoder to pass 2 mode implicitly; this cannot be disabled.255* The encoder may require reading data from some or all of the frames in256* advance, depending on, e.g., the reservoir size used in the second pass.257* You must call this function repeatedly before each frame to provide data258* until either a) it fails to consume all of the data presented or b) all of259* the pass 1 data has been consumed.260* In the first case, you must save the remaining data to be presented after261* the next frame.262* You can call this function with a NULL argument to get an upper bound on263* the number of bytes that will be required before the next frame.264*265* When pass 2 is first enabled, the default bit reservoir is set to the entire266* file; this gives maximum flexibility but can lead to very high peak rates.267* You can subsequently set it to another value with #TH_ENCCTL_SET_RATE_BUFFER268* (e.g., to set it to the keyframe interval for non-live streaming), however,269* you may then need to provide more data before the next frame.270*271* \param[in] _buf <tt>char[]</tt>: A buffer containing the data returned by272* #TH_ENCCTL_2PASS_OUT in pass 1.273* You may pass <tt>NULL</tt> for \a _buf to return an upper274* bound on the number of additional bytes needed before the275* next frame.276* The summary data returned at the end of pass 1 must be at277* the head of the buffer on the first call with a278* non-<tt>NULL</tt> \a _buf, and the placeholder data279* returned at the start of pass 1 should be omitted.280* After each call you should advance this buffer by the number281* of bytes consumed.282* \retval >0 The number of bytes of metric data required/consumed.283* \retval 0 No more data is required before the next frame.284* \retval TH_EFAULT \a _enc is <tt>NULL</tt>.285* \retval TH_EINVAL No target bitrate has been set, or the first call was286* made after the first frame was submitted for287* encoding.288* \retval TH_ENOTFORMAT The data did not appear to be pass 1 from a compatible289* implementation of this library.290* \retval TH_EBADHEADER The data was invalid; this may be returned when291* attempting to read an aborted pass 1 file that still292* has the placeholder data in place of the summary293* data.294* \retval TH_EIMPL Not supported by this implementation.*/295#define TH_ENCCTL_2PASS_IN (26)296/**Sets the current encoding quality.297* This is only valid so long as no bitrate has been specified, either through298* the #th_info struct used to initialize the encoder or through299* #TH_ENCCTL_SET_BITRATE (this restriction may be relaxed in a future300* version).301* If it is set before the headers are emitted, the target quality encoded in302* them will be updated.303*304* \param[in] _buf <tt>int</tt>: The new target quality, in the range 0...63,305* inclusive.306* \retval 0 Success.307* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.308* \retval TH_EINVAL A target bitrate has already been specified, or the309* quality index was not in the range 0...63.310* \retval TH_EIMPL Not supported by this implementation.*/311#define TH_ENCCTL_SET_QUALITY (28)312/**Sets the current encoding bitrate.313* Once a bitrate is set, the encoder must use a rate-controlled mode for all314* future frames (this restriction may be relaxed in a future version).315* If it is set before the headers are emitted, the target bitrate encoded in316* them will be updated.317* Due to the buffer delay, the exact bitrate of each section of the encode is318* not guaranteed.319* The encoder may have already used more bits than allowed for the frames it320* has encoded, expecting to make them up in future frames, or it may have321* used fewer, holding the excess in reserve.322* The exact transition between the two bitrates is not well-defined by this323* API, but may be affected by flags set with #TH_ENCCTL_SET_RATE_FLAGS.324* After a number of frames equal to the buffer delay, one may expect further325* output to average at the target bitrate.326*327* \param[in] _buf <tt>long</tt>: The new target bitrate, in bits per second.328* \retval 0 Success.329* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.330* \retval TH_EINVAL The target bitrate was not positive.331* A future version of this library may allow passing 0332* to disabled rate-controlled mode and return to a333* quality-based mode, in which case this function will334* not return an error for that value.335* \retval TH_EIMPL Not supported by this implementation.*/336#define TH_ENCCTL_SET_BITRATE (30)337/**Sets the configuration to be compatible with that from the given setup338* header.339* This sets the Huffman codebooks and quantization parameters to match those340* found in the given setup header.341* This guarantees that packets encoded by this encoder will be decodable using342* a decoder configured with the passed-in setup header.343* It does <em>not</em> guarantee that th_encode_flushheader() will produce a344* bit-identical setup header, only that they will be compatible.345* If you need a bit-identical setup header, then use the one you passed into346* this command, and not the one returned by th_encode_flushheader().347*348* This also does <em>not</em> enable or disable VP3 compatibility; that is not349* signaled in the setup header (or anywhere else in the encoded stream), and350* is controlled independently by the #TH_ENCCTL_SET_VP3_COMPATIBLE function.351* If you wish to enable VP3 compatibility mode <em>and</em> want the codebooks352* and quantization parameters to match the given setup header, you should353* enable VP3 compatibility before invoking this command, otherwise the354* codebooks and quantization parameters will be reset to the VP3 defaults.355*356* The current encoder does not support Huffman codebooks which do not contain357* codewords for all 32 tokens.358* Such codebooks are legal, according to the specification, but cannot be359* configured with this function.360*361* \param[in] _buf <tt>unsigned char[]</tt>: The encoded setup header to copy362* the configuration from.363* This should be the original,364* undecoded setup header packet,365* and <em>not</em> a #th_setup_info366* structure filled in by367* th_decode_headerin().368* \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.369* \retval TH_EINVAL Encoding has already begun, so the codebooks and370* quantization parameters cannot be changed, or the371* data in the setup header was not supported by this372* encoder.373* \retval TH_EBADHEADER \a _buf did not contain a valid setup header packet.374* \retval TH_ENOTFORMAT \a _buf did not contain a Theora header at all.375* \retval TH_EIMPL Not supported by this implementation.*/376#define TH_ENCCTL_SET_COMPAT_CONFIG (32)377378/*@}*/379380381/**\name TH_ENCCTL_SET_RATE_FLAGS flags382* \anchor ratectlflags383* These are the flags available for use with #TH_ENCCTL_SET_RATE_FLAGS.*/384/*@{*/385/**Drop frames to keep within bitrate buffer constraints.386* This can have a severe impact on quality, but is the only way to ensure that387* bitrate targets are met at low rates during sudden bursts of activity.388* It is enabled by default.*/389#define TH_RATECTL_DROP_FRAMES (0x1)390/**Ignore bitrate buffer overflows.391* If the encoder uses so few bits that the reservoir of available bits392* overflows, ignore the excess.393* The encoder will not try to use these extra bits in future frames.394* At high rates this may cause the result to be undersized, but allows a395* client to play the stream using a finite buffer; it should normally be396* enabled, which is the default.*/397#define TH_RATECTL_CAP_OVERFLOW (0x2)398/**Ignore bitrate buffer underflows.399* If the encoder uses so many bits that the reservoir of available bits400* underflows, ignore the deficit.401* The encoder will not try to make up these extra bits in future frames.402* At low rates this may cause the result to be oversized; it should normally403* be disabled, which is the default.*/404#define TH_RATECTL_CAP_UNDERFLOW (0x4)405/*@}*/406407408409/**The quantization parameters used by VP3.*/410extern const th_quant_info TH_VP31_QUANT_INFO;411412/**The Huffman tables used by VP3.*/413extern const th_huff_code414TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];415416417418/**\name Encoder state419The following data structure is opaque, and its contents are not publicly420defined by this API.421Referring to its internals directly is unsupported, and may break without422warning.*/423/*@{*/424/**The encoder context.*/425typedef struct th_enc_ctx th_enc_ctx;426/*@}*/427428429430/**\defgroup encfuncs Functions for Encoding*/431/*@{*/432/**\name Functions for encoding433* You must link to <tt>libtheoraenc</tt> and <tt>libtheoradec</tt>434* if you use any of the functions in this section.435*436* The functions are listed in the order they are used in a typical encode.437* The basic steps are:438* - Fill in a #th_info structure with details on the format of the video you439* wish to encode.440* - Allocate a #th_enc_ctx handle with th_encode_alloc().441* - Perform any additional encoder configuration required with442* th_encode_ctl().443* - Repeatedly call th_encode_flushheader() to retrieve all the header444* packets.445* - For each uncompressed frame:446* - Submit the uncompressed frame via th_encode_ycbcr_in()447* - Repeatedly call th_encode_packetout() to retrieve any video448* data packets that are ready.449* - Call th_encode_free() to release all encoder memory.*/450/*@{*/451/**Allocates an encoder instance.452* \param _info A #th_info struct filled with the desired encoding parameters.453* \return The initialized #th_enc_ctx handle.454* \retval NULL If the encoding parameters were invalid.*/455extern th_enc_ctx *th_encode_alloc(const th_info *_info);456/**Encoder control function.457* This is used to provide advanced control the encoding process.458* \param _enc A #th_enc_ctx handle.459* \param _req The control code to process.460* See \ref encctlcodes "the list of available control codes"461* for details.462* \param _buf The parameters for this control code.463* \param _buf_sz The size of the parameter buffer.464* \return Possible return values depend on the control code used.465* See \ref encctlcodes "the list of control codes" for466* specific values. Generally 0 indicates success.*/467extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz);468/**Outputs the next header packet.469* This should be called repeatedly after encoder initialization until it470* returns 0 in order to get all of the header packets, in order, before471* encoding actual video data.472* \param _enc A #th_enc_ctx handle.473* \param _comments The metadata to place in the comment header, when it is474* encoded.475* \param _op An <tt>ogg_packet</tt> structure to fill.476* All of the elements of this structure will be set,477* including a pointer to the header data.478* The memory for the header data is owned by479* <tt>libtheoraenc</tt>, and may be invalidated when the480* next encoder function is called.481* \return A positive value indicates that a header packet was successfully482* produced.483* \retval 0 No packet was produced, and no more header packets remain.484* \retval TH_EFAULT \a _enc, \a _comments, or \a _op was <tt>NULL</tt>.*/485extern int th_encode_flushheader(th_enc_ctx *_enc,486th_comment *_comments,ogg_packet *_op);487/**Submits an uncompressed frame to the encoder.488* \param _enc A #th_enc_ctx handle.489* \param _ycbcr A buffer of Y'CbCr data to encode.490* If the width and height of the buffer matches the frame size491* the encoder was initialized with, the encoder will only492* reference the portion inside the picture region.493* Any data outside this region will be ignored, and need not map494* to a valid address.495* Alternatively, you can pass a buffer equal to the size of the496* picture region, if this is less than the full frame size.497* When using subsampled chroma planes, odd picture sizes or odd498* picture offsets may require an unexpected chroma plane size,499* and their use is generally discouraged, as they will not be500* well-supported by players and other media frameworks.501* See Section 4.4 of502* <a href="https://www.theora.org/doc/Theora.pdf">the Theora503* specification</a> for details if you wish to use them anyway.504* \retval 0 Success.505* \retval TH_EFAULT \a _enc or \a _ycbcr is <tt>NULL</tt>.506* \retval TH_EINVAL The buffer size matches neither the frame size nor the507* picture size the encoder was initialized with, or508* encoding has already completed.*/509extern int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr);510/**Retrieves encoded video data packets.511* This should be called repeatedly after each frame is submitted to flush any512* encoded packets, until it returns 0.513* The encoder will not buffer these packets as subsequent frames are514* compressed, so a failure to do so will result in lost video data.515* \note Currently the encoder operates in a one-frame-in, one-packet-out516* manner.517* However, this may be changed in the future.518* \param _enc A #th_enc_ctx handle.519* \param _last Set this flag to a non-zero value if no more uncompressed520* frames will be submitted.521* This ensures that a proper EOS flag is set on the last packet.522* \param _op An <tt>ogg_packet</tt> structure to fill.523* All of the elements of this structure will be set, including a524* pointer to the video data.525* The memory for the video data is owned by526* <tt>libtheoraenc</tt>, and may be invalidated when the next527* encoder function is called.528* \return A positive value indicates that a video data packet was successfully529* produced.530* \retval 0 No packet was produced, and no more encoded video data531* remains.532* \retval TH_EFAULT \a _enc or \a _op was <tt>NULL</tt>.*/533extern int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op);534/**Frees an allocated encoder instance.535* \param _enc A #th_enc_ctx handle.*/536extern void th_encode_free(th_enc_ctx *_enc);537/*@}*/538/*@}*/539540541542#if defined(__cplusplus)543}544#endif545546#endif /* OGG_THEORA_THEORAENC_HEADER */547548549