ReactOS  0.4.13-dev-482-ge57f103
frame.h File Reference
#include <stdio.h>
#include "config.h"
#include "mpg123.h"
#include "optimize.h"
#include "id3.h"
#include "icy.h"
#include "reader.h"
#include "index.h"
#include "synths.h"
Include dependency graph for frame.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  al_table
 
struct  outbuffer
 
struct  audioformat
 
struct  mpg123_pars_struct
 
struct  mpg123_handle_struct
 

Macros

#define MAXFRAMESIZE   3456
 
#define NUM_CHANNELS   2
 
#define SINGLE_STEREO   -1
 
#define SINGLE_LEFT   0
 
#define SINGLE_RIGHT   1
 
#define SINGLE_MIX   3
 
#define GAPLESS_DELAY   529
 

Enumerations

enum  frame_state_flags { FRAME_ACCURATE = 0x1, FRAME_FRANKENSTEIN = 0x2, FRAME_FRESH_DECODER = 0x4 }
 

Functions

void invalidate_format (struct audioformat *af)
 
void frame_init (mpg123_handle *fr)
 
void frame_init_par (mpg123_handle *fr, mpg123_pars *mp)
 
int frame_outbuffer (mpg123_handle *fr)
 
int frame_output_format (mpg123_handle *fr)
 
int frame_buffers (mpg123_handle *fr)
 
int frame_reset (mpg123_handle *fr)
 
int frame_buffers_reset (mpg123_handle *fr)
 
void frame_exit (mpg123_handle *fr)
 
int mpg123_print_index (mpg123_handle *fr, FILE *out)
 
off_t frame_index_find (mpg123_handle *fr, off_t want_frame, off_t *get_frame)
 
int frame_index_setup (mpg123_handle *fr)
 
void do_volume (mpg123_handle *fr, double factor)
 
void do_rva (mpg123_handle *fr)
 
void frame_gapless_init (mpg123_handle *fr, off_t framecount, off_t bskip, off_t eskip)
 
void frame_gapless_realinit (mpg123_handle *fr)
 
void frame_gapless_update (mpg123_handle *mh, off_t total_samples)
 
off_t frame_expect_outsamples (mpg123_handle *fr)
 
void frame_skip (mpg123_handle *fr)
 
off_t frame_ins2outs (mpg123_handle *fr, off_t ins)
 
off_t frame_outs (mpg123_handle *fr, off_t num)
 
off_t frame_expect_outsampels (mpg123_handle *fr)
 
off_t frame_offset (mpg123_handle *fr, off_t outs)
 
void frame_set_frameseek (mpg123_handle *fr, off_t fe)
 
void frame_set_seek (mpg123_handle *fr, off_t sp)
 
off_t frame_tell_seek (mpg123_handle *fr)
 
int frame_fill_toc (mpg123_handle *fr, unsigned char *in)
 

Macro Definition Documentation

◆ GAPLESS_DELAY

#define GAPLESS_DELAY   529

Definition at line 381 of file frame.h.

◆ MAXFRAMESIZE

#define MAXFRAMESIZE   3456

Definition at line 30 of file frame.h.

◆ NUM_CHANNELS

#define NUM_CHANNELS   2

Definition at line 72 of file frame.h.

◆ SINGLE_LEFT

#define SINGLE_LEFT   0

Definition at line 188 of file frame.h.

◆ SINGLE_MIX

#define SINGLE_MIX   3

Definition at line 190 of file frame.h.

◆ SINGLE_RIGHT

#define SINGLE_RIGHT   1

Definition at line 189 of file frame.h.

◆ SINGLE_STEREO

#define SINGLE_STEREO   -1

Definition at line 187 of file frame.h.

Enumeration Type Documentation

◆ frame_state_flags

Enumerator
FRAME_ACCURATE 

0001 Positions are considered accurate.

FRAME_FRANKENSTEIN 

0010 This stream is concatenated.

FRAME_FRESH_DECODER 

0100 Decoder is fleshly initialized.

Definition at line 89 of file frame.h.

90 {
91  FRAME_ACCURATE = 0x1
92  ,FRAME_FRANKENSTEIN = 0x2
93  ,FRAME_FRESH_DECODER = 0x4
94 };

Function Documentation

◆ do_rva()

void do_rva ( mpg123_handle fr)

Definition at line 980 of file frame.c.

981 {
982  double peak = 0;
983  double gain = 0;
984  double newscale;
985  double rvafact = 1;
986  if(get_rva(fr, &peak, &gain))
987  {
988  if(NOQUIET && fr->p.verbose > 1) fprintf(stderr, "Note: doing RVA with gain %f\n", gain);
989  rvafact = pow(10,gain/20);
990  }
991 
992  newscale = fr->p.outscale*rvafact;
993 
994  /* if peak is unknown (== 0) this check won't hurt */
995  if((peak*newscale) > 1.0)
996  {
997  newscale = 1.0/peak;
998  warning2("limiting scale value to %f to prevent clipping with indicated peak factor of %f", newscale, peak);
999  }
1000  /* first rva setting is forced with fr->lastscale < 0 */
1001  if(newscale != fr->lastscale || fr->decoder_change)
1002  {
1003  debug3("changing scale value from %f to %f (peak estimated to %f)", fr->lastscale != -1 ? fr->lastscale : fr->p.outscale, newscale, (double) (newscale*peak));
1004  fr->lastscale = newscale;
1005  /* It may be too early, actually. */
1006  if(fr->make_decode_tables != NULL) fr->make_decode_tables(fr); /* the actual work */
1007  }
1008 }
struct mpg123_pars_struct p
Definition: frame.h:287
#define debug3(s, a, b, c)
Definition: debug.h:54
float pow(float __x, int __y)
Definition: _cmath.h:458
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void(* make_decode_tables)(mpg123_handle *fr)
Definition: frame.h:183
smooth NULL
Definition: ftsmooth.c:416
static int get_rva(mpg123_handle *fr, double *peak, double *gain)
Definition: frame.c:957
#define warning2(s, a, b)
Definition: debug.h:73
#define NOQUIET
double lastscale
Definition: frame.h:235
FILE * stderr

