libtheora 1.2.0alpha1+git
codec.h
Go to the documentation of this file.
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 * *
11 ********************************************************************
12
13 function:
14 last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
15
16 ********************************************************************/
17
60
64
65#if !defined(_O_THEORA_CODEC_H_)
66# define _O_THEORA_CODEC_H_ (1)
67# include <ogg/ogg.h>
68
69#if defined(__cplusplus)
70extern "C" {
71#endif
72
73
74
78#define TH_EFAULT (-1)
80#define TH_EINVAL (-10)
82#define TH_EBADHEADER (-20)
84#define TH_ENOTFORMAT (-21)
86#define TH_EVERSION (-22)
88#define TH_EIMPL (-23)
90#define TH_EBADPACKET (-24)
94#define TH_DUPFRAME (1)
96
112
134
135
136
145typedef struct{
147 int width;
153 unsigned char *data;
155
172
207typedef struct{
211 unsigned char version_major;
212 unsigned char version_minor;
213 unsigned char version_subminor;
217 ogg_uint32_t frame_width;
220 ogg_uint32_t frame_height;
223 ogg_uint32_t pic_width;
226 ogg_uint32_t pic_height;
230 ogg_uint32_t pic_x;
238 ogg_uint32_t pic_y;
243 ogg_uint32_t fps_numerator;
244 ogg_uint32_t fps_denominator;
255 ogg_uint32_t aspect_numerator;
256 ogg_uint32_t aspect_denominator;
271 /*Currently this is set so that a qi of 0 corresponds to distortions of 24
272 times the JND, and each increase by 16 halves that value.
273 This gives us fine discrimination at low qualities, yet effective rate
274 control at high qualities.
275 The qi value 63 is special, however.
276 For this, the highest quality, we use one half of a JND for our threshold.
277 Due to the lower bounds placed on allowable quantizers in Theora, we will
278 not actually be able to achieve quality this good, but this should
279 provide as close to visually lossless quality as Theora is capable of.
280 We could lift the quantizer restrictions without breaking VP3.1
281 compatibility, but this would result in quantized coefficients that are
282 too large for the current bitstream to be able to store.
283 We'd have to redesign the token syntax to store these large coefficients,
284 which would make transcoding complex.*/
300}th_info;
301
337
338
339
341typedef unsigned char th_quant_base[64];
342
344typedef struct{
349 const int *sizes;
354
412typedef struct{
414 ogg_uint16_t dc_scale[64];
416 ogg_uint16_t ac_scale[64];
418 unsigned char loop_filter_limits[64];
422
423
424
426#define TH_NHUFFMAN_TABLES (80)
428#define TH_NDCT_TOKENS (32)
429
441typedef struct{
444 ogg_uint32_t pattern;
447 int nbits;
449
450
451
465extern const char *th_version_string(void);
475extern ogg_uint32_t th_version_number(void);
485extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
497extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
507extern int th_packet_isheader(ogg_packet *_op);
518extern int th_packet_iskeyframe(ogg_packet *_op);
520
521
533extern void th_info_init(th_info *_info);
538extern void th_info_clear(th_info *_info);
539
544extern void th_comment_init(th_comment *_tc);
554extern void th_comment_add(th_comment *_tc,const char *_comment);
565extern void th_comment_add_tag(th_comment *_tc,const char *_tag,
566 const char *_val);
582extern char *th_comment_query(th_comment *_tc,const char *_tag,int _count);
590extern int th_comment_query_count(th_comment *_tc,const char *_tag);
596extern void th_comment_clear(th_comment *_tc);
599
600
601
602#if defined(__cplusplus)
603}
604#endif
605
606#endif
int th_packet_isheader(ogg_packet *_op)
Determines whether a Theora packet is a header or not.
th_img_plane th_ycbcr_buffer[3]
A complete image buffer for an uncompressed frame.
Definition codec.h:171
void th_info_init(th_info *_info)
Initializes a th_info structure.
th_colorspace
The currently defined color space tags.
Definition codec.h:101
@ TH_CS_ITU_REC_470BG
A color space designed for PAL/SECAM content.
Definition codec.h:108
@ TH_CS_NSPACES
The total number of currently defined color spaces.
Definition codec.h:110
@ TH_CS_ITU_REC_470M
A color space designed for NTSC content.
Definition codec.h:106
@ TH_CS_UNSPECIFIED
The color space was not specified at the encoder.
Definition codec.h:104
const char * th_version_string(void)
Retrieves a human-readable string to identify the library vendor and version.
th_pixel_fmt
The currently defined pixel format tags.
Definition codec.h:117
@ TH_PF_422
Chroma decimation by 2 in the X direction (4:2:2).
Definition codec.h:127
@ TH_PF_444
No chroma decimation (4:4:4).
Definition codec.h:130
@ TH_PF_NFORMATS
The total number of currently defined pixel formats.
Definition codec.h:132
@ TH_PF_RSVD
Currently reserved.
Definition codec.h:123
@ TH_PF_420
Chroma decimation by 2 in both the X and Y directions (4:2:0).
Definition codec.h:121
unsigned char th_quant_base[64]
A single base matrix.
Definition codec.h:341
void th_comment_add(th_comment *_tc, const char *_comment)
Add a comment to an initialized th_comment structure.
void th_comment_init(th_comment *_tc)
Initialize a th_comment structure.
double th_granule_time(void *_encdec, ogg_int64_t _granpos)
Converts a granule position to an absolute time in seconds.
ogg_int64_t th_granule_frame(void *_encdec, ogg_int64_t _granpos)
Converts a granule position to an absolute frame index, starting at 0.
char * th_comment_query(th_comment *_tc, const char *_tag, int _count)
Look up a comment value by its tag.
int th_comment_query_count(th_comment *_tc, const char *_tag)
Look up the number of instances of a tag.
void th_info_clear(th_info *_info)
Clears a th_info structure.
ogg_uint32_t th_version_number(void)
Retrieves the library version number.
void th_comment_add_tag(th_comment *_tc, const char *_tag, const char *_val)
Add a comment to an initialized th_comment structure.
void th_comment_clear(th_comment *_tc)
Clears a th_comment structure.
int th_packet_iskeyframe(ogg_packet *_op)
Determines whether a theora packet is a key frame or not.
The comment information.
Definition codec.h:326
int comments
The total number of comment strings.
Definition codec.h:332
int * comment_lengths
An array of the corresponding length of each vector, in bytes.
Definition codec.h:330
char * vendor
The null-terminated vendor string.
Definition codec.h:335
char ** user_comments
The array of comment string vectors.
Definition codec.h:328
A Huffman code for a Theora DCT token.
Definition codec.h:441
ogg_uint32_t pattern
The bit pattern for the code, with the LSbit of the pattern aligned in the LSbit of the word.
Definition codec.h:444
int nbits
The number of bits in the code.
Definition codec.h:447
A buffer for a single color plane in an uncompressed image.
Definition codec.h:145
int height
The height of this plane.
Definition codec.h:149
int width
The width of this plane.
Definition codec.h:147
int stride
The offset in bytes between successive rows.
Definition codec.h:151
unsigned char * data
A pointer to the beginning of the first row.
Definition codec.h:153
Theora bitstream information.
Definition codec.h:207
ogg_uint32_t aspect_denominator
Definition codec.h:256
int target_bitrate
The target bit-rate in bits per second.
Definition codec.h:265
ogg_uint32_t fps_numerator
Definition codec.h:243
th_pixel_fmt pixel_fmt
The pixel format.
Definition codec.h:261
ogg_uint32_t pic_width
The displayed picture width.
Definition codec.h:223
ogg_uint32_t pic_x
The X offset of the displayed picture.
Definition codec.h:230
ogg_uint32_t aspect_numerator
Definition codec.h:255
unsigned char version_major
Definition codec.h:211
int keyframe_granule_shift
The amount to shift to extract the last keyframe number from the granule position.
Definition codec.h:299
ogg_uint32_t frame_height
The encoded frame height.
Definition codec.h:220
ogg_uint32_t frame_width
The encoded frame width.
Definition codec.h:217
ogg_uint32_t pic_height
The displayed picture height.
Definition codec.h:226
ogg_uint32_t pic_y
The Y offset of the displayed picture.
Definition codec.h:238
th_colorspace colorspace
The color space.
Definition codec.h:259
int quality
The target quality level.
Definition codec.h:285
ogg_uint32_t fps_denominator
Definition codec.h:244
unsigned char version_minor
Definition codec.h:212
unsigned char version_subminor
Definition codec.h:213
A complete set of quantization parameters.
Definition codec.h:412
ogg_uint16_t ac_scale[64]
The AC scaling factors.
Definition codec.h:416
unsigned char loop_filter_limits[64]
The loop filter limit values.
Definition codec.h:418
th_quant_ranges qi_ranges[2][3]
The qi ranges for each ci and pli.
Definition codec.h:420
ogg_uint16_t dc_scale[64]
The DC scaling factors.
Definition codec.h:414
A set of qi ranges.
Definition codec.h:344
const th_quant_base * base_matrices
nranges +1 base matrices.
Definition codec.h:352
int nranges
The number of ranges in the set.
Definition codec.h:346
const int * sizes
The size of each of the nranges ranges.
Definition codec.h:349