group__basefuncs.tex 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. \section{Functions Shared by Encode and Decode}
  2. \label{group__basefuncs}\index{Functions Shared by Encode and Decode@{Functions Shared by Encode and Decode}}
  3. \subsection*{Basic shared functions}
  4. \label{_amgrpb625c22fa07613c734f71c378fe32d7a}
  5. \begin{DoxyCompactItemize}
  6. \item
  7. const char $\ast$ {\bf th\_\-version\_\-string} (void)
  8. \begin{DoxyCompactList}\small\item\em Retrieves a human-\/readable string to identify the library vendor and version. \item\end{DoxyCompactList}\item
  9. ogg\_\-uint32\_\-t {\bf th\_\-version\_\-number} (void)
  10. \begin{DoxyCompactList}\small\item\em Retrieves the library version number. \item\end{DoxyCompactList}\item
  11. ogg\_\-int64\_\-t {\bf th\_\-granule\_\-frame} (void $\ast$\_\-encdec, ogg\_\-int64\_\-t \_\-granpos)
  12. \begin{DoxyCompactList}\small\item\em Converts a granule position to an absolute frame index, starting at {\ttfamily 0}. \item\end{DoxyCompactList}\item
  13. double {\bf th\_\-granule\_\-time} (void $\ast$\_\-encdec, ogg\_\-int64\_\-t \_\-granpos)
  14. \begin{DoxyCompactList}\small\item\em Converts a granule position to an absolute time in seconds. \item\end{DoxyCompactList}\item
  15. int {\bf th\_\-packet\_\-isheader} (ogg\_\-packet $\ast$\_\-op)
  16. \begin{DoxyCompactList}\small\item\em Determines whether a Theora packet is a header or not. \item\end{DoxyCompactList}\item
  17. int {\bf th\_\-packet\_\-iskeyframe} (ogg\_\-packet $\ast$\_\-op)
  18. \begin{DoxyCompactList}\small\item\em Determines whether a theora packet is a key frame or not. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
  19. \subsection*{Functions for manipulating header data}
  20. \label{_amgrp14ef5f819e97c870c128539ed1f334e3}
  21. \begin{DoxyCompactItemize}
  22. \item
  23. void {\bf th\_\-info\_\-init} ({\bf th\_\-info} $\ast$\_\-info)
  24. \begin{DoxyCompactList}\small\item\em Initializes a \doxyref{th\_\-info}{p.}{structth__info} structure. \item\end{DoxyCompactList}\item
  25. void {\bf th\_\-info\_\-clear} ({\bf th\_\-info} $\ast$\_\-info)
  26. \begin{DoxyCompactList}\small\item\em Clears a \doxyref{th\_\-info}{p.}{structth__info} structure. \item\end{DoxyCompactList}\item
  27. void {\bf th\_\-comment\_\-init} ({\bf th\_\-comment} $\ast$\_\-tc)
  28. \begin{DoxyCompactList}\small\item\em Initialize a \doxyref{th\_\-comment}{p.}{structth__comment} structure. \item\end{DoxyCompactList}\item
  29. void {\bf th\_\-comment\_\-add} ({\bf th\_\-comment} $\ast$\_\-tc, char $\ast$\_\-comment)
  30. \begin{DoxyCompactList}\small\item\em Add a comment to an initialized \doxyref{th\_\-comment}{p.}{structth__comment} structure. \item\end{DoxyCompactList}\item
  31. void {\bf th\_\-comment\_\-add\_\-tag} ({\bf th\_\-comment} $\ast$\_\-tc, char $\ast$\_\-tag, char $\ast$\_\-val)
  32. \begin{DoxyCompactList}\small\item\em Add a comment to an initialized \doxyref{th\_\-comment}{p.}{structth__comment} structure. \item\end{DoxyCompactList}\item
  33. char $\ast$ {\bf th\_\-comment\_\-query} ({\bf th\_\-comment} $\ast$\_\-tc, char $\ast$\_\-tag, int \_\-count)
  34. \begin{DoxyCompactList}\small\item\em Look up a comment value by its tag. \item\end{DoxyCompactList}\item
  35. int {\bf th\_\-comment\_\-query\_\-count} ({\bf th\_\-comment} $\ast$\_\-tc, char $\ast$\_\-tag)
  36. \begin{DoxyCompactList}\small\item\em Look up the number of instances of a tag. \item\end{DoxyCompactList}\item
  37. void {\bf th\_\-comment\_\-clear} ({\bf th\_\-comment} $\ast$\_\-tc)
  38. \begin{DoxyCompactList}\small\item\em Clears a \doxyref{th\_\-comment}{p.}{structth__comment} structure. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
  39. \subsection{Function Documentation}
  40. \index{basefuncs@{basefuncs}!th\_\-comment\_\-add@{th\_\-comment\_\-add}}
  41. \index{th\_\-comment\_\-add@{th\_\-comment\_\-add}!basefuncs@{basefuncs}}
  42. \subsubsection[{th\_\-comment\_\-add}]{\setlength{\rightskip}{0pt plus 5cm}void th\_\-comment\_\-add ({\bf th\_\-comment} $\ast$ {\em \_\-tc}, \/ char $\ast$ {\em \_\-comment})}\label{group__basefuncs_ga19a1f7b8032db957df151a34e5ac9272}
  43. Add a comment to an initialized \doxyref{th\_\-comment}{p.}{structth__comment} structure. \begin{DoxyNote}{Note}
  44. Neither \doxyref{th\_\-comment\_\-add()}{p.}{group__basefuncs_ga19a1f7b8032db957df151a34e5ac9272} nor \doxyref{th\_\-comment\_\-add\_\-tag()}{p.}{group__basefuncs_ga6c5edc201ca220a30787ca6c1ddcaeaf} support comments containing null values, although the bitstream format does support them. To add such comments you will need to manipulate the \doxyref{th\_\-comment}{p.}{structth__comment} structure directly.
  45. \end{DoxyNote}
  46. \begin{DoxyParams}{Parameters}
  47. \item[{\em \_\-tc}]The \doxyref{th\_\-comment}{p.}{structth__comment} struct to add the comment to. \item[{\em \_\-comment}]Must be a null-\/terminated UTF-\/8 string containing the comment in \char`\"{}TAG=the value\char`\"{} form. \end{DoxyParams}
  48. \index{basefuncs@{basefuncs}!th\_\-comment\_\-add\_\-tag@{th\_\-comment\_\-add\_\-tag}}
  49. \index{th\_\-comment\_\-add\_\-tag@{th\_\-comment\_\-add\_\-tag}!basefuncs@{basefuncs}}
  50. \subsubsection[{th\_\-comment\_\-add\_\-tag}]{\setlength{\rightskip}{0pt plus 5cm}void th\_\-comment\_\-add\_\-tag ({\bf th\_\-comment} $\ast$ {\em \_\-tc}, \/ char $\ast$ {\em \_\-tag}, \/ char $\ast$ {\em \_\-val})}\label{group__basefuncs_ga6c5edc201ca220a30787ca6c1ddcaeaf}
  51. Add a comment to an initialized \doxyref{th\_\-comment}{p.}{structth__comment} structure. \begin{DoxyNote}{Note}
  52. Neither \doxyref{th\_\-comment\_\-add()}{p.}{group__basefuncs_ga19a1f7b8032db957df151a34e5ac9272} nor \doxyref{th\_\-comment\_\-add\_\-tag()}{p.}{group__basefuncs_ga6c5edc201ca220a30787ca6c1ddcaeaf} support comments containing null values, although the bitstream format does support them. To add such comments you will need to manipulate the \doxyref{th\_\-comment}{p.}{structth__comment} structure directly.
  53. \end{DoxyNote}
  54. \begin{DoxyParams}{Parameters}
  55. \item[{\em \_\-tc}]The \doxyref{th\_\-comment}{p.}{structth__comment} struct to add the comment to. \item[{\em \_\-tag}]A null-\/terminated string containing the tag associated with the comment. \item[{\em \_\-val}]The corresponding value as a null-\/terminated string. \end{DoxyParams}
  56. \index{basefuncs@{basefuncs}!th\_\-comment\_\-clear@{th\_\-comment\_\-clear}}
  57. \index{th\_\-comment\_\-clear@{th\_\-comment\_\-clear}!basefuncs@{basefuncs}}
  58. \subsubsection[{th\_\-comment\_\-clear}]{\setlength{\rightskip}{0pt plus 5cm}void th\_\-comment\_\-clear ({\bf th\_\-comment} $\ast$ {\em \_\-tc})}\label{group__basefuncs_gae736c1afa514947a3feb223143af95e3}
  59. Clears a \doxyref{th\_\-comment}{p.}{structth__comment} structure. This should be called on a \doxyref{th\_\-comment}{p.}{structth__comment} structure after it is no longer needed. It will free all memory used by the structure members.
  60. \begin{DoxyParams}{Parameters}
  61. \item[{\em \_\-tc}]The \doxyref{th\_\-comment}{p.}{structth__comment} struct to clear. \end{DoxyParams}
  62. \index{basefuncs@{basefuncs}!th\_\-comment\_\-init@{th\_\-comment\_\-init}}
  63. \index{th\_\-comment\_\-init@{th\_\-comment\_\-init}!basefuncs@{basefuncs}}
  64. \subsubsection[{th\_\-comment\_\-init}]{\setlength{\rightskip}{0pt plus 5cm}void th\_\-comment\_\-init ({\bf th\_\-comment} $\ast$ {\em \_\-tc})}\label{group__basefuncs_ga6c8ab25988e7ea9d7b1e31a54cf58f09}
  65. Initialize a \doxyref{th\_\-comment}{p.}{structth__comment} structure. This should be called on a freshly allocated \doxyref{th\_\-comment}{p.}{structth__comment} structure before attempting to use it.
  66. \begin{DoxyParams}{Parameters}
  67. \item[{\em \_\-tc}]The \doxyref{th\_\-comment}{p.}{structth__comment} struct to initialize. \end{DoxyParams}
  68. \index{basefuncs@{basefuncs}!th\_\-comment\_\-query@{th\_\-comment\_\-query}}
  69. \index{th\_\-comment\_\-query@{th\_\-comment\_\-query}!basefuncs@{basefuncs}}
  70. \subsubsection[{th\_\-comment\_\-query}]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ th\_\-comment\_\-query ({\bf th\_\-comment} $\ast$ {\em \_\-tc}, \/ char $\ast$ {\em \_\-tag}, \/ int {\em \_\-count})}\label{group__basefuncs_ga33c8b4f57a03217636d704c2ebb211fa}
  71. Look up a comment value by its tag.
  72. \begin{DoxyParams}{Parameters}
  73. \item[{\em \_\-tc}]An initialized \doxyref{th\_\-comment}{p.}{structth__comment} structure. \item[{\em \_\-tag}]The tag to look up. \item[{\em \_\-count}]The instance of the tag. The same tag can appear multiple times, each with a distinct value, so an index is required to retrieve them all. The order in which these values appear is significant and should be preserved. Use \doxyref{th\_\-comment\_\-query\_\-count()}{p.}{group__basefuncs_ga81d518dc4426f63ceaedcbe2668679fc} to get the legal range for the {\itshape \_\-count\/} parameter. \end{DoxyParams}
  74. \begin{DoxyReturn}{Returns}
  75. A pointer to the queried tag's value. This points directly to data in the \doxyref{th\_\-comment}{p.}{structth__comment} structure. It should not be modified or freed by the application, and modifications to the structure may invalidate the pointer.
  76. \end{DoxyReturn}
  77. \begin{DoxyRetVals}{Return values}
  78. \item[{\em NULL}]If no matching tag is found. \end{DoxyRetVals}
  79. \index{basefuncs@{basefuncs}!th\_\-comment\_\-query\_\-count@{th\_\-comment\_\-query\_\-count}}
  80. \index{th\_\-comment\_\-query\_\-count@{th\_\-comment\_\-query\_\-count}!basefuncs@{basefuncs}}
  81. \subsubsection[{th\_\-comment\_\-query\_\-count}]{\setlength{\rightskip}{0pt plus 5cm}int th\_\-comment\_\-query\_\-count ({\bf th\_\-comment} $\ast$ {\em \_\-tc}, \/ char $\ast$ {\em \_\-tag})}\label{group__basefuncs_ga81d518dc4426f63ceaedcbe2668679fc}
  82. Look up the number of instances of a tag. Call this first when querying for a specific tag and then iterate over the number of instances with separate calls to \doxyref{th\_\-comment\_\-query()}{p.}{group__basefuncs_ga33c8b4f57a03217636d704c2ebb211fa} to retrieve all the values for that tag in order.
  83. \begin{DoxyParams}{Parameters}
  84. \item[{\em \_\-tc}]An initialized \doxyref{th\_\-comment}{p.}{structth__comment} structure. \item[{\em \_\-tag}]The tag to look up. \end{DoxyParams}
  85. \begin{DoxyReturn}{Returns}
  86. The number on instances of this particular tag.
  87. \end{DoxyReturn}
  88. \index{basefuncs@{basefuncs}!th\_\-granule\_\-frame@{th\_\-granule\_\-frame}}
  89. \index{th\_\-granule\_\-frame@{th\_\-granule\_\-frame}!basefuncs@{basefuncs}}
  90. \subsubsection[{th\_\-granule\_\-frame}]{\setlength{\rightskip}{0pt plus 5cm}ogg\_\-int64\_\-t th\_\-granule\_\-frame (void $\ast$ {\em \_\-encdec}, \/ ogg\_\-int64\_\-t {\em \_\-granpos})}\label{group__basefuncs_ga95b10e76fc4c05d0240ea2dfd9fd62bd}
  91. Converts a granule position to an absolute frame index, starting at {\ttfamily 0}. The granule position is interpreted in the context of a given \doxyref{th\_\-enc\_\-ctx}{p.}{theoraenc_8h_af5cc40472b925456d42526a035d66edd} or \doxyref{th\_\-dec\_\-ctx}{p.}{theoradec_8h_a843d70bb02563885a8d54b9c1a781729} handle (either will suffice).
  92. \begin{DoxyParams}{Parameters}
  93. \item[{\em \_\-encdec}]A previously allocated \doxyref{th\_\-enc\_\-ctx}{p.}{theoraenc_8h_af5cc40472b925456d42526a035d66edd} or \doxyref{th\_\-dec\_\-ctx}{p.}{theoradec_8h_a843d70bb02563885a8d54b9c1a781729} handle. \item[{\em \_\-granpos}]The granule position to convert. \end{DoxyParams}
  94. \begin{DoxyReturn}{Returns}
  95. The absolute frame index corresponding to {\itshape \_\-granpos\/}.
  96. \end{DoxyReturn}
  97. \begin{DoxyRetVals}{Return values}
  98. \item[{\em -\/1}]The given granule position was invalid (i.e. negative). \end{DoxyRetVals}
  99. \index{basefuncs@{basefuncs}!th\_\-granule\_\-time@{th\_\-granule\_\-time}}
  100. \index{th\_\-granule\_\-time@{th\_\-granule\_\-time}!basefuncs@{basefuncs}}
  101. \subsubsection[{th\_\-granule\_\-time}]{\setlength{\rightskip}{0pt plus 5cm}double th\_\-granule\_\-time (void $\ast$ {\em \_\-encdec}, \/ ogg\_\-int64\_\-t {\em \_\-granpos})}\label{group__basefuncs_ga707e1e281de788af0df39ef00f3fb432}
  102. Converts a granule position to an absolute time in seconds. The granule position is interpreted in the context of a given \doxyref{th\_\-enc\_\-ctx}{p.}{theoraenc_8h_af5cc40472b925456d42526a035d66edd} or \doxyref{th\_\-dec\_\-ctx}{p.}{theoradec_8h_a843d70bb02563885a8d54b9c1a781729} handle (either will suffice).
  103. \begin{DoxyParams}{Parameters}
  104. \item[{\em \_\-encdec}]A previously allocated \doxyref{th\_\-enc\_\-ctx}{p.}{theoraenc_8h_af5cc40472b925456d42526a035d66edd} or \doxyref{th\_\-dec\_\-ctx}{p.}{theoradec_8h_a843d70bb02563885a8d54b9c1a781729} handle. \item[{\em \_\-granpos}]The granule position to convert. \end{DoxyParams}
  105. \begin{DoxyReturn}{Returns}
  106. The absolute time in seconds corresponding to {\itshape \_\-granpos\/}. This is the \char`\"{}end time\char`\"{} for the frame, or the latest time it should be displayed. It is not the presentation time.
  107. \end{DoxyReturn}
  108. \begin{DoxyRetVals}{Return values}
  109. \item[{\em -\/1}]The given granule position was invalid (i.e. negative). \end{DoxyRetVals}
  110. \index{basefuncs@{basefuncs}!th\_\-info\_\-clear@{th\_\-info\_\-clear}}
  111. \index{th\_\-info\_\-clear@{th\_\-info\_\-clear}!basefuncs@{basefuncs}}
  112. \subsubsection[{th\_\-info\_\-clear}]{\setlength{\rightskip}{0pt plus 5cm}void th\_\-info\_\-clear ({\bf th\_\-info} $\ast$ {\em \_\-info})}\label{group__basefuncs_gab3d6441ab4a4969859ef5fd78a9e3c1c}
  113. Clears a \doxyref{th\_\-info}{p.}{structth__info} structure. This should be called on a \doxyref{th\_\-info}{p.}{structth__info} structure after it is no longer needed.
  114. \begin{DoxyParams}{Parameters}
  115. \item[{\em \_\-info}]The \doxyref{th\_\-info}{p.}{structth__info} struct to clear. \end{DoxyParams}
  116. \index{basefuncs@{basefuncs}!th\_\-info\_\-init@{th\_\-info\_\-init}}
  117. \index{th\_\-info\_\-init@{th\_\-info\_\-init}!basefuncs@{basefuncs}}
  118. \subsubsection[{th\_\-info\_\-init}]{\setlength{\rightskip}{0pt plus 5cm}void th\_\-info\_\-init ({\bf th\_\-info} $\ast$ {\em \_\-info})}\label{group__basefuncs_ga430d9c605816a6ca0bdce3a0b965b926}
  119. Initializes a \doxyref{th\_\-info}{p.}{structth__info} structure. This should be called on a freshly allocated \doxyref{th\_\-info}{p.}{structth__info} structure before attempting to use it.
  120. \begin{DoxyParams}{Parameters}
  121. \item[{\em \_\-info}]The \doxyref{th\_\-info}{p.}{structth__info} struct to initialize. \end{DoxyParams}
  122. \index{basefuncs@{basefuncs}!th\_\-packet\_\-isheader@{th\_\-packet\_\-isheader}}
  123. \index{th\_\-packet\_\-isheader@{th\_\-packet\_\-isheader}!basefuncs@{basefuncs}}
  124. \subsubsection[{th\_\-packet\_\-isheader}]{\setlength{\rightskip}{0pt plus 5cm}int th\_\-packet\_\-isheader (ogg\_\-packet $\ast$ {\em \_\-op})}\label{group__basefuncs_ga02f3f38261a9b39452d8a5e6f8737cc1}
  125. Determines whether a Theora packet is a header or not. This function does no verification beyond checking the packet type bit, so it should not be used for bitstream identification; use \doxyref{th\_\-decode\_\-headerin()}{p.}{group__decfuncs_ga006d01d36fbe64768c571e6a12b7fc50} for that. As per the Theora specification, an empty (0-\/byte) packet is treated as a data packet (a delta frame with no coded blocks).
  126. \begin{DoxyParams}{Parameters}
  127. \item[{\em \_\-op}]An {\ttfamily ogg\_\-packet} containing encoded Theora data. \end{DoxyParams}
  128. \begin{DoxyRetVals}{Return values}
  129. \item[{\em 1}]The packet is a header packet \item[{\em 0}]The packet is a video data packet. \end{DoxyRetVals}
  130. \index{basefuncs@{basefuncs}!th\_\-packet\_\-iskeyframe@{th\_\-packet\_\-iskeyframe}}
  131. \index{th\_\-packet\_\-iskeyframe@{th\_\-packet\_\-iskeyframe}!basefuncs@{basefuncs}}
  132. \subsubsection[{th\_\-packet\_\-iskeyframe}]{\setlength{\rightskip}{0pt plus 5cm}int th\_\-packet\_\-iskeyframe (ogg\_\-packet $\ast$ {\em \_\-op})}\label{group__basefuncs_gafe95cfd06f0fef413266c9168a66248a}
  133. Determines whether a theora packet is a key frame or not. This function does no verification beyond checking the packet type and key frame bits, so it should not be used for bitstream identification; use \doxyref{th\_\-decode\_\-headerin()}{p.}{group__decfuncs_ga006d01d36fbe64768c571e6a12b7fc50} for that. As per the Theora specification, an empty (0-\/byte) packet is treated as a delta frame (with no coded blocks).
  134. \begin{DoxyParams}{Parameters}
  135. \item[{\em \_\-op}]An {\ttfamily ogg\_\-packet} containing encoded Theora data. \end{DoxyParams}
  136. \begin{DoxyRetVals}{Return values}
  137. \item[{\em 1}]The packet contains a key frame. \item[{\em 0}]The packet contains a delta frame. \item[{\em -\/1}]The packet is not a video data packet. \end{DoxyRetVals}
  138. \index{basefuncs@{basefuncs}!th\_\-version\_\-number@{th\_\-version\_\-number}}
  139. \index{th\_\-version\_\-number@{th\_\-version\_\-number}!basefuncs@{basefuncs}}
  140. \subsubsection[{th\_\-version\_\-number}]{\setlength{\rightskip}{0pt plus 5cm}ogg\_\-uint32\_\-t th\_\-version\_\-number (void)}\label{group__basefuncs_gab723a75c0f95b3eb817f7f769846016b}
  141. Retrieves the library version number. This is the highest bitstream version that the encoder library will produce, or that the decoder library can decode. This number is composed of a 16-\/bit major version, 8-\/bit minor version and 8 bit sub-\/version, composed as follows:
  142. \begin{DoxyCode}
  143. (VERSION_MAJOR<<16)+(VERSION_MINOR<<8)+(VERSION_SUBMINOR)
  144. \end{DoxyCode}
  145. \begin{DoxyReturn}{Returns}
  146. the version number.
  147. \end{DoxyReturn}
  148. \index{basefuncs@{basefuncs}!th\_\-version\_\-string@{th\_\-version\_\-string}}
  149. \index{th\_\-version\_\-string@{th\_\-version\_\-string}!basefuncs@{basefuncs}}
  150. \subsubsection[{th\_\-version\_\-string}]{\setlength{\rightskip}{0pt plus 5cm}const char$\ast$ th\_\-version\_\-string (void)}\label{group__basefuncs_ga04846066738d9f2024fc9961162b2dbc}
  151. Retrieves a human-\/readable string to identify the library vendor and version. \begin{DoxyReturn}{Returns}
  152. the version string.
  153. \end{DoxyReturn}