ReactOS  r75384
mpg123 status and information

Classes

struct  mpg123_frameinfo
 

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 }
 

Functions

MPG123_EXPORT int mpg123_info (mpg123_handle *mh, struct mpg123_frameinfo *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

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 893 of file mpg123.h.

893  {
894  MPG123_CRC=0x1,
895  MPG123_COPYRIGHT=0x2,
896  MPG123_PRIVATE=0x4,
897  MPG123_ORIGINAL=0x8
898 };

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 884 of file mpg123.h.

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.

Definition at line 978 of file mpg123.h.

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 868 of file mpg123.h.

868  {
869  MPG123_CBR=0,
870  MPG123_VBR,
871  MPG123_ABR
872 };

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 875 of file mpg123.h.

875  {
876  MPG123_1_0=0,
877  MPG123_2_0,
878  MPG123_2_5
879 };

Function Documentation

MPG123_EXPORT long mpg123_clip ( mpg123_handle mh)

Get and reset the clip count.

Parameters
mhhandle
Returns
count of clipped samples

Definition at line 986 of file libmpg123.c.

987 {
988  long ret = 0;
989 
990  if(mh != NULL)
991  {
992  ret = mh->clip;
993  mh->clip = 0;
994  }
995  return ret;
996 }
smooth NULL
Definition: ftsmooth.c:513
int ret
MPG123_EXPORT off_t mpg123_framelength ( mpg123_handle mh)

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

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

Definition at line 200 of file lfs_alias.c.

201 {
202  return NATIVE_NAME(mpg123_framelength)(mh);
203 }
lfs_alias_t NATIVE_NAME() mpg123_framelength(mpg123_handle *mh)
Definition: lfs_alias.c:200
#define NATIVE_NAME(func)
Definition: lfs_alias.c:52
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 351 of file libmpg123.c.

352 {
353  int ret = MPG123_OK;
354  long theval = 0;
355  double thefval = 0.;
356 
357  if(mh == NULL) return MPG123_BAD_HANDLE;
358 
359  switch(key)
360  {
361  case MPG123_ACCURATE:
362  theval = mh->state_flags & FRAME_ACCURATE;
363  break;
364  case MPG123_FRANKENSTEIN:
365  theval = mh->state_flags & FRAME_FRANKENSTEIN;
366  break;
367  case MPG123_BUFFERFILL:
368 #ifndef NO_FEEDER
369  {
370  size_t sval = bc_fill(&mh->rdat.buffer);
371  theval = (long)sval;
372  if(theval < 0 || (size_t)theval != sval)
373  {
374  mh->err = MPG123_INT_OVERFLOW;
375  ret = MPG123_ERR;
376  }
377  }
378 #else
380  ret = MPG123_ERR;
381 #endif
382  break;
384  theval = mh->state_flags & FRAME_FRESH_DECODER;
386  break;
387  default:
388  mh->err = MPG123_BAD_KEY;
389  ret = MPG123_ERR;
390  }
391 
392  if(val != NULL) *val = theval;
393  if(fval != NULL) *fval = thefval;
394 
395  return ret;
396 }
struct reader_data rdat
Definition: frame.h:286
smooth NULL
Definition: ftsmooth.c:513
unsigned long
Definition: typeof.h:99
GLuint GLfloat * val
Definition: glext.h:7180
int ret
#define bc_fill
Definition: intsym.h:240
Definition: path.c:42
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 1012 of file libmpg123.c.

1013 {
1014  int b;
1015 
1016  if(mh == NULL) return MPG123_BAD_HANDLE;
1017  if(mi == NULL)
1018  {
1019  mh->err = MPG123_ERR_NULL;
1020  return MPG123_ERR;
1021  }
1022  b = init_track(mh);
1023  if(b < 0) return b;
1024 
1025  mi->version = mh->mpeg25 ? MPG123_2_5 : (mh->lsf ? MPG123_2_0 : MPG123_1_0);
1026  mi->layer = mh->lay;
1027  mi->rate = frame_freq(mh);
1028  switch(mh->mode)
1029  {
1030  case 0: mi->mode = MPG123_M_STEREO; break;
1031  case 1: mi->mode = MPG123_M_JOINT; break;
1032  case 2: mi->mode = MPG123_M_DUAL; break;
1033  case 3: mi->mode = MPG123_M_MONO; break;
1034  default: error("That mode cannot be!");
1035  }
1036  mi->mode_ext = mh->mode_ext;
1037  mi->framesize = mh->framesize+4; /* Include header. */
1038  mi->flags = 0;
1039  if(mh->error_protection) mi->flags |= MPG123_CRC;
1040  if(mh->copyright) mi->flags |= MPG123_COPYRIGHT;
1041  if(mh->extension) mi->flags |= MPG123_PRIVATE;
1042  if(mh->original) mi->flags |= MPG123_ORIGINAL;
1043  mi->emphasis = mh->emphasis;
1044  mi->bitrate = frame_bitrate(mh);
1045  mi->abr_rate = mh->abr_rate;
1046  mi->vbr = mh->vbr;
1047  return MPG123_OK;
1048 }
enum mpg123_mode mode
Definition: mpg123.h:906
#define error(str)
Definition: mkdosfs.c:1605
enum mpg123_vbr vbr
Definition: mpg123.h:913
smooth NULL
Definition: ftsmooth.c:513
#define b
Definition: ke_i.h:79
enum mpg123_version version
Definition: mpg123.h:903
enum mpg123_flags flags
Definition: mpg123.h:909
static int init_track(mpg123_handle *mh)
Definition: libmpg123.c:1001
#define frame_bitrate
Definition: intsym.h:228
#define frame_freq
Definition: intsym.h:229
enum mpg123_vbr vbr
Definition: frame.h:214
MPG123_EXPORT off_t mpg123_length ( mpg123_handle mh)

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

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

Definition at line 206 of file lfs_alias.c.

207 {
208  return NATIVE_NAME(mpg123_length)(mh);
209 }
lfs_alias_t NATIVE_NAME() mpg123_length(mpg123_handle *mh)
Definition: lfs_alias.c:206
#define NATIVE_NAME(func)
Definition: lfs_alias.c:52
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 577 of file libmpg123.c.

Referenced by mpg123_outblock().

578 {
579  /* real is the largest possible output (it's 32bit float, 32bit int or 64bit double). */
580  return sizeof(real)*2*1152*NTOM_MAX;
581 }
_Tp _STLP_CALL real(const complex< _Tp > &__z)
Definition: _complex.h:727
#define NTOM_MAX
Definition: decode.h:30
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 1386 of file libmpg123.c.

Referenced by mpg123_seek().

1387 {
1388  int b;
1389  off_t oldpos;
1390  off_t track_frames = 0;
1391  off_t track_samples = 0;
1392 
1393  if(mh == NULL) return MPG123_BAD_HANDLE;
1394  if(!(mh->rdat.flags & READER_SEEKABLE)){ mh->err = MPG123_NO_SEEK; return MPG123_ERR; }
1395  /* Scan through the _whole_ file, since the current position is no count but computed assuming constant samples per frame. */
1396  /* Also, we can just keep the current buffer and seek settings. Just operate on input frames here. */
1397  debug("issuing scan");
1398  b = init_track(mh); /* mh->num >= 0 !! */
1399  if(b<0)
1400  {
1401  if(b == MPG123_DONE) return MPG123_OK;
1402  else return MPG123_ERR; /* Must be error here, NEED_MORE is not for seekable streams. */
1403  }
1404  oldpos = mpg123_tell(mh);
1405  b = mh->rd->seek_frame(mh, 0);
1406  if(b<0 || mh->num != 0) return MPG123_ERR;
1407  /* One frame must be there now. */
1408  track_frames = 1;
1409  track_samples = mh->spf; /* Internal samples. */
1410  debug("TODO: We should disable gapless code when encountering inconsistent mh->spf!");
1411  debug(" ... at least unset MPG123_ACCURATE.");
1412  /* Do not increment mh->track_frames in the loop as tha would confuse Frankenstein detection. */
1413  while(read_frame(mh) == 1)
1414  {
1415  ++track_frames;
1416  track_samples += mh->spf;
1417  }
1418  mh->track_frames = track_frames;
1419  mh->track_samples = track_samples;
1420  debug2("Scanning yielded %"OFF_P" track samples, %"OFF_P" frames.", (off_p)mh->track_samples, (off_p)mh->track_frames);
1421 #ifdef GAPLESS
1422  /* Also, think about usefulness of that extra value track_samples ... it could be used for consistency checking. */
1423  if(mh->p.flags & MPG123_GAPLESS) frame_gapless_update(mh, mh->track_samples);
1424 #endif
1425  return mpg123_seek(mh, oldpos, SEEK_SET) >= 0 ? MPG123_OK : MPG123_ERR;
1426 }
#define READER_SEEKABLE
Definition: reader.h:115
struct mpg123_pars_struct p
Definition: frame.h:287
__kernel_off_t off_t
Definition: linux.h:201
off_t attribute_align_arg mpg123_tell(mpg123_handle *mh)
Definition: libmpg123.c:1089
#define debug2(s, a, b)
Definition: debug.h:53
struct reader_data rdat
Definition: frame.h:286
off_t track_frames
Definition: frame.h:244
smooth NULL
Definition: ftsmooth.c:513
#define b
Definition: ke_i.h:79
#define SEEK_SET
Definition: jmemansi.c:26
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
off_t attribute_align_arg mpg123_seek(mpg123_handle *mh, off_t sampleoff, int whence)
Definition: libmpg123.c:1182
GLuint GLuint num
Definition: glext.h:9618
#define read_frame
Definition: intsym.h:231
static int init_track(mpg123_handle *mh)
Definition: libmpg123.c:1001
long off_p
Definition: compat.h:130
#define debug(msg)
Definition: key_call.c:71
struct reader * rd
Definition: frame.h:285
void frame_gapless_update(mpg123_handle *mh, off_t total_samples)
off_t track_samples
Definition: frame.h:245
#define OFF_P
Definition: compat.h:129
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
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 914 of file parse.c.

915 {
916  if(mh == NULL) return MPG123_ERR;
917 
918  return mh->firsthead ? mh->spf : MPG123_ERR;
919 }
smooth NULL
Definition: ftsmooth.c:513
unsigned long firsthead
Definition: frame.h:258
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 921 of file parse.c.

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

922 {
923  static int bs[4] = { 0,384,1152,1152 };
924  double tpf;
925  if(fr == NULL || !fr->firsthead) return MPG123_ERR;
926 
927  tpf = (double) bs[fr->lay];
928  tpf /= freqs[fr->sampling_frequency] << (fr->lsf);
929  return tpf;
930 }
smooth NULL
Definition: ftsmooth.c:513
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:79
static const long freqs[9]
Definition: parse.c:64
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539