ReactOS  r74244
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_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 773 of file mpg123.h.

773  {
774  MPG123_CRC=0x1,
775  MPG123_COPYRIGHT=0x2,
776  MPG123_PRIVATE=0x4,
777  MPG123_ORIGINAL=0x8
778 };

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 764 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 833 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 748 of file mpg123.h.

748  {
749  MPG123_CBR=0,
750  MPG123_VBR,
751  MPG123_ABR
752 };

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

755  {
756  MPG123_1_0=0,
757  MPG123_2_0,
758  MPG123_2_5
759 };

Function Documentation

MPG123_EXPORT long mpg123_clip ( mpg123_handle mh)

Get and reset the clip count.

Definition at line 973 of file libmpg123.c.

974 {
975  long ret = 0;
976 
977  if(mh != NULL)
978  {
979  ret = mh->clip;
980  mh->clip = 0;
981  }
982  return ret;
983 }
smooth NULL
Definition: ftsmooth.c:464
int ret
MPG123_EXPORT int mpg123_getstate ( mpg123_handle mh,
enum mpg123_state  key,
long val,
double fval 
)

Get various current decoder/stream state information.

Parameters
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 339 of file libmpg123.c.

340 {
341  int ret = MPG123_OK;
342  long theval = 0;
343  double thefval = 0.;
344 
345  if(mh == NULL) return MPG123_BAD_HANDLE;
346 
347  switch(key)
348  {
349  case MPG123_ACCURATE:
350  theval = mh->state_flags & FRAME_ACCURATE;
351  break;
352  case MPG123_FRANKENSTEIN:
353  theval = mh->state_flags & FRAME_FRANKENSTEIN;
354  break;
355  case MPG123_BUFFERFILL:
356 #ifndef NO_FEEDER
357  {
358  size_t sval = bc_fill(&mh->rdat.buffer);
359  theval = (long)sval;
360  if((size_t)theval != sval)
361  {
362  mh->err = MPG123_INT_OVERFLOW;
363  ret = MPG123_ERR;
364  }
365  }
366 #else
368  ret = MPG123_ERR;
369 #endif
370  break;
372  theval = mh->state_flags & FRAME_FRESH_DECODER;
374  break;
375  default:
376  mh->err = MPG123_BAD_KEY;
377  ret = MPG123_ERR;
378  }
379 
380  if(val != NULL) *val = theval;
381  if(fval != NULL) *fval = thefval;
382 
383  return ret;
384 }
struct reader_data rdat
Definition: frame.h:285
smooth NULL
Definition: ftsmooth.c:464
unsigned long
Definition: typeof.h:98
size_t bc_fill(struct bufferchain *bc)
Definition: readers.c:504
GLuint GLfloat * val
Definition: glext.h:7180
int ret
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.

Returns
MPG123_OK on success

Definition at line 999 of file libmpg123.c.

1000 {
1001  int b;
1002 
1003  if(mh == NULL) return MPG123_BAD_HANDLE;
1004  if(mi == NULL)
1005  {
1006  mh->err = MPG123_ERR_NULL;
1007  return MPG123_ERR;
1008  }
1009  b = init_track(mh);
1010  if(b < 0) return b;
1011 
1012  mi->version = mh->mpeg25 ? MPG123_2_5 : (mh->lsf ? MPG123_2_0 : MPG123_1_0);
1013  mi->layer = mh->lay;
1014  mi->rate = frame_freq(mh);
1015  switch(mh->mode)
1016  {
1017  case 0: mi->mode = MPG123_M_STEREO; break;
1018  case 1: mi->mode = MPG123_M_JOINT; break;
1019  case 2: mi->mode = MPG123_M_DUAL; break;
1020  case 3: mi->mode = MPG123_M_MONO; break;
1021  default: error("That mode cannot be!");
1022  }
1023  mi->mode_ext = mh->mode_ext;
1024  mi->framesize = mh->framesize+4; /* Include header. */
1025  mi->flags = 0;
1026  if(mh->error_protection) mi->flags |= MPG123_CRC;
1027  if(mh->copyright) mi->flags |= MPG123_COPYRIGHT;
1028  if(mh->extension) mi->flags |= MPG123_PRIVATE;
1029  if(mh->original) mi->flags |= MPG123_ORIGINAL;
1030  mi->emphasis = mh->emphasis;
1031  mi->bitrate = frame_bitrate(mh);
1032  mi->abr_rate = mh->abr_rate;
1033  mi->vbr = mh->vbr;
1034  return MPG123_OK;
1035 }
enum mpg123_mode mode
Definition: mpg123.h:786
#define error(str)
Definition: mkdosfs.c:1605
enum mpg123_vbr vbr
Definition: mpg123.h:793
smooth NULL
Definition: ftsmooth.c:464
#define b
Definition: ke_i.h:79
enum mpg123_version version
Definition: mpg123.h:783
enum mpg123_flags flags
Definition: mpg123.h:789
static int init_track(mpg123_handle *mh)
Definition: libmpg123.c:988
#define frame_bitrate
Definition: intsym.h:210
#define frame_freq
Definition: intsym.h:211
enum mpg123_vbr vbr
Definition: frame.h:213
MPG123_EXPORT off_t mpg123_length ( mpg123_handle mh)

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

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_length)(mh);
203 }
lfs_alias_t NATIVE_NAME() mpg123_length(mpg123_handle *mh)
Definition: lfs_alias.c:200
#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)

Definition at line 564 of file libmpg123.c.

Referenced by mpg123_outblock().

565 {
566  /* real is the largest possible output (it's 32bit float, 32bit int or 64bit double). */
567  return sizeof(real)*2*1152*NTOM_MAX;
568 }
_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.

Returns
MPG123_OK on success

Definition at line 1341 of file libmpg123.c.

Referenced by mpg123_seek().

1342 {
1343  int b;
1344  off_t oldpos;
1345  off_t track_frames = 0;
1346  off_t track_samples = 0;
1347 
1348  if(mh == NULL) return MPG123_BAD_HANDLE;
1349  if(!(mh->rdat.flags & READER_SEEKABLE)){ mh->err = MPG123_NO_SEEK; return MPG123_ERR; }
1350  /* Scan through the _whole_ file, since the current position is no count but computed assuming constant samples per frame. */
1351  /* Also, we can just keep the current buffer and seek settings. Just operate on input frames here. */
1352  debug("issuing scan");
1353  b = init_track(mh); /* mh->num >= 0 !! */
1354  if(b<0)
1355  {
1356  if(b == MPG123_DONE) return MPG123_OK;
1357  else return MPG123_ERR; /* Must be error here, NEED_MORE is not for seekable streams. */
1358  }
1359  oldpos = mpg123_tell(mh);
1360  b = mh->rd->seek_frame(mh, 0);
1361  if(b<0 || mh->num != 0) return MPG123_ERR;
1362  /* One frame must be there now. */
1363  track_frames = 1;
1364  track_samples = mh->spf; /* Internal samples. */
1365  debug("TODO: We should disable gapless code when encountering inconsistent mh->spf!");
1366  debug(" ... at least unset MPG123_ACCURATE.");
1367  /* Do not increment mh->track_frames in the loop as tha would confuse Frankenstein detection. */
1368  while(read_frame(mh) == 1)
1369  {
1370  ++track_frames;
1371  track_samples += mh->spf;
1372  }
1373  mh->track_frames = track_frames;
1374  mh->track_samples = track_samples;
1375  debug2("Scanning yielded %"OFF_P" track samples, %"OFF_P" frames.", (off_p)mh->track_samples, (off_p)mh->track_frames);
1376 #ifdef GAPLESS
1377  /* Also, think about usefulness of that extra value track_samples ... it could be used for consistency checking. */
1378  if(mh->p.flags & MPG123_GAPLESS) frame_gapless_update(mh, mh->track_samples);
1379 #endif
1380  return mpg123_seek(mh, oldpos, SEEK_SET) >= 0 ? MPG123_OK : MPG123_ERR;
1381 }
#define READER_SEEKABLE
Definition: reader.h:115
struct mpg123_pars_struct p
Definition: frame.h:286
__kernel_off_t off_t
Definition: linux.h:201
off_t attribute_align_arg mpg123_tell(mpg123_handle *mh)
Definition: libmpg123.c:1070
#define debug2(s, a, b)
Definition: debug.h:46
struct reader_data rdat
Definition: frame.h:285
off_t track_frames
Definition: frame.h:243
smooth NULL
Definition: ftsmooth.c:464
#define debug(s)
Definition: debug.h:44
#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:1163
GLuint GLuint num
Definition: glext.h:9618
#define read_frame
Definition: intsym.h:213
static int init_track(mpg123_handle *mh)
Definition: libmpg123.c:988
long off_p
Definition: compat.h:109
struct reader * rd
Definition: frame.h:284
void frame_gapless_update(mpg123_handle *mh, off_t total_samples)
off_t track_samples
Definition: frame.h:244
#define OFF_P
Definition: compat.h:108
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.

Returns
MPG123_OK on success

Definition at line 490 of file lfs_wrap.c.

491 {
492  return MPG123_LARGENAME(mpg123_set_filesize)(mh, size);
493 }
GLsizeiptr size
Definition: glext.h:5919
int attribute_align_arg mpg123_set_filesize(mpg123_handle *mh, long size)
Definition: lfs_wrap.c:490
MPG123_EXPORT int mpg123_spf ( mpg123_handle mh)

Returns the samples per frame for the most recently parsed frame; <0 is error.

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:464
unsigned long firsthead
Definition: frame.h:257
MPG123_EXPORT double mpg123_tpf ( mpg123_handle mh)

Returns the time (seconds) per frame; <0 is 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:464
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