Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# 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-2001             *
    00009  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
    00010
    00011  ********************************************************************
    00012
    00013  function: toplevel libogg include
    00014  last mod: $Id: ogg.h,v 1.2 2004/10/01 03:52:02 Assassin Exp $
    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_reset(oggpack_buffer *b);
    00114 extern void  oggpack_writeclear(oggpack_buffer *b);
    00115 extern void  oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
    00116 extern void  oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
    00117 extern long  oggpack_look(oggpack_buffer *b,int bits);
    00118 extern long  oggpack_look_huff(oggpack_buffer *b,int bits);
    00119 extern long  oggpack_look1(oggpack_buffer *b);
    00120 extern void  oggpack_adv(oggpack_buffer *b,int bits);
    00121 extern int   oggpack_adv_huff(oggpack_buffer *b,int bits);
    00122 extern void  oggpack_adv1(oggpack_buffer *b);
    00123 extern long  oggpack_read(oggpack_buffer *b,int bits);
    00124 extern long  oggpack_read1(oggpack_buffer *b);
    00125 extern long  oggpack_bytes(oggpack_buffer *b);
    00126 extern long  oggpack_bits(oggpack_buffer *b);
    00127 extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
    00128
    00129 /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
    00130
    00131 extern int      ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
    00132 extern int      ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
    00133 extern int      ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
    00134
    00135 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
    00136
    00137 extern int      ogg_sync_init(ogg_sync_state *oy);
    00138 extern int      ogg_sync_clear(ogg_sync_state *oy);
    00139 extern int      ogg_sync_reset(ogg_sync_state *oy);
    00140 extern int  ogg_sync_destroy(ogg_sync_state *oy);
    00141
    00142 extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
    00143 extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
    00144 extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
    00145 extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
    00146 extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
    00147 extern int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
    00148 extern int      ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
    00149
    00150 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
    00151
    00152 extern int      ogg_stream_init(ogg_stream_state *os,int serialno);
    00153 extern int      ogg_stream_clear(ogg_stream_state *os);
    00154 extern int      ogg_stream_reset(ogg_stream_state *os);
    00155 extern int      ogg_stream_destroy(ogg_stream_state *os);
    00156 extern int      ogg_stream_eos(ogg_stream_state *os);
    00157
    00158 extern int      ogg_page_version(ogg_page *og);
    00159 extern int      ogg_page_continued(ogg_page *og);
    00160 extern int      ogg_page_bos(ogg_page *og);
    00161 extern int      ogg_page_eos(ogg_page *og);
    00162 extern ogg_int64_t  ogg_page_granulepos(ogg_page *og);
    00163 extern int      ogg_page_serialno(ogg_page *og);
    00164 extern long     ogg_page_pageno(ogg_page *og);
    00165 extern int      ogg_page_packets(ogg_page *og);
    00166
    00167 extern void     ogg_packet_clear(ogg_packet *op);
    00168
    00169
    00170 #ifdef __cplusplus
    00171 }
    00172 #endif
    00173
    00174 #endif  /* _OGG_H */