/**********************************************************************
 * ISO MPEG Audio Subgroup Software Simulation Group (1996)
 * ISO 13818-3 MPEG-2 Audio Encoder - Lower Sampling Frequency Extension
 *
 * $Id: encoder.h,v 1.1 1996/02/14 04:04:23 rowlands Exp $
 *
 * $Log: encoder.h,v $
 * Revision 1.1  1996/02/14 04:04:23  rowlands
 * Initial revision
 *
 * Received from Mike Coleman
 **********************************************************************/

#ifndef ENCODER_DOT_H
#define ENCODER_DOT_H
/***********************************************************************
*
*  Encoder Include Files
*
***********************************************************************/

/***********************************************************************
*
*  Encoder Definitions
*
***********************************************************************/

/* General Definitions */

/* Default Input Arguments (for command line control) */

#define DFLT_LAY        3      /* default encoding layer is III */
#define DFLT_MOD        'j'    /* default mode is stereo */
#define DFLT_PSY        2      /* default psych model is 2 */
#define DFLT_SFQ        44.1   /* default input sampling rate is 44.1 kHz */
#define DFLT_EMP        'n'    /* default de-emphasis is none */
#define DFLT_EXT        ".mp3" /* default output file extension */

#define FILETYPE_ENCODE 'TEXT'
#define CREATOR_ENCODE  'MpgD'

/* This is the smallest MNR a subband can have before it is counted
   as 'noisy' by the logic which chooses the number of JS subbands */

#define NOISY_MIN_MNR   0.0

/* Psychoacoustic Model 2 Definitions */

#define LOGBLKSIZE      10
#define BLKSIZE         1024
#define HBLKSIZE        513
#define CBANDS          63
#define LXMIN           32.0

/***********************************************************************
*
*  Encoder Type Definitions
*
***********************************************************************/


/* Psychoacoustic Model 2 Type Definitions */

typedef int        ICB[CBANDS];
typedef int        IHBLK[HBLKSIZE];
typedef FLOAT      F32[32];
typedef FLOAT      F2_32[2][32];
typedef FLOAT      FCB[CBANDS];
typedef FLOAT      FCBCB[CBANDS][CBANDS];
typedef FLOAT      FBLK[BLKSIZE];
typedef FLOAT      FHBLK[HBLKSIZE];
typedef FLOAT      F2HBLK[2][HBLKSIZE];
typedef FLOAT      F22HBLK[2][2][HBLKSIZE];
typedef double     DCB[CBANDS];

extern int iswav;
/***********************************************************************
*
*  Encoder Function Prototype Declarations
*
***********************************************************************/

/* The following functions are in the file "musicin.c" */

#ifdef        PROTO_ARGS
extern void   obtain_parameters(frame_params*, int*, unsigned long*,
                           char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
extern void   parse_args(int, char**, frame_params*, int*, unsigned long*,
                           char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
extern void   print_config(frame_params*, int*,
                           char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
void   usage(void);
extern void   aiff_check(char*, IFF_AIFF*, int*);
#else
extern void   obtain_parameters();
extern void   parse_args();
extern void   print_config();
static void   usage();
extern void   aiff_check();
#endif

/* The following functions are in the file "encode.c" */

#ifdef        PROTO_ARGS
extern unsigned long    read_samples(FILE*, short[2304], unsigned long,
                           unsigned long);
#if 0
/*
extern unsigned long    get_audio(FILE*, short[2][1152], unsigned long,
                           int, int);
*/
extern unsigned long    get_audio(FILE*, short [1152],short [1152], unsigned long,
                           int, int);
#else
extern unsigned long    get_audio(FILE*, short[2][1152], unsigned long,
                           int, layer* info);
#endif
extern void   read_ana_window(double[HAN_SIZE]);
extern void   window_subband(short**, double[HAN_SIZE], int);
extern void   create_ana_filter(double[SBLIMIT][64]);
extern void   filter_subband(double[HAN_SIZE], double[SBLIMIT]);
extern void   encode_info(frame_params*, Bit_stream_struc*);
extern double mod(double);
extern void   pick_scale(unsigned int[2][3][SBLIMIT], frame_params*,
                           double[2][SBLIMIT]);
extern void   put_scale(unsigned int[2][3][SBLIMIT], frame_params*,
                           double[2][SBLIMIT]);
#else
extern unsigned long  read_samples();
extern unsigned long  get_audio();
extern void        read_ana_window();
extern void        window_subband();
extern void        create_ana_filter();
extern void        filter_subband();
extern void        encode_info();
extern double      mod();
extern void        pick_scale();
extern void        put_scale();
#endif

/* The following functions are in the file "tonal.c" */

#ifdef     PROTO_ARGS
extern void        make_map(mask[HAN_SIZE], g_thres*);
extern double      add_db(double, double);
extern void        noise_label(mask*, int*, g_thres*);
extern void        subsampling(mask[HAN_SIZE], g_thres*, int*, int*);
extern void        threshold(mask[HAN_SIZE], g_thres*, int*, int*, int);
#else
extern void        make_map();
extern double      add_db();
extern void        noise_label();
extern void        subsampling();
extern void        threshold();
#endif

/* The following functions are in the file "psy.c" */

#ifdef     PROTO_ARGS
extern void        psycho_anal(short int*, short int[1056], int, int,
                           FLOAT[32], double);
#else
extern void        psycho_anal();
#endif

/* The following functions are in the file "subs.c" */

#ifdef     PROTO_ARGS
extern void        fft(FLOAT[BLKSIZE], FLOAT[BLKSIZE], FLOAT[BLKSIZE],
                           FLOAT[BLKSIZE], int );
extern double fft_side( FLOAT in[2][1024], int s);
#else
extern void        fft();
extern double fft_side();
#endif
#endif
