VisualC/external/include/vorbis/codec.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 09 Jan 2012 04:20:54 -0500
changeset 556 2686e67b59fd
parent 532 VisualC/vorbis/include/vorbis/codec.h@b8e8ae4852b2
child 937 3797c39725bf
permissions -rwxr-xr-x
Moved external libraries into the "external" directory and added x64 build configuration.
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-2001             *
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: libvorbis codec headers
slouken@532
    14
 last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $
slouken@495
    15
slouken@495
    16
 ********************************************************************/
slouken@495
    17
slouken@495
    18
#ifndef _vorbis_codec_h_
slouken@495
    19
#define _vorbis_codec_h_
slouken@495
    20
slouken@495
    21
#ifdef __cplusplus
slouken@495
    22
extern "C"
slouken@495
    23
{
slouken@495
    24
#endif /* __cplusplus */
slouken@495
    25
slouken@495
    26
#include <ogg/ogg.h>
slouken@495
    27
slouken@495
    28
typedef struct vorbis_info{
slouken@495
    29
  int version;
slouken@495
    30
  int channels;
slouken@495
    31
  long rate;
slouken@495
    32
slouken@495
    33
  /* The below bitrate declarations are *hints*.
slouken@495
    34
     Combinations of the three values carry the following implications:
slouken@495
    35
slouken@495
    36
     all three set to the same value:
slouken@495
    37
       implies a fixed rate bitstream
slouken@495
    38
     only nominal set:
slouken@495
    39
       implies a VBR stream that averages the nominal bitrate.  No hard
slouken@495
    40
       upper/lower limit
slouken@495
    41
     upper and or lower set:
slouken@495
    42
       implies a VBR bitstream that obeys the bitrate limits. nominal
slouken@495
    43
       may also be set to give a nominal rate.
slouken@495
    44
     none set:
slouken@495
    45
       the coder does not care to speculate.
slouken@495
    46
  */
slouken@495
    47
slouken@495
    48
  long bitrate_upper;
slouken@495
    49
  long bitrate_nominal;
slouken@495
    50
  long bitrate_lower;
slouken@495
    51
  long bitrate_window;
slouken@495
    52
slouken@495
    53
  void *codec_setup;
slouken@495
    54
} vorbis_info;
slouken@495
    55
slouken@495
    56
/* vorbis_dsp_state buffers the current vorbis audio
slouken@495
    57
   analysis/synthesis state.  The DSP state belongs to a specific
slouken@495
    58
   logical bitstream ****************************************************/
slouken@495
    59
typedef struct vorbis_dsp_state{
slouken@495
    60
  int analysisp;
slouken@495
    61
  vorbis_info *vi;
slouken@495
    62
slouken@495
    63
  float **pcm;
slouken@495
    64
  float **pcmret;
slouken@495
    65
  int      pcm_storage;
slouken@495
    66
  int      pcm_current;
slouken@495
    67
  int      pcm_returned;
slouken@495
    68
slouken@495
    69
  int  preextrapolate;
slouken@495
    70
  int  eofflag;
slouken@495
    71
slouken@495
    72
  long lW;
slouken@495
    73
  long W;
slouken@495
    74
  long nW;
slouken@495
    75
  long centerW;
slouken@495
    76
slouken@495
    77
  ogg_int64_t granulepos;
slouken@495
    78
  ogg_int64_t sequence;
slouken@495
    79
slouken@495
    80
  ogg_int64_t glue_bits;
slouken@495
    81
  ogg_int64_t time_bits;
slouken@495
    82
  ogg_int64_t floor_bits;
slouken@495
    83
  ogg_int64_t res_bits;
slouken@495
    84
slouken@495
    85
  void       *backend_state;
slouken@495
    86
} vorbis_dsp_state;
slouken@495
    87
slouken@495
    88
typedef struct vorbis_block{
slouken@495
    89
  /* necessary stream state for linking to the framing abstraction */
slouken@495
    90
  float  **pcm;       /* this is a pointer into local storage */
slouken@495
    91
  oggpack_buffer opb;
slouken@495
    92
slouken@495
    93
  long  lW;
slouken@495
    94
  long  W;
slouken@495
    95
  long  nW;
slouken@495
    96
  int   pcmend;
slouken@495
    97
  int   mode;
slouken@495
    98
slouken@495
    99
  int         eofflag;
slouken@495
   100
  ogg_int64_t granulepos;
slouken@495
   101
  ogg_int64_t sequence;
slouken@495
   102
  vorbis_dsp_state *vd; /* For read-only access of configuration */
slouken@495
   103
slouken@495
   104
  /* local storage to avoid remallocing; it's up to the mapping to
slouken@495
   105
     structure it */
slouken@495
   106
  void               *localstore;
slouken@495
   107
  long                localtop;
slouken@495
   108
  long                localalloc;
slouken@495
   109
  long                totaluse;
slouken@495
   110
  struct alloc_chain *reap;
slouken@495
   111
slouken@495
   112
  /* bitmetrics for the frame */
slouken@495
   113
  long glue_bits;
slouken@495
   114
  long time_bits;
slouken@495
   115
  long floor_bits;
slouken@495
   116
  long res_bits;
slouken@495
   117
slouken@495
   118
  void *internal;
slouken@495
   119
slouken@495
   120
} vorbis_block;
slouken@495
   121
slouken@495
   122
/* vorbis_block is a single block of data to be processed as part of
slouken@495
   123
the analysis/synthesis stream; it belongs to a specific logical
slouken@532
   124
bitstream, but is independent from other vorbis_blocks belonging to
slouken@495
   125
that logical bitstream. *************************************************/
slouken@495
   126
slouken@495
   127
struct alloc_chain{
slouken@495
   128
  void *ptr;
slouken@495
   129
  struct alloc_chain *next;
slouken@495
   130
};
slouken@495
   131
slouken@495
   132
/* vorbis_info contains all the setup information specific to the
slouken@495
   133
   specific compression/decompression mode in progress (eg,
slouken@495
   134
   psychoacoustic settings, channel setup, options, codebook
slouken@495
   135
   etc). vorbis_info and substructures are in backends.h.
slouken@495
   136
*********************************************************************/
slouken@495
   137
slouken@495
   138
/* the comments are not part of vorbis_info so that vorbis_info can be
slouken@495
   139
   static storage */
slouken@495
   140
typedef struct vorbis_comment{
slouken@495
   141
  /* unlimited user comment fields.  libvorbis writes 'libvorbis'
slouken@495
   142
     whatever vendor is set to in encode */
slouken@495
   143
  char **user_comments;
slouken@495
   144
  int   *comment_lengths;
slouken@495
   145
  int    comments;
slouken@495
   146
  char  *vendor;
slouken@495
   147
slouken@495
   148
} vorbis_comment;
slouken@495
   149
slouken@495
   150
slouken@495
   151
/* libvorbis encodes in two abstraction layers; first we perform DSP
slouken@495
   152
   and produce a packet (see docs/analysis.txt).  The packet is then
slouken@495
   153
   coded into a framed OggSquish bitstream by the second layer (see
slouken@495
   154
   docs/framing.txt).  Decode is the reverse process; we sync/frame
slouken@495
   155
   the bitstream and extract individual packets, then decode the
slouken@495
   156
   packet back into PCM audio.
slouken@495
   157
slouken@495
   158
   The extra framing/packetizing is used in streaming formats, such as
slouken@495
   159
   files.  Over the net (such as with UDP), the framing and
slouken@495
   160
   packetization aren't necessary as they're provided by the transport
slouken@495
   161
   and the streaming layer is not used */
slouken@495
   162
slouken@495
   163
/* Vorbis PRIMITIVES: general ***************************************/
slouken@495
   164
slouken@495
   165
extern void     vorbis_info_init(vorbis_info *vi);
slouken@495
   166
extern void     vorbis_info_clear(vorbis_info *vi);
slouken@495
   167
extern int      vorbis_info_blocksize(vorbis_info *vi,int zo);
slouken@495
   168
extern void     vorbis_comment_init(vorbis_comment *vc);
slouken@495
   169
extern void     vorbis_comment_add(vorbis_comment *vc, const char *comment);
slouken@495
   170
extern void     vorbis_comment_add_tag(vorbis_comment *vc,
slouken@495
   171
                                       const char *tag, const char *contents);
slouken@495
   172
extern char    *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count);
slouken@495
   173
