16 #define NTOM_MUL (32768) 18 #define aligned_pointer(p, type, alignment) align_the_pointer(p, alignment) 29 debug3(
"align_the_pointer: pointer %p is off by %u from %u",
30 base, (
unsigned int)aoff, alignment);
32 if(aoff)
return (
char*)
base+alignment-aoff;
90 fr->dithernoise =
NULL;
148 if(fr->dithernoise ==
NULL)
151 if(fr->dithernoise ==
NULL)
return 0;
242 if(fr->
p.index_size >= 0)
244 fr->
index.grow_size = 0;
255 debug2(
"set up frame index of size %lu (ret=%i)", (
unsigned long)fr->
index.size,
ret);
257 error(
"frame index setup (initial resize) failed");
271 debug1(
"frame %p buffer", (
void*)fr);
287 if(fr->cpu_opts.type ==
altivec) buffssize = 4*4*0x110*
sizeof(
real);
289 else if(fr->cpu_opts.type ==
ivier) buffssize = 2*2*17*FIR_BUFFER_SIZE*
sizeof(
int);
292 buffssize = 2*2*0x110*4;
294 if(2*2*0x110*
sizeof(
real) > buffssize)
295 buffssize = 2*2*0x110*
sizeof(
real);
298 if(fr->rawbuffs !=
NULL && fr->rawbuffss != buffssize)
304 if(fr->rawbuffs ==
NULL) fr->rawbuffs = (
unsigned char*)
malloc(buffssize);
305 if(fr->rawbuffs ==
NULL)
return -1;
306 fr->rawbuffss = buffssize;
308 fr->short_buffs[0][1] = fr->short_buffs[0][0] + 0x110;
309 fr->short_buffs[1][0] = fr->short_buffs[0][1] + 0x110;
310 fr->short_buffs[1][1] = fr->short_buffs[1][0] + 0x110;
312 fr->real_buffs[0][1] = fr->real_buffs[0][0] + 0x110;
313 fr->real_buffs[1][0] = fr->real_buffs[0][1] + 0x110;
314 fr->real_buffs[1][1] = fr->real_buffs[1][0] + 0x110;
316 if(fr->cpu_opts.type ==
ivier)
318 fr->int_buffs[0][0] = (
int*) fr->rawbuffs;
319 fr->int_buffs[0][1] = fr->int_buffs[0][0] + 17*FIR_BUFFER_SIZE;
320 fr->int_buffs[1][0] = fr->int_buffs[0][1] + 17*FIR_BUFFER_SIZE;
321 fr->int_buffs[1][1] = fr->int_buffs[1][0] + 17*FIR_BUFFER_SIZE;
325 if(fr->cpu_opts.type ==
altivec)
328 fr->areal_buffs[0][0] = (
real*) fr->rawbuffs;
329 for(
i=0;
i<4; ++
i)
for(
j=0;
j<4; ++
j)
330 fr->areal_buffs[
i][
j] = fr->areal_buffs[0][0] + (
i*4+
j)*0x110;
336 int decwin_size = (512+32)*
sizeof(
real);
339 if(fr->cpu_opts.class ==
mmxsse)
343 if(decwin_size < (512+32)*4) decwin_size = (512+32)*4;
347 decwin_size += (512+32)*4 + 63;
353 #if defined(OPT_ALTIVEC) || defined(OPT_ARM) 356 decwin_size += 512*
sizeof(
real);
359 if(fr->rawdecwin !=
NULL && fr->rawdecwins != decwin_size)
362 fr->rawdecwin =
NULL;
365 if(fr->rawdecwin ==
NULL)
366 fr->rawdecwin = (
unsigned char*)
malloc(decwin_size);
368 if(fr->rawdecwin ==
NULL)
return -1;
370 fr->rawdecwins = decwin_size;
371 fr->decwin = (
real*) fr->rawdecwin;
374 if(fr->cpu_opts.class ==
mmxsse)
380 debug1(
"aligned decwin: %p", (
void*)fr->decwin);
381 fr->decwin_mmx = (
float*)fr->decwin;
382 fr->decwins = fr->decwin_mmx+512+32;
385 else debug(
"no decwins/decwin_mmx for that class");
391 if(fr->layerscratch ==
NULL)
394 size_t scratchsize = 0;
410 fr->layerscratch =
malloc(scratchsize+63);
411 if(fr->layerscratch ==
NULL)
return -1;
422 fr->layer2.fraction = (
real(*)[4][
SBLIMIT])scratcher;
437 debug1(
"frame %p buffer done", (
void*)fr);
462 fr->
icy.interval = 0;
480 debug(
"Got a TOC! Showing the values...");
534 fr->
rva.level[0] = -1;
535 fr->
rva.level[1] = -1;
553 fr->i486bo[0] = fr->i486bo[1] = FIR_SIZE-1;
563 fr->
icy.interval = 0;
597 debug1(
"freeing buffer at %p", (
void*)fr->
buffer.rdata);
607 if(fr->dithernoise !=
NULL)
609 free(fr->dithernoise);
610 fr->dithernoise =
NULL;
632 if(bodydata !=
NULL) *bodydata = mh->
bsbuf;
673 if(toc_entry < 0) toc_entry = 0;
674 if(toc_entry > 99) toc_entry = 99;
689 *get_frame = want_frame;
692 debug5(
"fuzzy: want %li of %li, get %li at %li B of %li B",
718 fi = want_frame/fr->
index.step;
719 if(fi >= fr->
index.fill)
729 fi = fr->
index.fill - 1;
732 *get_frame = fi*fr->
index.step;
733 gopos = fr->
index.data[fi];
747 debug2(
"index: 0x%lx for frame %li", (
unsigned long)gopos, (
long) *get_frame);
757 # ifndef NO_DOWNSAMPLE 767 merror(
"Bad down_sample (%i) ... should not be possible!!" 779 # ifndef NO_DOWNSAMPLE 789 merror(
"Bad down_sample (%i) ... should not be possible!!" 803 # ifndef NO_DOWNSAMPLE 813 merror(
"Bad down_sample (%i) ... should not be possible!!" 825 # ifndef NO_DOWNSAMPLE 835 error(
"Bad down_sample ... should not be possible!!");
876 debug2(
"gapless update with new sample count %"OFF_P" as opposed to known %"OFF_P, total_samples, gapless_samples);
877 if(
NOQUIET && total_samples != gapless_samples)
878 fprintf(
stderr,
"\nWarning: Real sample count %"OFF_P" differs from given gapless sample count %"OFF_P". Frankenstein stream?\n" 879 , total_samples, gapless_samples);
881 if(gapless_samples > total_samples)
884 merror(
"End sample count smaller than gapless end! (%"OFF_P 885 " < %"OFF_P"). Disabling gapless mode from now on." 900 off_t preshift = fr->
p.preframes;
902 if(fr->
lay==3 && preshift < 1) preshift = 1;
904 if(fr->
lay!=3 && preshift > 2) preshift = 2;
937 debug5(
"frame_set_frameseek: begin at %li frames and %li samples, end at %li and %li; ignore from %li",
941 debug3(
"frame_set_frameseek: begin at %li frames, end at %li; ignore from %li",
965 debug5(
"frame_set_seek: begin at %li frames and %li samples, end at %li and %li; ignore from %li",
969 debug3(
"frame_set_seek: begin at %li frames, end at %li; ignore from %li",
984 if(vol >= 0) mh->
p.outscale = vol;
985 else mh->
p.outscale = 0.;
1000 if(fr->
p.rva == 2 && fr->
rva.level[1] != -1) rt = 1;
1001 if(fr->
rva.level[rt] != -1)
1003 p = fr->
rva.peak[rt];
1004 g = fr->
rva.gain[rt];
1008 if(peak !=
NULL) *peak =
p;
1009 if(gain !=
NULL) *gain =
g;
1023 rvafact =
pow(10,gain/20);
1026 newscale = fr->
p.outscale*rvafact;
1029 if((peak*newscale) > 1.0)
1031 newscale = 1.0/peak;
1032 warning2(
"limiting scale value to %f to prevent clipping with indicated peak factor of %f", newscale, peak);
1037 debug3(
"changing scale value from %f to %f (peak estimated to %f)", fr->
lastscale != -1 ? fr->
lastscale : fr->
p.outscale, newscale, (
double) (newscale*peak));
#define ntom_frame_outsamples
int frame_buffers(mpg123_handle *fr)
void frame_gapless_init(mpg123_handle *fr, off_t framecount, off_t bskip, off_t eskip)
double pow(double x, double y)
void frame_set_seek(mpg123_handle *fr, off_t sp)
int frame_outbuffer(mpg123_handle *fr)
struct mpg123_pars_struct p
#define DOUBLE_TO_REAL(x)
off_t frame_expect_outsamples(mpg123_handle *fr)
long freeformat_framesize
#define invalidate_format
unsigned char * id3v2_raw
struct mpg123_handle_struct::@3425 cpu_opts
static void frame_free_buffers(mpg123_handle *fr)
void frame_skip(mpg123_handle *fr)
#define debug4(s, a, b, c, d)
off_t frame_index_find(mpg123_handle *fr, off_t want_frame, off_t *get_frame)
struct mpg123_handle_struct::@3426 rva
_Tp _STLP_CALL real(const complex< _Tp > &__z)
void frame_init_par(mpg123_handle *fr, mpg123_pars *mp)
static void frame_icy_reset(mpg123_handle *fr)
static off_t ignoreframe(mpg123_handle *fr)
int frame_fill_toc(mpg123_handle *fr, unsigned char *in)
#define debug3(s, a, b, c)
static void frame_free_toc(mpg123_handle *fr)
void(* wrapperclean)(void *)
#define dither_table_init
static void frame_default_pars(mpg123_pars *mp)
unsigned char bsspace[2][MAXFRAMESIZE+512+4]
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int attribute_align_arg mpg123_reset_eq(mpg123_handle *mh)
void(* make_decode_tables)(mpg123_handle *fr)
void frame_init(mpg123_handle *fr)
static void frame_decode_buffers_reset(mpg123_handle *fr)
int frame_reset(mpg123_handle *fr)
int attribute_align_arg mpg123_set_moreinfo(mpg123_handle *mh, struct mpg123_moreinfo *mi)
func_synth_mono synth_mono
static int get_rva(mpg123_handle *fr, double *peak, double *gain)
#define warning2(s, a, b)
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 GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
struct mpg123_moreinfo * pinfo
void frame_exit(mpg123_handle *fr)
void attribute_align_arg mpg123_delete_pars(mpg123_pars *mp)
int frame_buffers_reset(mpg123_handle *fr)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void do_rva(mpg123_handle *fr)
real hybrid_block[2][2][SBLIMIT *SSLIMIT]
long freeformat_framesize
int frame_index_setup(mpg123_handle *fr)
#define memcpy(s1, s2, n)
unsigned long ntom_val[2]
static off_t frame_fuzzy_find(mpg123_handle *fr, off_t want_frame, off_t *get_frame)
#define aligned_pointer(p, type, alignment)
void frame_set_frameseek(mpg123_handle *fr, off_t fe)
void frame_gapless_realinit(mpg123_handle *fr)
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 GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
unsigned char id3buf[128]
off_t frame_outs(mpg123_handle *fr, off_t num)
unsigned int bitreservoir
int attribute_align_arg mpg123_getvolume(mpg123_handle *mh, double *base, double *really, double *rva_db)
int attribute_align_arg mpg123_replace_buffer(mpg123_handle *mh, void *data, size_t size)
int attribute_align_arg mpg123_volume(mpg123_handle *mh, double vol)
MPG123_EXPORT int mpg123_fmt_all(mpg123_pars *mp)
off_t frame_offset(mpg123_handle *fr, off_t outs)
static void * align_the_pointer(void *base, unsigned int alignment)
static void frame_fixed_reset(mpg123_handle *fr)
off_t frame_ins2outs(mpg123_handle *fr, off_t ins)
#define debug5(s, a, b, c, d, e)
int attribute_align_arg mpg123_volume_change(mpg123_handle *mh, double change)
void frame_gapless_update(mpg123_handle *mh, off_t total_samples)
#define attribute_align_arg
unsigned char * conv16to8_buf
#define frame_dither_init
unsigned char * rawdecwin
mpg123_pars attribute_align_arg * mpg123_new_pars(int *error)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *