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-2007                *
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 #include <stddef.h>     /* for size_t */
00027 
00028 #include <ogg/ogg.h>
00029 
00031 /*  @{ */
00032 
00157 typedef struct {
00158     int   y_width;      
00159     int   y_height;     
00160     int   y_stride;     
00162     int   uv_width;     
00163     int   uv_height;    
00164     int   uv_stride;    
00165     unsigned char *y;   
00166     unsigned char *u;   
00167     unsigned char *v;   
00169 } yuv_buffer;
00170 
00174 typedef enum {
00175   OC_CS_UNSPECIFIED,    
00176   OC_CS_ITU_REC_470M,   
00177   OC_CS_ITU_REC_470BG,  
00178   OC_CS_NSPACES         
00179 } theora_colorspace;
00180 
00188 typedef enum {
00189   OC_PF_420,    
00190   OC_PF_RSVD,   
00191   OC_PF_422,    
00192   OC_PF_444,    
00193 } theora_pixelformat;
00194 
00216 typedef struct {
00217   ogg_uint32_t  width;          
00218   ogg_uint32_t  height;         
00219   ogg_uint32_t  frame_width;    
00220   ogg_uint32_t  frame_height;   
00221   ogg_uint32_t  offset_x;       
00222   ogg_uint32_t  offset_y;       
00223   ogg_uint32_t  fps_numerator;      
00224   ogg_uint32_t  fps_denominator;    
00225   ogg_uint32_t  aspect_numerator;   
00226   ogg_uint32_t  aspect_denominator; 
00227   theora_colorspace colorspace;     
00228   int           target_bitrate;     
00229   int           quality;  
00230   int           quick_p;  
00232   /* decode only */
00233   unsigned char version_major;
00234   unsigned char version_minor;
00235   unsigned char version_subminor;
00236 
00237   void *codec_setup;
00238 
00239   /* encode only */
00240   int           dropframes_p;
00241   int           keyframe_auto_p;
00242   ogg_uint32_t  keyframe_frequency;
00243   ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
00244                                               get granpos shift correct */
00245   ogg_uint32_t  keyframe_data_target_bitrate;
00246   ogg_int32_t   keyframe_auto_threshold;
00247   ogg_uint32_t  keyframe_mindistance;
00248   ogg_int32_t   noise_sensitivity;
00249   ogg_int32_t   sharpness;
00250 
00251   theora_pixelformat pixelformat;       
00253 } theora_info;
00254 
00257 typedef struct{
00258   theora_info *i;
00259   ogg_int64_t granulepos;
00260 
00261   void *internal_encode;
00262   void *internal_decode;
00263 
00264 } theora_state;
00265 
00285 typedef struct theora_comment{
00286   char **user_comments;         
00287   int   *comment_lengths;       
00288   int    comments;              
00289   char  *vendor;                
00291 } theora_comment;
00292 
00293 
00309 #define TH_DECCTL_GET_PPLEVEL_MAX (1)
00310 
00316 #define TH_DECCTL_SET_PPLEVEL (3)
00317 
00330 #define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
00331 
00339 #define TH_DECCTL_SET_GRANPOS (5)
00340 
00341 
00367 #define TH_ENCCTL_SET_QUANT_PARAMS (2)
00368 
00395 #define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
00396 
00409 #define TH_ENCCTL_GET_SPLEVEL_MAX (12)
00410 
00423 #define TH_ENCCTL_SET_SPLEVEL (14)
00424 
00426 #define OC_FAULT       -1       
00427 #define OC_EINVAL      -10      
00428 #define OC_DISABLED    -11      
00429 #define OC_BADHEADER   -20      
00430 #define OC_NOTFORMAT   -21      
00431 #define OC_VERSION     -22      
00432 #define OC_IMPL        -23      
00433 #define OC_BADPACKET   -24      
00434 #define OC_NEWPACKET   -25      
00435 #define OC_DUPFRAME    1        
00441 extern const char *theora_version_string(void);
00442 
00452 extern ogg_uint32_t theora_version_number(void);
00453 
00460 extern int theora_encode_init(theora_state *th, theora_info *ti);
00461 
00472 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
00473 
00486 extern int theora_encode_packetout( theora_state *t, int last_p,
00487                                     ogg_packet *op);
00488 
00499 extern int theora_encode_header(theora_state *t, ogg_packet *op);
00500 
00512 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
00513 
00524 extern int theora_encode_tables(theora_state *t, ogg_packet *op);
00525 
00567 extern int theora_decode_header(theora_info *ci, theora_comment *cc,
00568                                 ogg_packet *op);
00569 
00578 extern int theora_decode_init(theora_state *th, theora_info *c);
00579 
00587 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
00588 
00599 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
00600 
00613 extern int theora_packet_isheader(ogg_packet *op);
00614 
00625 extern int theora_packet_iskeyframe(ogg_packet *op);
00626 
00652 int theora_granule_shift(theora_info *ti);
00653 
00670 extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
00671 
00687 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
00688 
00695 extern void theora_info_init(theora_info *c);
00696 
00702 extern void theora_info_clear(theora_info *c);
00703 
00708 extern void theora_clear(theora_state *t);
00709 
00714 extern void theora_comment_init(theora_comment *tc);
00715 
00728 extern void theora_comment_add(theora_comment *tc, char *comment);
00729 
00742 extern void theora_comment_add_tag(theora_comment *tc,
00743                                        char *tag, char *value);
00744 
00759 extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
00760 
00770 extern int   theora_comment_query_count(theora_comment *tc, char *tag);
00771 
00776 extern void  theora_comment_clear(theora_comment *tc);
00777 
00786 extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);
00787 
00788 /* @} */ /* end oldfuncs doxygen group */
00789 
00790 #ifdef __cplusplus
00791 }
00792 #endif /* __cplusplus */
00793 
00794 #endif /* _O_THEORA_H_ */

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