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 #ifndef LAYER1_H 22 #define LAYER1_H 23 24 #include "allLayers.H" 25 #include "MPEGfile.H" 26 #include "mpegPlatform.h" 27 28 using namespace std; 29 30 //-------------------------------------------------------------------------- 31 32 // class definition 33 class CSAPI_MPEG Layer1 : public AllLayers { 34 public: 35 Layer1(MPEGfile *mp); 36 37 38 int bitallocation (unsigned int ch, 39 unsigned int sb); scfsi(unsigned int ch,unsigned int sb)40 int scfsi (unsigned int ch, unsigned int sb) { 41 /* Layer 1 does not have any scfs information */ 42 return -1; 43 }; 44 float scalefactor (unsigned int ch, 45 unsigned int sb, 46 unsigned int ss=0); 47 int sample (unsigned int ch, 48 unsigned int sb, 49 unsigned int no, 50 unsigned int ss=0); 51 double restored_sample (unsigned int ch, 52 unsigned int sb, 53 unsigned int no, 54 unsigned int ss=0); 55 short pcm_sample (unsigned int ch, 56 unsigned int sb, 57 unsigned int no, 58 unsigned int ss=0); 59 60 unsigned int calc_CRC(); 61 bool parse_data(DecodeLevel decode); 62 63 64 private: 65 MPEGfile *frame; 66 67 // AUDIO DATA CONTENT: 68 // channels()*subbands() bitallocations (4 bit to be read per entry) 69 unsigned int allocation[2][SBLIMIT]; 70 // channels()*subbands() scale factor indexes (6 bit to be read per entry) 71 unsigned int scale_index[2][SBLIMIT]; 72 // 12*channels()*subbands() sample data (2-15 bit to be read per entry) 73 unsigned int samples[12][2][SBLIMIT]; 74 // 12*channels()*subbands() restored samples 75 double restoredsamples[12][2][SBLIMIT]; 76 // 12*channels()*subbands() restored pcm samples 77 short pcm[12][2][SBLIMIT]; 78 79 void decode_bitalloc(); 80 void decode_scale(); 81 void buffer_samples(); 82 void restore_samples(); 83 84 unsigned int bits_per_sample (unsigned int ch, unsigned int sb); 85 86 87 }; 88 89 //-------------------------------------------------------------------------- 90 91 #endif 92