theoradec.h File Reference

The libtheoradec C decoding API. More...

#include <stddef.h>
#include <ogg/ogg.h>
#include "codec.h"

Go to the source code of this file.

Data Structures

struct  th_stripe_callback
 The striped decode callback data to pass to TH_DECCTL_SET_STRIPE_CB. More...

Defines

#define _O_THEORA_THEORADEC_H_   (1)
th_decode_ctl() codes

These are the available request codes for th_decode_ctl(). By convention, these are odd, to distinguish them from the encoder control codes. Keep any experimental or vendor-specific values above 0x8000.



#define TH_DECCTL_GET_PPLEVEL_MAX   (1)
 Gets the maximum post-processing level.
#define TH_DECCTL_SET_PPLEVEL   (3)
 Sets the post-processing level.
#define TH_DECCTL_SET_GRANPOS   (5)
 Sets the granule position.
#define TH_DECCTL_SET_STRIPE_CB   (7)
 Sets the striped decode callback function.
#define TH_DECCTL_SET_TELEMETRY_MBMODE   (9)
 Enables telemetry and sets the macroblock display mode.
#define TH_DECCTL_SET_TELEMETRY_MV   (11)
 Enables telemetry and sets the motion vector display mode.
#define TH_DECCTL_SET_TELEMETRY_QI   (13)
 Enables telemetry and sets the adaptive quantization display mode.
#define TH_DECCTL_SET_TELEMETRY_BITS   (15)
 Enables telemetry and sets the bitstream breakdown visualization mode.

Typedefs

typedef void(* th_stripe_decoded_func )(void *_ctx, th_ycbcr_buffer _buf, int _yfrag0, int _yfrag_end)
 A callback function for striped decode.
Decoder state

The following data structures are opaque, and their contents are not publicly defined by this API.

Referring to their internals directly is unsupported, and may break without warning.



typedef struct th_dec_ctx th_dec_ctx
 The decoder context.
typedef struct th_setup_info th_setup_info
 Setup information.

Functions

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_ctxth_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.

Detailed Description

The libtheoradec C decoding API.


Define Documentation

#define _O_THEORA_THEORADEC_H_   (1)
#define TH_DECCTL_GET_PPLEVEL_MAX   (1)

Gets the maximum post-processing level.

The decoder supports a post-processing filter that can improve the appearance of the decoded images. This returns the highest level setting for this post-processor, corresponding to maximum improvement and computational expense.

Parameters:
[out] _buf int: The maximum post-processing level.
Return values:
TH_EFAULT _dec_ctx or _buf is NULL.
TH_EINVAL _buf_sz is not sizeof(int).
TH_EIMPL Not supported by this implementation.
#define TH_DECCTL_SET_GRANPOS   (5)

Sets the granule position.

Call this after a seek, before decoding the first frame, to ensure that the proper granule position is returned for all subsequent frames. If you track timestamps yourself and do not use the granule position returned by the decoder, then you need not call this function.

Parameters:
[in] _buf ogg_int64_t: The granule position of the next frame.
Return values:
TH_EFAULT _dec_ctx or _buf is NULL.
TH_EINVAL _buf_sz is not sizeof(ogg_int64_t), or the granule position is negative.
#define TH_DECCTL_SET_PPLEVEL   (3)

Sets the post-processing level.

By default, post-processing is disabled.

Sets the level of post-processing to use when decoding the compressed stream. This must be a value between zero (off) and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX.

Parameters:
[in] _buf int: The new post-processing level. 0 to disable; larger values use more CPU.
Return values:
TH_EFAULT _dec_ctx or _buf is NULL.
TH_EINVAL _buf_sz is not sizeof(int), or the post-processing level is out of bounds. The maximum post-processing level may be implementation-specific, and can be obtained via TH_DECCTL_GET_PPLEVEL_MAX.
TH_EIMPL Not supported by this implementation.
#define TH_DECCTL_SET_STRIPE_CB   (7)

Sets the striped decode callback function.

If set, this function will be called as each piece of a frame is fully decoded in th_decode_packetin(). You can pass in a th_stripe_callback with th_stripe_callback::stripe_decoded set to NULL to disable the callbacks at any point. Enabling striped decode does not prevent you from calling th_decode_ycbcr_out() after the frame is fully decoded.

Parameters:
[in] _buf th_stripe_callback: The callback parameters.
Return values:
TH_EFAULT _dec_ctx or _buf is NULL.
TH_EINVAL _buf_sz is not sizeof(th_stripe_callback).
#define TH_DECCTL_SET_TELEMETRY_BITS   (15)

Enables telemetry and sets the bitstream breakdown visualization mode.

#define TH_DECCTL_SET_TELEMETRY_MBMODE   (9)

Enables telemetry and sets the macroblock display mode.

#define TH_DECCTL_SET_TELEMETRY_MV   (11)

Enables telemetry and sets the motion vector display mode.

#define TH_DECCTL_SET_TELEMETRY_QI   (13)

Enables telemetry and sets the adaptive quantization display mode.


Typedef Documentation

typedef struct th_dec_ctx th_dec_ctx

The decoder context.

typedef struct th_setup_info th_setup_info

Setup information.

This contains auxiliary information (Huffman tables and quantization parameters) decoded from the setup header by th_decode_headerin() to be passed to th_decode_alloc(). It can be re-used to initialize any number of decoders, and can be freed via th_setup_free() at any time.

typedef void(* th_stripe_decoded_func)(void *_ctx, th_ycbcr_buffer _buf, int _yfrag0, int _yfrag_end)

A callback function for striped decode.

This is a function pointer to an application-provided function that will be called each time a section of the image is fully decoded in th_decode_packetin(). This allows the application to process the section immediately, while it is still in cache. Note that the frame is decoded bottom to top, so _yfrag0 will steadily decrease with each call until it reaches 0, at which point the full frame is decoded. The number of fragment rows made available in each call depends on the pixel format and the number of post-processing filters enabled, and may not even be constant for the entire frame. If a non-NULL _granpos pointer is passed to th_decode_packetin(), the granule position for the frame will be stored in it before the first callback is made. If an entire frame is dropped (a 0-byte packet), then no callbacks will be made at all for that frame.

Parameters:
_ctx An application-provided context pointer.
_buf The image buffer for the decoded frame.
_yfrag0 The Y coordinate of the first row of 8x8 fragments decoded. Multiply this by 8 to obtain the pixel row number in the luma plane. If the chroma planes are subsampled in the Y direction, this will always be divisible by two.
_yfrag_end The Y coordinate of the first row of 8x8 fragments past the newly decoded section. If the chroma planes are subsampled in the Y direction, this will always be divisible by two. I.e., this section contains fragment rows _yfrag0 ..._yfrag_end -1.

Generated on 24 Sep 2009 for libtheora by  doxygen 1.6.1