\section{theoraenc.\+h File Reference}
\label{theoraenc_8h}\index{theoraenc.\+h@{theoraenc.\+h}}


The {\ttfamily libtheoraenc} C encoding A\+PI.  


{\ttfamily \#include $<$stddef.\+h$>$}\\*
{\ttfamily \#include $<$ogg/ogg.\+h$>$}\\*
{\ttfamily \#include \char`\"{}codec.\+h\char`\"{}}\\*
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define {\bf \+\_\+\+O\+\_\+\+T\+H\+E\+O\+R\+A\+\_\+\+T\+H\+E\+O\+R\+A\+E\+N\+C\+\_\+\+H\+\_\+}~(1)
\end{DoxyCompactItemize}
\begin{Indent}{\bf th\+\_\+encode\+\_\+ctl() codes}\par
{\em \label{theoraenc_8h_encctlcodes}%
These are the available request codes for \doxyref{th\+\_\+encode\+\_\+ctl()}{p.}{group__encfuncs_ga3a427f6514dfdc01ea72172c469d51d9}. By convention, these are even, to distinguish them from the \doxyref{decoder control codes}{p.}{theoradec_8h_decctlcodes}. Keep any experimental or vendor-\/specific values above {\ttfamily 0x8000}. }\begin{DoxyCompactItemize}
\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+H\+U\+F\+F\+M\+A\+N\+\_\+\+C\+O\+D\+ES}~(0)
\begin{DoxyCompactList}\small\item\em Sets the Huffman tables to use. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+P\+A\+R\+A\+MS}~(2)
\begin{DoxyCompactList}\small\item\em Sets the quantization parameters to use. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+K\+E\+Y\+F\+R\+A\+M\+E\+\_\+\+F\+R\+E\+Q\+U\+E\+N\+C\+Y\+\_\+\+F\+O\+R\+CE}~(4)
\begin{DoxyCompactList}\small\item\em Sets the maximum distance between key frames. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+V\+P3\+\_\+\+C\+O\+M\+P\+A\+T\+I\+B\+LE}~(10)
\begin{DoxyCompactList}\small\item\em Disables any encoder features that would prevent lossless transcoding back to V\+P3. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX}~(12)
\begin{DoxyCompactList}\small\item\em Gets the maximum speed level. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}~(14)
\begin{DoxyCompactList}\small\item\em Sets the speed level. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}~(16)
\begin{DoxyCompactList}\small\item\em Gets the current speed level. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+D\+U\+P\+\_\+\+C\+O\+U\+NT}~(18)
\begin{DoxyCompactList}\small\item\em Sets the number of duplicates of the next frame to produce. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS}~(20)
\begin{DoxyCompactList}\small\item\em Modifies the default bitrate management behavior. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER}~(22)
\begin{DoxyCompactList}\small\item\em Sets the size of the bitrate management bit reservoir as a function of number of frames. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT}~(24)
\begin{DoxyCompactList}\small\item\em Enable pass 1 of two-\/pass encoding mode and retrieve the first pass metrics. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN}~(26)
\begin{DoxyCompactList}\small\item\em Submits two-\/pass encoding metric data collected the first encoding pass to the second pass. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+L\+I\+TY}~(28)
\begin{DoxyCompactList}\small\item\em Sets the current encoding quality. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE}~(30)
\begin{DoxyCompactList}\small\item\em Sets the current encoding bitrate. \end{DoxyCompactList}\end{DoxyCompactItemize}
\end{Indent}
\begin{Indent}{\bf T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS flags}\par
{\em \label{theoraenc_8h_ratectlflags}%
These are the flags available for use with \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS}{p.}{theoraenc_8h_a026502e08fbe1af0a1063f39bd18129c}. }\begin{DoxyCompactItemize}
\item 
\#define {\bf T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES}~(0x1)
\begin{DoxyCompactList}\small\item\em Drop frames to keep within bitrate buffer constraints. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW}~(0x2)
\begin{DoxyCompactList}\small\item\em Ignore bitrate buffer overflows. \end{DoxyCompactList}\item 
\#define {\bf T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW}~(0x4)
\begin{DoxyCompactList}\small\item\em Ignore bitrate buffer underflows. \end{DoxyCompactList}\end{DoxyCompactItemize}
\end{Indent}
\subsection*{Typedefs}
\begin{Indent}{\bf Encoder state}\par
{\em The following data structure is opaque, and its contents are not publicly defined by this A\+PI.

Referring to its internals directly is unsupported, and may break without warning. }\begin{DoxyCompactItemize}
\item 
typedef struct {\bf th\+\_\+enc\+\_\+ctx} {\bf th\+\_\+enc\+\_\+ctx}
\begin{DoxyCompactList}\small\item\em The encoder context. \end{DoxyCompactList}\end{DoxyCompactItemize}
\end{Indent}
\subsection*{Functions}
\begin{Indent}{\bf Functions for encoding}\par
{\em You must link to {\ttfamily libtheoraenc} and {\ttfamily libtheoradec} if you use any of the functions in this section.

The functions are listed in the order they are used in a typical encode. The basic steps are\+:
\begin{DoxyItemize}
\item Fill in a \doxyref{th\+\_\+info}{p.}{structth__info} structure with details on the format of the video you wish to encode.
\item Allocate a \doxyref{th\+\_\+enc\+\_\+ctx}{p.}{theoraenc_8h_af5cc40472b925456d42526a035d66edd} handle with \doxyref{th\+\_\+encode\+\_\+alloc()}{p.}{group__encfuncs_gaa91e47bc9dd5f6ee52045bd7b815e5a7}.
\item Perform any additional encoder configuration required with \doxyref{th\+\_\+encode\+\_\+ctl()}{p.}{group__encfuncs_ga3a427f6514dfdc01ea72172c469d51d9}.
\item Repeatedly call \doxyref{th\+\_\+encode\+\_\+flushheader()}{p.}{group__encfuncs_ga9439d61b566039d194ff782681fbc408} to retrieve all the header packets.
\item For each uncompressed frame\+:
\begin{DoxyItemize}
\item Submit the uncompressed frame via \doxyref{th\+\_\+encode\+\_\+ycbcr\+\_\+in()}{p.}{group__encfuncs_gadbe7dd66b411c2d61ab8153c15308750}
\item Repeatedly call \doxyref{th\+\_\+encode\+\_\+packetout()}{p.}{group__encfuncs_ga96d8ac1dda53187455352f99bbb5b04b} to retrieve any video data packets that are ready.
\end{DoxyItemize}
\item Call \doxyref{th\+\_\+encode\+\_\+free()}{p.}{group__encfuncs_ga36b23d216532231925c4107894204680} to release all encoder memory. 
\end{DoxyItemize}}\begin{DoxyCompactItemize}
\item 
{\bf th\+\_\+enc\+\_\+ctx} $\ast$ {\bf th\+\_\+encode\+\_\+alloc} (const {\bf th\+\_\+info} $\ast$\+\_\+info)
\begin{DoxyCompactList}\small\item\em Allocates an encoder instance. \end{DoxyCompactList}\item 
int {\bf th\+\_\+encode\+\_\+ctl} ({\bf th\+\_\+enc\+\_\+ctx} $\ast$\+\_\+enc, int \+\_\+req, void $\ast$\+\_\+buf, size\+\_\+t \+\_\+buf\+\_\+sz)
\begin{DoxyCompactList}\small\item\em Encoder control function. \end{DoxyCompactList}\item 
int {\bf th\+\_\+encode\+\_\+flushheader} ({\bf th\+\_\+enc\+\_\+ctx} $\ast$\+\_\+enc, {\bf th\+\_\+comment} $\ast$\+\_\+comments, ogg\+\_\+packet $\ast$\+\_\+op)
\begin{DoxyCompactList}\small\item\em Outputs the next header packet. \end{DoxyCompactList}\item 
int {\bf th\+\_\+encode\+\_\+ycbcr\+\_\+in} ({\bf th\+\_\+enc\+\_\+ctx} $\ast$\+\_\+enc, {\bf th\+\_\+ycbcr\+\_\+buffer} \+\_\+ycbcr)
\begin{DoxyCompactList}\small\item\em Submits an uncompressed frame to the encoder. \end{DoxyCompactList}\item 
int {\bf th\+\_\+encode\+\_\+packetout} ({\bf th\+\_\+enc\+\_\+ctx} $\ast$\+\_\+enc, int \+\_\+last, ogg\+\_\+packet $\ast$\+\_\+op)
\begin{DoxyCompactList}\small\item\em Retrieves encoded video data packets. \end{DoxyCompactList}\item 
void {\bf th\+\_\+encode\+\_\+free} ({\bf th\+\_\+enc\+\_\+ctx} $\ast$\+\_\+enc)
\begin{DoxyCompactList}\small\item\em Frees an allocated encoder instance. \end{DoxyCompactList}\end{DoxyCompactItemize}
\end{Indent}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const {\bf th\+\_\+quant\+\_\+info} {\bf T\+H\+\_\+\+V\+P31\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+I\+N\+FO}
\begin{DoxyCompactList}\small\item\em The quantization parameters used by V\+P3. \end{DoxyCompactList}\item 
const {\bf th\+\_\+huff\+\_\+code} {\bf T\+H\+\_\+\+V\+P31\+\_\+\+H\+U\+F\+F\+\_\+\+C\+O\+D\+ES} [{\bf T\+H\+\_\+\+N\+H\+U\+F\+F\+M\+A\+N\+\_\+\+T\+A\+B\+L\+ES}][{\bf T\+H\+\_\+\+N\+D\+C\+T\+\_\+\+T\+O\+K\+E\+NS}]
\begin{DoxyCompactList}\small\item\em The Huffman tables used by V\+P3. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
The {\ttfamily libtheoraenc} C encoding A\+PI. 



