ReactOS  0.4.13-dev-544-gede3fdd
format.c File Reference
#include "mpg123lib_intern.h"
#include "debug.h"
Include dependency graph for format.c:

Go to the source code of this file.

Macros

#define MPG123_FLOAT_ENC   MPG123_ENC_FLOAT_32
 

Functions

static int good_enc (const int enc)
 
void attribute_align_arg mpg123_rates (const long **list, size_t *number)
 
void attribute_align_arg mpg123_encodings (const int **list, size_t *number)
 
int attribute_align_arg mpg123_encsize (int encoding)
 
static int rate2num (mpg123_pars *mp, long r)
 
static int enc2num (int encoding)
 
static int cap_fit (mpg123_handle *fr, struct audioformat *nf, int f0, int f2)
 
static int freq_fit (mpg123_handle *fr, struct audioformat *nf, int f0, int f2)
 
int frame_output_format (mpg123_handle *fr)
 
int attribute_align_arg mpg123_format_none (mpg123_handle *mh)
 
int attribute_align_arg mpg123_fmt_none (mpg123_pars *mp)
 
int attribute_align_arg mpg123_format_all (mpg123_handle *mh)
 
int attribute_align_arg mpg123_fmt_all (mpg123_pars *mp)
 
int attribute_align_arg mpg123_format (mpg123_handle *mh, long rate, int channels, int encodings)
 
int attribute_align_arg mpg123_fmt (mpg123_pars *mp, long rate, int channels, int encodings)
 
int attribute_align_arg mpg123_format_support (mpg123_handle *mh, long rate, int encoding)
 
int attribute_align_arg mpg123_fmt_support (mpg123_pars *mp, long rate, int encoding)
 
void invalidate_format (struct audioformat *af)
 
off_t decoder_synth_bytes (mpg123_handle *fr, off_t s)
 
off_t samples_to_bytes (mpg123_handle *fr, off_t s)
 
off_t bytes_to_samples (mpg123_handle *fr, off_t b)
 
off_t outblock_bytes (mpg123_handle *fr, off_t s)
 
static void chop_fourth_byte (struct outbuffer *buf)
 
static void conv_s32_to_u32 (struct outbuffer *buf)
 
static void conv_s16_to_u16 (struct outbuffer *buf)
 
static void conv_s16_to_f32 (struct outbuffer *buf)
 
static void conv_s16_to_s32 (struct outbuffer *buf)
 
void postprocess_buffer (mpg123_handle *fr)
 

Variables

static const long my_rates [MPG123_RATES]
 
static const int my_encodings [MPG123_ENCODINGS]
 
static const int enc_float_range [2] = { 6, 8 }
 
static const int enc_8bit_range [2] = { 8, 12 }
 
static const int good_encodings []
 
static const charbufsizeerr = "Fatal: Buffer too small for postprocessing!"
 

Macro Definition Documentation

◆ MPG123_FLOAT_ENC

#define MPG123_FLOAT_ENC   MPG123_ENC_FLOAT_32

Definition at line 75 of file format.c.

Function Documentation

◆ bytes_to_samples()

off_t bytes_to_samples ( mpg123_handle fr,
off_t  b 
)

Definition at line 470 of file format.c.

471 {
472  return b / fr->af.encsize / fr->af.channels;
473 }
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
struct audioformat af
Definition: frame.h:266

◆ cap_fit()

static int cap_fit ( mpg123_handle fr,
struct audioformat nf,
int  f0,
int  f2 
)
static

Definition at line 153 of file format.c.

154 {
155  int i;
156  int c = nf->channels-1;
157  int rn = rate2num(&fr->p, nf->rate);
158  if(rn >= 0) for(i=f0;i<f2;i++)
159  {
160  if(fr->p.audio_caps[c][rn][i])
161  {
162  nf->encoding = my_encodings[i];
163  return 1;
164  }
165  }
166  return 0;
167 }
struct mpg123_pars_struct p
Definition: frame.h:287
int encoding
Definition: frame.h:50
int channels
Definition: frame.h:54
long rate
Definition: frame.h:55
static const int my_encodings[MPG123_ENCODINGS]
Definition: format.c:39
const GLubyte * c
Definition: glext.h:8905
static int rate2num(mpg123_pars *mp, long r)
Definition: format.c:133
int i
Definition: format.c:271
int f2(S1 &, S2 &)

Referenced by frame_output_format(), and freq_fit().

◆ chop_fourth_byte()