Referenced by mpg123_volume().

◆ do_volume()

void do_volume ( mpg123_handle fr,
double  factor 
)

◆ frame_buffers()

int frame_buffers ( mpg123_handle fr)

Definition at line 263 of file frame.c.

264 {
265  int buffssize = 0;
266  debug1("frame %p buffer", (void*)fr);
267 /*
268  the used-to-be-static buffer of the synth functions, has some subtly different types/sizes
269 
270  2to1, 4to1, ntom, generic, i386: real[2][2][0x110]
271  mmx, sse: short[2][2][0x110]
272  i586(_dither): 4352 bytes; int/long[2][2][0x110]
273  i486: int[2][2][17*FIR_BUFFER_SIZE]
274  altivec: static real __attribute__ ((aligned (16))) buffs[4][4][0x110]
275 
276  Huh, altivec looks like fun. Well, let it be large... then, the 16 byte alignment seems to be implicit on MacOSX malloc anyway.
277  Let's make a reasonable attempt to allocate enough memory...
278  Keep in mind: biggest ones are i486 and altivec (mutually exclusive!), then follows i586 and normal real.
279  mmx/sse use short but also real for resampling.
280  Thus, minimum is 2*2*0x110*sizeof(real).
281 */
282  if(fr->cpu_opts.type == altivec) buffssize = 4*4*0x110*sizeof(real);
283 #ifdef OPT_I486
284  else if(fr->cpu_opts.type == ivier) buffssize = 2*2*17*FIR_BUFFER_SIZE*sizeof(int);
285 #endif
286  else if(fr->cpu_opts.type == ifuenf || fr->cpu_opts.type == ifuenf_dither || fr->cpu_opts.type == dreidnow)
287  buffssize = 2*2*0x110*4; /* don't rely on type real, we need 4352 bytes */
288 
289  if(2*2*0x110*sizeof(real) > buffssize)
290  buffssize = 2*2*0x110*sizeof(real);
291  buffssize += 15; /* For 16-byte alignment (SSE likes that). */
292 
293  if(fr->rawbuffs != NULL && fr->rawbuffss != buffssize)
294  {
295  free(fr->rawbuffs);
296  fr->rawbuffs = NULL;
297  }
298 
299  if(fr->rawbuffs == NULL) fr->rawbuffs = (unsigned char*) malloc(buffssize);
300  if(fr->rawbuffs == NULL) return -1;
301  fr->rawbuffss = buffssize;
302  fr->short_buffs[0][0] = aligned_pointer(fr->rawbuffs,short,16);
303  fr->short_buffs[0][1] = fr->short_buffs[0][0] + 0x110;
304  fr->short_buffs[1][0] = fr->short_buffs[0][1] + 0x110;
305  fr->short_buffs[1][1] = fr->short_buffs[1][0] + 0x110;
306  fr->real_buffs[0][0] = aligned_pointer(fr->rawbuffs,real,16);
307  fr->real_buffs[0][1] = fr->real_buffs[0][0] + 0x110;
308  fr->real_buffs[1][0] = fr->real_buffs[0][1] + 0x110;
309  fr->real_buffs[1][1] = fr->real_buffs[1][0] + 0x110;
310 #ifdef OPT_I486
311  if(fr->cpu_opts.type == ivier)
312  {
313  fr->int_buffs[0][0] = (int*) fr->rawbuffs;
314  fr->int_buffs[0][1] = fr->int_buffs[0][0] + 17*FIR_BUFFER_SIZE;
315  fr->int_buffs[1][0] = fr->int_buffs[0][1] + 17*FIR_BUFFER_SIZE;
316  fr->int_buffs[1][1] = fr->int_buffs[1][0] + 17*FIR_BUFFER_SIZE;
317  }
318 #endif
319 #ifdef OPT_ALTIVEC
320  if(fr->cpu_opts.type == altivec)
321  {
322  int i,j;
323  fr->areal_buffs[0][0] = (real*) fr->rawbuffs;
324  for(i=0; i<4; ++i) for(j=0; j<4; ++j)
325  fr->areal_buffs[i][j] = fr->areal_buffs[0][0] + (i*4+j)*0x110;
326  }
327 #endif
328  /* now the different decwins... all of the same size, actually */
329  /* The MMX ones want 32byte alignment, which I'll try to ensure manually */
330  {
331  int decwin_size = (512+32)*sizeof(real);
332 #ifdef OPT_MMXORSSE
333 #ifdef OPT_MULTI
334  if(fr->cpu_opts.class == mmxsse)
335  {
336 #endif
337  /* decwin_mmx will share, decwins will be appended ... sizeof(float)==4 */
338  if(decwin_size < (512+32)*4) decwin_size = (512+32)*4;
339 
340  /* the second window + alignment zone -- we align for 32 bytes for SSE as
341  requirement, 64 byte for matching cache line size (that matters!) */
342  decwin_size += (512+32)*4 + 63;
343  /* (512+32)*4/32 == 2176/32 == 68, so one decwin block retains alignment for 32 or 64 bytes */
344 #ifdef OPT_MULTI
345  }
346 #endif
347 #endif
348 #if defined(OPT_ALTIVEC) || defined(OPT_ARM)
349  /* sizeof(real) >= 4 ... yes, it could be 8, for example.
350  We got it intialized to at least (512+32)*sizeof(real).*/
351  decwin_size += 512*sizeof(real);
352 #endif
353  /* Hm, that's basically realloc() ... */
354  if(fr->rawdecwin != NULL && fr->rawdecwins != decwin_size)
355  {
356  free(fr->rawdecwin);
357  fr->rawdecwin = NULL;
358  }
359 
360  if(fr->rawdecwin == NULL)
361  fr->rawdecwin = (unsigned char*) malloc(decwin_size);
362 
363  if(fr->rawdecwin == NULL) return -1;
364 
365  fr->rawdecwins = decwin_size;
366  fr->decwin = (real*) fr->rawdecwin;
367 #ifdef OPT_MMXORSSE
368 #ifdef OPT_MULTI
369  if(fr->cpu_opts.class == mmxsse)
370  {
371 #endif
372  /* align decwin, assign that to decwin_mmx, append decwins */
373  /* I need to add to decwin what is missing to the next full 64 byte -- also I want to make gcc -pedantic happy... */
374  fr->decwin = aligned_pointer(fr->rawdecwin,real,64);
375  debug1("aligned decwin: %p", (void*)fr->decwin);
376  fr->decwin_mmx = (float*)fr->decwin;
377  fr->decwins = fr->decwin_mmx+512+32;
378 #ifdef OPT_MULTI
379  }
380  else debug("no decwins/decwin_mmx for that class");
381 #endif
382 #endif
383  }
384 
385  /* Layer scratch buffers are of compile-time fixed size, so allocate only once. */
386  if(fr->layerscratch == NULL)
387  {
388  /* Allocate specific layer1/2/3 buffers, so that we know they'll work for SSE. */
389  size_t scratchsize = 0;
390  real *scratcher;
391 #ifndef NO_LAYER1
392  scratchsize += sizeof(real) * 2 * SBLIMIT;
393 #endif
394 #ifndef NO_LAYER2
395  scratchsize += sizeof(real) * 2 * 4 * SBLIMIT;
396 #endif
397 #ifndef NO_LAYER3
398  scratchsize += sizeof(real) * 2 * SBLIMIT * SSLIMIT; /* hybrid_in */
399  scratchsize += sizeof(real) * 2 * SSLIMIT * SBLIMIT; /* hybrid_out */
400 #endif
401  /*
402  Now figure out correct alignment:
403  We need 16 byte minimum, smallest unit of the blocks is 2*SBLIMIT*sizeof(real), which is 64*4=256. Let's do 64bytes as heuristic for cache line (as proven useful in buffs above).
404  */
405  fr->layerscratch = malloc(scratchsize+63);
406  if(fr->layerscratch == NULL) return -1;
407 
408  /* Get aligned part of the memory, then divide it up. */
409  scratcher = aligned_pointer(fr->layerscratch,real,64);
410  /* Those funky pointer casts silence compilers...
411  One might change the code at hand to really just use 1D arrays, but in practice, that would not make a (positive) difference. */
412 #ifndef NO_LAYER1
413  fr->layer1.fraction = (real(*)[SBLIMIT])scratcher;
414  scratcher += 2 * SBLIMIT;
415 #endif
416 #ifndef NO_LAYER2
417  fr->layer2.fraction = (real(*)[4][SBLIMIT])scratcher;
418  scratcher += 2 * 4 * SBLIMIT;
419 #endif
420 #ifndef NO_LAYER3
421  fr->layer3.hybrid_in = (real(*)[SBLIMIT][SSLIMIT])scratcher;
422  scratcher += 2 * SBLIMIT * SSLIMIT;
423  fr->layer3.hybrid_out = (real(*)[SSLIMIT][SBLIMIT])scratcher;
424  scratcher += 2 * SSLIMIT * SBLIMIT;
425 #endif
426  /* Note: These buffers don't need resetting here. */
427  }
428 
429  /* Only reset the buffers we created just now. */
431 
432  debug1("frame %p buffer done", (void*)fr);
433  return 0;
434 }
real * layerscratch
Definition: frame.h:310
struct mpg123_handle_struct::@3301 layer3
#define free
Definition: debug_ros.c:5
#define SBLIMIT
struct mpg123_handle_struct::@3299 layer1
_Tp _STLP_CALL real(const complex< _Tp > &__z)
Definition: _complex.h:727
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
real * real_buffs[2][2]
Definition: frame.h:105
static void frame_decode_buffers_reset(mpg123_handle *fr)
Definition: frame.c:257
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define SSLIMIT
#define aligned_pointer(p, type, alignment)
Definition: frame.c:18
short * short_buffs[2][2]
Definition: frame.h:104
struct mpg123_handle_struct::@3300 layer2
struct mpg123_handle_struct::@3297 cpu_opts
unsigned char * rawbuffs
Definition: frame.h:106
#define debug(msg)
Definition: key_call.c:71
#define malloc
Definition: debug_ros.c:4
unsigned char * rawdecwin
Definition: frame.h:116
#define debug1(s, a)
Definition: debug.h:52
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ frame_buffers_reset()