\subsection{Macro Definition Documentation}
\index{theoraenc.\+h@{theoraenc.\+h}!\+\_\+\+O\+\_\+\+T\+H\+E\+O\+R\+A\+\_\+\+T\+H\+E\+O\+R\+A\+E\+N\+C\+\_\+\+H\+\_\+@{\+\_\+\+O\+\_\+\+T\+H\+E\+O\+R\+A\+\_\+\+T\+H\+E\+O\+R\+A\+E\+N\+C\+\_\+\+H\+\_\+}}
\index{\+\_\+\+O\+\_\+\+T\+H\+E\+O\+R\+A\+\_\+\+T\+H\+E\+O\+R\+A\+E\+N\+C\+\_\+\+H\+\_\+@{\+\_\+\+O\+\_\+\+T\+H\+E\+O\+R\+A\+\_\+\+T\+H\+E\+O\+R\+A\+E\+N\+C\+\_\+\+H\+\_\+}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{\+\_\+\+O\+\_\+\+T\+H\+E\+O\+R\+A\+\_\+\+T\+H\+E\+O\+R\+A\+E\+N\+C\+\_\+\+H\+\_\+}]{\setlength{\rightskip}{0pt plus 5cm}\#define \+\_\+\+O\+\_\+\+T\+H\+E\+O\+R\+A\+\_\+\+T\+H\+E\+O\+R\+A\+E\+N\+C\+\_\+\+H\+\_\+~(1)}\label{theoraenc_8h_ab915dd90f069a2431454fd62365e9381}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN~(26)}\label{theoraenc_8h_a4a84f982cdd9a3e3c803a29bbde9df0b}


Submits two-\/pass encoding metric data collected the first encoding pass to the second pass. 

The first call must be made before the first frame is encoded, and a target bitrate must have already been specified to the encoder. It sets the encoder to pass 2 mode implicitly; this cannot be disabled. The encoder may require reading data from some or all of the frames in advance, depending on, e.\+g., the reservoir size used in the second pass. You must call this function repeatedly before each frame to provide data until either a) it fails to consume all of the data presented or b) all of the pass 1 data has been consumed. In the first case, you must save the remaining data to be presented after the next frame. You can call this function with a N\+U\+LL argument to get an upper bound on the number of bytes that will be required before the next frame.

