1 /* types.h 2 * All the defines, and structures and Kexis uses. 3 * Copyright (C) 2000 Wayde Milas (wmilas@rarcoa.com) 4 * 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 /* includes: 21 */ 22 23 #include <sys/time.h> 24 25 /* defines 26 */ 27 28 #define VERSION_MAJOR 0 29 #define VERSION_MINOR 2 30 #define VERSION_SUB_MINOR 2 31 32 #define DEBUG 0 33 #define PRED_DEBUG 0 34 #define DEBUG_UP 10 35 #define DEBUG_DOWN 2 36 #define DEBUG_POS 113964 37 38 #define COMPRESS 0 39 #define DECOMPRESS 1 40 41 #define MID 0 42 #define AVE 1 43 44 #define STANDARD_ENCODER 3 45 #define RICE_SINGLE_K 1 46 #define RICE_DUAL_K 2 47 #define RICE_DUAL_K_BLOCK 3 48 #define MAX_STANDARD_ENCODER 3 49 #define MIN_STANDARD_ENCODER 1 50 51 #define STANDARD_PREDICTOR 6 52 #define ZEROO_PREDICTOR 1 53 #define FIRSTO_PREDICTOR 2 54 #define SECONDO_PREDICTOR 3 55 #define THIRDO_PREDICTOR 4 56 #define L_HISTORY_PREDICTOR 5 57 #define FRAME_PREDICTOR 6 58 #define MAX_STANDARD_PREDICTOR 6 59 #define MIN_STANDARD_PREDICTOR 1 60 61 #define MAX_M 100 62 63 #define MAX_KHISTORY 256 64 #define DEFAULT_KHISTORY 32 65 66 #define INITIAL_KEXIS_HEADER 1 67 #define CURRENT_KEXIS_HEADER 1 68 69 #define FRAME_UNITS 1024 70 #define K_LOOKUP_SIZE 32000 71 72 #define INITIAL_K 8 73 74 /* Structs 75 */ 76 77 typedef struct { 78 char ckID[4]; 79 unsigned long ckSize; 80 char wave_ckID[4]; 81 char fmt_ckID[4]; 82 unsigned long fmt_ckSize; 83 unsigned short formatTag; 84 unsigned short nChannels; 85 unsigned long nSamplesPerSec; 86 unsigned long nAvgBytesPerSec; 87 unsigned short nBlockAlign; 88 unsigned short nBitsPerSample; 89 char data_ckID[4]; 90 unsigned long data_ckSize; 91 } WAVHEADER; 92 93 // Dont change this struct until we update parse_kexis_header 94 typedef struct { 95 char kexisID[4]; 96 unsigned short headerVersion; 97 unsigned short encoderVersion; 98 unsigned short predictorVersion; 99 unsigned short kHistorySize; 100 unsigned long dataLength; 101 unsigned long frameSize; 102 unsigned short options; // First bit is joint stereo or not. 103 unsigned short pad3; 104 } KEXISHEADER; 105 106 typedef struct { 107 int mode; 108 int progress; 109 int verbose; 110 int displayHeader; 111 int dec_stdout; 112 int kHistorySize; 113 int argPosition; 114 int joint; 115 int del_file; 116 unsigned long frameSize; 117 unsigned short predictorVersion; 118 unsigned short encoderVersion; 119 FILE *inFileStream; 120 FILE *outFileStream; 121 struct timeval time; 122 struct timeval progTime; 123 char errorString[256]; 124 char *inFileName; 125 char *outFileName; 126 } OPTIONSTRUCT; 127 128 typedef struct { 129 int mid_I[4]; 130 int ave_I[4]; 131 int midM; 132 int aveM; 133 int diffAve; 134 int diffMid; 135 int lowDiffAve; 136 int highDiffAve; 137 int lowDiffMid; 138 int highDiffMid; 139 140 int *mid_K; 141 int *ave_K; 142 int kBlockPointer; 143 int midLowK; 144 int aveLowK; 145 int midHighK; 146 int aveHighK; 147 148 double sumDiffAve; 149 double countDiffAve; 150 double sumDiffMid; 151 double countDiffMid; 152 double midSumK; 153 double aveSumK; 154 double midCountK; 155 double aveCountK; 156 157 double preLog10_2; 158 long *newKLookUP; 159 } PREDICTORTABLE; 160 161 typedef struct { 162 int bitCounter; //Keeps track of the halfway assembled word when 163 //encoding. 164 unsigned long blockPointer; 165 unsigned long subBlockPointer; 166 unsigned long sumTotalSize; 167 unsigned long debugBlockCount; 168 169 long dataPosition; //position in the block that data is stacked 170 //to currently. 171 long bitBucket; //used to hold partial words between bit pushes 172 double countK; 173 PREDICTORTABLE predictor; 174 long *data; 175 } KEXISBLOCKSTRUCT; 176 177 typedef struct { 178 unsigned long size; 179 unsigned long pcmStreamLength; 180 int currentAve; 181 int currentMid; 182 short *data; 183 } PCMBLOCKSTRUCT; 184