extern int      vorbis_comment_query_count(vorbis_comment *vc, const char *tag);
slouken@495
   174
extern void     vorbis_comment_clear(vorbis_comment *vc);
slouken@495
   175
slouken@495
   176
extern int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
slouken@495
   177
extern int      vorbis_block_clear(vorbis_block *vb);
slouken@495
   178
extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
slouken@495
   179
extern double   vorbis_granule_time(vorbis_dsp_state *v,
slouken@495
   180
                                    ogg_int64_t granulepos);
slouken@495
   181
slouken@495
   182
extern const char *vorbis_version_string(void);
slouken@495
   183
slouken@495
   184
/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
slouken@495
   185
slouken@495
   186
extern int      vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
slouken@495
   187
extern int      vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
slouken@495
   188
extern int      vorbis_analysis_headerout(vorbis_dsp_state *v,
slouken@495
   189
                                          vorbis_comment *vc,
slouken@495
   190
                                          ogg_packet *op,
slouken@495
   191
                                          ogg_packet *op_comm,
slouken@495
   192
                                          ogg_packet *op_code);
slouken@495
   193
extern float  **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
slouken@495
   194
extern int      vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
slouken@495
   195
extern int      vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
slouken@495
   196
extern int      vorbis_analysis(vorbis_block *vb,ogg_packet *op);
slouken@495
   197
