Main Page | Data Structures | Directories | File List | Data Fields | Globals

theora.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-2003                *
00009  * by the Xiph.Org Foundation http://www.xiph.org/                  *
00010  *                                                                  *
00011  ********************************************************************
00012 
00013   function:
00014   last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $
00015 
00016  ********************************************************************/
00017 
00018 #ifndef _O_THEORA_H_
00019 #define _O_THEORA_H_
00020 
00021 #ifdef __cplusplus
00022 extern "C"
00023 {
00024 #endif /* __cplusplus */
00025 
00026 #ifndef LIBOGG2
00027 #include <ogg/ogg.h>
00028 #else
00029 #include <ogg2/ogg.h>
00030 /* This is temporary until libogg2 is more complete */
00031 ogg_buffer_state *ogg_buffer_create(void);
00032 #endif
00033 
00060 typedef struct {
00061     int   y_width;      
00062     int   y_height;     
00063     int   y_stride;     
00065     int   uv_width;     
00066     int   uv_height;    
00067     int   uv_stride;    
00068     unsigned char *y;   
00069     unsigned char *u;   
00070     unsigned char *v;   
00072 } yuv_buffer;
00073 
00077 typedef enum {
00078   OC_CS_UNSPECIFIED,    
00079   OC_CS_ITU_REC_470M,   
00080   OC_CS_ITU_REC_470BG,  
00081   OC_CS_NSPACES         
00082 } theora_colorspace;
00083 
00091 typedef enum {
00092   OC_PF_420,    
00093   OC_PF_RSVD,   
00094   OC_PF_422,    
00095   OC_PF_444,    
00096 } theora_pixelformat;
00097 
00118 typedef struct {
00119   ogg_uint32_t  width;
00120   ogg_uint32_t  height;
00121   ogg_uint32_t  frame_width;
00122   ogg_uint32_t  frame_height;
00123   ogg_uint32_t  offset_x;
00124   ogg_uint32_t  offset_y;
00125   ogg_uint32_t  fps_numerator;
00126   ogg_uint32_t  fps_denominator;
00127   ogg_uint32_t  aspect_numerator;
00128   ogg_uint32_t  aspect_denominator;
00129   theora_colorspace colorspace;
00130   int           target_bitrate;
00131   int           quality;  
00132   int           quick_p;  
00134   /* decode only */
00135   unsigned char version_major;
00136   unsigned char version_minor;
00137   unsigned char version_subminor;
00138 
00139   void *codec_setup;
00140 
00141   /* encode only */
00142   int           dropframes_p;
00143   int           keyframe_auto_p;
00144   ogg_uint32_t  keyframe_frequency;
00145   ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
00146                                               get granpos shift correct */
00147   ogg_uint32_t  keyframe_data_target_bitrate;
00148   ogg_int32_t   keyframe_auto_threshold;
00149   ogg_uint32_t  keyframe_mindistance;
00150   ogg_int32_t   noise_sensitivity;
00151   ogg_int32_t   sharpness;
00152 
00153   theora_pixelformat pixelformat;
00154 
00155 } theora_info;
00156 
00159 typedef struct{
00160   theora_info *i;
00161   ogg_int64_t granulepos;
00162 
00163   void *internal_encode;
00164   void *internal_decode;
00165 
00166 } theora_state;
00167 
00187 typedef struct theora_comment{
00188   char **user_comments;         
00189   int   *comment_lengths;       
00190   int    comments;              
00191   char  *vendor;                
00193 } theora_comment;
00194 
00195 #define OC_FAULT       -1       
00196 #define OC_EINVAL      -10      
00197 #define OC_DISABLED    -11      
00198 #define OC_BADHEADER   -20      
00199 #define OC_NOTFORMAT   -21      
00200 #define OC_VERSION     -22      
00201 #define OC_IMPL        -23      
00202 #define OC_BADPACKET   -24      
00203 #define OC_NEWPACKET   -25      
00209 extern const char *theora_version_string(void);
00210 
00220 extern ogg_uint32_t theora_version_number(void);
00221 
00228 extern int theora_encode_init(theora_state *th, theora_info *ti);
00229 
00238 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
00239 
00252 extern int theora_encode_packetout( theora_state *t, int last_p,
00253                                     ogg_packet *op);
00254 
00265 extern int theora_encode_header(theora_state *t, ogg_packet *op);
00266 
00278 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
00279 
00290 extern int theora_encode_tables(theora_state *t, ogg_packet *op);
00291 
00333 extern int theora_decode_header(theora_info *ci, theora_comment *cc,
00334                                 ogg_packet *op);
00335 
00344 extern int theora_decode_init(theora_state *th, theora_info *c);
00345 
00353 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
00354 
00361 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
00362 
00375 extern int theora_packet_isheader(ogg_packet *op);
00376 
00387 extern int theora_packet_iskeyframe(ogg_packet *op);
00388 
00414 int theora_granule_shift(theora_info *ti);
00415 
00427 extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
00428 
00439 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
00440 
00447 extern void theora_info_init(theora_info *c);
00448 
00454 extern void theora_info_clear(theora_info *c);
00455 
00460 extern void theora_clear(theora_state *t);
00461 
00466 extern void theora_comment_init(theora_comment *tc);
00467 
00480 extern void theora_comment_add(theora_comment *tc, char *comment);
00481 
00494 extern void theora_comment_add_tag(theora_comment *tc,
00495                                        char *tag, char *value);
00496 
00511 extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
00512 
00522 extern int   theora_comment_query_count(theora_comment *tc, char *tag);
00523 
00528 extern void  theora_comment_clear(theora_comment *tc);
00529 
00530 #ifdef __cplusplus
00531 }
00532 #endif /* __cplusplus */
00533 
00534 #endif /* _O_THEORA_H_ */

Generated on Sat Aug 20 12:41:44 2005 for libtheora by  doxygen 1.4.0