- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# codec.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.8 2004/03/15 22:17:32 derf Exp $
    00015
    00016  ********************************************************************/
    00017
    00044 #if !defined(_O_THEORA_CODEC_H_)
    00045 # define _O_THEORA_CODEC_H_ (1)
    00046 # include <ogg/ogg.h>
    00047
    00048 #if defined(__cplusplus)
    00049 extern "C" {
    00050 #endif
    00051
    00052
    00053
    00057 #define TH_EFAULT     (-1)
    00058
    00059 #define TH_EINVAL     (-10)
    00060
    00061 #define TH_EBADHEADER (-20)
    00062
    00063 #define TH_ENOTFORMAT (-21)
    00064
    00065 #define TH_EVERSION   (-22)
    00066
    00067 #define TH_EIMPL      (-23)
    00068
    00069 #define TH_EBADPACKET (-24)
    00070
    00073 #define TH_DUPFRAME   (1)
    00074
    00080 typedef enum{
    00083   TH_CS_UNSPECIFIED,
    00085   TH_CS_ITU_REC_470M,
    00087   TH_CS_ITU_REC_470BG,
    00089   TH_CS_NSPACES
    00090 }th_colorspace;
    00091
    00096 typedef enum{
    00098   TH_PF_420,
    00100   TH_PF_RSVD,
    00102   TH_PF_422,
    00104   TH_PF_444,
    00106   TH_PF_NFORMATS
    00107 }th_pixel_fmt;
    00108
    00109
    00110
    00119 typedef struct{
    00121   int            width;
    00123   int            height;
    00125   int            ystride;
    00127   unsigned char *data;
    00128 }th_img_plane;
    00129
    00145 typedef th_img_plane th_ycbcr_buffer[3];
    00146
    00181 typedef struct{
    00185   unsigned char version_major;
    00186   unsigned char version_minor;
    00187   unsigned char version_subminor;
    00191   ogg_uint32_t  frame_width;
    00194   ogg_uint32_t  frame_height;
    00197   ogg_uint32_t  pic_width;
    00200   ogg_uint32_t  pic_height;
    00204   ogg_uint32_t  pic_x;
    00212   ogg_uint32_t  pic_y;
    00217   ogg_uint32_t  fps_numerator;
    00218   ogg_uint32_t  fps_denominator;
    00229   ogg_uint32_t  aspect_numerator;
    00230   ogg_uint32_t  aspect_denominator;
    00233   th_colorspace colorspace;
    00235   th_pixel_fmt  pixel_fmt;
    00239   /*TODO: Current encoder does not support CBR mode, or anything like it.
    00240     We also don't really know what nominal rate each quality level
    00241      corresponds to yet.*/
    00242   int           target_bitrate;
    00248   /*Currently this is set so that a qi of 0 corresponds to distortions of 24
    00249      times the JND, and each increase by 16 halves that value.
    00250     This gives us fine discrimination at low qualities, yet effective rate
    00251      control at high qualities.
    00252     The qi value 63 is special, however.
    00253     For this, the highest quality, we use one half of a JND for our threshold.
    00254     Due to the lower bounds placed on allowable quantizers in Theora, we will
    00255      not actually be able to achieve quality this good, but this should
    00256      provide as close to visually lossless quality as Theora is capable of.
    00257     We could lift the quantizer restrictions without breaking VP3.1
    00258      compatibility, but this would result in quantized coefficients that are
    00259      too large for the current bitstream to be able to store.
    00260     We'd have to redesign the token syntax to store these large coefficients,
    00261      which would make transcoding complex.*/
    00262   int           quality;
    00276   int           keyframe_granule_shift;
    00277 }th_info;
    00278
    00303 typedef struct th_comment{
    00305   char **user_comments;
    00307   int   *comment_lengths;
    00309   int    comments;
    00312   char  *vendor;
    00313 }th_comment;
    00314
    00315
    00316
    00318 typedef unsigned char th_quant_base[64];
    00319
    00321 typedef struct{
    00323   int                  nranges;
    00326   const int           *sizes;
    00329   const th_quant_base *base_matrices;
    00330 }th_quant_ranges;
    00331
    00389 typedef struct{
    00391   ogg_uint16_t    dc_scale[64];
    00393   ogg_uint16_t    ac_scale[64];
    00395   unsigned char   loop_filter_limits[64];
    00397   th_quant_ranges qi_ranges[2][3];
    00398 }th_quant_info;
    00399
    00400
    00401
    00403 #define TH_NHUFFMAN_TABLES (80)
    00404
    00405 #define TH_NDCT_TOKENS     (32)
    00406
    00418 typedef struct{
    00421   ogg_uint32_t pattern;
    00424   int          nbits;
    00425 }th_huff_code;
    00426
    00427
    00428
    00436 extern const char *th_version_string(void);
    00446 extern ogg_uint32_t th_version_number(void);
    00455 extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
    00464 extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
    00474 extern int th_packet_isheader(ogg_packet *_op);
    00485 extern int th_packet_iskeyframe(ogg_packet *_op);
    00495 extern void th_info_init(th_info *_info);
    00500 extern void th_info_clear(th_info *_info);
    00501
    00506 extern void th_comment_init(th_comment *_tc);
    00516 extern void th_comment_add(th_comment *_tc, char *_comment);
    00527 extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
    00543 extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
    00551 extern int th_comment_query_count(th_comment *_tc,char *_tag);
    00557 extern void th_comment_clear(th_comment *_tc);
    00560
    00561
    00562
    00563 #if defined(__cplusplus)
    00564 }
    00565 #endif
    00566
    00567 #endif