ReactOS  0.4.13-dev-247-g0f29b3f
mpg123lib_intern.h File Reference
#include "config.h"
#include "intsym.h"
#include "abi_align.h"
#include "compat.h"
#include "mpg123.h"
#include "true.h"
#include "optimize.h"
#include "decode.h"
#include "parse.h"
#include "frame.h"
Include dependency graph for mpg123lib_intern.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MPG123_RATES   9
 
#define MPG123_ENCODINGS   12
 
#define SKIP_JUNK   1
 
#define M_PI   3.14159265358979323846
 
#define M_SQRT2   1.41421356237309504880
 
#define REAL_IS_DOUBLE
 
#define real   double
 
#define DOUBLE_TO_REAL(x)   (real)(x)
 
#define DOUBLE_TO_REAL_15(x)   (real)(x)
 
#define DOUBLE_TO_REAL_POW43(x)   (real)(x)
 
#define DOUBLE_TO_REAL_SCALE_LAYER12(x)   (real)(x)
 
#define DOUBLE_TO_REAL_SCALE_LAYER3(x, y)   (real)(x)
 
#define REAL_TO_DOUBLE(x)   (x)
 
#define REAL_MUL(x, y)   ((x) * (y))
 
#define REAL_MUL_SYNTH(x, y)   ((x) * (y))
 
#define REAL_MUL_15(x, y)   ((x) * (y))
 
#define REAL_MUL_SCALE_LAYER12(x, y)   ((x) * (y))
 
#define REAL_MUL_SCALE_LAYER3(x, y, z)   ((x) * (y))
 
#define REAL_SCALE_LAYER12(x)   (x)
 
#define REAL_SCALE_LAYER3(x, y)   (x)
 
#define REAL_SCALE_DCT64(x)   (x)
 
#define AUDIOBUFSIZE   2
 
#define MAX_NAME_SIZE   81
 
#define SBLIMIT   32
 
#define SCALE_BLOCK   12
 
#define SSLIMIT   18
 
#define MPG_MD_STEREO   0
 
#define MPG_MD_JOINT_STEREO   1
 
#define MPG_MD_DUAL_CHANNEL   2
 
#define MPG_MD_MONO   3
 
#define SHORT_SCALE   32768
 
#define S32_RESCALE   65536
 
#define AUSHIFT   (3)
 
#define NOQUIET   (!(fr->p.flags & MPG123_QUIET))
 
#define VERBOSE   (NOQUIET && fr->p.verbose)
 
#define VERBOSE2   (NOQUIET && fr->p.verbose > 1)
 
#define VERBOSE3   (NOQUIET && fr->p.verbose > 2)
 
#define VERBOSE4   (NOQUIET && fr->p.verbose > 3)
 
#define PVERB(mp, level)   (!((mp)->flags & MPG123_QUIET) && (mp)->verbose >= (level))
 

Functions

int decode_update (mpg123_handle *mh)
 
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)
 
void postprocess_buffer (mpg123_handle *fr)
 

Macro Definition Documentation

◆ AUDIOBUFSIZE

#define AUDIOBUFSIZE   2

Definition at line 259 of file mpg123lib_intern.h.

◆ AUSHIFT

#define AUSHIFT   (3)

Definition at line 282 of file mpg123lib_intern.h.

◆ DOUBLE_TO_REAL

#define DOUBLE_TO_REAL (   x)    (real)(x)

Definition at line 214 of file mpg123lib_intern.h.

◆ DOUBLE_TO_REAL_15

#define DOUBLE_TO_REAL_15 (   x)    (real)(x)

Definition at line 217 of file mpg123lib_intern.h.

◆ DOUBLE_TO_REAL_POW43

#define DOUBLE_TO_REAL_POW43 (   x)    (real)(x)

Definition at line 220 of file mpg123lib_intern.h.

◆ DOUBLE_TO_REAL_SCALE_LAYER12

#define DOUBLE_TO_REAL_SCALE_LAYER12 (   x)    (real)(x)

Definition at line 223 of file mpg123lib_intern.h.

◆ DOUBLE_TO_REAL_SCALE_LAYER3

#define DOUBLE_TO_REAL_SCALE_LAYER3 (   x,
  y 
)    (real)(x)

Definition at line 226 of file mpg123lib_intern.h.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 31 of file mpg123lib_intern.h.

