openalbridge/oggvorbis.h
author smxx
Wed, 10 Feb 2010 13:53:31 +0000
changeset 2792 a3efbf1c4500
parent 2421 a4b039ee2eb0
permissions -rw-r--r--
Engine: * Submit gear UID to script functions instead of gear pointer on gear add/delete
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     1
/********************************************************************
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     2
 *                                                                  *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     3
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     4
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     5
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     6
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     7
 *                                                                  *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     8
 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
     9
 * by the Xiph.Org Foundation http://www.xiph.org/                  *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    10
 *                                                                  *
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    11
 ********************************************************************/
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    12
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    13
#ifndef _OGGVORBIS_H
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    14
#define _OGGVORBIS_H
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    15
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    16
/*data types for ogg and vorbis that are required to be external*/
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    17
#ifndef ogg_int64_t	
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    18
#define ogg_int64_t int64_t
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    19
#endif
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    20
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    21
typedef struct {
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    22
        unsigned char *data;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    23
        int storage;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    24
        int fill;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    25
        int returned;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    26
        int unsynced;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    27
        int headerbytes;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    28
        int bodybytes;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    29
} ogg_sync_state;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    30
typedef struct vorbis_info{
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    31
        int version;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    32
        int channels;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    33
        long rate;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    34
        /* The below bitrate declarations are *hints*.
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    35
         Combinations of the three values carry the following implications: all three set to the same value: implies a fixed rate bitstream
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    36
         only nominal set: implies a VBR stream that averages the nominal bitrate.  No hard upper/lower limit
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    37
         upper and or lower set: implies a VBR bitstream that obeys the bitrate limits. nominal may also be set to give a nominal rate.
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    38
         none set: the coder does not care to speculate. */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    39
        long bitrate_upper;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    40
        long bitrate_nominal;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    41
        long bitrate_lower;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    42
        long bitrate_window;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    43
        void *codec_setup;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    44
} vorbis_info;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    45
typedef struct vorbis_comment{
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    46
        /* unlimited user comment fields.  libvorbis writes 'libvorbis' whatever vendor is set to in encode */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    47
        char **user_comments;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    48
        int   *comment_lengths;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    49
        int    comments;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    50
        char  *vendor;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    51
} vorbis_comment;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    52
typedef struct {
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    53
        unsigned char   *body_data;    /* bytes from packet bodies */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    54
        long    body_storage;          /* storage elements allocated */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    55
        long    body_fill;             /* elements stored; fill mark */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    56
        long    body_returned;         /* elements of fill returned */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    57
        int     *lacing_vals;      	   /* The values that will go to the segment table */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    58
        ogg_int64_t *granule_vals; 
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    59
        /* granulepos values for headers. Not compact this way, but it is simple coupled to the lacing fifo */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    60
        long    lacing_storage;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    61
        long    lacing_fill;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    62
        long    lacing_packet;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    63
        long    lacing_returned;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    64
        unsigned char    header[282];      /* working space for header encode */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    65
        int              header_fill;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    66
        int     e_o_s;          /* set when we have buffered the last packet in the logical bitstream */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    67
        int     b_o_s;          /* set after we've written the initial page of a logical bitstream */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    68
        long    serialno;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    69
        long    pageno;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    70
        ogg_int64_t  packetno;      
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    71
        /* sequence number for decode; the framing knows where there's a hole in the data,
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    72
         but we need coupling so that the codec (which is in a seperate abstraction layer) also knows about the gap */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    73
        ogg_int64_t   granulepos;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    74
} ogg_stream_state;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    75
typedef struct vorbis_dsp_state{
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    76
        int analysisp;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    77
        vorbis_info *vi;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    78
        float **pcm;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    79
        float **pcmret;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    80
        int  pcm_storage;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    81
        int  pcm_current;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    82
        int  pcm_returned;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    83
        int  preextrapolate;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    84
        int  eofflag;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    85
        long lW;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    86
        long W;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    87
        long nW;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    88
        long centerW;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    89
        ogg_int64_t granulepos;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    90
        ogg_int64_t sequence;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    91
        ogg_int64_t glue_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    92
        ogg_int64_t time_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    93
        ogg_int64_t floor_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    94
        ogg_int64_t res_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    95
        void       *backend_state;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    96
} vorbis_dsp_state;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
    97
typedef struct {
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    98
        long endbyte;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
    99
        int  endbit;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   100
        unsigned char *buffer;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   101
        unsigned char *ptr;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   102
        long storage;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   103
} oggpack_buffer;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   104
typedef struct vorbis_block{
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   105
        /* necessary stream state for linking to the framing abstraction */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   106
        float **pcm;       /* this is a pointer into local storage */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   107
        oggpack_buffer opb;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   108
        long  lW;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   109
        long  W;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   110
        long  nW;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   111
        int   pcmend;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   112
        int   mode;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   113
        int   eofflag;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   114
        ogg_int64_t granulepos;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   115
        ogg_int64_t sequence;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   116
        vorbis_dsp_state *vd; /* For read-only access of configuration */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   117
        /* local storage to avoid remallocing; it's up to the mapping to structure it */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   118
        void  *localstore;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   119
        long  localtop;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   120
        long  localalloc;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   121
        long  totaluse;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   122
        struct alloc_chain *reap;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   123
        /* bitmetrics for the frame */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   124
        long glue_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   125
        long time_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   126
        long floor_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   127
        long res_bits;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   128
        void *internal;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   129
} vorbis_block;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   130
typedef struct {
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   131
        size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   132
        int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   133
        int    (*close_func) (void *datasource);
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   134
        long   (*tell_func)  (void *datasource);
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   135
} ov_callbacks;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   136
typedef struct OggVorbis_File {
2421
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   137
        void            *datasource; /* Pointer to a FILE *, etc. */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   138
        int              seekable;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   139
        ogg_int64_t      offset;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   140
        ogg_int64_t      end;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   141
        ogg_sync_state   oy;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   142
        /* If the FILE handle isn't seekable (eg, a pipe), only the current stream appears */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   143
        int              links;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   144
        ogg_int64_t     *offsets;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   145
        ogg_int64_t     *dataoffsets;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   146
        long            *serialnos;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   147
        ogg_int64_t     *pcmlengths; 
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   148
        /* overloaded to maintain binary
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   149
         compatability; x2 size, stores both
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   150
         beginning and end values */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   151
        vorbis_info     *vi;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   152
        vorbis_comment  *vc;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   153
        /* Decoding working state local storage */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   154
        ogg_int64_t      pcm_offset;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   155
        int              ready_state;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   156
        long             current_serialno;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   157
        int              current_link;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   158
        double           bittrack;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   159
        double           samptrack;
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   160
        ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   161
        vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   162
        vorbis_block     vb; /* local working space for packet->PCM decode */
a4b039ee2eb0 hopefully last fix
koda
parents: 2266
diff changeset
   163
        ov_callbacks callbacks;
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   164
} OggVorbis_File;
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   165
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   166
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   167
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
2266
289dc8e51210 switch to ov_fopen for simplicity
koda
parents: 2265
diff changeset
   168
extern int ov_fopen(char *path,OggVorbis_File *vf);
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   169
extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream);
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   170
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   171
extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   172
extern vorbis_comment *ov_comment(OggVorbis_File *f, int num);
2257
7eb31efcfb9b updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents: 2213
diff changeset
   173
extern int ov_clear(OggVorbis_File *vf);
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   174
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents:
diff changeset
   175
#endif /*_OGGVORBIS_H*/