int frame_buffers_reset ( mpg123_handle fr)

Definition at line 436 of file frame.c.

437 {
438  fr->buffer.fill = 0; /* hm, reset buffer fill... did we do a flush? */
439  fr->bsnum = 0;
440  /* Wondering: could it be actually _wanted_ to retain buffer contents over different files? (special gapless / cut stuff) */
441  fr->bsbuf = fr->bsspace[1];
442  fr->bsbufold = fr->bsbuf;
443  fr->bitreservoir = 0;
445  memset(fr->bsspace, 0, 2*(MAXFRAMESIZE+512));
446  memset(fr->ssave, 0, 34);
447  fr->hybrid_blc[0] = fr->hybrid_blc[1] = 0;
448  memset(fr->hybrid_block, 0, sizeof(real)*2*2*SBLIMIT*SSLIMIT);
449  return 0;
450 }
unsigned char * bsbufold
Definition: frame.h:253
#define SBLIMIT
_Tp _STLP_CALL real(const complex< _Tp > &__z)
Definition: _complex.h:727
struct outbuffer buffer
Definition: frame.h:265
static void frame_decode_buffers_reset(mpg123_handle *fr)
Definition: frame.c:257
#define SSLIMIT
#define MAXFRAMESIZE
Definition: frame.h:30
unsigned char bsspace[2][MAXFRAMESIZE+512]
Definition: frame.h:251
real hybrid_block[2][2][SBLIMIT *SSLIMIT]
Definition: frame.h:101
unsigned int bitreservoir
Definition: frame.h:250
int hybrid_blc[2]
Definition: frame.h:102
unsigned char ssave[34]
Definition: frame.h:129
#define memset(x, y, z)
Definition: compat.h:39
unsigned char * bsbuf
Definition: frame.h:252

