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{
00118   TH_PF_420,
00120   TH_PF_RSVD,
00124   TH_PF_422,
00127   TH_PF_444,
00129   TH_PF_NFORMATS
00130 }th_pixel_fmt;
00131 
00132 
00133 
00142 typedef struct{
00144   int            width;
00146   int            height;
00148   int            stride;
00150   unsigned char *data;
00151 }th_img_plane;
00152 
00168 typedef th_img_plane th_ycbcr_buffer[3];
00169 
00204 typedef struct{
00208   unsigned char version_major;
00209   unsigned char version_minor;
00210   unsigned char version_subminor;
00214   ogg_uint32_t  frame_width;
00217   ogg_uint32_t  frame_height;
00220   ogg_uint32_t  pic_width;
00223   ogg_uint32_t  pic_height;
00227   ogg_uint32_t  pic_x;
00235   ogg_uint32_t  pic_y;
00240   ogg_uint32_t  fps_numerator;
00241   ogg_uint32_t  fps_denominator;
00252   ogg_uint32_t  aspect_numerator;
00253   ogg_uint32_t  aspect_denominator;
00256   th_colorspace colorspace;
00258   th_pixel_fmt  pixel_fmt;
00262   /*TODO: Current encoder does not support CBR mode, or anything like it.
00263     We also don't really know what nominal rate each quality level
00264      corresponds to yet.*/
00265   int           target_bitrate;
00271   /*Currently this is set so that a qi of 0 corresponds to distortions of 24
00272      times the JND, and each increase by 16 halves that value.
00273     This gives us fine discrimination at low qualities, yet effective rate
00274      control at high qualities.
00275     The qi value 63 is special, however.
00276     For this, the highest quality, we use one half of a JND for our threshold.
00277     Due to the lower bounds placed on allowable quantizers in Theora, we will
00278      not actually be able to achieve quality this good, but this should
00279      provide as close to visually lossless quality as Theora is capable of.
00280     We could lift the quantizer restrictions without breaking VP3.1
00281      compatibility, but this would result in quantized coefficients that are
00282      too large for the current bitstream to be able to store.
00283     We'd have to redesign the token syntax to store these large coefficients,
00284      which would make transcoding complex.*/
00285   int           quality;
00299   int           keyframe_granule_shift;
00300 }th_info;
00301 
00326 typedef struct th_comment{
00328   char **user_comments;
00330   int   *comment_lengths;
00332   int    comments;
00335   char  *vendor;
00336 }th_comment;
00337 
00338 
00339 
00341 typedef unsigned char th_quant_base[64];
00342 
00344 typedef struct{
00346   int                  nranges;
00349   const int           *sizes;
00352   const th_quant_base *base_matrices;
00353 }th_quant_ranges;
00354 
00412 typedef struct{
00414   ogg_uint16_t    dc_scale[64];
00416   ogg_uint16_t    ac_scale[64];
00418   unsigned char   loop_filter_limits[64];
00420   th_quant_ranges qi_ranges[2][3];
00421 }th_quant_info;
00422 
00423 
00424 
00426 #define TH_NHUFFMAN_TABLES (80)
00427 
00428 #define TH_NDCT_TOKENS     (32)
00429 
00441 typedef struct{
00444   ogg_uint32_t pattern;
00447   int          nbits;
00448 }th_huff_code;
00449 
00450 
00451 
00459 extern const char *th_version_string(void);
00469 extern ogg_uint32_t th_version_number(void);
00479 extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
00491 extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
00501 extern int th_packet_isheader(ogg_packet *_op);
00512 extern int th_packet_iskeyframe(ogg_packet *_op);
00522 extern void th_info_init(th_info *_info);
00527 extern void th_info_clear(th_info *_info);
00528 
00533 extern void th_comment_init(th_comment *_tc);
00543 extern void th_comment_add(th_comment *_tc, char *_comment);
00554 extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
00570 extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
00578 extern int th_comment_query_count(th_comment *_tc,char *_tag);
00584 extern void th_comment_clear(th_comment *_tc);
00587 
00588 
00589 
00590 #if defined(__cplusplus)
00591 }
00592 #endif
00593 
00594 #endif

Generated on Mon Nov 3 10:42:44 2008 for libtheora by  doxygen 1.4.6