Main Page | Class List | Directories | File List | Class Members | File Members

ogg.h

Go to the documentation of this file.
00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggVorbis 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 OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
00009  * by the Xiph.Org Foundation http://www.xiph.org/                  *
00010  *                                                                  *
00011  ********************************************************************
00012 
00013  function: toplevel libogg include
00014  last mod: $Id: ogg.h 7188 2004-07-20 07:26:04Z xiphmont $
00015 
00016  ********************************************************************/
00017 #ifndef _OGG_H
00018 #define _OGG_H
00019 
00020 #ifdef __cplusplus
00021 extern "C" {
00022 #endif
00023 
00024 #include <ogg/os_types.h>
00025 
00026 typedef struct {
00027   long endbyte;
00028   int  endbit;
00029 
00030   unsigned char *buffer;
00031   unsigned char *ptr;
00032   long storage;
00033 } oggpack_buffer;
00034 
00035 /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
00036 
00037 typedef struct {
00038   unsigned char *header;
00039   long header_len;
00040   unsigned char *body;
00041   long body_len;
00042 } ogg_page;
00043 
00044 /* ogg_stream_state contains the current encode/decode state of a logical
00045    Ogg bitstream **********************************************************/
00046 
00047 typedef struct {
00048   unsigned char   *body_data;    /* bytes from packet bodies */
00049   long    body_storage;          /* storage elements allocated */
00050   long    body_fill;             /* elements stored; fill mark */
00051   long    body_returned;         /* elements of fill returned */
00052 
00053 
00054   int     *lacing_vals;      /* The values that will go to the segment table */
00055   ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
00056                                 this way, but it is simple coupled to the
00057                                 lacing fifo */
00058   long    lacing_storage;
00059   long    lacing_fill;
00060   long    lacing_packet;
00061   long    lacing_returned;
00062 
00063   unsigned char    header[282];      /* working space for header encode */
00064   int              header_fill;
00065 
00066   int     e_o_s;          /* set when we have buffered the last packet in the
00067                              logical bitstream */
00068   int     b_o_s;          /* set after we've written the initial page
00069                              of a logical bitstream */
00070   long    serialno;
00071   long    pageno;
00072   ogg_int64_t  packetno;      /* sequence number for decode; the framing
00073                              knows where there's a hole in the data,
00074                              but we need coupling so that the codec
00075                              (which is in a seperate abstraction
00076                              layer) also knows about the gap */
00077   ogg_int64_t   granulepos;
00078 
00079 } ogg_stream_state;
00080 
00081 /* ogg_packet is used to encapsulate the data and metadata belonging
00082    to a single raw Ogg/Vorbis packet *************************************/
00083 
00084 typedef struct {
00085   unsigned char *packet;
00086   long  bytes;
00087   long  b_o_s;
00088   long  e_o_s;
00089 
00090   ogg_int64_t  granulepos;
00091   
00092   ogg_int64_t  packetno;     /* sequence number for decode; the framing
00093                                 knows where there's a hole in the data,
00094                                 but we need coupling so that the codec
00095                                 (which is in a seperate abstraction
00096                                 layer) also knows about the gap */
00097 } ogg_packet;
00098 
00099 typedef struct {
00100   unsigned char *data;
00101   int storage;
00102   int fill;
00103   int returned;
00104 
00105   int unsynced;
00106   int headerbytes;
00107   int bodybytes;
00108 } ogg_sync_state;
00109 
00110 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
00111 
00112 extern void  oggpack_writeinit(oggpack_buffer *b);
00113 extern void  oggpack_writetrunc(oggpack_buffer *b,long bits);
00114 extern void  oggpack_writealign(oggpack_buffer *b);
00115 extern void  oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
00116 extern void  oggpack_reset(oggpack_buffer *b);
00117 extern void  oggpack_writeclear(oggpack_buffer *b);
00118 extern void  oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
00119 extern void  oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
00120 extern long  oggpack_look(oggpack_buffer *b,int bits);
00121 extern long  oggpack_look1(oggpack_buffer *b);
00122 extern void  oggpack_adv(oggpack_buffer *b,int bits);
00123 extern void  oggpack_adv1(oggpack_buffer *b);
00124 extern long  oggpack_read(oggpack_buffer *b,int bits);
00125 extern long  oggpack_read1(oggpack_buffer *b);
00126 extern long  oggpack_bytes(oggpack_buffer *b);
00127 extern long  oggpack_bits(oggpack_buffer *b);
00128 extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
00129 
00130 extern void  oggpackB_writeinit(oggpack_buffer *b);
00131 extern void  oggpackB_writetrunc(oggpack_buffer *b,long bits);
00132 extern void  oggpackB_writealign(oggpack_buffer *b);
00133 extern void  oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
00134 extern void  oggpackB_reset(oggpack_buffer *b);
00135 extern void  oggpackB_writeclear(oggpack_buffer *b);
00136 extern void  oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
00137 extern void  oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
00138 extern long  oggpackB_look(oggpack_buffer *b,int bits);
00139 extern long  oggpackB_look1(oggpack_buffer *b);
00140 extern void  oggpackB_adv(oggpack_buffer *b,int bits);
00141 extern void  oggpackB_adv1(oggpack_buffer *b);
00142 extern long  oggpackB_read(oggpack_buffer *b,int bits);
00143 extern long  oggpackB_read1(oggpack_buffer *b);
00144 extern long  oggpackB_bytes(oggpack_buffer *b);
00145 extern long  oggpackB_bits(oggpack_buffer *b);
00146 extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
00147 
00148 /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
00149 
00150 extern int      ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
00151 extern int      ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
00152 extern int      ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
00153 
00154 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
00155 
00156 extern int      ogg_sync_init(ogg_sync_state *oy);
00157 extern int      ogg_sync_clear(ogg_sync_state *oy);
00158 extern int      ogg_sync_reset(ogg_sync_state *oy);
00159 extern int      ogg_sync_destroy(ogg_sync_state *oy);
00160 
00161 extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
00162 extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
00163 extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
00164 extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
00165 extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
00166 extern int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
00167 extern int      ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
00168 
00169 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
00170 
00171 extern int      ogg_stream_init(ogg_stream_state *os,int serialno);
00172 extern int      ogg_stream_clear(ogg_stream_state *os);
00173 extern int      ogg_stream_reset(ogg_stream_state *os);
00174 extern int      ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
00175 extern int      ogg_stream_destroy(ogg_stream_state *os);
00176 extern int      ogg_stream_eos(ogg_stream_state *os);
00177 
00178 extern void     ogg_page_checksum_set(ogg_page *og);
00179 
00180 extern int      ogg_page_version(ogg_page *og);
00181 extern int      ogg_page_continued(ogg_page *og);
00182 extern int      ogg_page_bos(ogg_page *og);
00183 extern int      ogg_page_eos(ogg_page *og);
00184 extern ogg_int64_t  ogg_page_granulepos(ogg_page *og);
00185 extern int      ogg_page_serialno(ogg_page *og);
00186 extern long     ogg_page_pageno(ogg_page *og);
00187 extern int      ogg_page_packets(ogg_page *og);
00188 
00189 extern void     ogg_packet_clear(ogg_packet *op);
00190 
00191 
00192 #ifdef __cplusplus
00193 }
00194 #endif
00195 
00196 #endif  /* _OGG_H */
00197 
00198 
00199 
00200 
00201 
00202 

© sourcejam.com 2005-2008