ReactOS 0.4.16-dev-297-gc569aee
Collaboration diagram for mpg123 status and information:

Modules

 

Classes

struct  mpg123_frameinfo
 
struct  mpg123_moreinfo
 

Enumerations

enum  mpg123_vbr { MPG123_CBR =0 , MPG123_VBR , MPG123_ABR }
 
enum  mpg123_version { MPG123_1_0 =0 , MPG123_2_0 , MPG123_2_5 }
 
enum  mpg123_mode { MPG123_M_STEREO =0 , MPG123_M_JOINT , MPG123_M_DUAL , MPG123_M_MONO }
 
enum  mpg123_flags { MPG123_CRC =0x1 , MPG123_COPYRIGHT =0x2 , MPG123_PRIVATE =0x4 , MPG123_ORIGINAL =0x8 }
 
enum  mpg123_state {
  MPG123_ACCURATE = 1 , MPG123_BUFFERFILL , MPG123_FRANKENSTEIN , MPG123_FRESH_DECODER ,
  MPG123_ENC_DELAY , MPG123_ENC_PADDING , MPG123_DEC_DELAY
}
 

Functions

MPG123_EXPORT int mpg123_info (mpg123_handle *mh, struct mpg123_frameinfo *mi)
 
MPG123_EXPORT int mpg123_set_moreinfo (mpg123_handle *mh, struct mpg123_moreinfo *mi)
 
MPG123_EXPORT size_t mpg123_safe_buffer (void)
 
MPG123_EXPORT int mpg123_scan (mpg123_handle *mh)
 
MPG123_EXPORT off_t mpg123_framelength (mpg123_handle *mh)
 
MPG123_EXPORT off_t mpg123_length (mpg123_handle *mh)
 
MPG123_EXPORT int mpg123_set_filesize (mpg123_handle *mh, off_t size)
 
MPG123_EXPORT double mpg123_tpf (mpg123_handle *mh)
 
MPG123_EXPORT int mpg123_spf (mpg123_handle *mh)
 
MPG123_EXPORT long mpg123_clip (mpg123_handle *mh)
 
MPG123_EXPORT int mpg123_getstate (mpg123_handle *mh, enum mpg123_state key, long *val, double *fval)
 

Detailed Description

Enumeration Type Documentation

◆ mpg123_flags

Enumeration of the MPEG Audio flag bits

Enumerator
MPG123_CRC 

The bitstream is error protected using 16-bit CRC.

MPG123_COPYRIGHT 

The bitstream is copyrighted.

MPG123_PRIVATE 

The private bit has been set.

MPG123_ORIGINAL 

The bitstream is an original, not a copy.

Definition at line 1030 of file mpg123.h.

1030 {
1031 MPG123_CRC=0x1,
1032 MPG123_COPYRIGHT=0x2,
1033 MPG123_PRIVATE=0x4,
1034 MPG123_ORIGINAL=0x8
1035};
@ MPG123_PRIVATE
Definition: mpg123.h:1033
@ MPG123_COPYRIGHT
Definition: mpg123.h:1032
@ MPG123_CRC
Definition: mpg123.h:1031
@ MPG123_ORIGINAL
Definition: mpg123.h:1034

◆ mpg123_mode

Enumeration of the MPEG Audio mode. Only the mono mode has 1 channel, the others have 2 channels.

Enumerator
MPG123_M_STEREO 

Standard Stereo.

MPG123_M_JOINT 

Joint Stereo.

MPG123_M_DUAL 

Dual Channel.

MPG123_M_MONO 

Single Channel.

Definition at line 1021 of file mpg123.h.

1021 {
1022 MPG123_M_STEREO=0,
1026};
@ MPG123_M_MONO
Definition: mpg123.h:1025
@ MPG123_M_DUAL
Definition: mpg123.h:1024
@ MPG123_M_JOINT
Definition: mpg123.h:1023
@ MPG123_M_STEREO
Definition: mpg123.h:1022

◆ mpg123_state

The key values for state information from mpg123_getstate().

Enumerator
MPG123_ACCURATE 

Query if positons are currently accurate (integer value, 0 if false, 1 if true).

MPG123_BUFFERFILL 

