Mercurial > mplayer.hg
comparison tremor/ivorbiscodec.h @ 14280:8631a3803289
internal Tremor decoder for Ogg/Vorbis
author | henry |
---|---|
date | Thu, 30 Dec 2004 12:11:32 +0000 |
parents | |
children | cd6b211be811 |
comparison
equal
deleted
inserted
replaced
14279:b4b202086260 | 14280:8631a3803289 |
---|---|
1 /******************************************************************** | |
2 * * | |
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * | |
4 * * | |
5 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * | |
6 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * | |
7 * ALL REDISTRIBUTION RIGHTS RESERVED. * | |
8 * * | |
9 ******************************************************************** | |
10 | |
11 function: libvorbis codec headers | |
12 | |
13 ********************************************************************/ | |
14 | |
15 #ifndef _vorbis_codec_h_ | |
16 #define _vorbis_codec_h_ | |
17 | |
18 #ifdef __cplusplus | |
19 extern "C" | |
20 { | |
21 #endif /* __cplusplus */ | |
22 | |
23 #include "ogg.h" | |
24 | |
25 typedef struct vorbis_info{ | |
26 int version; | |
27 int channels; | |
28 long rate; | |
29 | |
30 /* The below bitrate declarations are *hints*. | |
31 Combinations of the three values carry the following implications: | |
32 | |
33 all three set to the same value: | |
34 implies a fixed rate bitstream | |
35 only nominal set: | |
36 implies a VBR stream that averages the nominal bitrate. No hard | |
37 upper/lower limit | |
38 upper and or lower set: | |
39 implies a VBR bitstream that obeys the bitrate limits. nominal | |
40 may also be set to give a nominal rate. | |
41 none set: | |
42 the coder does not care to speculate. | |
43 */ | |
44 | |
45 long bitrate_upper; | |
46 long bitrate_nominal; | |
47 long bitrate_lower; | |
48 long bitrate_window; | |
49 | |
50 void *codec_setup; | |
51 } vorbis_info; | |
52 | |
53 /* vorbis_dsp_state buffers the current vorbis audio | |
54 analysis/synthesis state. The DSP state belongs to a specific | |
55 logical bitstream ****************************************************/ | |
56 typedef struct vorbis_dsp_state{ | |
57 int analysisp; | |
58 vorbis_info *vi; | |
59 | |
60 ogg_int32_t **pcm; | |
61 ogg_int32_t **pcmret; | |
62 int pcm_storage; | |
63 int pcm_current; | |
64 int pcm_returned; | |
65 | |
66 int preextrapolate; | |
67 int eofflag; | |
68 | |
69 long lW; | |
70 long W; | |
71 long nW; | |
72 long centerW; | |
73 | |
74 ogg_int64_t granulepos; | |
75 ogg_int64_t sequence; | |
76 | |
77 void *backend_state; | |
78 } vorbis_dsp_state; | |
79 | |
80 typedef struct vorbis_block{ | |
81 /* necessary stream state for linking to the framing abstraction */ | |
82 ogg_int32_t **pcm; /* this is a pointer into local storage */ | |
83 oggpack_buffer opb; | |
84 | |
85 long lW; | |
86 long W; | |
87 long nW; | |
88 int pcmend; | |
89 int mode; | |
90 | |
91 int eofflag; | |
92 ogg_int64_t granulepos; | |
93 ogg_int64_t sequence; | |
94 vorbis_dsp_state *vd; /* For read-only access of configuration */ | |
95 | |
96 /* local storage to avoid remallocing; it's up to the mapping to | |
97 structure it */ | |
98 void *localstore; | |
99 long localtop; | |
100 long localalloc; | |
101 long totaluse; | |
102 struct alloc_chain *reap; | |
103 | |
104 } vorbis_block; | |
105 | |
106 /* vorbis_block is a single block of data to be processed as part of | |
107 the analysis/synthesis stream; it belongs to a specific logical | |
108 bitstream, but is independant from other vorbis_blocks belonging to | |
109 that logical bitstream. *************************************************/ | |
110 | |
111 struct alloc_chain{ | |
112 void *ptr; | |
113 struct alloc_chain *next; | |
114 }; | |
115 | |
116 /* vorbis_info contains all the setup information specific to the | |
117 specific compression/decompression mode in progress (eg, | |
118 psychoacoustic settings, channel setup, options, codebook | |
119 etc). vorbis_info and substructures are in backends.h. | |
120 *********************************************************************/ | |
121 | |
122 /* the comments are not part of vorbis_info so that vorbis_info can be | |
123 static storage */ | |
124 typedef struct vorbis_comment{ | |
125 /* unlimited user comment fields. libvorbis writes 'libvorbis' | |
126 whatever vendor is set to in encode */ | |
127 char **user_comments; | |
128 int *comment_lengths; | |
129 int comments; | |
130 char *vendor; | |
131 | |
132 } vorbis_comment; | |
133 | |
134 | |
135 /* libvorbis encodes in two abstraction layers; first we perform DSP | |
136 and produce a packet (see docs/analysis.txt). The packet is then | |
137 coded into a framed OggSquish bitstream by the second layer (see | |
138 docs/framing.txt). Decode is the reverse process; we sync/frame | |
139 the bitstream and extract individual packets, then decode the | |
140 packet back into PCM audio. | |
141 | |
142 The extra framing/packetizing is used in streaming formats, such as | |
143 files. Over the net (such as with UDP), the framing and | |
144 packetization aren't necessary as they're provided by the transport | |
145 and the streaming layer is not used */ | |
146 | |
147 /* Vorbis PRIMITIVES: general ***************************************/ | |
148 | |
149 extern void vorbis_info_init(vorbis_info *vi); | |
150 extern void vorbis_info_clear(vorbis_info *vi); | |
151 extern int vorbis_info_blocksize(vorbis_info *vi,int zo); | |
152 extern void vorbis_comment_init(vorbis_comment *vc); | |
153 extern void vorbis_comment_add(vorbis_comment *vc, char *comment); | |
154 extern void vorbis_comment_add_tag(vorbis_comment *vc, | |
155 char *tag, char *contents); | |
156 extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count); | |
157 extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag); | |
158 extern void vorbis_comment_clear(vorbis_comment *vc); | |
159 | |
160 extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); | |
161 extern int vorbis_block_clear(vorbis_block *vb); | |
162 extern void vorbis_dsp_clear(vorbis_dsp_state *v); | |
163 | |
164 /* Vorbis PRIMITIVES: synthesis layer *******************************/ | |
165 extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, | |
166 ogg_packet *op); | |
167 | |
168 extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); | |
169 extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); | |
170 extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); | |
171 extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm); | |
172 extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); | |
173 extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); | |
174 | |
175 /* Vorbis ERRORS and return codes ***********************************/ | |
176 | |
177 #define OV_FALSE -1 | |
178 #define OV_EOF -2 | |
179 #define OV_HOLE -3 | |
180 | |
181 #define OV_EREAD -128 | |
182 #define OV_EFAULT -129 | |
183 #define OV_EIMPL -130 | |
184 #define OV_EINVAL -131 | |
185 #define OV_ENOTVORBIS -132 | |
186 #define OV_EBADHEADER -133 | |
187 #define OV_EVERSION -134 | |
188 #define OV_ENOTAUDIO -135 | |
189 #define OV_EBADPACKET -136 | |
190 #define OV_EBADLINK -137 | |
191 #define OV_ENOSEEK -138 | |
192 | |
193 #ifdef __cplusplus | |
194 } | |
195 #endif /* __cplusplus */ | |
196 | |
197 #endif | |
198 |