home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / APP / ANIPL218 / PROG / SLB / VORBIS / OGG.H < prev    next >
C/C++ Source or Header  |  2001-11-24  |  6KB  |  175 lines

  1. /********************************************************************
  2.  *                                                                  *
  3.  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
  4.  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
  5.  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  6.  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  7.  *                                                                  *
  8.  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
  9.  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
  10.  
  11.  ********************************************************************
  12.  
  13.  function: toplevel libogg include
  14.  last mod: $Id: ogg.h,v 1.11 2001/05/24 01:04:36 xiphmont Exp $
  15.  
  16.  ********************************************************************/
  17. #ifndef _OGG_H
  18. #define _OGG_H
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24. #include <ogg/os_types.h>
  25.  
  26. typedef struct {
  27.   long endbyte;
  28.   int  endbit;
  29.  
  30.   unsigned char *buffer;
  31.   unsigned char *ptr;
  32.   long storage;
  33. } oggpack_buffer;
  34.  
  35. /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
  36.  
  37. typedef struct {
  38.   unsigned char *header;
  39.   long header_len;
  40.   unsigned char *body;
  41.   long body_len;
  42. } ogg_page;
  43.  
  44. /* ogg_stream_state contains the current encode/decode state of a logical
  45.    Ogg bitstream **********************************************************/
  46.  
  47. typedef struct {
  48.   unsigned char   *body_data;    /* bytes from packet bodies */
  49.   long    body_storage;          /* storage elements allocated */
  50.   long    body_fill;             /* elements stored; fill mark */
  51.   long    body_returned;         /* elements of fill returned */
  52.  
  53.  
  54.   int     *lacing_vals;      /* The values that will go to the segment table */
  55.   ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
  56.                 this way, but it is simple coupled to the
  57.                 lacing fifo */
  58.   long    lacing_storage;
  59.   long    lacing_fill;
  60.   long    lacing_packet;
  61.   long    lacing_returned;
  62.  
  63.   unsigned char    header[282];      /* working space for header encode */
  64.   int              header_fill;
  65.  
  66.   int     e_o_s;          /* set when we have buffered the last packet in the
  67.                              logical bitstream */
  68.   int     b_o_s;          /* set after we've written the initial page
  69.                              of a logical bitstream */
  70.   long    serialno;
  71.   long    pageno;
  72.   ogg_int64_t  packetno;      /* sequence number for decode; the framing
  73.                              knows where there's a hole in the data,
  74.                              but we need coupling so that the codec
  75.                              (which is in a seperate abstraction
  76.                              layer) also knows about the gap */
  77.   ogg_int64_t   granulepos;
  78.  
  79. } ogg_stream_state;
  80.  
  81. /* ogg_packet is used to encapsulate the data and metadata belonging
  82.    to a single raw Ogg/Vorbis packet *************************************/
  83.  
  84. typedef struct {
  85.   unsigned char *packet;
  86.   long  bytes;
  87.   long  b_o_s;
  88.   long  e_o_s;
  89.  
  90.   ogg_int64_t  granulepos;
  91.   
  92.   ogg_int64_t  packetno;     /* sequence number for decode; the framing
  93.                 knows where there's a hole in the data,
  94.                 but we need coupling so that the codec
  95.                 (which is in a seperate abstraction
  96.                 layer) also knows about the gap */
  97. } ogg_packet;
  98.  
  99. typedef struct {
  100.   unsigned char *data;
  101.   int storage;
  102.   int fill;
  103.   int returned;
  104.  
  105.   int unsynced;
  106.   int headerbytes;
  107.   int bodybytes;
  108. } ogg_sync_state;
  109.  
  110. /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
  111.  
  112. extern void  oggpack_writeinit(oggpack_buffer *b);
  113. extern void  oggpack_reset(oggpack_buffer *b);
  114. extern void  oggpack_writeclear(oggpack_buffer *b);
  115. extern void  oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
  116. extern void  oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
  117. extern long  oggpack_look(oggpack_buffer *b,int bits);
  118. extern long  oggpack_look_huff(oggpack_buffer *b,int bits);
  119. extern long  oggpack_look1(oggpack_buffer *b);
  120. extern void  oggpack_adv(oggpack_buffer *b,int bits);
  121. extern int   oggpack_adv_huff(oggpack_buffer *b,int bits);
  122. extern void  oggpack_adv1(oggpack_buffer *b);
  123. extern long  oggpack_read(oggpack_buffer *b,int bits);
  124. extern long  oggpack_read1(oggpack_buffer *b);
  125. extern long  oggpack_bytes(oggpack_buffer *b);
  126. extern long  oggpack_bits(oggpack_buffer *b);
  127. extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
  128.  
  129. /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
  130.  
  131. extern int      ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
  132. extern int      ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
  133. extern int      ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
  134.  
  135. /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
  136.  
  137. extern int      ogg_sync_init(ogg_sync_state *oy);
  138. extern int      ogg_sync_clear(ogg_sync_state *oy);
  139. extern int      ogg_sync_reset(ogg_sync_state *oy);
  140. extern int    ogg_sync_destroy(ogg_sync_state *oy);
  141.  
  142. extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
  143. extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
  144. extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
  145. extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
  146. extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
  147. extern int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
  148. extern int      ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
  149.  
  150. /* Ogg BITSTREAM PRIMITIVES: general ***************************/
  151.  
  152. extern int      ogg_stream_init(ogg_stream_state *os,int serialno);
  153. extern int      ogg_stream_clear(ogg_stream_state *os);
  154. extern int      ogg_stream_reset(ogg_stream_state *os);
  155. extern int      ogg_stream_destroy(ogg_stream_state *os);
  156. extern int      ogg_stream_eos(ogg_stream_state *os);
  157.  
  158. extern int      ogg_page_version(ogg_page *og);
  159. extern int      ogg_page_continued(ogg_page *og);
  160. extern int      ogg_page_bos(ogg_page *og);
  161. extern int      ogg_page_eos(ogg_page *og);
  162. extern ogg_int64_t  ogg_page_granulepos(ogg_page *og);
  163. extern int      ogg_page_serialno(ogg_page *og);
  164. extern long     ogg_page_pageno(ogg_page *og);
  165. extern int      ogg_page_packets(ogg_page *og);
  166.  
  167. extern void     ogg_packet_clear(ogg_packet *op);
  168.  
  169.  
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173.  
  174. #endif  /* _OGG_H */
  175.