Get fill of internal (feed) input buffer as integer byte count returned as long and as double. An error is returned on integer overflow while converting to (signed) long, but the returned floating point value shold still be fine.

MPG123_FRANKENSTEIN 

Stream consists of carelessly stitched together files. Seeking may yield unexpected results (also with MPG123_ACCURATE, it may be confused).

MPG123_FRESH_DECODER 

Decoder structure has been updated, possibly indicating changed stream (integer value, 0 if false, 1 if true). Flag is cleared after retrieval.

MPG123_ENC_DELAY 

Encoder delay read from Info tag (layer III, -1 if unknown).

MPG123_ENC_PADDING 

Encoder padding read from Info tag (layer III, -1 if unknown).

MPG123_DEC_DELAY 

Decoder delay (for layer III only, -1 otherwise).

Definition at line 1157 of file mpg123.h.

1158{
1159 MPG123_ACCURATE = 1
1166};
@ MPG123_ACCURATE
Definition: mpg123.h:1159
@ MPG123_BUFFERFILL
Definition: mpg123.h:1160
@ MPG123_DEC_DELAY
Definition: mpg123.h:1165
@ MPG123_ENC_DELAY
Definition: mpg123.h:1163
@ MPG123_FRANKENSTEIN
Definition: mpg123.h:1161
@ MPG123_ENC_PADDING
Definition: mpg123.h:1164
@ MPG123_FRESH_DECODER
Definition: mpg123.h:1162

◆ mpg123_vbr

Enumeration of the mode types of Variable Bitrate

Enumerator
MPG123_CBR 

Constant Bitrate Mode (default)

MPG123_VBR 

Variable Bitrate Mode

MPG123_ABR 

Average Bitrate Mode

Definition at line 1005 of file mpg123.h.

1005 {
1006 MPG123_CBR=0,
1007 MPG123_VBR,
1008 MPG123_ABR
1009};
@ MPG123_CBR
Definition: mpg123.h:1006
@ MPG123_ABR
Definition: mpg123.h:1008
@ MPG123_VBR
Definition: mpg123.h:1007

◆ mpg123_version

Enumeration of the MPEG Versions

Enumerator
MPG123_1_0 

MPEG Version 1.0

MPG123_2_0 

MPEG Version 2.0

MPG123_2_5 

MPEG Version 2.5

Definition at line 1012 of file mpg123.h.

1012 {
1013 MPG123_1_0=0,
1014 MPG123_2_0,
1015 MPG123_2_5
1016};
@ MPG123_2_0
Definition: mpg123.h:1014
@ MPG123_1_0
Definition: mpg123.h:1013
@ MPG123_2_5
Definition: mpg123.h:1015

Function Documentation

◆ mpg123_clip()

MPG123_EXPORT long mpg123_clip ( mpg123_handle mh)

Get and reset the clip count.

Parameters
mhhandle
Returns
count of clipped samples

Definition at line 1061 of file libmpg123.c.

1062{
1063 long ret = 0;
1064
1065 if(mh != NULL)
1066 {
1067 ret = mh->clip;
1068 mh->clip = 0;
1069 }
1070 return ret;
1071}
#define NULL
Definition: types.h:112
int ret

◆ mpg123_framelength()

MPG123_EXPORT off_t mpg123_framelength ( mpg123_handle mh)

Return, if possible, the full (expected) length of current track in MPEG frames.

Parameters
mhhandle
Returns
length >= 0 or MPG123_ERR if there is no length guess possible.

Definition at line 208 of file lfs_alias.c.

209{
211}
lfs_alias_t NATIVE_NAME() mpg123_framelength(mpg123_handle *mh)
Definition: lfs_alias.c:208
#define NATIVE_NAME(func)
Definition: lfs_alias.c:52

Referenced by mpg123_framelength().

◆ mpg123_getstate()

MPG123_EXPORT int mpg123_getstate ( mpg123_handle mh,
enum mpg123_state  key,
long val,
double fval 
)

Get various current decoder/stream state information.

Parameters
mhhandle
keythe key to identify the information to give.
valthe address to return (long) integer values to
fvalthe address to return floating point values to
Returns
MPG123_OK on success

Definition at line 360 of file libmpg123.c.