Referenced by frame_reset().

◆ frame_exit()

void frame_exit ( mpg123_handle fr)

Definition at line 581 of file frame.c.

582 {
583  if(fr->buffer.rdata != NULL)
584  {
585  debug1("freeing buffer at %p", (void*)fr->buffer.rdata);
586  free(fr->buffer.rdata);
587  }
588  fr->buffer.rdata = NULL;
589  frame_free_buffers(fr);
590  frame_free_toc(fr);
591 #ifdef FRAME_INDEX
592  fi_exit(&fr->index);
593 #endif
594 #ifdef OPT_DITHER
595  if(fr->dithernoise != NULL)
596  {
597  free(fr->dithernoise);
598  fr->dithernoise = NULL;
599  }
600 #endif
601  exit_id3(fr);
602  clear_icy(&fr->icy);
603  /* Clean up possible mess from LFS wrapper. */
604  if(fr->wrapperclean != NULL)
605  {
606  fr->wrapperclean(fr->wrapperdata);
607  fr->wrapperdata = NULL;
608  }
609 #ifndef NO_FEEDER
610  bc_cleanup(&fr->rdat.buffer);
611 #endif
612 }
#define exit_id3
Definition: intsym.h:202
#define bc_cleanup
Definition: intsym.h:238
void * wrapperdata
Definition: frame.h:333
#define fi_exit
Definition: intsym.h:208
#define free
Definition: debug_ros.c:5
static void frame_free_buffers(mpg123_handle *fr)
Definition: frame.c:566
struct outbuffer buffer
Definition: frame.h:265
struct reader_data rdat
Definition: frame.h:286
static void frame_free_toc(mpg123_handle *fr)
Definition: frame.c:462
void(* wrapperclean)(void *)
Definition: frame.h:335
struct icy_meta icy
Definition: frame.h:299
smooth NULL
Definition: ftsmooth.c:416
#define clear_icy
Definition: intsym.h:199
struct frame_index index
Definition: frame.h:261
#define debug1(s, a)
Definition: debug.h:52

◆ frame_expect_outsampels()

off_t frame_expect_outsampels ( mpg123_handle fr)

◆ frame_expect_outsamples()

off_t frame_expect_outsamples ( mpg123_handle fr)

Definition at line 769 of file frame.c.

770 {
771  off_t outs = 0;
772  switch(fr->down_sample)
773  {
774  case 0:
775 # ifndef NO_DOWNSAMPLE
776  case 1:
777  case 2:
778 # endif
779  outs = fr->spf>>fr->down_sample;
780  break;
781 #ifndef NO_NTOM
782  case 3: outs = ntom_frame_outsamples(fr); break;
783 #endif
784  default: error1("Bad down_sample (%i) ... should not be possible!!", fr->down_sample);
785  }
786  return outs;
787 }
#define ntom_frame_outsamples
Definition: intsym.h:145
#define error1(s, a)
Definition: debug.h:109
__kernel_off_t off_t
Definition: linux.h:201

◆ frame_fill_toc()

int frame_fill_toc ( mpg123_handle fr,
unsigned char in 
)

Definition at line 468 of file frame.c.

469 {
470  if(fr->xing_toc == NULL) fr->xing_toc = malloc(100);
471  if(fr->xing_toc != NULL)
472  {
473  memcpy(fr->xing_toc, in, 100);
474 #ifdef DEBUG
475  debug("Got a TOC! Showing the values...");
476  {
477  int i;
478  for(i=0; i<100; ++i)
479  debug2("entry %i = %i", i, fr->xing_toc[i]);
480  }
481 #endif
482  return TRUE;
483  }
484  return FALSE;
485 }
#define TRUE
Definition: types.h:120
#define debug2(s, a, b)
Definition: debug.h:53
unsigned char * xing_toc
Definition: frame.h:221
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint in
Definition: glext.h:9616
#define debug(msg)
Definition: key_call.c:71
#define malloc
Definition: debug_ros.c:4

◆ frame_gapless_init()

void frame_gapless_init ( mpg123_handle fr,
off_t  framecount,
off_t  bskip,
off_t  eskip 
)

◆ frame_gapless_realinit()

void frame_gapless_realinit ( mpg123_handle fr)

Referenced by get_next_frame().

◆ frame_gapless_update()

void frame_gapless_update ( mpg123_handle mh,
off_t  total_samples 
)

Referenced by mpg123_scan().

◆ frame_index_find()

off_t frame_index_find ( mpg123_handle fr,
off_t  want_frame,
off_t get_frame 
)

Definition at line 682 of file frame.c.

