libtheora: theora.h Source File

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
    00063 typedef struct {
    00064     int   y_width;
    00065     int   y_height;
    00066     int   y_stride;
    00068     int   uv_width;
    00069     int   uv_height;
    00070     int   uv_stride;
    00071     unsigned char *y;
    00072     unsigned char *u;
    00073     unsigned char *v;
    00075 } yuv_buffer;
    00076
    00080 typedef enum {
    00081   OC_CS_UNSPECIFIED,
    00082   OC_CS_ITU_REC_470M,
    00083   OC_CS_ITU_REC_470BG,
    00084   OC_CS_NSPACES
    00085 } theora_colorspace;
    00086
    00094 typedef enum {
    00095   OC_PF_420,
    00096   OC_PF_RSVD,
    00097   OC_PF_422,
    00098   OC_PF_444,
    00099 } theora_pixelformat;
    00100
    00122 typedef struct {
    00123   ogg_uint32_t  width;
    00124   ogg_uint32_t  height;
    00125   ogg_uint32_t  frame_width;
    00126   ogg_uint32_t  frame_height;
    00127   ogg_uint32_t  offset_x;
    00128   ogg_uint32_t  offset_y;
    00129   ogg_uint32_t  fps_numerator;
    00130   ogg_uint32_t  fps_denominator;
    00131   ogg_uint32_t  aspect_numerator;
    00132   ogg_uint32_t  aspect_denominator;
    00133   theora_colorspace colorspace;
    00134   int           target_bitrate;
    00135   int           quality;
    00136   int           quick_p;
    00138   /* decode only */
    00139   unsigned char version_major;
    00140   unsigned char version_minor;
    00141   unsigned char version_subminor;
    00142
    00143   void *codec_setup;
    00144
    00145   /* encode only */
    00146   int           dropframes_p;
    00147   int           keyframe_auto_p;
    00148   ogg_uint32_t  keyframe_frequency;
    00149   ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
    00150                                               get granpos shift correct */
    00151   ogg_uint32_t  keyframe_data_target_bitrate;
    00152   ogg_int32_t   keyframe_auto_threshold;
    00153   ogg_uint32_t  keyframe_mindistance;
    00154   ogg_int32_t   noise_sensitivity;
    00155   ogg_int32_t   sharpness;
    00156
    00157   theora_pixelformat pixelformat;
    00159 } theora_info;
    00160
    00163 typedef struct{
    00164   theora_info *i;
    00165   ogg_int64_t granulepos;
    00166
    00167   void *internal_encode;
    00168   void *internal_decode;
    00169
    00170 } theora_state;
    00171
    00191 typedef struct theora_comment{
    00192   char **user_comments;
    00193   int   *comment_lengths;
    00194   int    comments;
    00195   char  *vendor;
    00197 } theora_comment;
    00198
    00199 #define OC_FAULT       -1
    00200 #define OC_EINVAL      -10
    00201 #define OC_DISABLED    -11
    00202 #define OC_BADHEADER   -20
    00203 #define OC_NOTFORMAT   -21
    00204 #define OC_VERSION     -22
    00205 #define OC_IMPL        -23
    00206 #define OC_BADPACKET   -24
    00207 #define OC_NEWPACKET   -25
    00208 #define OC_DUPFRAME    1
    00214 extern const char *theora_version_string(void);
    00215
    00225 extern ogg_uint32_t theora_version_number(void);
    00226
    00233 extern int theora_encode_init(theora_state *th, theora_info *ti);
    00234
    00243 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
    00244
    00257 extern int theora_encode_packetout( theora_state *t, int last_p,
    00258                                     ogg_packet *op);
    00259
    00270 extern int theora_encode_header(theora_state *t, ogg_packet *op);
    00271
    00283 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
    00284
    00295 extern int theora_encode_tables(theora_state *t, ogg_packet *op);
    00296
    00338 extern int theora_decode_header(theora_info *ci, theora_comment *cc,
    00339                                 ogg_packet *op);
    00340
    00349 extern int theora_decode_init(theora_state *th, theora_info *c);
    00350
    00358 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
    00359
    00366 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
    00367
    00380 extern int theora_packet_isheader(ogg_packet *op);
    00381
    00392 extern int theora_packet_iskeyframe(ogg_packet *op);
    00393
    00419 int theora_granule_shift(theora_info *ti);
    00420
    00432 extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
    00433
    00444 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
    00445
    00452 extern void theora_info_init(theora_info *c);
    00453
    00459 extern void theora_info_clear(theora_info *c);
    00460
    00465 extern void theora_clear(theora_state *t);
    00466
    00471 extern void theora_comment_init(theora_comment *tc);
    00472
    00485 extern void theora_comment_add(theora_comment *tc, char *comment);
    00486
    00499 extern void theora_comment_add_tag(theora_comment *tc,
    00500                                        char *tag, char *value);
    00501
    00516 extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
    00517
    00527 extern int   theora_comment_query_count(theora_comment *tc, char *tag);
    00528
    00533 extern void  theora_comment_clear(theora_comment *tc);
    00534
    00535 #ifdef __cplusplus
    00536 }
    00537 #endif /* __cplusplus */
    00538
    00539 #endif /* _O_THEORA_H_ */