- Main Page
- Modules
- Data Structures
- Files

- File List
- 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 #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
    00312 #define TH_ENCCTL_SET_HUFFMAN_CODES (0)
    00313
    00331 #define TH_ENCCTL_SET_QUANT_PARAMS (2)
    00332
    00344 #define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
    00345
    00372 #define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
    00373
    00386 #define TH_ENCCTL_GET_SPLEVEL_MAX (12)
    00387
    00400 #define TH_ENCCTL_SET_SPLEVEL (14)
    00401
    00420 #define TH_ENCCTL_SETUP_VBR (16)
    00421
    00435 #define TH_ENCCTL_SETUP_CQI (18)
    00436
    00438 #define OC_FAULT       -1
    00439 #define OC_EINVAL      -10
    00440 #define OC_DISABLED    -11
    00441 #define OC_BADHEADER   -20
    00442 #define OC_NOTFORMAT   -21
    00443 #define OC_VERSION     -22
    00444 #define OC_IMPL        -23
    00445 #define OC_BADPACKET   -24
    00446 #define OC_NEWPACKET   -25
    00447 #define OC_DUPFRAME    1
    00453 extern const char *theora_version_string(void);
    00454
    00464 extern ogg_uint32_t theora_version_number(void);
    00465
    00472 extern int theora_encode_init(theora_state *th, theora_info *ti);
    00473
    00484 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
    00485
    00498 extern int theora_encode_packetout( theora_state *t, int last_p,
    00499                                     ogg_packet *op);
    00500
    00511 extern int theora_encode_header(theora_state *t, ogg_packet *op);
    00512
    00524 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
    00525
    00536 extern int theora_encode_tables(theora_state *t, ogg_packet *op);
    00537
    00579 extern int theora_decode_header(theora_info *ci, theora_comment *cc,
    00580                                 ogg_packet *op);
    00581
    00590 extern int theora_decode_init(theora_state *th, theora_info *c);
    00591
    00599 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
    00600
    00611 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
    00612
    00625 extern int theora_packet_isheader(ogg_packet *op);
    00626
    00637 extern int theora_packet_iskeyframe(ogg_packet *op);
    00638
    00664 int theora_granule_shift(theora_info *ti);
    00665
    00677 extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
    00678
    00689 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
    00690
    00697 extern void theora_info_init(theora_info *c);
    00698
    00704 extern void theora_info_clear(theora_info *c);
    00705
    00710 extern void theora_clear(theora_state *t);
    00711
    00716 extern void theora_comment_init(theora_comment *tc);
    00717
    00730 extern void theora_comment_add(theora_comment *tc, char *comment);
    00731
    00744 extern void theora_comment_add_tag(theora_comment *tc,
    00745                                        char *tag, char *value);
    00746
    00761 extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
    00762
    00772 extern int   theora_comment_query_count(theora_comment *tc, char *tag);
    00773
    00778 extern void  theora_comment_clear(theora_comment *tc);
    00779
    00788 extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);
    00789
    00790 #ifdef __cplusplus
    00791 }
    00792 #endif /* __cplusplus */
    00793
    00794 #endif /* _O_THEORA_H_ */