683 {
684  /* default is file start if no index position */
685  off_t gopos = 0;
686  *get_frame = 0;
687 #ifdef FRAME_INDEX
688  /* Possibly use VBRI index, too? I'd need an example for this... */
689  if(fr->index.fill)
690  {
691  /* find in index */
692  size_t fi;
693  /* at index fi there is frame step*fi... */
694  fi = want_frame/fr->index.step;
695  if(fi >= fr->index.fill) /* If we are beyond the end of frame index...*/
696  {
697  /* When fuzzy seek is allowed, we have some limited tolerance for the frames we want to read rather then jump over. */
698  if(fr->p.flags & MPG123_FUZZY && want_frame - (fr->index.fill-1)*fr->index.step > 10)
699  {
700  gopos = frame_fuzzy_find(fr, want_frame, get_frame);
701  if(gopos > fr->audio_start) return gopos; /* Only in that case, we have a useful guess. */
702  /* Else... just continue, fuzzyness didn't help. */
703  }
704  /* Use the last available position, slowly advancing from that one. */
705  fi = fr->index.fill - 1;
706  }
707  /* We have index position, that yields frame and byte offsets. */
708  *get_frame = fi*fr->index.step;
709  gopos = fr->index.data[fi];
710  fr->state_flags |= FRAME_ACCURATE; /* When using the frame index, we are accurate. */
711  }
712  else
713  {
714 #endif
715  if(fr->p.flags & MPG123_FUZZY)
716  return frame_fuzzy_find(fr, want_frame, get_frame);
717  /* A bit hackish here... but we need to be fresh when looking for the first header again. */
718  fr->firsthead = 0;
719  fr->oldhead = 0;
720 #ifdef FRAME_INDEX
721  }
722 #endif
723  debug2("index: 0x%lx for frame %li", (unsigned long)gopos, (long) *get_frame);
724  return gopos;
725 }
struct mpg123_pars_struct p
Definition: frame.h:287
__kernel_off_t off_t
Definition: linux.h:201
#define debug2(s, a, b)
Definition: debug.h:53
static off_t frame_fuzzy_find(mpg123_handle *fr, off_t want_frame, off_t *get_frame)
Definition: frame.c:634
unsigned long firsthead
Definition: frame.h:258
struct frame_index index
Definition: frame.h:261
unsigned long oldhead
Definition: frame.h:256

◆ frame_index_setup()

int frame_index_setup ( mpg123_handle fr)

Referenced by frame_init_par(), and mpg123_param().

◆ frame_init()

void frame_init ( mpg123_handle fr)

Definition at line 69 of file frame.c.

70 {
71  frame_init_par(fr, NULL);
72 }
void frame_init_par(mpg123_handle *fr, mpg123_pars *mp)
Definition: frame.c:74
smooth NULL
Definition: ftsmooth.c:416

◆ frame_init_par()

void frame_init_par ( mpg123_handle fr,
mpg123_pars mp 
)

Definition at line 74 of file frame.c.

75 {
76  fr->own_buffer = TRUE;
77  fr->buffer.data = NULL;
78  fr->buffer.rdata = NULL;
79  fr->buffer.fill = 0;
80  fr->buffer.size = 0;
81  fr->rawbuffs = NULL;
82  fr->rawbuffss = 0;
83  fr->rawdecwin = NULL;
84  fr->rawdecwins = 0;
85 #ifndef NO_8BIT
86  fr->conv16to8_buf = NULL;
87 #endif
88 #ifdef OPT_DITHER
89  fr->dithernoise = NULL;
90 #endif
91  fr->layerscratch = NULL;
92  fr->xing_toc = NULL;
93  fr->cpu_opts.type = defdec();
94  fr->cpu_opts.class = decclass(fr->cpu_opts.type);
95 #ifndef NO_NTOM
96  /* these two look unnecessary, check guarantee for synth_ntom_set_step (in control_generic, even)! */
97  fr->ntom_val[0] = NTOM_MUL>>1;
98  fr->ntom_val[1] = NTOM_MUL>>1;
99  fr->ntom_step = NTOM_MUL;
100 #endif
101  /* unnecessary: fr->buffer.size = fr->buffer.fill = 0; */
102  mpg123_reset_eq(fr);
103  init_icy(&fr->icy);
104  init_id3(fr);
105  /* frame_outbuffer is missing... */
106  /* frame_buffers is missing... that one needs cpu opt setting! */
107  /* after these... frame_reset is needed before starting full decode */
108  invalidate_format(&fr->af);
109  fr->rdat.r_read = NULL;
110  fr->rdat.r_lseek = NULL;
111  fr->rdat.iohandle = NULL;
112  fr->rdat.r_read_handle = NULL;
113  fr->rdat.r_lseek_handle = NULL;
114  fr->rdat.cleanup_handle = NULL;
115  fr->wrapperdata = NULL;
116  fr->wrapperclean = NULL;
117  fr->decoder_change = 1;
118  fr->err = MPG123_OK;
119  if(mp == NULL) frame_default_pars(&fr->p);
120  else memcpy(&fr->p, mp, sizeof(struct mpg123_pars_struct));
121 
122 #ifndef NO_FEEDER
123  bc_prepare(&fr->rdat.buffer, fr->p.feedpool, fr->p.feedbuffer);
124 #endif
125 
126  fr->down_sample = 0; /* Initialize to silence harmless errors when debugging. */
127  frame_fixed_reset(fr); /* Reset only the fixed data, dynamic buffers are not there yet! */
128  fr->synth = NULL;
129  fr->synth_mono = NULL;
130  fr->make_decode_tables = NULL;
131 #ifdef FRAME_INDEX
132  fi_init(&fr->index);
133  frame_index_setup(fr); /* Apply the size setting. */
134 #endif
135 }
#define decclass
Definition: intsym.h:225
#define TRUE
Definition: types.h:120
struct mpg123_pars_struct p
Definition: frame.h:287
real * layerscratch
Definition: frame.h:310
void * wrapperdata
Definition: frame.h:333
#define invalidate_format
Definition: intsym.h:167
#define defdec
Definition: intsym.h:224
#define NTOM_MUL
Definition: frame.c:16
struct outbuffer buffer
Definition: frame.h:265
struct reader_data rdat
Definition: frame.h:286
void(* wrapperclean)(void *)
Definition: frame.h:335
unsigned char * xing_toc
Definition: frame.h:221
static void frame_default_pars(mpg123_pars *mp)
Definition: frame.c:36
#define init_id3
Definition: intsym.h:201
int attribute_align_arg mpg123_reset_eq(mpg123_handle *mh)
Definition: frame.c:167
void(* make_decode_tables)(mpg123_handle *fr)
Definition: frame.h:183
struct icy_meta icy
Definition: frame.h:299
smooth NULL
Definition: ftsmooth.c:416
func_synth_mono synth_mono
Definition: frame.h:181
#define init_icy
Definition: intsym.h:198
int frame_index_setup(mpg123_handle *fr)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned long ntom_val[2]
Definition: frame.h:148
func_synth synth
Definition: frame.h:179
#define bc_prepare
Definition: intsym.h:237
struct audioformat af
Definition: frame.h:266
struct mpg123_handle_struct::@3297 cpu_opts
struct frame_index index
Definition: frame.h:261
unsigned char * rawbuffs
Definition: frame.h:106
static void frame_fixed_reset(mpg123_handle *fr)
Definition: frame.c:502
unsigned long ntom_step
Definition: frame.h:149
#define fi_init
Definition: intsym.h:207
unsigned char * conv16to8_buf
Definition: frame.h:133
unsigned char * rawdecwin
Definition: frame.h:116