361{
362 int ret = MPG123_OK;
363 long theval = 0;
364 double thefval = 0.;
365
366 if(mh == NULL) return MPG123_BAD_HANDLE;
367
368 switch(key)
369 {
370 case MPG123_ACCURATE:
371 theval = mh->state_flags & FRAME_ACCURATE;
372 break;
374 theval = mh->state_flags & FRAME_FRANKENSTEIN;
375 break;
377#ifndef NO_FEEDER
378 {
379 size_t sval = bc_fill(&mh->rdat.buffer);
380 theval = (long)sval;
381 if(theval < 0 || (size_t)theval != sval)
382 {
384 ret = MPG123_ERR;
385 }
386 }
387#else
389 ret = MPG123_ERR;
390#endif
391 break;
393 theval = mh->state_flags & FRAME_FRESH_DECODER;
394 mh->state_flags &= ~FRAME_FRESH_DECODER;
395 break;
396 case MPG123_ENC_DELAY:
397 theval = mh->enc_delay;
398 break;
400 theval = mh->enc_padding;
401 break;
402 case MPG123_DEC_DELAY:
403 theval = mh->lay == 3 ? GAPLESS_DELAY : -1;
404 break;
405 default:
406 mh->err = MPG123_BAD_KEY;
407 ret = MPG123_ERR;
408 }
409
410 if(val != NULL) *val = theval;
411 if(fval != NULL) *fval = thefval;
412
413 return ret;
414}
@ FRAME_FRESH_DECODER
Definition: frame.h:94
@ FRAME_ACCURATE
Definition: frame.h:92
@ FRAME_FRANKENSTEIN
Definition: frame.h:93
#define GAPLESS_DELAY
Definition: frame.h:390
GLuint GLfloat * val
Definition: glext.h:7180
@ MPG123_INT_OVERFLOW
Definition: mpg123.h:426
@ MPG123_BAD_HANDLE
Definition: mpg123.h:393
@ MPG123_ERR
Definition: mpg123.h:382
@ MPG123_BAD_KEY
Definition: mpg123.h:417
@ MPG123_MISSING_FEATURE
Definition: mpg123.h:421
@ MPG123_OK
Definition: mpg123.h:383
#define bc_fill
Definition: intsym.h:250
#define long
Definition: qsort.c:33
Definition: copy.c:22
struct reader_data rdat
Definition: frame.h:288

◆ mpg123_info()

MPG123_EXPORT int mpg123_info ( mpg123_handle mh,
struct mpg123_frameinfo mi 
)

Get frame information about the MPEG audio bitstream and store it in a mpg123_frameinfo structure.

Parameters
mhhandle
miaddress of existing frameinfo structure to write to
Returns
MPG123_OK on success

Definition at line 1087 of file libmpg123.c.

1088{
1089 int b;
1090
1091 if(mh == NULL) return MPG123_BAD_HANDLE;
1092 if(mi == NULL)
1093 {
1094 mh->err = MPG123_ERR_NULL;
1095 return MPG123_ERR;
1096 }
1097 b = init_track(mh);
1098 if(b < 0) return b;
1099
1100 mi->version = mh->mpeg25 ? MPG123_2_5 : (mh->lsf ? MPG123_2_0 : MPG123_1_0);
1101 mi->layer = mh->lay;
1102 mi->rate = frame_freq(mh);
1103 switch(mh->mode)
1104 {
1105 case 0: mi->mode = MPG123_M_STEREO; break;
1106 case 1: mi->mode = MPG123_M_JOINT; break;
1107 case 2: mi->mode = MPG123_M_DUAL; break;
1108 case 3: mi->mode = MPG123_M_MONO; break;
1109 default: mi->mode = 0; // Nothing good to do here.
1110 }
1111 mi->mode_ext = mh->mode_ext;
1112 mi->framesize = mh->framesize+4; /* Include header. */
1113 mi->flags = 0;
1114 if(mh->error_protection) mi->flags |= MPG123_CRC;
1115 if(mh->copyright) mi->flags |= MPG123_COPYRIGHT;
1116 if(mh->extension) mi->flags |= MPG123_PRIVATE;
1117 if(mh->original) mi->flags |= MPG123_ORIGINAL;
1118 mi->emphasis = mh->emphasis;
1119 mi->bitrate = frame_bitrate(mh);
1120 mi->abr_rate = mh->abr_rate;
1121 mi->vbr = mh->vbr;
1122 return MPG123_OK;
1123}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
@ MPG123_ERR_NULL
Definition: mpg123.h:400
#define frame_freq
Definition: intsym.h:239
#define frame_bitrate
Definition: intsym.h:238
#define b
Definition: ke_i.h:79
static int init_track(mpg123_handle *mh)
Definition: libmpg123.c:1076
enum mpg123_vbr vbr
Definition: frame.h:215
static MONITORINFO mi
Definition: win.c:7338