When pass 2 is first enabled, the default bit reservoir is set to the entire file; this gives maximum flexibility but can lead to very high peak rates. You can subsequently set it to another value with \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER}{p.}{theoraenc_8h_aaefb515876b2a180ad5c3120fc584a52} (e.\+g., to set it to the keyframe interval for non-\/live streaming), however, you may then need to provide more data before the next frame.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily char[]}\+: A buffer containing the data returned by \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT}{p.}{theoraenc_8h_ac3751b9c3838888ec2e3f0b0d2823282} in pass 1. You may pass {\ttfamily N\+U\+LL} for {\itshape \+\_\+buf} to return an upper bound on the number of additional bytes needed before the next frame. The summary data returned at the end of pass 1 must be at the head of the buffer on the first call with a non-\/{\ttfamily N\+U\+LL} {\itshape \+\_\+buf}, and the placeholder data returned at the start of pass 1 should be omitted. After each call you should advance this buffer by the number of bytes consumed. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em $>$0} & The number of bytes of metric data required/consumed. \\
\hline
{\em 0} & No more data is required before the next frame. \\
\hline
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & No target bitrate has been set, or the first call was made after the first frame was submitted for encoding. \\
\hline
{\em T\+H\+\_\+\+E\+N\+O\+T\+F\+O\+R\+M\+AT} & The data did not appear to be pass 1 from a compatible implementation of this library. \\
\hline
{\em T\+H\+\_\+\+E\+B\+A\+D\+H\+E\+A\+D\+ER} & The data was invalid; this may be returned when attempting to read an aborted pass 1 file that still has the placeholder data in place of the summary data. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+O\+UT~(24)}\label{theoraenc_8h_ac3751b9c3838888ec2e3f0b0d2823282}


