ReactOS 0.4.16-dev-338-g34e76ad
frame.h
Go to the documentation of this file.
1/*
2 frame: Central data structures and opmitization hooks.
3
4 copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6 initially written by Thomas Orgis
7*/
8
9#ifndef MPG123_FRAME_H
10#define MPG123_FRAME_H
11
12#include <stdio.h>
13#include "config.h"
14#include "mpg123.h"
15#include "optimize.h"
16#include "id3.h"
17#include "icy.h"
18#include "reader.h"
19#ifdef FRAME_INDEX
20#include "index.h"
21#endif
22#include "synths.h"
23
24#ifdef OPT_DITHER
25#include "dither.h"
27#endif
28
29/* max = 1728 */
30#define MAXFRAMESIZE 3456
31
33{
34 short bits;
35 short d;
36};
37
38/* the output buffer, used to be pcm_sample, pcm_point and audiobufsize */
40{
41 unsigned char *data; /* main data pointer, aligned */
42 unsigned char *p; /* read pointer */
43 size_t fill; /* fill from read pointer */
44 size_t size;
45 unsigned char *rdata; /* unaligned base pointer */
46};
47
49{
50 int encoding; /* Final encoding, after post-processing. */
51 int encsize; /* Size of one sample in bytes, plain int should be fine here... */
52 int dec_enc; /* Encoding of decoder synth. */
53 int dec_encsize; /* Size of one decoder sample. */
55 long rate;
56};
57
58void invalidate_format(struct audioformat *af);
59
61{
62 int verbose; /* verbose level */
63 long flags; /* combination of above */
64#ifndef NO_NTOM
66#endif
68 int rva; /* (which) rva to do: 0: nothing, 1: radio/mix/track 2: album/audiophile */
71 long timeout;
72#define NUM_CHANNELS 2
74/* long start_frame; */ /* frame offset to begin with */
75/* long frame_number;*/ /* number of frames to decode */
76#ifndef NO_ICY
78#endif
79 double outscale;
81 long index_size; /* Long, because: negative values have a meaning. */
83#ifndef NO_FEEDER
86#endif
88};
89
91{
92 FRAME_ACCURATE = 0x1
95};
96
97/* There is a lot to condense here... many ints can be merged as flags; though the main space is still consumed by buffers. */
99{
100 int fresh; /* to be moved into flags */
104 /* the scratch vars for the decoders, sometimes real, sometimes short... sometimes int/long */
105 short *short_buffs[2][2];
107 unsigned char *rawbuffs;
109#ifdef OPT_I486
110 int i486bo[2];
111#endif
112 int bo; /* Just have it always here. */
113#ifdef OPT_DITHER
114 int ditherindex;
115 float *dithernoise;
116#endif
117 unsigned char* rawdecwin; /* the block with all decwins */
118 int rawdecwins; /* size of rawdecwin memory */
119 real *decwin; /* _the_ decode table */
120#ifdef OPT_MMXORSSE
121 /* I am not really sure that I need both of them... used in assembler */
122 float *decwin_mmx;
123 float *decwins;
124#endif
125#ifndef NO_EQUALIZER
128#endif
129 /* for halfspeed mode */
130 unsigned char ssave[34];
132#ifndef NO_8BIT
133 /* a raw buffer and a pointer into the middle for signed short conversion, only allocated on demand */
134 unsigned char *conv16to8_buf;
135 unsigned char *conv16to8;
136#endif
137 /* There's some possible memory saving for stuff that is not _really_ dynamic. */
138
139 /* layer3 */
140 int longLimit[9][23];
141 int shortLimit[9][14];
142 real gainpow2[256+118+4]; /* not really dynamic, just different for mmx */
143
144 /* layer2 */
145 real muls[27][64]; /* also used by layer 1 */
146
147#ifndef NO_NTOM
148 /* decode_ntom */
149 unsigned long ntom_val[2];
150 unsigned long ntom_step;
151#endif
152 /* special i486 fun */
153#ifdef OPT_I486
154 int *int_buffs[2][2];
155#endif
156 /* special altivec... */
157#ifdef OPT_ALTIVEC
158 real *areal_buffs[4][4];
159#endif
161 struct
162 {
163#ifdef OPT_MULTI
164
165#ifndef NO_LAYER3
166#if (defined OPT_3DNOW_VINTAGE || defined OPT_3DNOWEXT_VINTAGE || defined OPT_SSE || defined OPT_X86_64 || defined OPT_AVX || defined OPT_NEON || defined OPT_NEON64)
167 void (*the_dct36)(real *,real *,real *,real *,real *);
168#endif
169#endif
170
171#endif
173 enum optcla class;
175
176 int verbose; /* 0: nothing, 1: just print chosen decoder, 2: be verbose */
177
178 const struct al_table *alloc;
179 /* The runtime-chosen decoding, based on input and output format. */
183 /* Yes, this function is runtime-switched, too. */
184 void (*make_decode_tables)(mpg123_handle *fr); /* That is the volume control. */
185
186 int stereo; /* I _think_ 1 for mono and 2 for stereo */
188#define SINGLE_STEREO -1
189#define SINGLE_LEFT 0
190#define SINGLE_RIGHT 1
191#define SINGLE_MIX 3
195 int lsf; /* 0: MPEG 1.0; 1: MPEG 2.0/2.5 -- both used as bool and array index! */
196 /* Many flags in disguise as integers... wasting bytes. */
200 int lay;
201 long spf; /* cached count of samples per frame */
208 int mode;
213 int framesize; /* computed framesize */
214 int freesize; /* free format frame size */
215 enum mpg123_vbr vbr; /* 1 if variable bitrate was detected */
216 off_t num; /* frame offset ... */
217 off_t input_offset; /* byte offset of this frame in input stream */
218 off_t playnum; /* playback offset... includes repetitions, reset at seeks */
219 off_t audio_start; /* The byte offset in the file where audio data begins. */
221 char silent_resync; /* Do not complain for the next n resyncs. */
222 unsigned char* xing_toc; /* The seek TOC from Xing header. */
225
226 /* bitstream info; bsi */
229 unsigned char *wordpointer;
230 /* temporary storage for getbits stuff */
231 unsigned long ultmp;
232 unsigned char uctmp;
233
234 /* rva data, used in common.c, set in id3.c */
235
236 double maxoutburst; /* The maximum amplitude in current sample represenation. */
237 double lastscale;
238 struct
239 {
240 int level[2];
241 float gain[2];
242 float peak[2];
244
245 /* input data */
251 int ssize;
252 unsigned int bitreservoir;
253 unsigned char bsspace[2][MAXFRAMESIZE+512+4]; /* MAXFRAMESIZE */
254 unsigned char *bsbuf;
255 unsigned char *bsbufold;
256 int bsnum;
257 /* That is the header matching the last read frame body. */
258 unsigned long oldhead;
259 /* That is the header that is supposedly the first of the stream. */
260 unsigned long firsthead;
262#ifdef FRAME_INDEX
264#endif
265
266 /* output data */
270 size_t outblock; /* number of bytes that this frame produces (upper bound) */
271 int to_decode; /* this frame holds data to be decoded */
272 int to_ignore; /* the same, somehow */
273 off_t firstframe; /* start decoding from here */
274 off_t lastframe; /* last frame to decode (for gapless or num_frames limit) */
275 off_t ignoreframe; /* frames to decode but discard before firstframe */
276#ifdef GAPLESS
277 off_t gapless_frames; /* frame count for the gapless part */
278 off_t firstoff; /* number of samples to ignore from firstframe */
279 off_t lastoff; /* number of samples to use from lastframe */
280 off_t begin_s; /* overall begin offset in samples */
282 off_t end_s; /* overall end offset in samples */
284 off_t fullend_os; /* gapless_frames translated to output samples */
285#endif
286 unsigned int crc; /* Well, I need a safe 16bit type, actually. But wider doesn't hurt. */
287 struct reader *rd; /* pointer to the reading functions */
288 struct reader_data rdat; /* reader data and state info */
290 int err;
293 long clip;
294 /* the meta crap */
296 unsigned char id3buf[128];
297#ifndef NO_ID3V2
299#endif
300 unsigned char *id3v2_raw;
302#ifndef NO_ICY
303 struct icy_meta icy;
304#endif
305 /*
306 More variables needed for decoders, layerX.c.
307 This time it is not about static variables but about the need for alignment which cannot be guaranteed on the stack by certain compilers (Sun Studio).
308 We do not require the compiler to align stuff for our hand-written assembly. We only hope that it's able to align stuff for SSE and similar ops it generates itself.
309 */
310 /*
311 Those layer-specific structs could actually share memory, as they are not in use simultaneously. One might allocate on decoder switch, too.
312 They all reside in one lump of memory (after each other), allocated to layerscratch.
313 */
315#ifndef NO_LAYER1
316 struct
317 {
318 real (*fraction)[SBLIMIT]; /* ALIGNED(16) real fraction[2][SBLIMIT]; */
320#endif
321#ifndef NO_LAYER2
322 struct
323 {
324 real (*fraction)[4][SBLIMIT]; /* ALIGNED(16) real fraction[2][4][SBLIMIT] */
326#endif
327#ifndef NO_LAYER3
328 /* These are significant chunks of memory already... */
329 struct
330 {
331 real (*hybrid_in)[SBLIMIT][SSLIMIT]; /* ALIGNED(16) real hybridIn[2][SBLIMIT][SSLIMIT]; */
332 real (*hybrid_out)[SSLIMIT][SBLIMIT]; /* ALIGNED(16) real hybridOut[2][SSLIMIT][SBLIMIT]; */
334#endif
335 /* A place for storing additional data for the large file wrapper.
336 This is cruft! */
338 /* A callback used to properly destruct the wrapper data. */
342#ifndef NO_MOREINFO
344#endif
345};
346
347/* generic init, does not include dynamic buffers */
348void frame_init(mpg123_handle *fr);
350/* output buffer and format */
353
354int frame_buffers(mpg123_handle *fr); /* various decoder buffers, needed once */
355int frame_reset(mpg123_handle* fr); /* reset for next track */
357void frame_exit(mpg123_handle *fr); /* end, free all buffers */
358
359/* Index functions... */
360/* Well... print it... */
362/* Find a seek position in index. */
363off_t frame_index_find(mpg123_handle *fr, off_t want_frame, off_t* get_frame);
364/* Apply index_size setting. */
366
368void do_rva(mpg123_handle *fr);
369
370/* samples per frame ...
371Layer I
372Layer II
373Layer III
374MPEG-1
375384
3761152
3771152
378MPEG-2 LSF
379384
3801152
381576
382MPEG 2.5
383384
3841152
385576
386*/
387
388// Well, I take that one for granted... at least layer3.
389// The value is needed for mpg123_getstate() in any build.
390#define GAPLESS_DELAY 529
391#ifdef GAPLESS
392void frame_gapless_init(mpg123_handle *fr, off_t framecount, off_t bskip, off_t eskip);
394void frame_gapless_update(mpg123_handle *mh, off_t total_samples);
395/*void frame_gapless_position(mpg123_handle* fr);
396void frame_gapless_bytify(mpg123_handle *fr);
397void frame_gapless_ignore(mpg123_handle *fr, off_t frames);*/
398/* void frame_gapless_buffercheck(mpg123_handle *fr); */
399#endif
400
401/* Number of samples the decoding of the current frame should yield. */
403
404/* Skip this frame... do some fake action to get away without actually decoding it. */
405void frame_skip(mpg123_handle *fr);
406
407/*
408 Seeking core functions:
409 - convert input sample offset to output sample offset
410 - convert frame offset to output sample offset
411 - get leading frame offset for output sample offset
412 The offsets are "unadjusted"/internal; resampling is being taken care of.
413*/
416/* This one just computes the expected sample count for _this_ frame. */
422/* Take a copy of the Xing VBR TOC for fuzzy seeking. */
423int frame_fill_toc(mpg123_handle *fr, unsigned char* in);
424#endif
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
__kernel_off_t off_t
Definition: linux.h:201
frame_state_flags
Definition: frame.h:91
@ FRAME_FRESH_DECODER
Definition: frame.h:94
@ FRAME_ACCURATE
Definition: frame.h:92
@ FRAME_FRANKENSTEIN
Definition: frame.h:93
int mpg123_print_index(mpg123_handle *fr, FILE *out)
#define NUM_CHANNELS
Definition: frame.h:72
#define MAXFRAMESIZE
Definition: frame.h:30
GLint level
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
GLuint in
Definition: glext.h:9616
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint factor
Definition: glfuncs.h:178
mpg123_vbr
Definition: mpg123.h:1005
#define invalidate_format
Definition: intsym.h:178
#define frame_set_frameseek
Definition: intsym.h:202
#define frame_index_find
Definition: intsym.h:187
#define frame_outbuffer
Definition: intsym.h:181
#define do_volume
Definition: intsym.h:189
#define frame_gapless_realinit
Definition: intsym.h:192
#define frame_expect_outsampels
Definition: intsym.h:200
#define do_rva
Definition: intsym.h:190
#define frame_fill_toc
Definition: intsym.h:205
#define frame_index_setup
Definition: intsym.h:188
#define frame_gapless_init
Definition: intsym.h:191
#define frame_buffers
Definition: intsym.h:183
#define frame_reset
Definition: intsym.h:184
#define frame_set_seek
Definition: intsym.h:203
#define frame_exit
Definition: intsym.h:186
#define frame_ins2outs
Definition: intsym.h:198
#define frame_gapless_update
Definition: intsym.h:193
#define frame_tell_seek
Definition: intsym.h:204
#define frame_init
Definition: intsym.h:179
#define frame_outs
Definition: intsym.h:199
#define frame_init_par
Definition: intsym.h:180
#define frame_dither_init
Definition: intsym.h:177
#define frame_buffers_reset
Definition: intsym.h:185
#define frame_expect_outsamples
Definition: intsym.h:196
#define frame_offset
Definition: intsym.h:201
#define frame_output_format
Definition: intsym.h:182
#define frame_skip
Definition: intsym.h:197
static const WCHAR sp[]
Definition: suminfo.c:287
#define real
#define MPG123_RATES
#define SBLIMIT
#define MPG123_ENCODINGS
#define SSLIMIT
optcla
Definition: optimize.h:166
optdec
Definition: optimize.h:95
static FILE * out
Definition: regtests2xml.c:44
Definition: frame.h:33
short bits
Definition: frame.h:34
short d
Definition: frame.h:35
int encoding
Definition: frame.h:50
int channels
Definition: frame.h:54
int encsize
Definition: frame.h:51
int dec_enc
Definition: frame.h:52
int dec_encsize
Definition: frame.h:53
long rate
Definition: frame.h:55
Definition: icy.h:17
real * real_buffs[2][2]
Definition: frame.h:106
float gain[2]
Definition: frame.h:241
func_synth_mono synth_mono
Definition: frame.h:182
unsigned long ntom_step
Definition: frame.h:150
struct mpg123_handle_struct::@3463 layer2
unsigned long ntom_val[2]
Definition: frame.h:149
short * short_buffs[2][2]
Definition: frame.h:105
unsigned char * id3v2_raw
Definition: frame.h:300
struct mpg123_handle_struct::@3460 cpu_opts
unsigned char * rawdecwin
Definition: frame.h:117
size_t id3v2_size
Definition: frame.h:301
real(* fraction)[SBLIMIT]
Definition: frame.h:318
int sampling_frequency
Definition: frame.h:205
struct icy_meta icy
Definition: frame.h:303
unsigned char * conv16to8_buf
Definition: frame.h:134
struct synth_s synths
Definition: frame.h:160
unsigned char * bsbufold
Definition: frame.h:255
struct mpg123_moreinfo * pinfo
Definition: frame.h:343
func_synth_stereo synth_stereo
Definition: frame.h:181
unsigned char * xing_toc
Definition: frame.h:222
unsigned long oldhead
Definition: frame.h:258
int longLimit[9][23]
Definition: frame.h:140
int down_sample_sblimit
Definition: frame.h:194
struct reader * rd
Definition: frame.h:287
struct mpg123_handle_struct::@3461 rva
off_t track_frames
Definition: frame.h:246
unsigned char * rawbuffs
Definition: frame.h:107
const struct al_table * alloc
Definition: frame.h:178
unsigned char * conv16to8
Definition: frame.h:135
struct audioformat af
Definition: frame.h:268
func_synth synth
Definition: frame.h:180
unsigned int bitreservoir
Definition: frame.h:252
int shortLimit[9][14]
Definition: frame.h:141
double mean_framesize
Definition: frame.h:248
unsigned long ultmp
Definition: frame.h:231
real(* hybrid_in)[SBLIMIT][SSLIMIT]
Definition: frame.h:331
enum mpg123_vbr vbr
Definition: frame.h:215
int hybrid_blc[2]
Definition: frame.h:103
double lastscale
Definition: frame.h:237
real hybrid_block[2][2][SBLIMIT *SSLIMIT]
Definition: frame.h:102
real muls[27][64]
Definition: frame.h:145
struct mpg123_handle_struct::@3462 layer1
off_t track_samples
Definition: frame.h:247
struct mpg123_handle_struct::@3464 layer3
void * wrapperdata
Definition: frame.h:337
float peak[2]
Definition: frame.h:242
unsigned char id3buf[128]
Definition: frame.h:296
int(* do_layer)(mpg123_handle *)
Definition: frame.h:202
real equalizer[2][32]
Definition: frame.h:127
unsigned char * wordpointer
Definition: frame.h:229
unsigned char ssave[34]
Definition: frame.h:130
real(* hybrid_out)[SSLIMIT][SBLIMIT]
Definition: frame.h:332
unsigned char * bsbuf
Definition: frame.h:254
mpg123_id3v2 id3v2
Definition: frame.h:298
unsigned int crc
Definition: frame.h:286
double maxoutburst
Definition: frame.h:236
real * layerscratch
Definition: frame.h:314
unsigned long firsthead
Definition: frame.h:260
struct reader_data rdat
Definition: frame.h:288
long freeformat_framesize
Definition: frame.h:224
unsigned char bsspace[2][MAXFRAMESIZE+512+4]
Definition: frame.h:253
void(* wrapperclean)(void *)
Definition: frame.h:339
unsigned char uctmp
Definition: frame.h:232
enum optdec type
Definition: frame.h:172
real gainpow2[256+118+4]
Definition: frame.h:142
off_t input_offset
Definition: frame.h:217
off_t gapless_frames
Definition: frame.h:277
void(* make_decode_tables)(mpg123_handle *fr)
Definition: frame.h:184
long index_size
Definition: frame.h:81
long doublespeed
Definition: frame.h:70
long halfspeed
Definition: frame.h:69
long force_rate
Definition: frame.h:65
long preframes
Definition: frame.h:82
long freeformat_framesize
Definition: frame.h:87
long icy_interval
Definition: frame.h:77
double outscale
Definition: frame.h:79
long resync_limit
Definition: frame.h:80
char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]
Definition: frame.h:73
long feedbuffer
Definition: frame.h:85
unsigned char * p
Definition: frame.h:42
size_t fill
Definition: frame.h:43
size_t size
Definition: frame.h:44
unsigned char * data
Definition: frame.h:41
unsigned char * rdata
Definition: frame.h:45
Definition: reader.h:84
Definition: synths.h:45
int(* func_synth)(real *, int, mpg123_handle *, int)
Definition: synths.h:10
int(* func_synth_mono)(real *, mpg123_handle *)
Definition: synths.h:11
int(* func_synth_stereo)(real *, real *, mpg123_handle *)
Definition: synths.h:12