◆ mpg123_length()

MPG123_EXPORT off_t mpg123_length ( mpg123_handle mh)

Return, if possible, the full (expected) length of current track in samples (PCM frames).

This relies either on an Info frame at the beginning or a previous call to mpg123_scan() to get the real number of MPEG frames in a file. It will guess based on file size if neither Info frame nor scan data are present. In any case, there is no guarantee that the decoder will not give you more data, for example in case the open file gets appended to during decoding.

Parameters
mhhandle
Returns
length >= 0 or MPG123_ERR if there is no length guess possible.

Definition at line 214 of file lfs_alias.c.

215{
216 return NATIVE_NAME(mpg123_length)(mh);
217}
lfs_alias_t NATIVE_NAME() mpg123_length(mpg123_handle *mh)
Definition: lfs_alias.c:214

Referenced by mpg123_length().

◆ mpg123_safe_buffer()

MPG123_EXPORT size_t mpg123_safe_buffer ( void  )

Get the safe output buffer size for all cases (when you want to replace the internal buffer)

Returns
safe buffer size

Definition at line 647 of file libmpg123.c.

648{
649 /* real is the largest possible output (it's 32bit float, 32bit int or 64bit double). */
650 return sizeof(real)*2*1152*NTOM_MAX;
651}
#define NTOM_MAX
Definition: decode.h:30
#define real

Referenced by mpg123_outblock().

◆ mpg123_scan()

MPG123_EXPORT int mpg123_scan ( mpg123_handle mh)

Make a full parsing scan of each frame in the file. ID3 tags are found. An accurate length value is stored. Seek index will be filled. A seek back to current position is performed. At all, this function refuses work when stream is not seekable.

Parameters
mhhandle
Returns
MPG123_OK on success

Definition at line 1461 of file libmpg123.c.

1462{
1463 int b;
1464 off_t oldpos;
1465 off_t track_frames = 0;
1466 off_t track_samples = 0;
1467
1468 if(mh == NULL) return MPG123_BAD_HANDLE;
1469 if(!(mh->rdat.flags & READER_SEEKABLE)){ mh->err = MPG123_NO_SEEK; return MPG123_ERR; }
1470 /* Scan through the _whole_ file, since the current position is no count but computed assuming constant samples per frame. */
1471 /* Also, we can just keep the current buffer and seek settings. Just operate on input frames here. */
1472 debug("issuing scan");
1473 b = init_track(mh); /* mh->num >= 0 !! */
1474 if(b<0)
1475 {
1476 if(b == MPG123_DONE) return MPG123_OK;
1477 else return MPG123_ERR; /* Must be error here, NEED_MORE is not for seekable streams. */
1478 }
1479 oldpos = mpg123_tell(mh);
1480 b = mh->rd->seek_frame(mh, 0);
1481 if(b<0 || mh->num != 0) return MPG123_ERR;
1482 /* One frame must be there now. */
1483 track_frames = 1;
1484 track_samples = mh->spf; /* Internal samples. */
1485 debug("TODO: We should disable gapless code when encountering inconsistent mh->spf!");
1486 debug(" ... at least unset MPG123_ACCURATE.");
1487 /* Do not increment mh->track_frames in the loop as tha would confuse Frankenstein detection. */
1488 while(read_frame(mh) == 1)
1489 {
1490 ++track_frames;
1491 track_samples += mh->spf;
1492 }
1493 mh->track_frames = track_frames;
1494 mh->track_samples = track_samples;
1495 debug2("Scanning yielded %"OFF_P" track samples, %"OFF_P" frames.", (off_p)mh->track_samples, (off_p)mh->track_frames);
1496#ifdef GAPLESS
1497 /* Also, think about usefulness of that extra value track_samples ... it could be used for consistency checking. */
1498 if(mh->p.flags & MPG123_GAPLESS) frame_gapless_update(mh, mh->track_samples);
1499#endif
1500 return mpg123_seek(mh, oldpos, SEEK_SET) >= 0 ? MPG123_OK : MPG123_ERR;
1501}
__kernel_off_t off_t
Definition: linux.h:201
GLuint GLuint num
Definition: glext.h:9618
@ MPG123_NO_SEEK
Definition: mpg123.h:406
@ MPG123_DONE
Definition: mpg123.h:379
@ MPG123_GAPLESS
Definition: mpg123.h:220
off_t attribute_align_arg mpg123_tell(mpg123_handle *mh)
Definition: libmpg123.c:1164
off_t attribute_align_arg mpg123_seek(mpg123_handle *mh, off_t sampleoff, int whence)
Definition: libmpg123.c:1257
#define read_frame
Definition: intsym.h:241
#define frame_gapless_update
Definition: intsym.h:193
#define SEEK_SET
Definition: jmemansi.c:26
#define debug(msg)
Definition: key_call.c:71
#define OFF_P
Definition: compat.h:131
long off_p
Definition: compat.h:132
#define debug2(s, a, b)
Definition: debug.h:62
#define READER_SEEKABLE
Definition: reader.h:115
struct mpg123_pars_struct p
Definition: frame.h:289
struct reader * rd
Definition: frame.h:287
off_t track_frames
Definition: frame.h:246
off_t track_samples
Definition: frame.h:247