Enable pass 1 of two-\/pass encoding mode and retrieve the first pass metrics. 

Pass 1 mode must be enabled before the first frame is encoded, and a target bitrate must have already been specified to the encoder. Although this does not have to be the exact rate that will be used in the second pass, closer values may produce better results. The first call returns the size of the two-\/pass header data, along with some placeholder content, and sets the encoder into pass 1 mode implicitly. This call sets the encoder to pass 1 mode implicitly. Then, a subsequent call must be made after each call to \doxyref{th\+\_\+encode\+\_\+ycbcr\+\_\+in()}{p.}{group__encfuncs_gadbe7dd66b411c2d61ab8153c15308750} to retrieve the metrics for that frame. An additional, final call must be made to retrieve the summary data, containing such information as the total number of frames, etc. This must be stored in place of the placeholder data that was returned in the first call, before the frame metrics data. All of this data must be presented back to the encoder during pass 2 using \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+2\+P\+A\+S\+S\+\_\+\+IN}{p.}{theoraenc_8h_a4a84f982cdd9a3e3c803a29bbde9df0b}.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt out}  & {\em $<$tt$>$char} & $\ast$\+\_\+buf\+: Returns a pointer to internal storage containing the two pass metrics data. This storage is only valid until the next call, or until the encoder context is freed, and must be copied by the application. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em $>$=0} & The number of bytes of metric data available in the returned buffer. \\
\hline
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(char $\ast$)}, no target bitrate has been set, or the first call was made after the first frame was submitted for encoding. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL~(16)}\label{theoraenc_8h_a114b7c552f50b7b8d881a39489af1f61}


Gets the current speed level. 

The default speed level may vary according to encoder implementation, but if this control code is not supported (it returns \doxyref{T\+H\+\_\+\+E\+I\+M\+PL}{p.}{codec_8h_a921c47accc17841f220af5a6afb79efe}), the default may be assumed to be the slowest available speed (0). The maximum encoding speed level may be implementation-\/ and encoding mode-\/specific, and can be obtained via \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX}{p.}{theoraenc_8h_a9baf5bdd206e80c78a8fd44687e89783}.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt out}  & {\em \+\_\+buf} & {\ttfamily int}\+: The current encoding speed level. 0 is slowest, larger values use less C\+PU. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(int)}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation in the current encoding mode. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX~(12)}\label{theoraenc_8h_a9baf5bdd206e80c78a8fd44687e89783}


Gets the maximum speed level. 

Higher speed levels favor quicker encoding over better quality per bit. Depending on the encoding mode, and the internal algorithms used, quality may actually improve, but in this case bitrate will also likely increase. In any case, overall rate/distortion performance will probably decrease. The maximum value, and the meaning of each value, may change depending on the current encoding mode (V\+BR vs. constant quality, etc.).


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt out}  & {\em \+\_\+buf} & {\ttfamily int}\+: The maximum encoding speed level. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(int)}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation in the current encoding mode. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE~(30)}\label{theoraenc_8h_a9b969df55ecad1acd1ae207fad42592e}


Sets the current encoding bitrate. 

Once a bitrate is set, the encoder must use a rate-\/controlled mode for all future frames (this restriction may be relaxed in a future version). If it is set before the headers are emitted, the target bitrate encoded in them will be updated. Due to the buffer delay, the exact bitrate of each section of the encode is not guaranteed. The encoder may have already used more bits than allowed for the frames it has encoded, expecting to make them up in future frames, or it may have used fewer, holding the excess in reserve. The exact transition between the two bitrates is not well-\/defined by this A\+PI, but may be affected by flags set with \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS}{p.}{theoraenc_8h_a026502e08fbe1af0a1063f39bd18129c}. After a number of frames equal to the buffer delay, one may expect further output to average at the target bitrate.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily long}\+: The new target bitrate, in bits per second. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & Success. \\
\hline
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & The target bitrate was not positive. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+D\+U\+P\+\_\+\+C\+O\+U\+NT@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+D\+U\+P\+\_\+\+C\+O\+U\+NT}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+D\+U\+P\+\_\+\+C\+O\+U\+NT@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+D\+U\+P\+\_\+\+C\+O\+U\+NT}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+D\+U\+P\+\_\+\+C\+O\+U\+NT}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+D\+U\+P\+\_\+\+C\+O\+U\+NT~(18)}\label{theoraenc_8h_a8bb9b05471c42a09f8684a2583b8a1df}


