annotate osx/include/vorbis/codec.h @ 2:cc5d363db385

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