static void chop_fourth_byte ( struct outbuffer buf)
static

Definition at line 489 of file format.c.

490 {
491  unsigned char *wpos = buf->data;
492  unsigned char *rpos = buf->data;
493 #ifdef WORDS_BIGENDIAN
494  while((size_t) (rpos - buf->data + 4) <= buf->fill)
495  {
496  /* Really stupid: Copy, increment. Byte per byte. */
497  *wpos = *rpos;
498  wpos++; rpos++;
499  *wpos = *rpos;
500  wpos++; rpos++;
501  *wpos = *rpos;
502  wpos++; rpos++;
503  rpos++; /* Skip the lowest byte (last). */
504  }
505 #else
506  while((size_t) (rpos - buf->data + 4) <= buf->fill)
507  {
508  /* Really stupid: Copy, increment. Byte per byte. */
509  rpos++; /* Skip the lowest byte (first). */
510  *wpos = *rpos;
511  wpos++; rpos++;
512  *wpos = *rpos;
513  wpos++; rpos++;
514  *wpos = *rpos;
515  wpos++; rpos++;
516  }
517 #endif
518  buf->fill = wpos-buf->data;
519 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

Referenced by postprocess_buffer().

◆ conv_s16_to_f32()

static void conv_s16_to_f32 ( struct outbuffer buf)
static

Definition at line 569 of file format.c.

570 {
571  ssize_t i;
572  int16_t *in = (int16_t*) buf->data;
573  float *out = (float*) buf->data;
574  size_t count = buf->fill/sizeof(int16_t);
575  /* Does that make any sense? In x86, there is an actual instruction to divide
576  float by integer ... but then, if we have that FPU, we don't really need
577  fixed point decoder hacks ...? */
578  float scale = 1./SHORT_SCALE;
579 
580  if(buf->size < count*sizeof(float))
581  {
582  error1("%s", bufsizeerr);
583  return;
584  }
585 
586  /* Work from the back since output is bigger. */
587  for(i=count-1; i>=0; --i)
588  out[i] = (float)in[i] * scale;
589 
590  buf->fill = count*sizeof(float);
591 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define error1(s, a)
Definition: debug.h:109
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
static FILE * out
Definition: regtests2xml.c:44
static const char * bufsizeerr
Definition: format.c:549
int ssize_t
Definition: rosdhcp.h:48
#define SHORT_SCALE
GLuint in
Definition: glext.h:9616
#define int16_t
Definition: nsiface.idl:55
int i
Definition: format.c:271
INT16 int16_t
Definition: types.h:70

Referenced by postprocess_buffer().

◆ conv_s16_to_s32()

static void conv_s16_to_s32 ( struct outbuffer buf)
static

Definition at line 595 of file format.c.

596 {
597  ssize_t i;
598  int16_t *in = (int16_t*) buf->data;
599  int32_t *out = (int32_t*) buf->data;
600  size_t count = buf->fill/sizeof(int16_t);
601 
602  if(buf->size < count*sizeof(int32_t))
603  {
604  error1("%s", bufsizeerr);
605  return;
606  }
607 
608  /* Work from the back since output is bigger. */
609  for(i=count-1; i>=0; --i)
610  {
611  out[i] = in[i];
612  /* Could just shift bytes, but would have to mess with sign bit. */
613  out[i] *= S32_RESCALE;
614  }
615 
616  buf->fill = count*sizeof(int32_t);
617 }
#define int32_t
Definition: nsiface.idl:56
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define error1(s, a)
Definition: debug.h:109
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define S32_RESCALE
static FILE * out
Definition: regtests2xml.c:44
static const char * bufsizeerr
Definition: format.c:549
int ssize_t
Definition: rosdhcp.h:48
INT32 int32_t
Definition: types.h:71
GLuint in
Definition: glext.h:9616
#define int16_t
Definition: nsiface.idl:55
int i
Definition: format.c:271
INT16 int16_t
Definition: types.h:70

Referenced by postprocess_buffer().

◆ conv_s16_to_u16()

static void conv_s16_to_u16 ( struct outbuffer buf)
static

Definition at line 554 of file format.c.

555 {
556  size_t i;
557  int16_t *ssamples = (int16_t*) buf->data;
558  uint16_t *usamples = (uint16_t*)buf->data;
559  size_t count = buf->fill/sizeof(int16_t);
560 
561  for(i=0; i<count; ++i)
562  {
563  long tmp = (long)ssamples[i]+32768;
564  usamples[i] = (uint16_t)tmp;
565  }
566 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
int count
Definition: format.c:269
unsigned short int uint16_t
Definition: acefiex.h:54
#define uint16_t
Definition: nsiface.idl:60
#define long
Definition: qsort.c:33
#define int16_t
Definition: nsiface.idl:55
int i
Definition: format.c:271
INT16 int16_t
Definition: types.h:70

Referenced by postprocess_buffer().

◆ conv_s32_to_u32()

static void conv_s32_to_u32 ( struct outbuffer buf)
static

Definition at line 521 of file format.c.

522 {
523  size_t i;
524  int32_t *ssamples = (int32_t*) buf->data;
525  uint32_t *usamples = (uint32_t*) buf->data;
526  size_t count = buf->fill/sizeof(int32_t);
527 
528  for(i=0; i<count; ++i)
529  {
530  /* Different strategy since we don't have a larger type at hand.
531  Also watch out for silly +-1 fun because integer constants are signed in C90! */
532  if(ssamples[i] >= 0)
533  usamples[i] = (uint32_t)ssamples[i] + 2147483647+1;
534  /* The smallest value goes zero. */
535  else if(ssamples[i] == ((int32_t)-2147483647-1))
536  usamples[i] = 0;
537  /* Now -value is in the positive range of signed int ... so it's a possible value at all. */
538  else
539  usamples[i] = (uint32_t)2147483647+1 - (uint32_t)(-ssamples[i]);
540  }
541 }
#define int32_t
Definition: nsiface.idl:56
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
int count
Definition: format.c:269
INT32 int32_t
Definition: types.h:71
UINT32 uint32_t
Definition: types.h:75
int i
Definition: format.c:271
#define uint32_t
Definition: nsiface.idl:61

Referenced by postprocess_buffer().

◆ decoder_synth_bytes()

off_t decoder_synth_bytes ( mpg123_handle fr,
off_t  s 
)

Definition at line 458 of file format.c.

459 {
460  return s * fr->af.dec_encsize * fr->af.channels;
461 }
GLdouble s
Definition: gl.h:2039
struct audioformat af
Definition: frame.h:266

◆ enc2num()

static int enc2num ( int  encoding)
static

Definition at line 144 of file format.c.

145 {
146  int i;
147  for(i=0;i<MPG123_ENCODINGS;++i)
148  if(my_encodings[i] == encoding) return i;
149 
150  return -1;
151 }
static const int my_encodings[MPG123_ENCODINGS]
Definition: format.c:39
ed encoding
Definition: write.c:2847
int i
Definition: format.c:271
#define MPG123_ENCODINGS

Referenced by mpg123_fmt_support().

◆ frame_output_format()

int frame_output_format ( mpg123_handle fr)

Definition at line 215 of file format.c.

216 {
217  struct audioformat nf;
218  int f0=0;
219  int f2=MPG123_ENCODINGS; /* Omit the 32bit and float encodings. */
220  mpg123_pars *p = &fr->p;
221  /* initialize new format, encoding comes later */
222  nf.channels = fr->stereo;
223 
224  /* All this forcing should be removed in favour of the capabilities table... */
225  if(p->flags & MPG123_FORCE_8BIT)
226  {
227  f0 = enc_8bit_range[0];
228  f2 = enc_8bit_range[1];
229  }
230  if(p->flags & MPG123_FORCE_FLOAT)
231  {
232  f0 = enc_float_range[0];
233  f2 = enc_float_range[1];
234  }
235 
236  /* force stereo is stronger */
237  if(p->flags & MPG123_FORCE_MONO) nf.channels = 1;
238  if(p->flags & MPG123_FORCE_STEREO) nf.channels = 2;
239 
240 #ifndef NO_NTOM
241  if(p->force_rate)
242  {
243  nf.rate = p->force_rate;
244  if(cap_fit(fr,&nf,f0,2)) goto end; /* 16bit encodings */
245  if(cap_fit(fr,&nf,f0<=2 ? 2 : f0,f2)) goto end; /* 8bit encodings */
246 
247  /* try again with different stereoness */
248  if(nf.channels == 2 && !(p->flags & MPG123_FORCE_STEREO)) nf.channels = 1;
249  else if(nf.channels == 1 && !(p->flags & MPG123_FORCE_MONO)) nf.channels = 2;
250 
251  if(cap_fit(fr,&nf,f0,2)) goto end; /* 16bit encodings */
252  if(cap_fit(fr,&nf,f0<=2 ? 2 : f0,f2)) goto end; /* 8bit encodings */
253 
254  if(NOQUIET)
255  error3( "Unable to set up output format! Constraints: %s%s%liHz.",
256  ( p->flags & MPG123_FORCE_STEREO ? "stereo, " :
257  (p->flags & MPG123_FORCE_MONO ? "mono, " : "") ),
258  (p->flags & MPG123_FORCE_8BIT ? "8bit, " : ""),
259  p->force_rate );
260 /* if(NOQUIET && p->verbose <= 1) print_capabilities(fr); */
261 
263  return -1;
264  }
265 #endif
266 
267  if(freq_fit(fr, &nf, f0, 2)) goto end; /* try rates with 16bit */
268  if(freq_fit(fr, &nf, f0<=2 ? 2 : f0, f2)) goto end; /* ... 8bit */
269 
270  /* try again with different stereoness */
271  if(nf.channels == 2 && !(p->flags & MPG123_FORCE_STEREO)) nf.channels = 1;
272  else if(nf.channels == 1 && !(p->flags & MPG123_FORCE_MONO)) nf.channels = 2;
273 
274  if(freq_fit(fr, &nf, f0, 2)) goto end; /* try rates with 16bit */
275  if(freq_fit(fr, &nf, f0<=2 ? 2 : f0, f2)) goto end; /* ... 8bit */
276 
277  /* Here is the _bad_ end. */
278  if(NOQUIET)
279  {
280  error5( "Unable to set up output format! Constraints: %s%s%li, %li or %liHz.",
281  ( p->flags & MPG123_FORCE_STEREO ? "stereo, " :
282  (p->flags & MPG123_FORCE_MONO ? "mono, " : "") ),
283  (p->flags & MPG123_FORCE_8BIT ? "8bit, " : ""),
284  frame_freq(fr), frame_freq(fr)>>1, frame_freq(fr)>>2 );
285  }
286 /* if(NOQUIET && p->verbose <= 1) print_capabilities(fr); */
287 
289  return -1;
290 
291 end: /* Here is the _good_ end. */
292  /* we had a successful match, now see if there's a change */
293  if(nf.rate == fr->af.rate && nf.channels == fr->af.channels && nf.encoding == fr->af.encoding)
294  {
295  debug2("Old format with %i channels, and FORCE_MONO=%li", nf.channels, p->flags & MPG123_FORCE_MONO);
296  return 0; /* the same format as before */
297  }
298  else /* a new format */
299  {
300  debug1("New format with %i channels!", nf.channels);
301  fr->af.rate = nf.rate;
302  fr->af.channels = nf.channels;
303  fr->af.encoding = nf.encoding;
304  /* Cache the size of one sample in bytes, for ease of use. */
305  fr->af.encsize = mpg123_encsize(fr->af.encoding);
306  if(fr->af.encsize < 1)
307  {
308  if(NOQUIET) error1("Some unknown encoding??? (%i)", fr->af.encoding);
309 
311  return -1;
312  }
313  /* Set up the decoder synth format. Might differ. */
314 #ifdef NO_SYNTH32
315  /* Without high-precision synths, 16 bit signed is the basis for
316  everything higher than 8 bit. */
317  if(fr->af.encsize > 2)
318  fr->af.dec_enc = MPG123_ENC_SIGNED_16;
319  else
320  {
321 #endif
322  switch(fr->af.encoding)
323  {
324 #ifndef NO_32BIT
328  fr->af.dec_enc = MPG123_ENC_SIGNED_32;
329  break;
330 #endif
331 #ifndef NO_16BIT
333  fr->af.dec_enc = MPG123_ENC_SIGNED_16;
334  break;
335 #endif
336  default:
337  fr->af.dec_enc = fr->af.encoding;
338  }
339 #ifdef NO_SYNTH32
340  }
341 #endif
342  fr->af.dec_encsize = mpg123_encsize(fr->af.dec_enc);
343  return 1;
344  }
345 }
static int freq_fit(mpg123_handle *fr, struct audioformat *nf, int f0, int f2)
Definition: format.c:169
struct mpg123_pars_struct p
Definition: frame.h:287
int attribute_align_arg mpg123_encsize(int encoding)
Definition: format.c:126
#define error1(s, a)
Definition: debug.h:109
static const int enc_float_range[2]
Definition: format.c:60
GLuint GLuint end
Definition: gl.h:1545
#define debug2(s, a, b)
Definition: debug.h:53
static int cap_fit(mpg123_handle *fr, struct audioformat *nf, int f0, int f2)
Definition: format.c:153
#define NOQUIET
struct audioformat af
Definition: frame.h:266
#define error5(s, a, b, c, d, e)
Definition: debug.h:113
#define error3(s, a, b, c)
Definition: debug.h:111
static const int enc_8bit_range[2]
Definition: format.c:62
#define MPG123_ENCODINGS
GLfloat GLfloat p
Definition: glext.h:8902
#define frame_freq
Definition: intsym.h:229
int f2(S1 &, S2 &)
#define debug1(s, a)
Definition: debug.h:52

◆ freq_fit()

static int freq_fit ( mpg123_handle fr,
struct audioformat nf,
int  f0,
int  f2 
)
static

Definition at line 169 of file format.c.

170 {
171  nf->rate = frame_freq(fr)>>fr->p.down_sample;
172  if(cap_fit(fr,nf,f0,f2)) return 1;
173  if(fr->p.flags & MPG123_AUTO_RESAMPLE)
174  {
175  nf->rate>>=1;
176  if(cap_fit(fr,nf,f0,f2)) return 1;
177  nf->rate>>=1;
178  if(cap_fit(fr,nf,f0,f2)) return 1;
179  }
180 #ifndef NO_NTOM
181  /* If nothing worked, try the other rates, only without constrains from user.
182  In case you didn't guess: We enable flexible resampling if we find a working rate. */
183  if( fr->p.flags & MPG123_AUTO_RESAMPLE &&
184  !fr->p.force_rate && fr->p.down_sample == 0)
185  {
186  int i;
187  int c = nf->channels-1;
188  int rn = rate2num(&fr->p, frame_freq(fr));
189  int rrn;
190  if(rn < 0) return 0;
191  /* Try higher rates first. */
192  for(i=f0;i<f2;i++) for(rrn=rn+1; rrn<MPG123_RATES; ++rrn)
193  if(fr->p.audio_caps[c][rrn][i])
194  {
195  nf->rate = my_rates[rrn];
196  nf->encoding = my_encodings[i];
197  return 1;
198  }
199  /* Then lower rates. */
200  for(i=f0;i<f2;i++) for(rrn=rn-1; rrn>=0; --rrn)
201  if(fr->p.audio_caps[c][rrn][i])
202  {
203  nf->rate = my_rates[rrn];
204  nf->encoding = my_encodings[i];
205  return 1;
206  }
207  }
208 #endif
209 
210  return 0;
211 }
struct mpg123_pars_struct p
Definition: frame.h:287
int encoding
Definition: frame.h:50
static const long my_rates[MPG123_RATES]
Definition: format.c:32
static int cap_fit(mpg123_handle *fr, struct audioformat *nf, int f0, int f2)
Definition: format.c:153
int channels
Definition: frame.h:54
long rate
Definition: frame.h:55
static const int my_encodings[MPG123_ENCODINGS]
Definition: format.c:39
const GLubyte * c
Definition: glext.h:8905
#define MPG123_RATES
static int rate2num(mpg123_pars *mp, long r)
Definition: format.c:133
int i
Definition: format.c:271
#define frame_freq
Definition: intsym.h:229
int f2(S1 &, S2 &)

Referenced by frame_output_format().

◆ good_enc()

static int good_enc ( const int  enc)
static

Definition at line 104 of file format.c.

105 {
106  size_t i;
107  for(i=0; i<sizeof(good_encodings)/sizeof(int); ++i)
108  if(enc == good_encodings[i]) return TRUE;
109 
110  return FALSE;
111 }
#define TRUE
Definition: types.h:120
static const int good_encodings[]
Definition: format.c:79
int i
Definition: format.c:271

Referenced by mpg123_fmt(), and mpg123_fmt_all().

◆ invalidate_format()

void invalidate_format ( struct audioformat af)

Definition at line 450 of file format.c.

451 {
452  af->encoding = 0;
453  af->rate = 0;
454  af->channels = 0;
455 }
int encoding
Definition: frame.h:50
int channels
Definition: frame.h:54
long rate
Definition: frame.h:55

◆ outblock_bytes()

off_t outblock_bytes ( mpg123_handle fr,
off_t  s 
)

Definition at line 476 of file format.c.

477 {
478  int encsize = (fr->af.encoding & MPG123_ENC_24)
479  ? 4 /* Intermediate 32 bit. */
480  : (fr->af.encsize > fr->af.dec_encsize
481  ? fr->af.encsize
482  : fr->af.dec_encsize);
483  return s * encsize * fr->af.channels;
484 }
GLdouble s
Definition: gl.h:2039
struct audioformat af
Definition: frame.h:266
int encsize
Definition: frame.h:51

◆ postprocess_buffer()

void postprocess_buffer ( mpg123_handle fr)

Definition at line 622 of file format.c.

623 {
624  /*
625  This caters for the final output formats that are never produced by
626  decoder synth directly (wide unsigned and 24 bit formats) or that are
627  missing because of limited decoder precision (16 bit synth but 32 or
628  24 bit output).
629  */
630  switch(fr->af.dec_enc)
631  {
632 #ifndef NO_32BIT
634  switch(fr->af.encoding)
635  {
637  conv_s32_to_u32(&fr->buffer);
638  break;
640  conv_s32_to_u32(&fr->buffer);
641  chop_fourth_byte(&fr->buffer);
642  break;
644  chop_fourth_byte(&fr->buffer);
645  break;
646  }
647  break;
648 #endif
649 #ifndef NO_16BIT
651  switch(fr->af.encoding)
652  {
654  conv_s16_to_u16(&fr->buffer);
655  break;
656 #ifndef NO_REAL
657  case MPG123_ENC_FLOAT_32:
658  conv_s16_to_f32(&fr->buffer);
659  break;
660 #endif
661 #ifndef NO_32BIT
663  conv_s16_to_s32(&fr->buffer);
664  break;
666  conv_s16_to_s32(&fr->buffer);
667  conv_s32_to_u32(&fr->buffer);
668  break;
670  conv_s16_to_s32(&fr->buffer);
671  conv_s32_to_u32(&fr->buffer);
672  chop_fourth_byte(&fr->buffer);
673  break;
675  conv_s16_to_s32(&fr->buffer);
676  chop_fourth_byte(&fr->buffer);
677  break;
678 #endif
679  }
680  break;
681 #endif
682  }
683 }
static void conv_s16_to_u16(struct outbuffer *buf)
Definition: format.c:554
struct outbuffer buffer
Definition: frame.h:265
static void conv_s32_to_u32(struct outbuffer *buf)
Definition: format.c:521
static void conv_s16_to_f32(struct outbuffer *buf)
Definition: format.c:569
static void chop_fourth_byte(struct outbuffer *buf)
Definition: format.c:489
struct audioformat af
Definition: frame.h:266
static void conv_s16_to_s32(struct outbuffer *buf)
Definition: format.c:595

◆ rate2num()

static int rate2num ( mpg123_pars mp,
long  r 
)
static

Definition at line 133 of file format.c.

134 {
135  int i;
136  for(i=0;i<MPG123_RATES;i++) if(my_rates[i] == r) return i;
137 #ifndef NO_NTOM
138  if(mp && mp->force_rate != 0 && mp->force_rate == r) return MPG123_RATES;
139 #endif
140 
141  return -1;
142 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static const long my_rates[MPG123_RATES]
Definition: format.c:32
long force_rate
Definition: frame.h:65
#define MPG123_RATES
int i
Definition: format.c:271

Referenced by cap_fit(), freq_fit(), mpg123_fmt(), and mpg123_fmt_support().

◆ samples_to_bytes()

off_t samples_to_bytes ( mpg123_handle fr,
off_t  s 
)

Definition at line 465 of file format.c.

466 {
467  return s * fr->af.encsize * fr->af.channels;
468 }
GLdouble s
Definition: gl.h:2039
struct audioformat af
Definition: frame.h:266

Variable Documentation

◆ bufsizeerr

const char* bufsizeerr = "Fatal: Buffer too small for postprocessing!"
static

Definition at line 549 of file format.c.

Referenced by conv_s16_to_f32(), and conv_s16_to_s32().

◆ enc_8bit_range

const int enc_8bit_range[2] = { 8, 12 }
static

Definition at line 62 of file format.c.

Referenced by frame_output_format().

◆ enc_float_range

const int enc_float_range[2] = { 6, 8 }
static

Definition at line 60 of file format.c.

Referenced by frame_output_format().

◆ good_encodings

◆ my_encodings

◆ my_rates

const long my_rates[MPG123_RATES]
static
Initial value:
=
{
8000, 11025, 12000,
16000, 22050, 24000,
32000, 44100, 48000,
}

Definition at line 32 of file format.c.

Referenced by freq_fit(), mpg123_rates(), and rate2num().