Sets the number of duplicates of the next frame to produce. 

Although libtheora can encode duplicate frames very cheaply, it costs some amount of C\+PU to detect them, and a run of duplicates cannot span a keyframe boundary. This control code tells the encoder to produce the specified number of extra duplicates of the next frame. This allows the encoder to make smarter keyframe placement decisions and rate control decisions, and reduces C\+PU usage as well, when compared to just submitting the same frame for encoding multiple times. This setting only applies to the next frame submitted for encoding. You M\+U\+ST call \doxyref{th\+\_\+encode\+\_\+packetout()}{p.}{group__encfuncs_ga96d8ac1dda53187455352f99bbb5b04b} repeatedly until it returns 0, or the extra duplicate frames will be lost.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily int}\+: The number of duplicates to produce. If this is negative or zero, no duplicates will be produced. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(int)}, or the number of duplicates is greater than or equal to the maximum keyframe interval. In the latter case, NO duplicate frames will be produced. You must ensure that the maximum keyframe interval is set larger than the maximum number of duplicates you will ever wish to insert prior to encoding. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation in the current encoding mode. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+H\+U\+F\+F\+M\+A\+N\+\_\+\+C\+O\+D\+ES@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+H\+U\+F\+F\+M\+A\+N\+\_\+\+C\+O\+D\+ES}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+H\+U\+F\+F\+M\+A\+N\+\_\+\+C\+O\+D\+ES@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+H\+U\+F\+F\+M\+A\+N\+\_\+\+C\+O\+D\+ES}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+H\+U\+F\+F\+M\+A\+N\+\_\+\+C\+O\+D\+ES}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+H\+U\+F\+F\+M\+A\+N\+\_\+\+C\+O\+D\+ES~(0)}\label{theoraenc_8h_a0165348788e560a19b7c61ae8f0c2283}


Sets the Huffman tables to use. 

The tables are copied, not stored by reference, so they can be freed after this call. {\ttfamily N\+U\+LL} may be specified to revert to the default tables.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily \doxyref{th\+\_\+huff\+\_\+code}{p.}{structth__huff__code}[\doxyref{T\+H\+\_\+\+N\+H\+U\+F\+F\+M\+A\+N\+\_\+\+T\+A\+B\+L\+ES}{p.}{codec_8h_a49bf449eae33c5320f0c308f32c6ae42}][\doxyref{T\+H\+\_\+\+N\+D\+C\+T\+\_\+\+T\+O\+K\+E\+NS}{p.}{codec_8h_a2a44f48084e76a58cae48fb5d47cd422}]} \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & Encoding has already begun or one or more of the given tables is not full or prefix-\/free, {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL} and {\itshape \+\_\+buf\+\_\+sz} is not zero, or {\itshape \+\_\+buf} is non-\/{\ttfamily N\+U\+LL} and {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(\doxyref{th\+\_\+huff\+\_\+code}{p.}{structth__huff__code})$\ast$\doxyref{T\+H\+\_\+\+N\+H\+U\+F\+F\+M\+A\+N\+\_\+\+T\+A\+B\+L\+ES}{p.}{codec_8h_a49bf449eae33c5320f0c308f32c6ae42}$\ast$\doxyref{T\+H\+\_\+\+N\+D\+C\+T\+\_\+\+T\+O\+K\+E\+NS}{p.}{codec_8h_a2a44f48084e76a58cae48fb5d47cd422}}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+K\+E\+Y\+F\+R\+A\+M\+E\+\_\+\+F\+R\+E\+Q\+U\+E\+N\+C\+Y\+\_\+\+F\+O\+R\+CE@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+K\+E\+Y\+F\+R\+A\+M\+E\+\_\+\+F\+R\+E\+Q\+U\+E\+N\+C\+Y\+\_\+\+F\+O\+R\+CE}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+K\+E\+Y\+F\+R\+A\+M\+E\+\_\+\+F\+R\+E\+Q\+U\+E\+N\+C\+Y\+\_\+\+F\+O\+R\+CE@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+K\+E\+Y\+F\+R\+A\+M\+E\+\_\+\+F\+R\+E\+Q\+U\+E\+N\+C\+Y\+\_\+\+F\+O\+R\+CE}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+K\+E\+Y\+F\+R\+A\+M\+E\+\_\+\+F\+R\+E\+Q\+U\+E\+N\+C\+Y\+\_\+\+F\+O\+R\+CE}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+K\+E\+Y\+F\+R\+A\+M\+E\+\_\+\+F\+R\+E\+Q\+U\+E\+N\+C\+Y\+\_\+\+F\+O\+R\+CE~(4)}\label{theoraenc_8h_a27e755e15b4b5604c54974b304037a49}


