Functions for decoding |
You must link to libtheoradec if you use any of the functions in this section.
The functions are listed in the order they are used in a typical decode. The basic steps are:
|
int | th_decode_headerin (th_info *_info, th_comment *_tc, th_setup_info **_setup, ogg_packet *_op) |
| Decodes the header packets of a Theora stream.
|
th_dec_ctx * | th_decode_alloc (const th_info *_info, const th_setup_info *_setup) |
| Allocates a decoder instance.
|
void | th_setup_free (th_setup_info *_setup) |
| Releases all storage used for the decoder setup information.
|
int | th_decode_ctl (th_dec_ctx *_dec, int _req, void *_buf, size_t _buf_sz) |
| Decoder control function.
|
int | th_decode_packetin (th_dec_ctx *_dec, const ogg_packet *_op, ogg_int64_t *_granpos) |
| Submits a packet containing encoded video data to the decoder.
|
int | th_decode_ycbcr_out (th_dec_ctx *_dec, th_ycbcr_buffer _ycbcr) |
| Outputs the next available frame of decoded Y'CbCr data.
|
void | th_decode_free (th_dec_ctx *_dec) |
| Frees an allocated decoder instance.
|
Allocates a decoder instance.
Security Warning: The Theora format supports very large frame sizes, potentially even larger than the address space of a 32-bit machine, and creating a decoder context allocates the space for several frames of data. If the allocation fails here, your program will crash, possibly at some future point because the OS kernel returned a valid memory range and will only fail when it tries to map the pages in it the first time they are used. Even if it succeeds, you may experience a denial of service if the frame size is large enough to cause excessive paging. If you are integrating libtheora in a larger application where such things are undesirable, it is highly recommended that you check the frame size in _info before calling this function and refuse to decode streams where it is larger than some reasonable maximum. libtheora will not check this for you, because there may be machines that can handle such streams and applications that wish to.
- Parameters:
-
- Returns:
- The initialized th_dec_ctx handle.
- Return values:
-
| NULL | If the decoding parameters were invalid. |
Decodes the header packets of a Theora stream.
This should be called on the initial packets of the stream, in succession, until it returns 0
, indicating that all headers have been processed, or an error is encountered. At least three header packets are required, and additional optional header packets may follow. This can be used on the first packet of any logical stream to determine if that stream is a Theora stream.
- Parameters:
-
| _info | A th_info structure to fill in. This must have been previously initialized with th_info_init(). The application may immediately begin using the contents of this structure after the first header is decoded, though it must continue to be passed in on all subsequent calls. |
| _tc | A th_comment structure to fill in. The application may immediately begin using the contents of this structure after the second header is decoded, though it must continue to be passed in on all subsequent calls. |
| _setup | Returns a pointer to additional, private setup information needed by the decoder. The contents of this pointer must be initialized to NULL on the first call, and the returned value must continue to be passed in on all subsequent calls. |
| _op | An ogg_packet structure which contains one of the initial packets of an Ogg logical stream. |
- Returns:
- A positive value indicates that a Theora header was successfully processed.
- Return values:
-
| 0 | The first video data packet was encountered after all required header packets were parsed. The packet just passed in on this call should be saved and fed to th_decode_packetin() to begin decoding video data. |
| TH_EFAULT | One of _info, _tc, or _setup was NULL . |
| TH_EBADHEADER | _op was NULL , the packet was not the next header packet in the expected sequence, or the format of the header data was invalid. |
| TH_EVERSION | The packet data was a Theora info header, but for a bitstream version not decodable with this version of libtheoradec . |
| TH_ENOTFORMAT | The packet was not a Theora header. |