dbf-halloween2015
diff libs/vorbis/codec.h @ 1:c3f5c32cb210
barfed all the libraries in the source tree to make porting easier
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 01 Nov 2015 00:36:56 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/vorbis/codec.h Sun Nov 01 00:36:56 2015 +0200 1.3 @@ -0,0 +1,243 @@ 1.4 +/******************************************************************** 1.5 + * * 1.6 + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 1.7 + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 1.8 + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 1.9 + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 1.10 + * * 1.11 + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * 1.12 + * by the Xiph.Org Foundation http://www.xiph.org/ * 1.13 + 1.14 + ******************************************************************** 1.15 + 1.16 + function: libvorbis codec headers 1.17 + last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $ 1.18 + 1.19 + ********************************************************************/ 1.20 + 1.21 +#ifndef _vorbis_codec_h_ 1.22 +#define _vorbis_codec_h_ 1.23 + 1.24 +#ifdef __cplusplus 1.25 +extern "C" 1.26 +{ 1.27 +#endif /* __cplusplus */ 1.28 + 1.29 +#include <ogg/ogg.h> 1.30 + 1.31 +typedef struct vorbis_info{ 1.32 + int version; 1.33 + int channels; 1.34 + long rate; 1.35 + 1.36 + /* The below bitrate declarations are *hints*. 1.37 + Combinations of the three values carry the following implications: 1.38 + 1.39 + all three set to the same value: 1.40 + implies a fixed rate bitstream 1.41 + only nominal set: 1.42 + implies a VBR stream that averages the nominal bitrate. No hard 1.43 + upper/lower limit 1.44 + upper and or lower set: 1.45 + implies a VBR bitstream that obeys the bitrate limits. nominal 1.46 + may also be set to give a nominal rate. 1.47 + none set: 1.48 + the coder does not care to speculate. 1.49 + */ 1.50 + 1.51 + long bitrate_upper; 1.52 + long bitrate_nominal; 1.53 + long bitrate_lower; 1.54 + long bitrate_window; 1.55 + 1.56 + void *codec_setup; 1.57 +} vorbis_info; 1.58 + 1.59 +/* vorbis_dsp_state buffers the current vorbis audio 1.60 + analysis/synthesis state. The DSP state belongs to a specific 1.61 + logical bitstream ****************************************************/ 1.62 +typedef struct vorbis_dsp_state{ 1.63 + int analysisp; 1.64 + vorbis_info *vi; 1.65 + 1.66 + float **pcm; 1.67 + float **pcmret; 1.68 + int pcm_storage; 1.69 + int pcm_current; 1.70 + int pcm_returned; 1.71 + 1.72 + int preextrapolate; 1.73 + int eofflag; 1.74 + 1.75 + long lW; 1.76 + long W; 1.77 + long nW; 1.78 + long centerW; 1.79 + 1.80 + ogg_int64_t granulepos; 1.81 + ogg_int64_t sequence; 1.82 + 1.83 + ogg_int64_t glue_bits; 1.84 + ogg_int64_t time_bits; 1.85 + ogg_int64_t floor_bits; 1.86 + ogg_int64_t res_bits; 1.87 + 1.88 + void *backend_state; 1.89 +} vorbis_dsp_state; 1.90 + 1.91 +typedef struct vorbis_block{ 1.92 + /* necessary stream state for linking to the framing abstraction */ 1.93 + float **pcm; /* this is a pointer into local storage */ 1.94 + oggpack_buffer opb; 1.95 + 1.96 + long lW; 1.97 + long W; 1.98 + long nW; 1.99 + int pcmend; 1.100 + int mode; 1.101 + 1.102 + int eofflag; 1.103 + ogg_int64_t granulepos; 1.104 + ogg_int64_t sequence; 1.105 + vorbis_dsp_state *vd; /* For read-only access of configuration */ 1.106 + 1.107 + /* local storage to avoid remallocing; it's up to the mapping to 1.108 + structure it */ 1.109 + void *localstore; 1.110 + long localtop; 1.111 + long localalloc; 1.112 + long totaluse; 1.113 + struct alloc_chain *reap; 1.114 + 1.115 + /* bitmetrics for the frame */ 1.116 + long glue_bits; 1.117 + long time_bits; 1.118 + long floor_bits; 1.119 + long res_bits; 1.120 + 1.121 + void *internal; 1.122 + 1.123 +} vorbis_block; 1.124 + 1.125 +/* vorbis_block is a single block of data to be processed as part of 1.126 +the analysis/synthesis stream; it belongs to a specific logical 1.127 +bitstream, but is independent from other vorbis_blocks belonging to 1.128 +that logical bitstream. *************************************************/ 1.129 + 1.130 +struct alloc_chain{ 1.131 + void *ptr; 1.132 + struct alloc_chain *next; 1.133 +}; 1.134 + 1.135 +/* vorbis_info contains all the setup information specific to the 1.136 + specific compression/decompression mode in progress (eg, 1.137 + psychoacoustic settings, channel setup, options, codebook 1.138 + etc). vorbis_info and substructures are in backends.h. 1.139 +*********************************************************************/ 1.140 + 1.141 +/* the comments are not part of vorbis_info so that vorbis_info can be 1.142 + static storage */ 1.143 +typedef struct vorbis_comment{ 1.144 + /* unlimited user comment fields. libvorbis writes 'libvorbis' 1.145 + whatever vendor is set to in encode */ 1.146 + char **user_comments; 1.147 + int *comment_lengths; 1.148 + int comments; 1.149 + char *vendor; 1.150 + 1.151 +} vorbis_comment; 1.152 + 1.153 + 1.154 +/* libvorbis encodes in two abstraction layers; first we perform DSP 1.155 + and produce a packet (see docs/analysis.txt). The packet is then 1.156 + coded into a framed OggSquish bitstream by the second layer (see 1.157 + docs/framing.txt). Decode is the reverse process; we sync/frame 1.158 + the bitstream and extract individual packets, then decode the 1.159 + packet back into PCM audio. 1.160 + 1.161 + The extra framing/packetizing is used in streaming formats, such as 1.162 + files. Over the net (such as with UDP), the framing and 1.163 + packetization aren't necessary as they're provided by the transport 1.164 + and the streaming layer is not used */ 1.165 + 1.166 +/* Vorbis PRIMITIVES: general ***************************************/ 1.167 + 1.168 +extern void vorbis_info_init(vorbis_info *vi); 1.169 +extern void vorbis_info_clear(vorbis_info *vi); 1.170 +extern int vorbis_info_blocksize(vorbis_info *vi,int zo); 1.171 +extern void vorbis_comment_init(vorbis_comment *vc); 1.172 +extern void vorbis_comment_add(vorbis_comment *vc, const char *comment); 1.173 +extern void vorbis_comment_add_tag(vorbis_comment *vc, 1.174 + const char *tag, const char *contents); 1.175 +extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count); 1.176 +extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag); 1.177 +extern void vorbis_comment_clear(vorbis_comment *vc); 1.178 + 1.179 +extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); 1.180 +extern int vorbis_block_clear(vorbis_block *vb); 1.181 +extern void vorbis_dsp_clear(vorbis_dsp_state *v); 1.182 +extern double vorbis_granule_time(vorbis_dsp_state *v, 1.183 + ogg_int64_t granulepos); 1.184 + 1.185 +extern const char *vorbis_version_string(void); 1.186 + 1.187 +/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ 1.188 + 1.189 +extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); 1.190 +extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); 1.191 +extern int vorbis_analysis_headerout(vorbis_dsp_state *v, 1.192 + vorbis_comment *vc, 1.193 + ogg_packet *op, 1.194 + ogg_packet *op_comm, 1.195 + ogg_packet *op_code); 1.196 +extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); 1.197 +extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); 1.198 +extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); 1.199 +extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); 1.200 + 1.201 +extern int vorbis_bitrate_addblock(vorbis_block *vb); 1.202 +extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, 1.203 + ogg_packet *op); 1.204 + 1.205 +/* Vorbis PRIMITIVES: synthesis layer *******************************/ 1.206 +extern int vorbis_synthesis_idheader(ogg_packet *op); 1.207 +extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, 1.208 + ogg_packet *op); 1.209 + 1.210 +extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); 1.211 +extern int vorbis_synthesis_restart(vorbis_dsp_state *v); 1.212 +extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); 1.213 +extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); 1.214 +extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); 1.215 +extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); 1.216 +extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); 1.217 +extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); 1.218 +extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); 1.219 + 1.220 +extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); 1.221 +extern int vorbis_synthesis_halfrate_p(vorbis_info *v); 1.222 + 1.223 +/* Vorbis ERRORS and return codes ***********************************/ 1.224 + 1.225 +#define OV_FALSE -1 1.226 +#define OV_EOF -2 1.227 +#define OV_HOLE -3 1.228 + 1.229 +#define OV_EREAD -128 1.230 +#define OV_EFAULT -129 1.231 +#define OV_EIMPL -130 1.232 +#define OV_EINVAL -131 1.233 +#define OV_ENOTVORBIS -132 1.234 +#define OV_EBADHEADER -133 1.235 +#define OV_EVERSION -134 1.236 +#define OV_ENOTAUDIO -135 1.237 +#define OV_EBADPACKET -136 1.238 +#define OV_EBADLINK -137 1.239 +#define OV_ENOSEEK -138 1.240 + 1.241 +#ifdef __cplusplus 1.242 +} 1.243 +#endif /* __cplusplus */ 1.244 + 1.245 +#endif 1.246 +