Referenced by frame_init().

◆ frame_ins2outs()

off_t frame_ins2outs ( mpg123_handle fr,
off_t  ins 
)

Definition at line 727 of file frame.c.

728 {
729  off_t outs = 0;
730  switch(fr->down_sample)
731  {
732  case 0:
733 # ifndef NO_DOWNSAMPLE
734  case 1:
735  case 2:
736 # endif
737  outs = ins>>fr->down_sample;
738  break;
739 # ifndef NO_NTOM
740  case 3: outs = ntom_ins2outs(fr, ins); break;
741 # endif
742  default: error1("Bad down_sample (%i) ... should not be possible!!", fr->down_sample);
743  }
744  return outs;
745 }
#define error1(s, a)
Definition: debug.h:109
__kernel_off_t off_t
Definition: linux.h:201
#define ntom_ins2outs
Definition: intsym.h:147

◆ frame_offset()

off_t frame_offset ( mpg123_handle fr,
off_t  outs 
)

Definition at line 789 of file frame.c.

790 {
791  off_t num = 0;
792  switch(fr->down_sample)
793  {
794  case 0:
795 # ifndef NO_DOWNSAMPLE
796  case 1:
797  case 2:
798 # endif
799  num = outs/(fr->spf>>fr->down_sample);
800  break;
801 #ifndef NO_NTOM
802  case 3: num = ntom_frameoff(fr, outs); break;
803 #endif
804  default: error("Bad down_sample ... should not be possible!!");
805  }
806  return num;
807 }
#define error(str)
Definition: mkdosfs.c:1605
__kernel_off_t off_t
Definition: linux.h:201
#define ntom_frameoff
Definition: intsym.h:148
GLuint GLuint num
Definition: glext.h:9618

Referenced by frame_set_frameseek(), and frame_set_seek().

◆ frame_outbuffer()

int frame_outbuffer ( mpg123_handle fr)

Definition at line 178 of file frame.c.

179 {
180  size_t size = fr->outblock;
181  if(!fr->own_buffer)
182  {
183  if(fr->buffer.size < size)
184  {
185  fr->err = MPG123_BAD_BUFFER;
186  if(NOQUIET) error2("have external buffer of size %"SIZE_P", need %"SIZE_P, (size_p)fr->buffer.size, (size_p)size);
187 
188  return MPG123_ERR;
189  }
190  }
191 
192  debug1("need frame buffer of %"SIZE_P, (size_p)size);
193  if(fr->buffer.rdata != NULL && fr->buffer.size != size)
194  {
195  free(fr->buffer.rdata);
196  fr->buffer.rdata = NULL;
197  }
198  fr->buffer.size = size;
199  fr->buffer.data = NULL;
200  /* be generous: use 16 byte alignment */
201  if(fr->buffer.rdata == NULL) fr->buffer.rdata = (unsigned char*) malloc(fr->buffer.size+15);
202  if(fr->buffer.rdata == NULL)
203  {
204  fr->err = MPG123_OUT_OF_MEM;
205  return MPG123_ERR;
206  }
207  fr->buffer.data = aligned_pointer(fr->buffer.rdata, unsigned char*, 16);
208  fr->own_buffer = TRUE;
209  fr->buffer.fill = 0;
210  return MPG123_OK;
211 }
#define TRUE
Definition: types.h:120
#define free
Definition: debug_ros.c:5
struct outbuffer buffer
Definition: frame.h:265
smooth NULL
Definition: ftsmooth.c:416
#define error2(s, a, b)
Definition: debug.h:110
unsigned long size_p
Definition: compat.h:138
GLsizeiptr size
Definition: glext.h:5919
#define NOQUIET
#define aligned_pointer(p, type, alignment)
Definition: frame.c:18
#define SIZE_P
Definition: compat.h:137
#define malloc
Definition: debug_ros.c:4
#define debug1(s, a)
Definition: debug.h:52

◆ frame_output_format()

int frame_output_format ( mpg123_handle fr)

Definition at line 215 of file format.c.

