examples/sfexamples/oggvorbiscodec/src/tremor/ogg.h

00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
00004  *                                                                  *
00005  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
00006  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
00007  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
00008  *                                                                  *
00009  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003    *
00010  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
00011  *                                                                  *
00012  ********************************************************************
00013 
00014  function: subsumed libogg includes
00015 
00016  ********************************************************************/
00017 #ifndef _OGG_H
00018 #define _OGG_H
00019 
00020 #ifndef __SYMBIAN32__
00021 # define IMPORT_C extern
00022 # define EXPORT_C
00023 #else
00024 # ifndef __cplusplus
00025 #ifndef __X86GCC__
00026 #  undef IMPORT_C
00027 #  define IMPORT_C __declspec(dllexport)
00028 #  define EXPORT_C __declspec(dllexport)
00029 # endif
00030 # endif
00031 #endif
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 #include "os_types.h"
00038 
00039 typedef struct ogg_buffer_state{
00040   struct ogg_buffer    *unused_buffers;
00041   struct ogg_reference *unused_references;
00042   int                   outstanding;
00043   int                   shutdown;
00044 } ogg_buffer_state;
00045 
00046 typedef struct ogg_buffer {
00047   unsigned char      *data;
00048   long                size;
00049   int                 refcount;
00050 
00051   union {
00052     ogg_buffer_state  *owner;
00053     struct ogg_buffer *next;
00054   } ptr;
00055 } ogg_buffer;
00056 
00057 typedef struct ogg_reference {
00058   ogg_buffer    *buffer;
00059   long           begin;
00060   long           length;
00061 
00062   struct ogg_reference *next;
00063 } ogg_reference;
00064 
00065 typedef struct oggpack_buffer {
00066   int            headbit;
00067   unsigned char *headptr;
00068   long           headend;
00069 
00070   /* memory management */
00071   ogg_reference *head;
00072   ogg_reference *tail;
00073 
00074   /* render the byte/bit counter API constant time */
00075   long              count; /* doesn't count the tail */
00076 } oggpack_buffer;
00077 
00078 typedef struct oggbyte_buffer {
00079   ogg_reference *baseref;
00080 
00081   ogg_reference *ref;
00082   unsigned char *ptr;
00083   long           pos;
00084   long           end;
00085 } oggbyte_buffer;
00086 
00087 typedef struct ogg_sync_state {
00088   /* decode memory management pool */
00089   ogg_buffer_state *bufferpool;
00090 
00091   /* stream buffers */
00092   ogg_reference    *fifo_head;
00093   ogg_reference    *fifo_tail;
00094   long              fifo_fill;
00095 
00096   /* stream sync management */
00097   int               unsynced;
00098   int               headerbytes;
00099   int               bodybytes;
00100 
00101 } ogg_sync_state;
00102 
00103 typedef struct ogg_stream_state {
00104   ogg_reference *header_head;
00105   ogg_reference *header_tail;
00106   ogg_reference *body_head;
00107   ogg_reference *body_tail;
00108 
00109   int            e_o_s;    /* set when we have buffered the last
00110                               packet in the logical bitstream */
00111   int            b_o_s;    /* set after we've written the initial page
00112                               of a logical bitstream */
00113   long           serialno;
00114   long           pageno;
00115   ogg_int64_t    packetno; /* sequence number for decode; the framing
00116                               knows where there's a hole in the data,
00117                               but we need coupling so that the codec
00118                               (which is in a seperate abstraction
00119                               layer) also knows about the gap */
00120   ogg_int64_t    granulepos;
00121 
00122   int            lacing_fill;
00123   ogg_uint32_t   body_fill;
00124 
00125   /* decode-side state data */
00126   int            holeflag;
00127   int            spanflag;
00128   int            clearflag;
00129   int            laceptr;
00130   ogg_uint32_t   body_fill_next;
00131 
00132 } ogg_stream_state;
00133 
00134 typedef struct {
00135   ogg_reference *packet;
00136   long           bytes;
00137   long           b_o_s;
00138   long           e_o_s;
00139   ogg_int64_t    granulepos;
00140   ogg_int64_t    packetno;     /* sequence number for decode; the framing
00141                                   knows where there's a hole in the data,
00142                                   but we need coupling so that the codec
00143                                   (which is in a seperate abstraction
00144                                   layer) also knows about the gap */
00145 } ogg_packet;
00146 
00147 typedef struct {
00148   ogg_reference *header;
00149   int            header_len;
00150   ogg_reference *body;
00151   long           body_len;
00152 } ogg_page;
00153 
00154 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
00155 
00156 IMPORT_C void  oggpack_readinit(oggpack_buffer *b,ogg_reference *r);
00157 IMPORT_C long  oggpack_look(oggpack_buffer *b,int bits);
00158 IMPORT_C void  oggpack_adv(oggpack_buffer *b,int bits);
00159 IMPORT_C long  oggpack_read(oggpack_buffer *b,int bits);
00160 IMPORT_C long  oggpack_bytes(oggpack_buffer *b);
00161 IMPORT_C long  oggpack_bits(oggpack_buffer *b);
00162 IMPORT_C int   oggpack_eop(oggpack_buffer *b);
00163 
00164 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
00165 
00166 IMPORT_C ogg_sync_state *ogg_sync_create(void);
00167 IMPORT_C int      ogg_sync_destroy(ogg_sync_state *oy);
00168 IMPORT_C int      ogg_sync_reset(ogg_sync_state *oy);
00169 
00170 IMPORT_C unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long size);
00171 IMPORT_C int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
00172 IMPORT_C long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
00173 IMPORT_C int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
00174 IMPORT_C int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
00175 IMPORT_C int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
00176 IMPORT_C int      ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
00177 
00178 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
00179 
00180 IMPORT_C ogg_stream_state *ogg_stream_create(int serialno);
00181 IMPORT_C int      ogg_stream_destroy(ogg_stream_state *os);
00182 IMPORT_C int      ogg_stream_reset(ogg_stream_state *os);
00183 IMPORT_C int      ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
00184 IMPORT_C int      ogg_stream_eos(ogg_stream_state *os);
00185 
00186 IMPORT_C int      ogg_page_checksum_set(ogg_page *og);
00187 
00188 IMPORT_C int      ogg_page_version(ogg_page *og);
00189 IMPORT_C int      ogg_page_continued(ogg_page *og);
00190 IMPORT_C int      ogg_page_bos(ogg_page *og);
00191 IMPORT_C int      ogg_page_eos(ogg_page *og);
00192 IMPORT_C ogg_int64_t  ogg_page_granulepos(ogg_page *og);
00193 IMPORT_C ogg_uint32_t ogg_page_serialno(ogg_page *og);
00194 IMPORT_C ogg_uint32_t ogg_page_pageno(ogg_page *og);
00195 IMPORT_C int      ogg_page_packets(ogg_page *og);
00196 IMPORT_C int      ogg_page_getbuffer(ogg_page *og, unsigned char **buffer);
00197 
00198 IMPORT_C int      ogg_packet_release(ogg_packet *op);
00199 IMPORT_C int      ogg_page_release(ogg_page *og);
00200 
00201 IMPORT_C void     ogg_page_dup(ogg_page *d, ogg_page *s);
00202 
00203 /* Ogg BITSTREAM PRIMITIVES: return codes ***************************/
00204 
00205 #define  OGG_SUCCESS   0
00206 
00207 #define  OGG_HOLE     -10
00208 #define  OGG_SPAN     -11
00209 #define  OGG_EVERSION -12
00210 #define  OGG_ESERIAL  -13
00211 #define  OGG_EINVAL   -14
00212 #define  OGG_EEOS     -15
00213 
00214 
00215 #ifdef __cplusplus
00216 }
00217 #endif
00218 
00219 #endif  /* _OGG_H */

Generated by  doxygen 1.6.2