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 #ifndef LIBOGG2
00029 #include <ogg/ogg.h>
00030 #else
00031 #include <ogg2/ogg.h>
00032 /* This is temporary until libogg2 is more complete */
00033 ogg_buffer_state *ogg_buffer_create(void);
00034 #endif
00035 
00155 typedef struct {
00156     int   y_width;      
00157     int   y_height;     
00158     int   y_stride;     
00160     int   uv_width;     
00161     int   uv_height;    
00162     int   uv_stride;    
00163     unsigned char *y;   
00164     unsigned char *u;   
00165     unsigned char *v;   
00167 } yuv_buffer;
00168 
00172 typedef enum {
00173   OC_CS_UNSPECIFIED,    
00174   OC_CS_ITU_REC_470M,   
00175   OC_CS_ITU_REC_470BG,  
00176   OC_CS_NSPACES         
00177 } theora_colorspace;
00178 
00186 typedef enum {
00187   OC_PF_420,    
00188   OC_PF_RSVD,   
00189   OC_PF_422,    
00190   OC_PF_444,    
00191 } theora_pixelformat;
00192 
00214 typedef struct {
00215   ogg_uint32_t  width;          
00216   ogg_uint32_t  height;         
00217   ogg_uint32_t  frame_width;    
00218   ogg_uint32_t  frame_height;   
00219   ogg_uint32_t  offset_x;       
00220   ogg_uint32_t  offset_y;       
00221   ogg_uint32_t  fps_numerator;      
00222   ogg_uint32_t  fps_denominator;    
00223   ogg_uint32_t  aspect_numerator;   
00224   ogg_uint32_t  aspect_denominator; 
00225   theora_colorspace colorspace;     
00226   int           target_bitrate;     
00227   int           quality;  
00228   int           quick_p;  
00230   /* decode only */
00231   unsigned char version_major;
00232   unsigned char version_minor;
00233   unsigned char version_subminor;
00234 
00235   void *codec_setup;
00236 
00237   /* encode only */
00238   int           dropframes_p;
00239   int           keyframe_auto_p;
00240   ogg_uint32_t  keyframe_frequency;
00241   ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
00242                                               get granpos shift correct */
00243   ogg_uint32_t  keyframe_data_target_bitrate;
00244   ogg_int32_t   keyframe_auto_threshold;
00245   ogg_uint32_t  keyframe_mindistance;
00246   ogg_int32_t   noise_sensitivity;
00247   ogg_int32_t   sharpness;
00248 
00249   theora_pixelformat pixelformat;       
00251 } theora_info;
00252 
00255 typedef struct{
00256   theora_info *i;
00257   ogg_int64_t granulepos;
00258 
00259   void *internal_encode;
00260   void *internal_decode;
00261 
00262 } theora_state;
00263 
00283 typedef struct theora_comment{
00284   char **user_comments;         
00285   int   *comment_lengths;       
00286   int    comments;              
00287   char  *vendor;                
00289 } theora_comment;
00290 
00291 
00307 #define TH_DECCTL_GET_PPLEVEL_MAX (1)
00308 
00314 #define TH_DECCTL_SET_PPLEVEL (3)
00315 
00323 #define TH_DECCTL_SET_GRANPOS (5)
00324 
00325 
00346 #define TH_ENCCTL_SET_HUFFMAN_CODES (0)
00347 
00365 #define TH_ENCCTL_SET_QUANT_PARAMS (2)
00366 
00378 #define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
00379 
00406 #define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
00407 
00420 #define TH_ENCCTL_GET_SPLEVEL_MAX (12)
00421 
00434 #define TH_ENCCTL_SET_SPLEVEL (14)
00435 
00454 #define TH_ENCCTL_SETUP_VBR (16)
00455 
00469 #define TH_ENCCTL_SETUP_CQI (18)
00470 
00472 #define OC_FAULT       -1       
00473 #define OC_EINVAL      -10      
00474 #define OC_DISABLED    -11      
00475 #define OC_BADHEADER   -20      
00476 #define OC_NOTFORMAT   -21      
00477 #define OC_VERSION     -22      
00478 #define OC_IMPL        -23      
00479 #define OC_BADPACKET   -24      
00480 #define OC_NEWPACKET   -25      
00481 #define OC_DUPFRAME    1        
00487 extern const char *theora_version_string(void);
00488 
00498 extern ogg_uint32_t theora_version_number(void);
00499 
00506 extern int theora_encode_init(theora_state *th, theora_info *ti);
00507 
00518 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
00519 
00532 extern int theora_encode_packetout( theora_state *t, int last_p,
00533                                     ogg_packet *op);
00534 
00545 extern int theora_encode_header(theora_state *t, ogg_packet *op);
00546 
00558 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
00559 
00570 extern int theora_encode_tables(theora_state *t, ogg_packet *op);
00571 
00613 extern int theora_decode_header(theora_info *ci, theora_comment *cc,
00614                                 ogg_packet *op);
00615 
00624 extern int theora_decode_init(theora_state *th, theora_info *c);
00625 
00633 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
00634 
00645 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
00646 
00659 extern int theora_packet_isheader(ogg_packet *op);
00660 
00671 extern int theora_packet_iskeyframe(ogg_packet *op);
00672 
00698 int theora_granule_shift(theora_info *ti);
00699 
00711 extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
00712 
00723 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
00724 
00731 extern void theora_info_init(theora_info *c);
00732 
00738 extern void theora_info_clear(theora_info *c);
00739 
00744 extern void theora_clear(theora_state *t);
00745 
00750 extern void theora_comment_init(theora_comment *tc);
00751 
00764 extern void theora_comment_add(theora_comment *tc, char *comment);
00765 
00778 extern void theora_comment_add_tag(theora_comment *tc,
00779                                        char *tag, char *value);
00780 
00795 extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
00796 
00806 extern int   theora_comment_query_count(theora_comment *tc, char *tag);
00807 
00812 extern void  theora_comment_clear(theora_comment *tc);
00813 
00822 extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);
00823 
00824 #ifdef __cplusplus
00825 }
00826 #endif /* __cplusplus */
00827 
00828 #endif /* _O_THEORA_H_ */

Generated on Thu Oct 4 16:23:03 2007 for libtheora by  doxygen 1.5.1