◆ M_SQRT2

#define M_SQRT2   1.41421356237309504880

Definition at line 34 of file mpg123lib_intern.h.

◆ MAX_NAME_SIZE

#define MAX_NAME_SIZE   81

Definition at line 263 of file mpg123lib_intern.h.

◆ MPG123_ENCODINGS

#define MPG123_ENCODINGS   12

Definition at line 14 of file mpg123lib_intern.h.

◆ MPG123_RATES

#define MPG123_RATES   9

Definition at line 13 of file mpg123lib_intern.h.

◆ MPG_MD_DUAL_CHANNEL

#define MPG_MD_DUAL_CHANNEL   2

Definition at line 271 of file mpg123lib_intern.h.

◆ MPG_MD_JOINT_STEREO

#define MPG_MD_JOINT_STEREO   1

Definition at line 270 of file mpg123lib_intern.h.

◆ MPG_MD_MONO

#define MPG_MD_MONO   3

Definition at line 272 of file mpg123lib_intern.h.

◆ MPG_MD_STEREO

#define MPG_MD_STEREO   0

Definition at line 269 of file mpg123lib_intern.h.

◆ NOQUIET

#define NOQUIET   (!(fr->p.flags & MPG123_QUIET))

Definition at line 290 of file mpg123lib_intern.h.

◆ PVERB

#define PVERB (   mp,
  level 
)    (!((mp)->flags & MPG123_QUIET) && (mp)->verbose >= (level))

Definition at line 295 of file mpg123lib_intern.h.

◆ real

#define real   double

Definition at line 204 of file mpg123lib_intern.h.

◆ REAL_IS_DOUBLE

#define REAL_IS_DOUBLE

Definition at line 203 of file mpg123lib_intern.h.

◆ REAL_MUL

#define REAL_MUL (   x,
  y 
)    ((x) * (y))

Definition at line 233 of file mpg123lib_intern.h.

◆ REAL_MUL_15

#define REAL_MUL_15 (   x,
  y 
)    ((x) * (y))

Definition at line 239 of file mpg123lib_intern.h.

◆ REAL_MUL_SCALE_LAYER12

#define REAL_MUL_SCALE_LAYER12 (   x,
  y 
)    ((x) * (y))

Definition at line 242 of file mpg123lib_intern.h.

◆ REAL_MUL_SCALE_LAYER3

#define REAL_MUL_SCALE_LAYER3 (   x,
  y,
  z 
)    ((x) * (y))

Definition at line 245 of file mpg123lib_intern.h.

◆ REAL_MUL_SYNTH

#define REAL_MUL_SYNTH (   x,
  y 
)    ((x) * (y))

Definition at line 236 of file mpg123lib_intern.h.

◆ REAL_SCALE_DCT64

#define REAL_SCALE_DCT64 (   x)    (x)

Definition at line 254 of file mpg123lib_intern.h.

◆ REAL_SCALE_LAYER12

#define REAL_SCALE_LAYER12 (   x)    (x)

Definition at line 248 of file mpg123lib_intern.h.

◆ REAL_SCALE_LAYER3

#define REAL_SCALE_LAYER3 (   x,
  y 
)    (x)

Definition at line 251 of file mpg123lib_intern.h.

◆ REAL_TO_DOUBLE

#define REAL_TO_DOUBLE (   x)    (x)

Definition at line 229 of file mpg123lib_intern.h.

◆ S32_RESCALE

#define S32_RESCALE   65536

Definition at line 279 of file mpg123lib_intern.h.

◆ SBLIMIT

#define SBLIMIT   32

Definition at line 264 of file mpg123lib_intern.h.

◆ SCALE_BLOCK

#define SCALE_BLOCK   12

Definition at line 265 of file mpg123lib_intern.h.

◆ SHORT_SCALE

#define SHORT_SCALE   32768

Definition at line 276 of file mpg123lib_intern.h.

◆ SKIP_JUNK

#define SKIP_JUNK   1

Definition at line 28 of file mpg123lib_intern.h.

◆ SSLIMIT

#define SSLIMIT   18

Definition at line 266 of file mpg123lib_intern.h.

◆ VERBOSE

#define VERBOSE   (NOQUIET && fr->p.verbose)

Definition at line 291 of file mpg123lib_intern.h.

◆ VERBOSE2

