libtheora  1.1.1
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 
62 #if !defined(_O_THEORA_CODEC_H_)
63 # define _O_THEORA_CODEC_H_ (1)
64 # include <ogg/ogg.h>
65 
66 #if defined(__cplusplus)
67 extern "C" {
68 #endif
69 
70 
71 
75 #define TH_EFAULT (-1)
76 
77 #define TH_EINVAL (-10)
78 
79 #define TH_EBADHEADER (-20)
80 
81 #define TH_ENOTFORMAT (-21)
82 
83 #define TH_EVERSION (-22)
84 
85 #define TH_EIMPL (-23)
86 
87 #define TH_EBADPACKET (-24)
88 
91 #define TH_DUPFRAME (1)
92 
98 typedef enum{
109 
114 typedef enum{
130 }th_pixel_fmt;
131 
132 
133 
142 typedef struct{
144  int width;
146  int height;
148  int stride;
150  unsigned char *data;
151 }th_img_plane;
152 
169 
204 typedef struct{
208  unsigned char version_major;
209  unsigned char version_minor;
210  unsigned char version_subminor;
214  ogg_uint32_t frame_width;
217  ogg_uint32_t frame_height;
220  ogg_uint32_t pic_width;
223  ogg_uint32_t pic_height;
227  ogg_uint32_t pic_x;
235  ogg_uint32_t pic_y;
240  ogg_uint32_t fps_numerator;
241  ogg_uint32_t fps_denominator;
252  ogg_uint32_t aspect_numerator;
253  ogg_uint32_t aspect_denominator;
268  /*Currently this is set so that a qi of 0 corresponds to distortions of 24
269  times the JND, and each increase by 16 halves that value.
270  This gives us fine discrimination at low qualities, yet effective rate
271  control at high qualities.
272  The qi value 63 is special, however.
273  For this, the highest quality, we use one half of a JND for our threshold.
274  Due to the lower bounds placed on allowable quantizers in Theora, we will
275  not actually be able to achieve quality this good, but this should
276  provide as close to visually lossless quality as Theora is capable of.
277  We could lift the quantizer restrictions without breaking VP3.1
278  compatibility, but this would result in quantized coefficients that are
279  too large for the current bitstream to be able to store.
280  We'd have to redesign the token syntax to store these large coefficients,
281  which would make transcoding complex.*/
282  int quality;
297 }th_info;
298 
323 typedef struct th_comment{
329  int comments;
332  char *vendor;
333 }th_comment;
334 
335 
336 
338 typedef unsigned char th_quant_base[64];
339 
341 typedef struct{
343  int nranges;
346  const int *sizes;
349  const th_quant_base *base_matrices;
351 
409 typedef struct{
411  ogg_uint16_t dc_scale[64];
413  ogg_uint16_t ac_scale[64];
415  unsigned char loop_filter_limits[64];
417  th_quant_ranges qi_ranges[2][3];
419 
420 
421 
423 #define TH_NHUFFMAN_TABLES (80)
424 
425 #define TH_NDCT_TOKENS (32)
426 
438 typedef struct{
441  ogg_uint32_t pattern;
444  int nbits;
445 }th_huff_code;
446 
447 
448 
456 extern const char *th_version_string(void);
466 extern ogg_uint32_t th_version_number(void);
476 extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
488 extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
498 extern int th_packet_isheader(ogg_packet *_op);
509 extern int th_packet_iskeyframe(ogg_packet *_op);
519 extern void th_info_init(th_info *_info);
524 extern void th_info_clear(th_info *_info);
525 
530 extern void th_comment_init(th_comment *_tc);
540 extern void th_comment_add(th_comment *_tc, char *_comment);
551 extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
567 extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
575 extern int th_comment_query_count(th_comment *_tc,char *_tag);
581 extern void th_comment_clear(th_comment *_tc);
584 
585 
586 
587 #if defined(__cplusplus)
588 }
589 #endif
590 
591 #endif