Sets the maximum distance between key frames. 

This can be changed during an encode, but will be bounded by {\ttfamily 1$<$$<$\doxyref{th\+\_\+info\+::keyframe\+\_\+granule\+\_\+shift}{p.}{structth__info_a693ca4ab11fbc0c3f32594b4bb8766ed}}. If it is set before encoding begins, \doxyref{th\+\_\+info\+::keyframe\+\_\+granule\+\_\+shift}{p.}{structth__info_a693ca4ab11fbc0c3f32594b4bb8766ed} will be enlarged appropriately.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily ogg\+\_\+uint32\+\_\+t}\+: The maximum distance between key frames. \\
\hline
\mbox{\tt out}  & {\em \+\_\+buf} & {\ttfamily ogg\+\_\+uint32\+\_\+t}\+: The actual maximum distance set. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(ogg\+\_\+uint32\+\_\+t)}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+L\+I\+TY@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+L\+I\+TY}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+L\+I\+TY@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+L\+I\+TY}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+L\+I\+TY}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+L\+I\+TY~(28)}\label{theoraenc_8h_aac087983fa951b9148c9db6bc2e81ef4}


Sets the current encoding quality. 

This is only valid so long as no bitrate has been specified, either through the \doxyref{th\+\_\+info}{p.}{structth__info} struct used to initialize the encoder or through \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+B\+I\+T\+R\+A\+TE}{p.}{theoraenc_8h_a9b969df55ecad1acd1ae207fad42592e} (this restriction may be relaxed in a future version). If it is set before the headers are emitted, the target quality encoded in them will be updated.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily int}\+: The new target quality, in the range 0...63, inclusive. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & Success. \\
\hline
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & A target bitrate has already been specified, or the quality index was not in the range 0...63. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+P\+A\+R\+A\+MS@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+P\+A\+R\+A\+MS}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+P\+A\+R\+A\+MS@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+P\+A\+R\+A\+MS}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+P\+A\+R\+A\+MS}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+P\+A\+R\+A\+MS~(2)}\label{theoraenc_8h_a3befcdd66678f8d27034f9c4b16d1b9c}


Sets the quantization parameters to use. 

The parameters are copied, not stored by reference, so they can be freed after this call. {\ttfamily N\+U\+LL} may be specified to revert to the default parameters.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & \doxyref{th\+\_\+quant\+\_\+info}{p.}{structth__quant__info} \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & Encoding has already begun, {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL} and {\itshape \+\_\+buf\+\_\+sz} is not zero, or {\itshape \+\_\+buf} is non-\/{\ttfamily N\+U\+LL} and {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(\doxyref{th\+\_\+quant\+\_\+info}{p.}{structth__quant__info})}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+B\+U\+F\+F\+ER~(22)}\label{theoraenc_8h_aaefb515876b2a180ad5c3120fc584a52}


Sets the size of the bitrate management bit reservoir as a function of number of frames. 

The reservoir size affects how quickly bitrate management reacts to instantaneous changes in the video complexity. Larger reservoirs react more slowly, and provide better overall quality, but require more buffering by a client, adding more latency to live streams. By default, libtheora sets the reservoir to the maximum distance between keyframes, subject to a minimum and maximum limit. This call may be used to increase or decrease the reservoir, increasing or decreasing the allowed temporary variance in bitrate. An implementation may impose some limits on the size of a reservoir it can handle, in which case the actual reservoir size may not be exactly what was requested. The actual value set will be returned.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily int}\+: Requested size of the reservoir measured in frames. \\
\hline
\mbox{\tt out}  & {\em \+\_\+buf} & {\ttfamily int}\+: The actual size of the reservoir set. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(int)}, or rate control is not enabled. The buffer has an implementation defined minimum and maximum size and the value in \+\_\+buf will be adjusted to match the actual value set. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation in the current encoding mode. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+R\+A\+T\+E\+\_\+\+F\+L\+A\+GS~(20)}\label{theoraenc_8h_a026502e08fbe1af0a1063f39bd18129c}


Modifies the default bitrate management behavior. 

