ReactOS 0.4.16-dev-306-g647d351
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)
 
int open_fixed_pre (mpg123_handle *mh, int channels, int encoding)
 
int open_fixed_post (mpg123_handle *mh, int channels, int encoding)
 

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 570 of file format.c.

571{
572 return b / fr->af.encsize / fr->af.channels;
573}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
struct audioformat af
Definition: frame.h:268

◆ decode_update()

int decode_update ( mpg123_handle mh)

Definition at line 573 of file libmpg123.c.

574{
575 long native_rate;
576 int b;
577
578 if(mh->num < 0)
579 {
580 if(!(mh->p.flags & MPG123_QUIET)) error("decode_update() has been called before reading the first MPEG frame! Internal programming error.");
581
583 return MPG123_ERR;
584 }
585
587 native_rate = frame_freq(mh);
588
589 b = frame_output_format(mh); /* Select the new output format based on given constraints. */
590 if(b < 0) return MPG123_ERR;
591
592 if(b == 1) mh->new_format = 1; /* Store for later... */
593
594 debug3("updating decoder structure with native rate %li and af.rate %li (new format: %i)", native_rate, mh->af.rate, mh->new_format);
595 if(mh->af.rate == native_rate) mh->down_sample = 0;
596 else if(mh->af.rate == native_rate>>1) mh->down_sample = 1;
597 else if(mh->af.rate == native_rate>>2) mh->down_sample = 2;
598 else mh->down_sample = 3; /* flexible (fixed) rate */
599 switch(mh->down_sample)
600 {
601 case 0:
602 case 1:
603 case 2:
605 /* With downsampling I get less samples per frame */
606 mh->outblock = outblock_bytes(mh, (mh->spf>>mh->down_sample));
607 break;
608#ifndef NO_NTOM
609 case 3:
610 {
611 if(synth_ntom_set_step(mh) != 0) return -1;
612 if(frame_freq(mh) > mh->af.rate)
613 {
614 mh->down_sample_sblimit = SBLIMIT * mh->af.rate;
616 if(mh->down_sample_sblimit < 1)
617 mh->down_sample_sblimit = 1;
618 }
619 else mh->down_sample_sblimit = SBLIMIT;
620 mh->outblock = outblock_bytes(mh,
621 ( ( NTOM_MUL-1+mh->spf
622 * (((size_t)NTOM_MUL*mh->af.rate)/frame_freq(mh))
623 )/NTOM_MUL ));
624 }
625 break;
626#endif
627 }
628
629 if(!(mh->p.flags & MPG123_FORCE_MONO))
630 {
631 if(mh->af.channels == 1) mh->single = SINGLE_MIX;
632 else mh->single = SINGLE_STEREO;
633 }
634 else mh->single = (mh->p.flags & MPG123_FORCE_MONO)-1;
635 if(set_synth_functions(mh) != 0) return -1;;
636
637 /* The needed size of output buffer may have changed. */
638 if(frame_outbuffer(mh) != MPG123_OK) return -1;
639
640 do_rva(mh);
641 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);
642
643 mh->decoder_change = 0;
644 return 0;
645}
#define NTOM_MUL
Definition: decode.h:32
@ FRAME_FRESH_DECODER
Definition: frame.h:94
#define SINGLE_STEREO
Definition: frame.h:188
#define SINGLE_MIX
Definition: frame.h:191
@ MPG123_ERR
Definition: mpg123.h:382
@ MPG123_BAD_DECODER_SETUP
Definition: mpg123.h:420
@ MPG123_OK
Definition: mpg123.h:383
@ MPG123_FORCE_MONO
Definition: mpg123.h:213
@ MPG123_QUIET
Definition: mpg123.h:219
#define frame_outbuffer
Definition: intsym.h:181
#define frame_freq
Definition: intsym.h:239
#define do_rva
Definition: intsym.h:190
#define set_synth_functions
Definition: intsym.h:232
#define outblock_bytes
Definition: intsym.h:227
#define synth_ntom_set_step
Definition: intsym.h:154
#define frame_output_format
Definition: intsym.h:182
#define b
Definition: ke_i.h:79
#define error(str)
Definition: mkdosfs.c:1605
#define SBLIMIT
#define debug3(s, a, b, c)
Definition: debug.h:63
struct mpg123_pars_struct p
Definition: frame.h:289
int down_sample_sblimit
Definition: frame.h:194

◆ decoder_synth_bytes()

off_t decoder_synth_bytes ( mpg123_handle fr,
off_t  s 
)

Definition at line 558 of file format.c.

559{
560 return s * fr->af.dec_encsize * fr->af.channels;
561}
GLdouble s
Definition: gl.h:2039

◆ open_fixed_post()

int open_fixed_post ( mpg123_handle mh,
int  channels,
int  encoding 
)

Definition at line 480 of file libmpg123.c.

