VisualC/vorbis/include/ogg/ogg.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 18 Jan 2011 11:11:21 -0800
changeset 495 b4d178cd982d
child 532 b8e8ae4852b2
permissions -rwxr-xr-x
Updated version to 1.2.12
slouken@495
     1
/********************************************************************
slouken@495
     2
 *                                                                  *
slouken@495
     3
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
slouken@495
     4
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
slouken@495
     5
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
slouken@495
     6
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
slouken@495
     7
 *                                                                  *
slouken@495
     8
 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
slouken@495
     9
 * by the Xiph.Org Foundation http://www.xiph.org/                  *
slouken@495
    10
 *                                                                  *
slouken@495
    11
 ********************************************************************
slouken@495
    12
slouken@495
    13
 function: toplevel libogg include
slouken@495
    14
 last mod: $Id: ogg.h 16051 2009-05-27 05:00:06Z xiphmont $
slouken@495
    15
slouken@495
    16
 ********************************************************************/
slouken@495
    17
#ifndef _OGG_H
slouken@495
    18
#define _OGG_H
slouken@495
    19
slouken@495
    20
#ifdef __cplusplus
slouken@495
    21
extern "C" {
slouken@495
    22
#endif
slouken@495
    23
slouken@495
    24
#include <stddef.h>
slouken@495
    25
#include <ogg/os_types.h>
slouken@495
    26
slouken@495
    27
typedef struct {
slouken@495
    28
  void *iov_base;
slouken@495
    29
  size_t iov_len;
slouken@495
    30
} ogg_iovec_t;
slouken@495
    31
slouken@495
    32
typedef struct {
slouken@495
    33
  long endbyte;
slouken@495
    34
  int  endbit;
slouken@495
    35
slouken@495
    36
  unsigned char *buffer;
slouken@495
    37
  unsigned char *ptr;
slouken@495
    38
  long storage;
slouken@495
    39
} oggpack_buffer;
slouken@495
    40
slouken@495
    41
/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
slouken@495
    42
slouken@495
    43
typedef struct {
slouken@495
    44
  unsigned char *header;
slouken@495
    45
  long header_len;
slouken@495
    46
  unsigned char *body;
slouken@495
    47
  long body_len;
slouken@495
    48
} ogg_page;
slouken@495
    49
slouken@495
    50
/* ogg_stream_state contains the current encode/decode state of a logical
slouken@495
    51
   Ogg bitstream **********************************************************/
slouken@495
    52
slouken@495
    53
typedef struct {
slouken@495
    54
  unsigned char   *body_data;    /* bytes from packet bodies */
slouken@495
    55
  long    body_storage;          /* storage elements allocated */
slouken@495
    56
  long    body_fill;             /* elements stored; fill mark */
slouken@495
    57
  long    body_returned;         /* elements of fill returned */
slouken@495
    58
slouken@495
    59
slouken@495
    60
  int     *lacing_vals;      /* The values that will go to the segment table */
slouken@495
    61
  ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
slouken@495
    62
                                this way, but it is simple coupled to the
slouken@495
    63
                                lacing fifo */
slouken@495
    64
  long    lacing_storage;
slouken@495
    65
  long    lacing_fill;
slouken@495
    66
  long    lacing_packet;
slouken@495
    67
  long    lacing_returned;
slouken@495
    68
slouken@495
    69
  unsigned char    header[282];      /* working space for header encode */
slouken@495
    70
  int              header_fill;
slouken@495
    71
slouken@495
    72
  int     e_o_s;          /* set when we have buffered the last packet in the
slouken@495
    73
                             logical bitstream */
slouken@495
    74
  int     b_o_s;          /* set after we've written the initial page
slouken@495
    75
                             of a logical bitstream */
slouken@495
    76
  long    serialno;
slouken@495
    77
  long    pageno;
slouken@495
    78
  ogg_int64_t  packetno;  /* sequence number for decode; the framing
slouken@495
    79
                             knows where there's a hole in the data,
slouken@495
    80
                             but we need coupling so that the codec
slouken@495
    81
                             (which is in a seperate abstraction
slouken@495
    82
                             layer) also knows about the gap */
slouken@495
    83
  ogg_int64_t   granulepos;
slouken@495
    84
slouken@495
    85
} ogg_stream_state;
slouken@495
    86
slouken@495
    87
/* ogg_packet is used to encapsulate the data and metadata belonging
slouken@495
    88
   to a single raw Ogg/Vorbis packet *************************************/
slouken@495
    89
slouken@495
    90
typedef struct {
slouken@495
    91
  unsigned char *packet;
slouken@495
    92
  long  bytes;
slouken@495
    93
  long  b_o_s;
slouken@495
    94
  long  e_o_s;
slouken@495
    95
slouken@495
    96
  ogg_int64_t  granulepos;
slouken@495
    97
slouken@495
    98
  ogg_int64_t  packetno;     /* sequence number for decode; the framing
slouken@495
    99
                                knows where there's a hole in the data,
slouken@495
   100
                                but we need coupling so that the codec
slouken@495
   101
                                (which is in a seperate abstraction
slouken@495
   102
                                layer) also knows about the gap */
slouken@495
   103
} ogg_packet;
slouken@495
   104
slouken@495
   105
typedef struct {
slouken@495
   106
  unsigned char *data;
slouken@495
   107
  int storage;
slouken@495
   108
  int fill;
slouken@495
   109
  int returned;
slouken@495
   110
slouken@495
   111
  int unsynced;
slouken@495
   112
  int headerbytes;
slouken@495
   113
  int bodybytes;
slouken@495
   114
} ogg_sync_state;
slouken@495
   115
slouken@495
   116
/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
slouken@495
   117
slouken@495
   118
extern void  oggpack_writeinit(oggpack_buffer *b);
slouken@495
   119
extern int   oggpack_writecheck(oggpack_buffer *b);
slouken@495
   120
extern void  oggpack_writetrunc(oggpack_buffer *b,long bits);
slouken@495
   121
extern void  oggpack_writealign(oggpack_buffer *b);
slouken@495
   122
extern void  oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
slouken@495
   123
extern void  oggpack_reset(oggpack_buffer *b);
slouken@495
   124
extern void  oggpack_writeclear(oggpack_buffer *b);
slouken@495
   125
extern void  oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
slouken@495
   126
extern void  oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
slouken@495
   127
extern long  oggpack_look(oggpack_buffer *b,int bits);
slouken@495
   128
extern long  oggpack_look1(oggpack_buffer *b);
slouken@495
   129
extern void  oggpack_adv(oggpack_buffer *b,int bits);
slouken@495
   130
extern void  oggpack_adv1(oggpack_buffer *b);
slouken@495
   131
extern long  oggpack_read(oggpack_buffer *b,int bits);
slouken@495
   132
extern long  oggpack_read1(oggpack_buffer *b);
slouken@495
   133
extern long  oggpack_bytes(oggpack_buffer *b);
slouken@495
   134
extern long  oggpack_bits(oggpack_buffer *b);
slouken@495
   135
extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
slouken@495
   136
slouken@495
   137
extern void  oggpackB_writeinit(oggpack_buffer *b);
slouken@495
   138
extern int   oggpackB_writecheck(oggpack_buffer *b);
slouken@495
   139
extern void  oggpackB_writetrunc(oggpack_buffer *b,long bits);
slouken@495
   140
extern void  oggpackB_writealign(oggpack_buffer *b);
slouken@495
   141
extern void  oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
slouken@495
   142
extern void  oggpackB_reset(oggpack_buffer *b);
slouken@495
   143
extern void  oggpackB_writeclear(oggpack_buffer *b);
slouken@495
   144
extern void  oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
slouken@495
   145
extern void  oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
slouken@495
   146
extern long  oggpackB_look(oggpack_buffer *b,int bits);
slouken@495
   147
extern long  oggpackB_look1(oggpack_buffer *b);
slouken@495
   148
extern void  oggpackB_adv(oggpack_buffer *b,int bits);
slouken@495
   149
extern void  oggpackB_adv1(oggpack_buffer *b);
slouken@495
   150
extern long  oggpackB_read(oggpack_buffer *b,int bits);
slouken@495
   151
extern long  oggpackB_read1(oggpack_buffer *b);
slouken@495
   152
extern long  oggpackB_bytes(oggpack_buffer *b);
slouken@495
   153
extern long  oggpackB_bits(oggpack_buffer *b);
slouken@495
   154
extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
slouken@495
   155
slouken@495
   156
/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
slouken@495
   157
slouken@495
   158
extern int      ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
slouken@495
   159
extern int      ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
slouken@495
   160
                                   int count, long e_o_s, ogg_int64_t granulepos);