Use to allow or disallow frame dropping, and to enable or disable capping bit reservoir overflows and underflows. See \doxyref{the list of available flags}{p.}{theoraenc_8h_encctlcodes}. The flags are set by default to {\ttfamily \doxyref{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES}{p.}{theoraenc_8h_a3e7fab53b902b54135522ba286f45e33}$\vert$\doxyref{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW}{p.}{theoraenc_8h_a32f9983b344a431334493cefb0b9337c}}.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily int}\+: Any combination of \doxyref{the available flags}{p.}{theoraenc_8h_ratectlflags}\+:
\begin{DoxyItemize}
\item \doxyref{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES}{p.}{theoraenc_8h_a3e7fab53b902b54135522ba286f45e33}\+: Enable frame dropping.
\item \doxyref{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW}{p.}{theoraenc_8h_a32f9983b344a431334493cefb0b9337c}\+: Don\textquotesingle{}t bank excess bits for later use.
\item \doxyref{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW}{p.}{theoraenc_8h_ad0d62d9dce542caf5296b03b97e020a6}\+: Don\textquotesingle{}t try to make up shortfalls later. 
\end{DoxyItemize}\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(int)} or rate control is not enabled. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation in the current encoding mode. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL~(14)}\label{theoraenc_8h_abd9fbcb6a25a77d991d3620164fe59d6}


Sets the speed level. 

The current speed level may be retrieved using \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+EL}{p.}{theoraenc_8h_a114b7c552f50b7b8d881a39489af1f61}.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily int}\+: The new encoding speed level. 0 is slowest, larger values use less C\+PU. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(int)}, or the encoding speed level is out of bounds. The maximum encoding speed level may be implementation-\/ and encoding mode-\/specific, and can be obtained via \doxyref{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+G\+E\+T\+\_\+\+S\+P\+L\+E\+V\+E\+L\+\_\+\+M\+AX}{p.}{theoraenc_8h_a9baf5bdd206e80c78a8fd44687e89783}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation in the current encoding mode. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+V\+P3\+\_\+\+C\+O\+M\+P\+A\+T\+I\+B\+LE@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+V\+P3\+\_\+\+C\+O\+M\+P\+A\+T\+I\+B\+LE}}
\index{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+V\+P3\+\_\+\+C\+O\+M\+P\+A\+T\+I\+B\+LE@{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+V\+P3\+\_\+\+C\+O\+M\+P\+A\+T\+I\+B\+LE}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+V\+P3\+\_\+\+C\+O\+M\+P\+A\+T\+I\+B\+LE}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+E\+N\+C\+C\+T\+L\+\_\+\+S\+E\+T\+\_\+\+V\+P3\+\_\+\+C\+O\+M\+P\+A\+T\+I\+B\+LE~(10)}\label{theoraenc_8h_a382d685a39a34d8e6ba76b00d804efd8}


Disables any encoder features that would prevent lossless transcoding back to V\+P3. 