216 {
217  struct audioformat nf;
218  int f0=0;
219  int f2=MPG123_ENCODINGS; /* Omit the 32bit and float encodings. */
220  mpg123_pars *p = &fr->p;
221  /* initialize new format, encoding comes later */
222  nf.channels = fr->stereo;
223 
224  /* All this forcing should be removed in favour of the capabilities table... */
225  if(p->flags & MPG123_FORCE_8BIT)
226  {
227  f0 = enc_8bit_range[0];
228  f2 = enc_8bit_range[1];
229  }
230  if(p->flags & MPG123_FORCE_FLOAT)
231  {
232  f0 = enc_float_range[0];
233  f2 = enc_float_range[1];
234  }
235 
236  /* force stereo is stronger */
237  if(p->flags & MPG123_FORCE_MONO) nf.channels = 1;
238  if(p->flags & MPG123_FORCE_STEREO) nf.channels = 2;
239 
240 #ifndef NO_NTOM
241  if(p->force_rate)
242  {
243  nf.rate = p->force_rate;
244  if(cap_fit(fr,&nf,f0,2)) goto end; /* 16bit encodings */
245  if(cap_fit(fr,&nf,f0<=2 ? 2 : f0,f2)) goto end; /* 8bit encodings */
246 
247  /* try again with different stereoness */
248  if(nf.channels == 2 && !(p->flags & MPG123_FORCE_STEREO)) nf.channels = 1;
249  else if(nf.channels == 1 && !(p->flags & MPG123_FORCE_MONO)) nf.channels = 2;
250 
251  if(cap_fit(fr,&nf,f0,2)) goto end; /* 16bit encodings */
252  if(cap_fit(fr,&nf,f0<=2 ? 2 : f0,f2)) goto end; /* 8bit encodings */
253 
254  if(NOQUIET)
255  error3( "Unable to set up output format! Constraints: %s%s%liHz.",
256  ( p->flags & MPG123_FORCE_STEREO ? "stereo, " :
257  (p->flags & MPG123_FORCE_MONO ? "mono, " : "") ),
258  (p->flags & MPG123_FORCE_8BIT ? "8bit, " : ""),
259  p->force_rate );
260 /* if(NOQUIET && p->verbose <= 1) print_capabilities(fr); */
261 
263  return -1;
264  }
265 #endif
266 
267  if(freq_fit(fr, &nf, f0, 2)) goto end; /* try rates with 16bit */
268  if(freq_fit(fr, &nf, f0<=2 ? 2 : f0, f2)) goto end; /* ... 8bit */
269 
270  /* try again with different stereoness */
271  if(nf.channels == 2 && !(p->flags & MPG123_FORCE_STEREO)) nf.channels = 1;
272  else if(nf.channels == 1 && !(p->flags & MPG123_FORCE_MONO)) nf.channels = 2;
273 
274  if(freq_fit(fr, &nf, f0, 2)) goto end; /* try rates with 16bit */
275  if(freq_fit(fr, &nf, f0<=2 ? 2 : f0, f2)) goto end; /* ... 8bit */
276 
277  /* Here is the _bad_ end. */
278  if(NOQUIET)
279  {
280  error5( "Unable to set up output format! Constraints: %s%s%li, %li or %liHz.",
281  ( p->flags & MPG123_FORCE_STEREO ? "stereo, " :
282  (p->flags & MPG123_FORCE_MONO ? "mono, " : "") ),
283  (p->flags & MPG123_FORCE_8BIT ? "8bit, " : ""),
284  frame_freq(fr), frame_freq(fr)>>1, frame_freq(fr)>>2 );
285  }
286 /* if(NOQUIET && p->verbose <= 1) print_capabilities(fr); */
287 
289  return -1;
290 
291 end: /* Here is the _good_ end. */
292  /* we had a successful match, now see if there's a change */
293  if(nf.rate == fr->af.rate && nf.channels == fr->af.channels && nf.encoding == fr->af.encoding)
294  {
295  debug2("Old format with %i channels, and FORCE_MONO=%li", nf.channels, p->flags & MPG123_FORCE_MONO);
296  return 0; /* the same format as before */
297  }
298  else /* a new format */
299  {
300  debug1("New format with %i channels!", nf.channels);
301  fr->af.rate = nf.rate;
302  fr->af.channels = nf.channels;
303  fr->af.encoding = nf.encoding;
304  /* Cache the size of one sample in bytes, for ease of use. */
305  fr->af.encsize = mpg123_encsize(fr->af.encoding);
306  if(fr->af.encsize < 1)
307  {
308  if(NOQUIET) error1("Some unknown encoding??? (%i)", fr->af.encoding);
309 
311  return -1;
312  }
313  /* Set up the decoder synth format. Might differ. */
314 #ifdef NO_SYNTH32
315  /* Without high-precision synths, 16 bit signed is the basis for
316  everything higher than 8 bit. */
317  if(fr->af.encsize > 2)
318  fr->af.dec_enc = MPG123_ENC_SIGNED_16;
319  else
320  {
321 #endif
322  switch(fr->af.encoding)
323  {
324 #ifndef NO_32BIT
328  fr->af.dec_enc = MPG123_ENC_SIGNED_32;
329  break;
330 #endif
331 #ifndef NO_16BIT
333  fr->af.dec_enc = MPG123_ENC_SIGNED_16;
334  break;
335 #endif
336  default:
337  fr->af.dec_enc = fr->af.encoding;
338  }
339 #ifdef NO_SYNTH32
340  }
341 #endif
342  fr->af.dec_encsize = mpg123_encsize(fr->af.dec_enc);
343  return 1;
344  }
345 }
static int freq_fit(mpg123_handle *fr, struct audioformat *nf, int f0, int f2)
Definition: format.c:169
struct mpg123_pars_struct p
Definition: frame.h:287
int attribute_align_arg mpg123_encsize(int encoding)
Definition: format.c:126
#define error1(s, a)
Definition: debug.h:109
static const int enc_float_range[2]
Definition: format.c:60
GLuint GLuint end
Definition: gl.h:1545
#define debug2(s, a, b)
Definition: debug.h:53
static int cap_fit(mpg123_handle *fr, struct audioformat *nf, int f0, int f2)
Definition: format.c:153
#define NOQUIET
struct audioformat af
Definition: frame.h:266
#define error5(s, a, b, c, d, e)
Definition: debug.h:113
#define error3(s, a, b, c)
Definition: debug.h:111
static const int enc_8bit_range[2]
Definition: format.c:62
#define MPG123_ENCODINGS
GLfloat GLfloat p
Definition: glext.h:8902
#define frame_freq
Definition: intsym.h:229
int f2(S1 &, S2 &)
#define debug1(s, a)
Definition: debug.h:52

◆ frame_outs()

off_t frame_outs ( mpg123_handle fr,
off_t  num 
)

Definition at line 747 of file frame.c.

748 {
749  off_t outs = 0;
750  switch(fr->down_sample)
751  {
752  case 0:
753 # ifndef NO_DOWNSAMPLE
754  case 1:
755  case 2:
756 # endif
757  outs = (fr->spf>>fr->down_sample)*num;
758  break;
759 #ifndef NO_NTOM
760  case 3: outs = ntom_frmouts(fr, num); break;
761 #endif
762  default: error1("Bad down_sample (%i) ... should not be possible!!", fr->down_sample);
763  }
764  return outs;
765 }
#define error1(s, a)
Definition: debug.h:109
__kernel_off_t off_t
Definition: linux.h:201
GLuint GLuint num
Definition: glext.h:9618
#define ntom_frmouts
Definition: intsym.h:146