#define VERBOSE2   (NOQUIET && fr->p.verbose > 1)

Definition at line 292 of file mpg123lib_intern.h.

◆ VERBOSE3

#define VERBOSE3   (NOQUIET && fr->p.verbose > 2)

Definition at line 293 of file mpg123lib_intern.h.

◆ VERBOSE4

#define VERBOSE4   (NOQUIET && fr->p.verbose > 3)

Definition at line 294 of file mpg123lib_intern.h.

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

◆ decode_update()

int decode_update ( mpg123_handle mh)

Definition at line 506 of file libmpg123.c.

507 {
508  long native_rate;
509  int b;
510 
511  if(mh->num < 0)
512  {
513  if(!(mh->p.flags & MPG123_QUIET)) error("decode_update() has been called before reading the first MPEG frame! Internal programming error.");
514 
516  return MPG123_ERR;
517  }
518 
520  native_rate = frame_freq(mh);
521 
522  b = frame_output_format(mh); /* Select the new output format based on given constraints. */
523  if(b < 0) return MPG123_ERR;
524 
525  if(b == 1) mh->new_format = 1; /* Store for later... */
526 
527  debug3("updating decoder structure with native rate %li and af.rate %li (new format: %i)", native_rate, mh->af.rate, mh->new_format);
528  if(mh->af.rate == native_rate) mh->down_sample = 0;
529  else if(mh->af.rate == native_rate>>1) mh->down_sample = 1;
530  else if(mh->af.rate == native_rate>>2) mh->down_sample = 2;
531  else mh->down_sample = 3; /* flexible (fixed) rate */
532  switch(mh->down_sample)
533  {
534  case 0:
535  case 1:
536  case 2:
538  /* With downsampling I get less samples per frame */
539  mh->outblock = outblock_bytes(mh, (mh->spf>>mh->down_sample));
540  break;
541 #ifndef NO_NTOM
542  case 3:
543  {
544  if(synth_ntom_set_step(mh) != 0) return -1;
545  if(frame_freq(mh) > mh->af.rate)
546  {
547  mh->down_sample_sblimit = SBLIMIT * mh->af.rate;
548  mh->down_sample_sblimit /= frame_freq(mh);
549  }
550  else mh->down_sample_sblimit = SBLIMIT;
551  mh->outblock = outblock_bytes(mh,
552  ( ( NTOM_MUL-1+mh->spf
553  * (((size_t)NTOM_MUL*mh->af.rate)/frame_freq(mh))
554  )/NTOM_MUL ));
555  }
556  break;
557 #endif
558  }
559 
560  if(!(mh->p.flags & MPG123_FORCE_MONO))
561  {
562  if(mh->af.channels == 1) mh->single = SINGLE_MIX;
563  else mh->single = SINGLE_STEREO;
564  }
565  else mh->single = (mh->p.flags & MPG123_FORCE_MONO)-1;
566  if(set_synth_functions(mh) != 0) return -1;;
567 
568  /* The needed size of output buffer may have changed. */
569  if(frame_outbuffer(mh) != MPG123_OK) return -1;
570 
571  do_rva(mh);
572  debug3("done updating decoder structure with native rate %li and af.rate %li and down_sample %i", frame_freq(mh), mh->af.rate, mh->down_sample);
573 
574  return 0;
575 }
struct mpg123_pars_struct p
Definition: frame.h:287
#define error(str)
Definition: mkdosfs.c:1605
#define SINGLE_STEREO
Definition: frame.h:187
#define SBLIMIT
#define NTOM_MUL
Definition: decode.h:32
#define outblock_bytes
Definition: intsym.h:219
#define debug3(s, a, b, c)
Definition: debug.h:54
#define set_synth_functions
Definition: intsym.h:222
int down_sample_sblimit
Definition: frame.h:193
#define b
Definition: ke_i.h:79
#define frame_outbuffer
Definition: intsym.h:170
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define synth_ntom_set_step
Definition: intsym.h:143
struct audioformat af
Definition: frame.h:266
#define do_rva
Definition: intsym.h:179
#define frame_freq
Definition: intsym.h:229
#define frame_output_format
Definition: intsym.h:171
#define SINGLE_MIX
Definition: frame.h:190

Referenced by do_the_seek(), and get_next_frame().

◆ 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

◆ 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

◆ 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