codec.h

Go to the documentation of this file.
00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
00004  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
00005  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
00006  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
00007  *                                                                  *
00008  * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
00009  * by the Xiph.Org Foundation http://www.xiph.org/                  *
00010  *                                                                  *
00011  ********************************************************************
00012 
00013   function:
00014   last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
00015 
00016  ********************************************************************/
00017 
00062 #if !defined(_O_THEORA_CODEC_H_)
00063 # define _O_THEORA_CODEC_H_ (1)
00064 # include <ogg/ogg.h>
00065 
00066 #if defined(__cplusplus)
00067 extern "C" {
00068 #endif
00069 
00070 
00071 
00075 #define TH_EFAULT     (-1)
00076 
00077 #define TH_EINVAL     (-10)
00078 
00079 #define TH_EBADHEADER (-20)
00080 
00081 #define TH_ENOTFORMAT (-21)
00082 
00083 #define TH_EVERSION   (-22)
00084 
00085 #define TH_EIMPL      (-23)
00086 
00087 #define TH_EBADPACKET (-24)
00088 
00091 #define TH_DUPFRAME   (1)
00092 
00098 typedef enum{
00101   TH_CS_UNSPECIFIED,
00103   TH_CS_ITU_REC_470M,
00105   TH_CS_ITU_REC_470BG,
00107   TH_CS_NSPACES
00108 }th_colorspace;
00109 
00114 typedef enum{
00116   TH_PF_420,
00118   TH_PF_RSVD,
00120   TH_PF_422,
00122   TH_PF_444,
00124   TH_PF_NFORMATS
00125 }th_pixel_fmt;
00126 
00127 
00128 
00137 typedef struct{
00139   int            width;
00141   int            height;
00143   int            stride;
00145   unsigned char *data;
00146 }th_img_plane;
00147 
00163 typedef th_img_plane th_ycbcr_buffer[3];
00164 
00199 typedef struct{
00203   unsigned char version_major;
00204   unsigned char version_minor;
00205   unsigned char version_subminor;
00209   ogg_uint32_t  frame_width;
00212   ogg_uint32_t  frame_height;
00215   ogg_uint32_t  pic_width;
00218   ogg_uint32_t  pic_height;
00222   ogg_uint32_t  pic_x;
00230   ogg_uint32_t  pic_y;
00235   ogg_uint32_t  fps_numerator;
00236   ogg_uint32_t  fps_denominator;
00247   ogg_uint32_t  aspect_numerator;
00248   ogg_uint32_t  aspect_denominator;
00251   th_colorspace colorspace;
00253   th_pixel_fmt  pixel_fmt;
00257   /*TODO: Current encoder does not support CBR mode, or anything like it.
00258     We also don't really know what nominal rate each quality level
00259      corresponds to yet.*/
00260   int           target_bitrate;
00266   /*Currently this is set so that a qi of 0 corresponds to distortions of 24
00267      times the JND, and each increase by 16 halves that value.
00268     This gives us fine discrimination at low qualities, yet effective rate
00269      control at high qualities.
00270     The qi value 63 is special, however.
00271     For this, the highest quality, we use one half of a JND for our threshold.
00272     Due to the lower bounds placed on allowable quantizers in Theora, we will
00273      not actually be able to achieve quality this good, but this should
00274      provide as close to visually lossless quality as Theora is capable of.
00275     We could lift the quantizer restrictions without breaking VP3.1
00276      compatibility, but this would result in quantized coefficients that are
00277      too large for the current bitstream to be able to store.
00278     We'd have to redesign the token syntax to store these large coefficients,
00279      which would make transcoding complex.*/
00280   int           quality;
00294   int           keyframe_granule_shift;
00295 }th_info;
00296 
00321 typedef struct th_comment{
00323   char **user_comments;
00325   int   *comment_lengths;
00327   int    comments;
00330   char  *vendor;
00331 }th_comment;
00332 
00333 
00334 
00336 typedef unsigned char th_quant_base[64];
00337 
00339 typedef struct{
00341   int                  nranges;
00344   const int           *sizes;
00347   const th_quant_base *base_matrices;
00348 }th_quant_ranges;
00349 
00407 typedef struct{
00409   ogg_uint16_t    dc_scale[64];
00411   ogg_uint16_t    ac_scale[64];
00413   unsigned char   loop_filter_limits[64];
00415   th_quant_ranges qi_ranges[2][3];
00416 }th_quant_info;
00417 
00418 
00419 
00421 #define TH_NHUFFMAN_TABLES (80)
00422 
00423 #define TH_NDCT_TOKENS     (32)
00424 
00436 typedef struct{
00439   ogg_uint32_t pattern;
00442   int          nbits;
00443 }th_huff_code;
00444 
00445 
00446 
00454 extern const char *th_version_string(void);
00464 extern ogg_uint32_t th_version_number(void);
00474 extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
00486 extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
00496 extern int th_packet_isheader(ogg_packet *_op);
00507 extern int th_packet_iskeyframe(ogg_packet *_op);
00517 extern void th_info_init(th_info *_info);
00522 extern void th_info_clear(th_info *_info);
00523 
00528 extern void th_comment_init(th_comment *_tc);
00538 extern void th_comment_add(th_comment *_tc, char *_comment);
00549 extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
00565 extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
00573 extern int th_comment_query_count(th_comment *_tc,char *_tag);
00579 extern void th_comment_clear(th_comment *_tc);
00582 
00583 
00584 
00585 #if defined(__cplusplus)
00586 }
00587 #endif
00588 
00589 #endif

Generated on Wed Apr 16 13:30:39 2008 for libtheora by  doxygen 1.5.3