Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

theoracc.h

00001 #ifndef THEORACC_H
00002 #define THEORACC_H
00003 
00004 #include "oggcc.h"
00005 #include <string>
00006 #include <theora/theora.h>
00007 
00008 #if 0
00009 
00010 typedef struct {
00011     int   y_width;
00012     int   y_height;
00013     int   y_stride;
00014 
00015     int   uv_width;
00016     int   uv_height;
00017     int   uv_stride;
00018     char *y;
00019     char *u;
00020     char *v;
00021 
00022 } yuv_buffer;
00023 
00024 typedef enum {
00025   OC_CS_UNSPECIFIED,
00026   OC_CS_ITU_REC_470M,
00027   OC_CS_ITU_REC_470BG,
00028 } theora_colorspace;
00029 
00030 typedef struct {
00031   ogg_uint32_t  width;
00032   ogg_uint32_t  height;
00033   ogg_uint32_t  frame_width;
00034   ogg_uint32_t  frame_height;
00035   ogg_uint32_t  offset_x;
00036   ogg_uint32_t  offset_y;
00037   ogg_uint32_t  fps_numerator;
00038   ogg_uint32_t  fps_denominator;
00039   ogg_uint32_t  aspect_numerator;
00040   ogg_uint32_t  aspect_denominator;
00041   theora_colorspace colorspace;
00042   int           target_bitrate;
00043   int           quality;
00044   int           quick_p;  /* quick encode/decode */
00045 
00046   /* decode only */
00047   unsigned char version_major;
00048   unsigned char version_minor;
00049   unsigned char version_subminor;
00050 
00051   void *codec_setup;
00052 
00053   /* encode only */
00054   int           dropframes_p;
00055   int           keyframe_auto_p;
00056   ogg_uint32_t  keyframe_frequency;
00057   ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
00058                                               get granpos shift correct */
00059   ogg_uint32_t  keyframe_data_target_bitrate;
00060   ogg_int32_t   keyframe_auto_threshold;
00061   ogg_uint32_t  keyframe_mindistance;
00062   ogg_int32_t   noise_sensitivity;
00063   ogg_int32_t   sharpness;
00064 
00065 } theora_info;
00066 
00067 #define OC_FAULT       -1
00068 #define OC_EINVAL      -10
00069 #define OC_BADHEADER   -20
00070 #define OC_NOTFORMAT   -21
00071 #define OC_VERSION     -22
00072 #define OC_IMPL        -23
00073 #define OC_BADPACKET   -24
00074 #define OC_NEWPACKET   -25
00075 
00076 #endif
00077 
00078 namespace ogg {
00080     namespace theora {
00082         enum theora_errors {
00083             ocFault     = OC_FAULT,
00084             ocEinval    = OC_EINVAL,
00085             ocBadHeader = OC_BADHEADER,
00086             ocNotFormat = OC_NOTFORMAT,
00087             ocImpl      = OC_IMPL,
00088             ocBadPacket = OC_BADPACKET,
00089             ocNewPacket = OC_NEWPACKET
00090         };
00091         
00093         class comment {
00094             private:
00095                 theora_comment data;
00096 
00097                 void init ( )   { theora_comment_init ( this->get_data() ); }
00098                 void clear ( )  { theora_comment_clear ( this->get_data() ); }
00099                 
00100             public:
00101                 comment()   { this->init(); }
00102                 ~comment()  { this->clear(); }
00103                 
00104                 theora_comment *get_data() { return &this->data; }
00105                 
00106                 const char *query (char *tag , int count) { 
00107                     return theora_comment_query (this->get_data(), tag , count ); }
00108 
00110                 std::string query_index(unsigned int index) { 
00111                     theora_comment *data = this->get_data();
00112                     return (index < (unsigned)(data->comments) ? 
00113                             std::string(data->user_comments[index], data->comment_lengths[index]) : ""); };
00114                     
00115                 int query_count (char *tag) { return  theora_comment_query_count ( this->get_data(), tag ); }
00116                 int encode (packet *op)     { return  theora_encode_comment ( this->get_data(), op->get_data() ); }
00117 
00118                 void add ( char *comment )  { return  theora_comment_add ( this->get_data(), comment ); }
00119                 void add_tag ( char *tag , char *value )  { return  theora_comment_add_tag ( this->get_data(), tag, value ); }
00120 
00121                 const char* get_vendor() { return this->get_data()->vendor; }
00122 
00123                 int size()  { return this->get_data()->comments; }
00124         };
00125 
00126         
00128         class info : public theora_info {
00129             private:
00130                 void init ( )   { return  theora_info_init ( this->get_data() ); }
00131                 void clear ( )  { return  theora_info_clear ( this->get_data() ); }
00132 
00133             public:
00134                 info()  { this->init(); }
00135                 ~info() { this->clear(); }
00136 
00137                 theora_info *get_data() { return (theora_info*)this; }
00138 
00139                 int decode_header ( theora::comment *cc , ogg::packet *op )  { 
00140                     return  theora_decode_header ( this->get_data() , cc->get_data() , op->get_data() ); }
00141         };
00142         
00143 
00145         class yuv_image : public yuv_buffer
00146         {
00147             public:
00148                 yuv_buffer *get_data()  { return (yuv_buffer*)this; }
00149         };
00150 
00151 
00153         class state {
00154             private:
00155                 theora_state data;
00156                 void clear ( )  { return  theora_clear ( this->get_data() ); }
00157 
00158             public:
00159                 state() { 
00160                     theora_state *ts = this->get_data(); 
00161                     ts->i = NULL;
00162                     ts->internal_encode = ts->internal_decode = NULL; 
00163                     ts->granulepos = 0; }
00164 
00165                 ~state() { this->clear(); }
00166                 
00167                 theora_state *get_data() { return &this->data; }
00168                 
00169                 double granule_time ( ogg_int64_t granulepos ) {
00170                     return  theora_granule_time ( this->get_data(), granulepos ); }
00171                 
00172                 int decode_init     ( info *c )         { return theora_decode_init     ( this->get_data(), c->get_data() ); }
00173                 int decode_packetin ( ogg::packet *op ) { return theora_decode_packetin ( this->get_data(), op->get_data() ); }
00174                 int decode_YUVout   ( yuv_image *yuv )  { return theora_decode_YUVout   ( this->get_data(), yuv ); }
00175                 
00176                 int encode_init     ( info *c )         { return theora_encode_init     ( this->get_data(), c->get_data() ); }
00177                 int encode_header   ( ogg::packet *op ) { return theora_encode_header   ( this->get_data(), op->get_data() ); }
00178                 int encode_tables   ( ogg::packet *op ) { return theora_encode_tables   ( this->get_data(), op->get_data() ); }
00179                 int encode_YUVin    ( yuv_image *yuv )  { return theora_encode_YUVin    ( this->get_data(), yuv ); }
00180                 
00181                 int encode_packetout ( int last_p, ogg::packet *op )  { 
00182                     return  theora_encode_packetout ( this->get_data(), last_p, op->get_data() ); }
00183         };
00184 
00185 
00187         const char *version_string  ( void )    { return  theora_version_string ( ); }
00188 
00190         ogg_uint32_t version_number ( void )    { return  theora_version_number ( ); }
00191     };
00192 };
00193 
00194 #endif

Generated on Wed Apr 7 03:10:32 2004 for oggpy/oggcc by doxygen 1.3.5