Referenced by mpg123_seek(), and open_fixed_post().

◆ mpg123_set_filesize()

MPG123_EXPORT int mpg123_set_filesize ( mpg123_handle mh,
off_t  size 
)

Override the value for file size in bytes. Useful for getting sensible track length values in feed mode or for HTTP streams.

Parameters
mhhandle
sizefile size in bytes
Returns
MPG123_OK on success

Definition at line 507 of file lfs_wrap.c.

508{
509 return MPG123_LARGENAME(mpg123_set_filesize)(mh, size);
510}
GLsizeiptr size
Definition: glext.h:5919
int attribute_align_arg mpg123_set_filesize(mpg123_handle *mh, long size)
Definition: lfs_wrap.c:507

Referenced by mpg123_set_filesize().

◆ mpg123_set_moreinfo()

MPG123_EXPORT int mpg123_set_moreinfo ( mpg123_handle mh,
struct mpg123_moreinfo mi 
)

Trigger collection of additional decoder information while decoding.

Parameters
mhhandle
mipointer to data storage (NULL to disable collection)
Returns
MPG123_OK if the collection was enabled/disabled as desired, MPG123_ERR otherwise (e.g. if the feature is disabled)

Definition at line 638 of file frame.c.

640{
641#ifndef NO_MOREINFO
642 mh->pinfo = mi;
643 return MPG123_OK;
644#else
646 return MPG123_ERR;
647#endif
648}
struct mpg123_moreinfo * pinfo
Definition: frame.h:343

◆ mpg123_spf()

MPG123_EXPORT int mpg123_spf ( mpg123_handle mh)

Get MPEG frame duration in samples.

Parameters
mhhandle
Returns
samples per frame for the most recently parsed frame; <0 on errors

Definition at line 973 of file parse.c.

974{
975 if(mh == NULL) return MPG123_ERR;
976
977 return mh->firsthead ? mh->spf : MPG123_ERR;
978}
unsigned long firsthead
Definition: frame.h:260

◆ mpg123_tpf()

MPG123_EXPORT double mpg123_tpf ( mpg123_handle mh)

Get MPEG frame duration in seconds.

Parameters
mhhandle
Returns
frame duration in seconds, <0 on error

Definition at line 980 of file parse.c.

981{
982 static int bs[4] = { 0,384,1152,1152 };
983 double tpf;
984 if(fr == NULL || !fr->firsthead) return MPG123_ERR;
985
986 tpf = (double) bs[fr->lay];
987 tpf /= freqs[fr->sampling_frequency] << (fr->lsf);
988 return tpf;
989}
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
static const long freqs[9]
Definition: parse.c:70

Referenced by get_songlen(), mpg123_position(), and mpg123_timeframe().