slouken@495
   161
extern int      ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
slouken@495
   162
extern int      ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
slouken@495
   163
slouken@495
   164
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
slouken@495
   165
slouken@495
   166
extern int      ogg_sync_init(ogg_sync_state *oy);
slouken@495
   167
extern int      ogg_sync_clear(ogg_sync_state *oy);
slouken@495
   168
extern int      ogg_sync_reset(ogg_sync_state *oy);
slouken@495
   169
extern int      ogg_sync_destroy(ogg_sync_state *oy);
slouken@495
   170
extern int      ogg_sync_check(ogg_sync_state *oy);
slouken@495
   171
slouken@495
   172
extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
slouken@495
   173
extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
slouken@495
   174
extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
slouken@495
   175
extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
slouken@495
   176
extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
slouken@495
   177
extern int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
slouken@495
   178
extern int      ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
slouken@495
   179
slouken@495
   180
/* Ogg BITSTREAM PRIMITIVES: general ***************************/
slouken@495
   181
slouken@495
   182
extern int      ogg_stream_init(ogg_stream_state *os,int serialno);
slouken@495
   183
extern int      ogg_stream_clear(ogg_stream_state *os);
slouken@495
   184
extern int      ogg_stream_reset(ogg_stream_state *os);
slouken@495
   185
extern int      ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
slouken@495
   186
extern int      ogg_stream_destroy(ogg_stream_state *os);
slouken@495
   187
extern int      ogg_stream_check(ogg_stream_state *os);
slouken@495
   188
extern int      ogg_stream_eos(ogg_stream_state *os);
slouken@495
   189
slouken@495
   190
extern void     ogg_page_checksum_set(ogg_page *og);
slouken@495
   191
slouken@495
   192
extern int      ogg_page_version(const ogg_page *og);
slouken@495
   193
extern int      ogg_page_continued(const ogg_page *og);
slouken@495
   194
extern int      ogg_page_bos(const ogg_page *og);
slouken@495
   195
extern int      ogg_page_eos(const ogg_page *og);
slouken@495
   196
extern ogg_int64_t  ogg_page_granulepos(const ogg_page *og);
slouken@495
   197
extern int      ogg_page_serialno(const ogg_page *og);
slouken@495
   198
extern long     ogg_page_pageno(const ogg_page *og);
slouken@495
   199
extern int      ogg_page_packets(const ogg_page *og);
slouken@495
   200
slouken@495
   201
extern void     ogg_packet_clear(ogg_packet *op);
slouken@495
   202
slouken@495
   203
slouken@495
   204
#ifdef __cplusplus
slouken@495
   205
}
slouken@495
   206
#endif
slouken@495
   207
slouken@495
   208
#endif  /* _OGG_H */