This primarily means disabling block-\/adaptive quantization and always coding all four luma blocks in a macro block when 4\+MV is used. It also includes using the V\+P3 quantization tables and Huffman codes; if you set them explicitly after calling this function, the resulting stream will not be V\+P3-\/compatible. If you enable V\+P3-\/compatibility when encoding 4\+:2\+:2 or 4\+:4\+:4 source material, or when using a picture region smaller than the full frame (e.\+g. a non-\/multiple-\/of-\/16 width or height), then non-\/\+V\+P3 bitstream features will still be disabled, but the stream will still not be V\+P3-\/compatible, as V\+P3 was not capable of encoding such formats. If you call this after encoding has already begun, then the quantization tables and codebooks cannot be changed, but the frame-\/level features will be enabled or disabled as requested.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \+\_\+buf} & {\ttfamily int}\+: a non-\/zero value to enable V\+P3 compatibility, or 0 to disable it (the default). \\
\hline
\mbox{\tt out}  & {\em \+\_\+buf} & {\ttfamily int}\+: 1 if all bitstream features required for V\+P3-\/compatibility could be set, and 0 otherwise. The latter will be returned if the pixel format is not 4\+:2\+:0, the picture region is smaller than the full frame, or if encoding has begun, preventing the quantization tables and codebooks from being set. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\+H\+\_\+\+E\+F\+A\+U\+LT} & {\itshape \+\_\+enc\+\_\+ctx} or {\itshape \+\_\+buf} is {\ttfamily N\+U\+LL}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+N\+V\+AL} & {\itshape \+\_\+buf\+\_\+sz} is not {\ttfamily sizeof(int)}. \\
\hline
{\em T\+H\+\_\+\+E\+I\+M\+PL} & Not supported by this implementation. \\
\hline
\end{DoxyRetVals}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW@{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW}}
\index{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW@{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+O\+V\+E\+R\+F\+L\+OW~(0x2)}\label{theoraenc_8h_a32f9983b344a431334493cefb0b9337c}


Ignore bitrate buffer overflows. 

If the encoder uses so few bits that the reservoir of available bits overflows, ignore the excess. The encoder will not try to use these extra bits in future frames. At high rates this may cause the result to be undersized, but allows a client to play the stream using a finite buffer; it should normally be enabled. \index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW@{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW}}
\index{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW@{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+C\+A\+P\+\_\+\+U\+N\+D\+E\+R\+F\+L\+OW~(0x4)}\label{theoraenc_8h_ad0d62d9dce542caf5296b03b97e020a6}


Ignore bitrate buffer underflows. 

If the encoder uses so many bits that the reservoir of available bits underflows, ignore the deficit. The encoder will not try to make up these extra bits in future frames. At low rates this may cause the result to be oversized; it should normally be disabled. \index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES@{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES}}
\index{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES@{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES}]{\setlength{\rightskip}{0pt plus 5cm}\#define T\+H\+\_\+\+R\+A\+T\+E\+C\+T\+L\+\_\+\+D\+R\+O\+P\+\_\+\+F\+R\+A\+M\+ES~(0x1)}\label{theoraenc_8h_a3e7fab53b902b54135522ba286f45e33}


Drop frames to keep within bitrate buffer constraints. 

This can have a severe impact on quality, but is the only way to ensure that bitrate targets are met at low rates during sudden bursts of activity. 

\subsection{Typedef Documentation}
\index{theoraenc.\+h@{theoraenc.\+h}!th\+\_\+enc\+\_\+ctx@{th\+\_\+enc\+\_\+ctx}}
\index{th\+\_\+enc\+\_\+ctx@{th\+\_\+enc\+\_\+ctx}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{th\+\_\+enc\+\_\+ctx}]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf th\+\_\+enc\+\_\+ctx} {\bf th\+\_\+enc\+\_\+ctx}}\label{theoraenc_8h_af5cc40472b925456d42526a035d66edd}


The encoder context. 



\subsection{Variable Documentation}
\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+V\+P31\+\_\+\+H\+U\+F\+F\+\_\+\+C\+O\+D\+ES@{T\+H\+\_\+\+V\+P31\+\_\+\+H\+U\+F\+F\+\_\+\+C\+O\+D\+ES}}
\index{T\+H\+\_\+\+V\+P31\+\_\+\+H\+U\+F\+F\+\_\+\+C\+O\+D\+ES@{T\+H\+\_\+\+V\+P31\+\_\+\+H\+U\+F\+F\+\_\+\+C\+O\+D\+ES}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+V\+P31\+\_\+\+H\+U\+F\+F\+\_\+\+C\+O\+D\+ES}]{\setlength{\rightskip}{0pt plus 5cm}const {\bf th\+\_\+huff\+\_\+code} T\+H\+\_\+\+V\+P31\+\_\+\+H\+U\+F\+F\+\_\+\+C\+O\+D\+ES[{\bf T\+H\+\_\+\+N\+H\+U\+F\+F\+M\+A\+N\+\_\+\+T\+A\+B\+L\+ES}][{\bf T\+H\+\_\+\+N\+D\+C\+T\+\_\+\+T\+O\+K\+E\+NS}]}\label{theoraenc_8h_aee1f7cb1fa0d3b7cc1d4ca0f17e6ae5e}


The Huffman tables used by V\+P3. 

\index{theoraenc.\+h@{theoraenc.\+h}!T\+H\+\_\+\+V\+P31\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+I\+N\+FO@{T\+H\+\_\+\+V\+P31\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+I\+N\+FO}}
\index{T\+H\+\_\+\+V\+P31\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+I\+N\+FO@{T\+H\+\_\+\+V\+P31\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+I\+N\+FO}!theoraenc.\+h@{theoraenc.\+h}}
\subsubsection[{T\+H\+\_\+\+V\+P31\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+I\+N\+FO}]{\setlength{\rightskip}{0pt plus 5cm}const {\bf th\+\_\+quant\+\_\+info} T\+H\+\_\+\+V\+P31\+\_\+\+Q\+U\+A\+N\+T\+\_\+\+I\+N\+FO}\label{theoraenc_8h_a3b1b462989f4e7a5a98e6e697f1a7f7d}


The quantization parameters used by V\+P3. 

