1 /* 2 MPEG Maaate: An Australian MPEG audio analysis toolkit 3 Copyright (C) 2000 Commonwealth Scientific and Industrial Research Organisation 4 (CSIRO), Australia. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21 22 #ifndef ALLLAYERS_H 23 #define ALLLAYERS_H 24 25 /* choice of decoding depth to be achieved */ 26 typedef enum { dec_fields=0, dec_subsubbands, dec_subbands, dec_pcm } DecodeLevel; 27 28 #include "mpegPlatform.h" 29 30 #ifdef __cplusplus 31 32 #include <algorithm> 33 #include <cstdio> 34 #include <cmath> 35 #include <iostream> 36 #include <string.h> 37 38 // for reading file size 39 #include <sys/types.h> 40 #include <sys/stat.h> 41 42 using namespace std; 43 44 #define SBLIMIT 32 // max no subbands 45 #define SSLIMIT 18 // max no sub-subbands Layer 3 46 #define SBSSLIMIT 576 // SBLIMIT * SSLIMIT 47 #define SCALE_RANGE 64 // refers to last scalefactor 48 49 extern const double maaate_scalefactors[SCALE_RANGE]; 50 51 #define HAN_SIZE 512 52 53 #ifndef PI 54 #define PI 3.14159265358979 55 #endif 56 57 //-------------------------------------------------------------------------- 58 59 // abstract class to keep functions that are the same for all layers 60 class CSAPI_MPEG AllLayers { 61 public: 62 63 // subband synthesis used by all layers 64 void create_syn_filter(double filter[64][SBLIMIT]); 65 void subband_syn (double *bandptr, int ch, short *pcm); 66 67 // layer-specific access to audio data 68 virtual int bitallocation (unsigned int ch, unsigned int sb) = 0; 69 virtual int scfsi (unsigned int ch, unsigned int sb) = 0; 70 virtual float scalefactor (unsigned int ch, unsigned int sb, 71 unsigned int ss) = 0; 72 virtual int sample (unsigned int ch, unsigned int sb, 73 unsigned int no, unsigned int ss) = 0; 74 virtual double restored_sample (unsigned int ch, unsigned int sb, 75 unsigned int no, unsigned int ss) = 0; 76 virtual short pcm_sample (unsigned int ch, unsigned int sb, 77 unsigned int no, unsigned int ss) = 0; 78 79 // layer-specific handling of audio data 80 virtual unsigned int calc_CRC () = 0; 81 virtual bool parse_data (DecodeLevel decode) = 0; 82 83 private: 84 }; 85 86 //-------------------------------------------------------------------------- 87 88 // inline operators 89 90 #else /* __cplusplus */ 91 92 typdef struct AllLayers AllLayers; 93 94 #endif /* __cplusplus */ 95 96 #endif 97