Referenced by frame_set_frameseek(), and frame_set_seek().

◆ frame_reset()

int frame_reset ( mpg123_handle fr)

Definition at line 489 of file frame.c.

490 {
492  frame_fixed_reset(fr);
493  frame_free_toc(fr);
494 #ifdef FRAME_INDEX
495  fi_reset(&fr->index);
496 #endif
497 
498  return 0;
499 }
#define fi_reset
Definition: intsym.h:212
static void frame_free_toc(mpg123_handle *fr)
Definition: frame.c:462
int frame_buffers_reset(mpg123_handle *fr)
Definition: frame.c:436
struct frame_index index
Definition: frame.h:261
static void frame_fixed_reset(mpg123_handle *fr)
Definition: frame.c:502

◆ frame_set_frameseek()

void frame_set_frameseek ( mpg123_handle fr,
off_t  fe 
)

Definition at line 879 of file frame.c.

880 {
881  fr->firstframe = fe;
882 #ifdef GAPLESS
883  if(fr->p.flags & MPG123_GAPLESS && fr->gapless_frames > 0)
884  {
885  /* Take care of the beginning... */
886  off_t beg_f = frame_offset(fr, fr->begin_os);
887  if(fe <= beg_f)
888  {
889  fr->firstframe = beg_f;
890  fr->firstoff = fr->begin_os - frame_outs(fr, beg_f);
891  }
892  else fr->firstoff = 0;
893  /* The end is set once for a track at least, on the frame_set_frameseek called in get_next_frame() */
894  if(fr->end_os > 0)
895  {
896  fr->lastframe = frame_offset(fr,fr->end_os);
897  fr->lastoff = fr->end_os - frame_outs(fr, fr->lastframe);
898  } else {fr->lastframe = -1; fr->lastoff = 0; }
899  } else { fr->firstoff = fr->lastoff = 0; fr->lastframe = -1; }
900 #endif
901  fr->ignoreframe = ignoreframe(fr);
902 #ifdef GAPLESS
903  debug5("frame_set_frameseek: begin at %li frames and %li samples, end at %li and %li; ignore from %li",
904  (long) fr->firstframe, (long) fr->firstoff,
905  (long) fr->lastframe, (long) fr->lastoff, (long) fr->ignoreframe);
906 #else
907  debug3("frame_set_frameseek: begin at %li frames, end at %li; ignore from %li",
908  (long) fr->firstframe, (long) fr->lastframe, (long) fr->ignoreframe);
909 #endif
910 }
struct mpg123_pars_struct p
Definition: frame.h:287
__kernel_off_t off_t
Definition: linux.h:201
static off_t ignoreframe(mpg123_handle *fr)
Definition: frame.c:864
#define debug3(s, a, b, c)
Definition: debug.h:54
off_t gapless_frames
Definition: frame.h:275
off_t frame_outs(mpg123_handle *fr, off_t num)
Definition: frame.c:747
off_t frame_offset(mpg123_handle *fr, off_t outs)
Definition: frame.c:789
#define debug5(s, a, b, c, d, e)
Definition: debug.h:56

◆ frame_set_seek()

void frame_set_seek ( mpg123_handle fr,
off_t  sp 
)

Definition at line 921 of file frame.c.

922 {
923  fr->firstframe = frame_offset(fr, sp);
924  debug1("frame_set_seek: from %"OFF_P, fr->num);
925 #ifndef NO_NTOM
926  if(fr->down_sample == 3) ntom_set_ntom(fr, fr->firstframe);
927 #endif
928  fr->ignoreframe = ignoreframe(fr);
929 #ifdef GAPLESS /* The sample offset is used for non-gapless mode, too! */
930  fr->firstoff = sp - frame_outs(fr, fr->firstframe);
931  debug5("frame_set_seek: begin at %li frames and %li samples, end at %li and %li; ignore from %li",
932  (long) fr->firstframe, (long) fr->firstoff,
933  (long) fr->lastframe, (long) fr->lastoff, (long) fr->ignoreframe);
934 #else
935  debug3("frame_set_seek: begin at %li frames, end at %li; ignore from %li",
936  (long) fr->firstframe, (long) fr->lastframe, (long) fr->ignoreframe);
937 #endif
938 }
static off_t ignoreframe(mpg123_handle *fr)
Definition: frame.c:864
#define debug3(s, a, b, c)
Definition: debug.h:54
off_t frame_outs(mpg123_handle *fr, off_t num)
Definition: frame.c:747
off_t frame_offset(mpg123_handle *fr, off_t outs)
Definition: frame.c:789
static const WCHAR sp[]
Definition: suminfo.c:288
#define debug5(s, a, b, c, d, e)
Definition: debug.h:56
#define debug1(s, a)
Definition: debug.h:52
#define OFF_P
Definition: compat.h:129
#define ntom_set_ntom
Definition: intsym.h:21

◆ frame_skip()

void frame_skip ( mpg123_handle fr)

Definition at line 912 of file frame.c.

913 {
914 #ifndef NO_LAYER3
915  if(fr->lay == 3) set_pointer(fr, 512);
916 #endif
917 }
#define set_pointer
Definition: intsym.h:232

◆ frame_tell_seek()

off_t frame_tell_seek ( mpg123_handle fr)

◆ invalidate_format()

void invalidate_format ( struct audioformat af)

Definition at line 450 of file format.c.

451 {
452  af->encoding = 0;
453  af->rate = 0;
454  af->channels = 0;
455 }
int encoding
Definition: frame.h:50
int channels
Definition: frame.h:54
long rate
Definition: frame.h:55

◆ mpg123_print_index()

int mpg123_print_index ( mpg123_handle fr,
FILE out 
)