481{
482 if(!mh)
483 return MPG123_BAD_HANDLE;
484 long rate;
485 int err = mpg123_getformat(mh, &rate, &channels, &encoding);
486 if(err == MPG123_OK)
488 if(err == MPG123_OK)
490 if(err == MPG123_OK)
491 {
492 if(mh->track_frames < 1 && (mh->rdat.flags & READER_SEEKABLE))
493 {
494 debug("open_fixed_post: scan because we can seek and do not know track_frames");
495 err = mpg123_scan(mh);
496 }
497 }
498 if(err != MPG123_OK)
499 mpg123_close(mh);
500 return err;
501}
@ MPG123_BAD_HANDLE
Definition: mpg123.h:393
int attribute_align_arg mpg123_close(mpg123_handle *mh)
Definition: libmpg123.c:1694
MPG123_EXPORT int mpg123_format_none(mpg123_handle *mh)
Definition: format.c:417
MPG123_EXPORT int mpg123_format(mpg123_handle *mh, long rate, int channels, int encodings)
Definition: format.c:475
int attribute_align_arg mpg123_getformat(mpg123_handle *mh, long *rate, int *channels, int *encoding)
Definition: libmpg123.c:1141
int attribute_align_arg mpg123_scan(mpg123_handle *mh)
Definition: libmpg123.c:1461
#define debug(msg)
Definition: key_call.c:71
int rate
Definition: pcmconverter.c:97
int This channels
Definition: rdpsnd_libao.c:37
#define err(...)
#define READER_SEEKABLE
Definition: reader.h:115
off_t track_frames
Definition: frame.h:246
struct reader_data rdat
Definition: frame.h:288
static char * encoding
Definition: xmllint.c:155

◆ open_fixed_pre()

int open_fixed_pre ( mpg123_handle mh,
int  channels,
int  encoding 
)

Definition at line 469 of file libmpg123.c.

470{
471 if(!mh)
472 return MPG123_BAD_HANDLE;
473 mh->p.flags |= MPG123_NO_FRANKENSTEIN;
474 int err = mpg123_format_none(mh);
475 if(err == MPG123_OK)
477 return err;
478}
@ MPG123_NO_FRANKENSTEIN
Definition: mpg123.h:261
MPG123_EXPORT int mpg123_format2(mpg123_handle *mh, long rate, int channels, int encodings)
Definition: format.c:464

◆ outblock_bytes()

off_t outblock_bytes ( mpg123_handle fr,
off_t  s 
)

Definition at line 576 of file format.c.

577{
578 int encsize = (fr->af.encoding & MPG123_ENC_24)
579 ? 4 /* Intermediate 32 bit. */
580 : (fr->af.encsize > fr->af.dec_encsize
581 ? fr->af.encsize
582 : fr->af.dec_encsize);
583 return s * encsize * fr->af.channels;
584}
@ MPG123_ENC_24
Definition: fmt123.h:50

◆ postprocess_buffer()

void postprocess_buffer ( mpg123_handle fr)

Definition at line 700 of file format.c.

701{
702 /*
703 This caters for the final output formats that are never produced by
704 decoder synth directly (wide unsigned and 24 bit formats) or that are
705 missing because of limited decoder precision (16 bit synth but 32 or
706 24 bit output).
707 */
708 switch(fr->af.dec_enc)
709 {
710#ifndef NO_32BIT
712 switch(fr->af.encoding)
713 {
716 break;
720 break;
723 break;
724 }
725 break;
726#endif
727#ifndef NO_16BIT
729 switch(fr->af.encoding)
730 {
733 break;
734#ifndef NO_REAL
737 break;
738#endif
739#ifndef NO_32BIT
742 break;
746 break;
751 break;
755 break;
756#endif
757 }
758 break;
759#endif
760 }
761 if(fr->p.flags & MPG123_FORCE_ENDIAN)
762 {
763 if(
764#ifdef WORDS_BIGENDIAN
765 !(
766#endif
767 fr->p.flags & MPG123_BIG_ENDIAN
768#ifdef WORDS_BIGENDIAN
769 )
770#endif
771 )
772 swap_endian(&fr->buffer, mpg123_encsize(fr->af.encoding));
773 }
774}
@ MPG123_ENC_UNSIGNED_32
Definition: fmt123.h:72
@ MPG123_ENC_SIGNED_16
Definition: fmt123.h:58
@ MPG123_ENC_UNSIGNED_24
Definition: fmt123.h:76
@ MPG123_ENC_SIGNED_24
Definition: fmt123.h:74
@ MPG123_ENC_SIGNED_32
Definition: fmt123.h:70
@ MPG123_ENC_UNSIGNED_16
Definition: fmt123.h:60
@ MPG123_ENC_FLOAT_32
Definition: fmt123.h:78
@ MPG123_BIG_ENDIAN
Definition: mpg123.h:245
@ MPG123_FORCE_ENDIAN
Definition: mpg123.h:239
int attribute_align_arg mpg123_encsize(int encoding)
Definition: format.c:131
void swap_endian(struct outbuffer *buf, int block)
Definition: format.c:689
static void conv_s16_to_s32(struct outbuffer *buf)
Definition: format.c:661
static void conv_s32_to_u32(struct outbuffer *buf)
Definition: format.c:601
static void conv_s16_to_u16(struct outbuffer *buf)
Definition: format.c:623
static void chop_fourth_byte(struct outbuffer *buf)
Definition: format.c:590
static void conv_s16_to_f32(struct outbuffer *buf)
Definition: format.c:635
struct outbuffer buffer
Definition: frame.h:267

◆ samples_to_bytes()

off_t samples_to_bytes ( mpg123_handle fr,
off_t  s 
)

Definition at line 565 of file format.c.

566{
567 return s * fr->af.encsize * fr->af.channels;
568}