slouken@495
   198
extern int      vorbis_bitrate_addblock(vorbis_block *vb);
slouken@495
   199
extern int      vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,
slouken@495
   200
                                           ogg_packet *op);
slouken@495
   201
slouken@495
   202
/* Vorbis PRIMITIVES: synthesis layer *******************************/
slouken@495
   203
extern int      vorbis_synthesis_idheader(ogg_packet *op);
slouken@495
   204
extern int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
slouken@495
   205
                                          ogg_packet *op);
slouken@495
   206
slouken@495
   207
extern int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
slouken@495
   208
extern int      vorbis_synthesis_restart(vorbis_dsp_state *v);
slouken@495
   209
extern int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
slouken@495
   210
extern int      vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
slouken@495
   211
extern int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
slouken@495
   212
extern int      vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
slouken@495
   213
extern int      vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm);
slouken@495
   214
extern int      vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
slouken@495
   215
extern long     vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
slouken@495
   216
slouken@495
   217
extern int      vorbis_synthesis_halfrate(vorbis_info *v,int flag);
slouken@495
   218
extern int      vorbis_synthesis_halfrate_p(vorbis_info *v);
slouken@495
   219
slouken@495
   220
/* Vorbis ERRORS and return codes ***********************************/
slouken@495
   221
slouken@495
   222
#define OV_FALSE      -1
slouken@495
   223
#define OV_EOF        -2
slouken@495
   224
#define OV_HOLE       -3
slouken@495
   225
slouken@495
   226
#define OV_EREAD      -128
slouken@495
   227
#define OV_EFAULT     -129
slouken@495
   228
#define OV_EIMPL      -130
slouken@495
   229
#define OV_EINVAL     -131
slouken@495
   230
#define OV_ENOTVORBIS -132
slouken@495
   231
#define OV_EBADHEADER -133
slouken@495
   232
#define OV_EVERSION   -134
slouken@495
   233
#define OV_ENOTAUDIO  -135
slouken@495
   234
#define OV_EBADPACKET -136
slouken@495
   235
#define OV_EBADLINK   -137
slouken@495
   236
#define OV_ENOSEEK    -138
slouken@495
   237
slouken@495
   238
#ifdef __cplusplus
slouken@495
   239
}
slouken@495
   240
#endif /* __cplusplus */
slouken@495
   241
slouken@495
   242
#endif
slouken@495
   243