/* private header file to attach common.c to mple.c */

/*
 * MP3 file stuff
 * This is largely to work around the huge number of globals present
 * in the mpg123 code
 */
#define MAXFRAMESIZE 1792

typedef struct _mp3file {
  /* one of these two will be set; if fp is set, we're reading from a
     file, otherwise from a memory buffer pointed to by fp */
  FILE *fp;
  unsigned char *fb;

  int fb_ptr; /* current 'file pointer' for fb */
  int fb_size; /* end of fb */

  int fsizeold;
  unsigned char bsspace[2][MAXFRAMESIZE + 512];
  unsigned char *bsbuf;
  unsigned char *bsbufold;
  int bsnum;
} mp3file;


/* and yet there are still globals */
extern const int mpg123_freqs[9];
extern const int tabsel_123[2][3][16];

typedef float real;

struct frame
{
  guint8 header[4]; /* raw header */
  int (*synth) (real *, int, unsigned char *, int *);
  int (*synth_mono) (real *, unsigned char *, int *);
#ifdef USE_SIMD
  void (*dct36)(real *,real *,real *,real *,real *);
#endif
  int stereo;
  int jsbound;
  int single;
  int II_sblimit;
  int down_sample_sblimit;
  int lsf;
  int mpeg25;
  int down_sample;
  int header_change;
  int lay;
  int (*do_layer) (struct frame * fr);
  int error_protection;
  int bitrate_index;
  int sampling_frequency;
  int padding;
  int extension;
  int mode;
  int mode_ext;
  int copyright;
  int original;
  int emphasis;
  int framesize;      /* computed framesize */
  int synth_type;
};

/* should probably inline these */
int framesize( struct frame * );
int bitrate_index( struct frame * );
int lsf( struct frame * );
guint8 *header( struct frame * );

/* the only real interface function */
gboolean mpg123_read_frame( mp3file *, struct frame **);


