4 #include "AnitaPacketUtil.h" 5 #include "AnitaGeomTool.h" 6 #include "simpleStructs.h" 7 #include "compress/mulawTables.h" 17 if((gHdr->code&BASE_PACKET_MASK)!=code ||
18 gHdr->verId!=expVerId ||
19 gHdr->numBytes!=packetSize) {
21 <<
"code:\t" << (int)gHdr->code <<
"\t" << (
int)code
22 <<
"\nversion:\t" << (int)gHdr->verId
23 <<
"\t" << (
int)expVerId
24 <<
"\nsize:\t" << gHdr->numBytes <<
"\t" 25 << packetSize << std::endl;
33 switch(code&BASE_PACKET_MASK) {
61 case PACKET_WAKEUP_LOS:
return WAKEUP_LOS_BUFFER_SIZE;
break;
62 case PACKET_WAKEUP_HIGHRATE:
return WAKEUP_TDRSS_BUFFER_SIZE;
64 case PACKET_WAKEUP_COMM1:
return WAKEUP_LOW_RATE_BUFFER_SIZE;
66 case PACKET_WAKEUP_COMM2:
return WAKEUP_LOW_RATE_BUFFER_SIZE;
100 for (i=0L; i<n; i++) {
105 return ((0xffffffff - sum) + 1);
110 switch(code&BASE_PACKET_MASK) {
111 case PACKET_BD:
return VER_EVENT_BODY;
break;
112 case PACKET_HD:
return VER_EVENT_HEADER;
break;
114 case PACKET_WV:
return VER_WAVE_PACKET;
break;
138 case PACKET_SLOW1:
return VER_SLOW_1;
break;
139 case PACKET_SLOW2:
return VER_SLOW_2;
break;
159 unsigned int *typedPtr = (
unsigned int *)thePtr;
162 unsigned long dodgyNum=(
unsigned long)typedPtr;
164 unsigned int *dataPtr=(
unsigned int*)dodgyNum;
168 gHdr->numBytes=numBytes;
175 #define PKT_E_CHECKSUM 0x1 176 #define PKT_E_CODE 0x2 177 #define PKT_E_FEBYTE 0x4 178 #define PKT_E_SIZE 0x8 187 unsigned int *typedPtr=(
unsigned int*) thePtr;
188 int retVal=0,packetSize=0;
191 unsigned long dodgyNum=(
unsigned long)typedPtr;
193 unsigned int *dataPtr=(
unsigned int*)dodgyNum;
196 unsigned int checksum=0;
200 if(checksum!=gHdr->checksum) {
203 retVal+=PKT_E_CHECKSUM;
208 if(packetSize && (packetSize!=gHdr->numBytes))
213 if(gHdr->verId!=expVerId) {
214 std::cout <<
"Version mis-match: " << (int) gHdr->verId <<
"\t" << (
int)expVerId <<
"\n";
218 if(gHdr->feByte!=0xfe) retVal+=PKT_E_FEBYTE;
225 switch(code&BASE_PACKET_MASK) {
226 case PACKET_BD:
string=
"AnitaEventBody_t";
break;
227 case PACKET_HD:
string=
"AnitaEventHeader_t";
break;
228 case PACKET_WV:
string=
"RawWaveformPacket_t";
break;
244 case PACKET_HKD:
string=
"HkDataStruct_t";
break;
248 case PACKET_WAKEUP_LOS:
string=
"LosWakeUpPacket";
break;
249 case PACKET_WAKEUP_HIGHRATE:
string=
"TdrssWakeUpPacket";
break;
250 case PACKET_WAKEUP_COMM1:
string=
"Comm1WakeUpPacket";
break;
251 case PACKET_WAKEUP_COMM2:
string=
"Comm2WakeUpPacket";
break;
252 case PACKET_SLOW1:
string=
"SlowRateType1_t";
break;
253 case PACKET_SLOW2:
string=
"SlowRateType1_t";
break;
267 string=
"Unknown Packet Code";
break;
275 char *input = (
char*) zipPacket;
276 unsigned int returnBytes=numBytesOut;
280 if(zipPacket->numUncompressedBytes!=returnBytes)
287 int zipBuffer(
char *input,
char *output,
unsigned int inputBytes,
unsigned int *outputBytes)
289 static int errorCounter=0;
290 int retVal=compress((
unsigned char*)output,(
unsigned long*)outputBytes,(
unsigned char*)input,(
unsigned long)inputBytes);
294 if(errorCounter<100) {
295 fprintf(stderr,
"zlib compress returned %d (%d of 100)\n",retVal,errorCounter);
303 int unzipBuffer(
char *input,
char *output,
unsigned int inputBytes,
unsigned int *outputBytes)
306 unsigned long outputBytesLong;
307 static int errorCounter=0;
310 outputBytesLong = *outputBytes;
311 int retVal=uncompress((
unsigned char*)output,&outputBytesLong,(
unsigned char*)input,(
unsigned long)inputBytes);
314 *outputBytes = outputBytesLong;
319 if(errorCounter<100) {
320 fprintf(stderr,
"zlib compress returned %d (%d of 100)\n",retVal,errorCounter);
340 unsigned char *output,
344 int count=0,surfStart=0;
351 encEvWrap->eventNumber=bdPtr->eventNumber;
354 for(surf=0;surf<ACTIVE_SURFS;surf++) {
358 surfHdPtr->eventNumber=bdPtr->eventNumber;
360 for(chan=0;chan<CHANNELS_PER_SURF;chan++) {
361 count+=encodePSChannel(cntlPtr->encTypes[surf][chan],
364 if(count>MAX_WAVE_BUFFER)
365 return COMPRESS_E_TOO_BIG;
374 return COMPRESS_E_OK;
381 unsigned char *input,
386 return unpackToPedSubbedEventWithStats(bdPtr,input,numBytes,0,0);
393 unsigned char *input,
406 bdPtr->eventNumber=surfHdPtr->eventNumber;
408 for(chan=0;chan<CHANNELS_PER_SURF;chan++) {
413 chanIndex=chanHdPtr->rawHdr.
chanId;
414 if(chanIndex%9 != chan) {
415 printf(
"Error reading encoded Ped Subbed SURF packet, have chanId %d and chan %d\n",chanIndex,chan);
416 return COMPRESS_E_UNPACK;
419 retVal=decodePSChannel(chanHdPtr,
421 &(bdPtr->channel[chanIndex]));
428 if(retVal!=COMPRESS_E_OK)
return retVal;
429 count+=chanHdPtr->numBytes;
431 return COMPRESS_E_BADSIZE;
436 return COMPRESS_E_OK;
443 unsigned char *input,
455 bdPtr->eventNumber=waveHdPtr->eventNumber;
460 chanIndex=chanHdPtr->rawHdr.
chanId;
461 retVal=decodePSChannel(chanHdPtr,
463 &(bdPtr->channel[chanIndex]));
464 if(retVal!=COMPRESS_E_OK)
return retVal;
465 count+=chanHdPtr->numBytes;
467 return COMPRESS_E_BADSIZE;
471 return COMPRESS_E_OK;
478 unsigned char *input,
497 for(surf=0;surf<ACTIVE_SURFS;surf++) {
500 bdPtr->eventNumber=surfHdPtr->eventNumber;
502 for(chan=0;chan<CHANNELS_PER_SURF;chan++) {
510 retVal=decodePSChannel(chanHdPtr,
513 if(retVal!=COMPRESS_E_OK)
return retVal;
514 count+=chanHdPtr->numBytes;
516 cntlPtr->encTypes[surf][chan]=chanHdPtr->encType;;
522 return COMPRESS_E_BADSIZE;
527 return COMPRESS_E_OK;
534 int wrappedHitbus=chanPtr->header.
chipIdFlag&WRAPPED_HITBUS;
535 int firstSamp=0,lastSamp=MAX_NUMBER_SAMPLES;
537 float mean=0,meanSq=0,nsamps=0;
547 lastSamp=MAX_NUMBER_SAMPLES+chanPtr->header.
firstHitbus;
549 for(samp=firstSamp;samp<lastSamp;samp++) {
551 if(index>=MAX_NUMBER_SAMPLES) index-=MAX_NUMBER_SAMPLES;
552 mean+=chanPtr->
data[index];
553 meanSq+=(chanPtr->
data[index]*chanPtr->
data[index]);
556 if(chanPtr->
data[index]>chanPtr->xMax)
557 chanPtr->xMax=chanPtr->
data[index];
558 if(chanPtr->
data[index]<chanPtr->xMin)
559 chanPtr->xMin=chanPtr->
data[index];
567 chanPtr->
rms=sqrt(meanSq-mean*mean);
585 chanHdPtr->rawHdr=chanPtr->header;
586 chanHdPtr->encType=encType;
591 encSize=encodeWaveNone(&buffer[count],chanPtr);
595 encSize=encodeWaveNone(&buffer[count],chanPtr);
598 chanHdPtr->numBytes=encSize;
599 chanHdPtr->crc=simpleCrcShort((
unsigned short*)&buffer[count],
601 return (count+encSize);
608 int numBytes=encChanHdPtr->numBytes;
609 int newCrc=simpleCrcShort((
unsigned short*)input,numBytes/2);
610 if(encChanHdPtr->crc!=newCrc)
return COMPRESS_E_BAD_CRC;
614 chanPtr->header=encChanHdPtr->rawHdr;
615 switch(encChanHdPtr->encType) {
617 retVal=decodeWaveNone(input,numBytes,chanPtr);
621 retVal=decodeWaveNone(input,numBytes,chanPtr);
622 retVal=COMPRESS_E_BAD_CODE;
629 int AnitaCompress::encodeWaveNone(
unsigned char *buffer,
SurfChannelFull_t *chanPtr) {
630 int encSize=MAX_NUMBER_SAMPLES*
sizeof(
unsigned short);
631 memcpy(buffer,chanPtr->data,encSize);
636 int encSize=MAX_NUMBER_SAMPLES*
sizeof(
unsigned short);
638 if(numBytes!=encSize)
return COMPRESS_E_BADSIZE;
639 memcpy(chanPtr->data,input,encSize);
640 return COMPRESS_E_OK;
653 chanHdPtr->rawHdr=chanPtr->header;
654 chanHdPtr->encType=encType;
659 encSize=encodePSWaveNone(&buffer[count],chanPtr);
662 encSize=encodePSWave12bitBinary(&buffer[count],chanPtr);
665 encSize=encodePSWaveLosslessBinary(&buffer[count],chanPtr,
666 &(chanHdPtr->encType));
669 encSize=encodePSWaveLosslessFibonacci(&buffer[count],chanPtr);
672 encSize=encodePSWaveLosslessBinFibCombo(&buffer[count],chanPtr,
673 &(chanHdPtr->encType));
676 case ENCODE_LOSSY_MULAW_8BIT:
677 encSize=encodePSWaveLossyMulawOptimally(&buffer[count],chanPtr,8,
678 &(chanHdPtr->encType));
680 case ENCODE_LOSSY_MULAW_7BIT:
681 encSize=encodePSWaveLossyMulawOptimally(&buffer[count],chanPtr,7,
682 &(chanHdPtr->encType));
684 case ENCODE_LOSSY_MULAW_6BIT:
685 encSize=encodePSWaveLossyMulawOptimally(&buffer[count],chanPtr,6,
686 &(chanHdPtr->encType));
688 case ENCODE_LOSSY_MULAW_5BIT:
689 encSize=encodePSWaveLossyMulawOptimally(&buffer[count],chanPtr,5,
690 &(chanHdPtr->encType));
692 case ENCODE_LOSSY_MULAW_4BIT:
693 encSize=encodePSWaveLossyMulawOptimally(&buffer[count],chanPtr,4,
694 &(chanHdPtr->encType));
696 case ENCODE_LOSSY_MULAW_3BIT:
697 encSize=encodePSWaveLossyMulawOptimally(&buffer[count],chanPtr,3,
698 &(chanHdPtr->encType));
702 encSize=encodePSWaveNone(&buffer[count],chanPtr);
705 chanHdPtr->numBytes=encSize;
706 chanHdPtr->crc=simpleCrcShort((
unsigned short*)&buffer[count],
708 return (count+encSize);
714 int numBytes=encChanHdPtr->numBytes;
715 int newCrc=simpleCrcShort((
unsigned short*)input,numBytes/2);
716 if(encChanHdPtr->crc!=newCrc)
return COMPRESS_E_BAD_CRC;
720 chanPtr->header=encChanHdPtr->rawHdr;
721 switch(encChanHdPtr->encType) {
723 retVal=decodePSWaveNone(input,numBytes,chanPtr);
726 retVal=decodePSWave12bitBinary(input,numBytes,chanPtr);
728 case ENCODE_LOSSLESS_11BIT:
729 case ENCODE_LOSSLESS_10BIT:
730 case ENCODE_LOSSLESS_9BIT:
731 case ENCODE_LOSSLESS_8BIT:
732 case ENCODE_LOSSLESS_7BIT:
733 case ENCODE_LOSSLESS_6BIT:
734 case ENCODE_LOSSLESS_5BIT:
735 case ENCODE_LOSSLESS_4BIT:
736 case ENCODE_LOSSLESS_3BIT:
737 case ENCODE_LOSSLESS_2BIT:
738 case ENCODE_LOSSLESS_1BIT:
739 retVal=decodePSWaveLosslessBinary(input,numBytes,chanPtr,encChanHdPtr->encType);
742 retVal=decodePSWaveLosslessFibonacci(input,numBytes,chanPtr);
745 case ENCODE_LOSSLESS_BINFIB_10BIT:
746 case ENCODE_LOSSLESS_BINFIB_9BIT:
747 case ENCODE_LOSSLESS_BINFIB_8BIT:
748 case ENCODE_LOSSLESS_BINFIB_7BIT:
749 case ENCODE_LOSSLESS_BINFIB_6BIT:
750 case ENCODE_LOSSLESS_BINFIB_5BIT:
751 case ENCODE_LOSSLESS_BINFIB_4BIT:
752 case ENCODE_LOSSLESS_BINFIB_3BIT:
753 case ENCODE_LOSSLESS_BINFIB_2BIT:
754 case ENCODE_LOSSLESS_BINFIB_1BIT:
755 retVal=decodePSWaveLosslessBinFibCombo(input,numBytes,chanPtr,
756 encChanHdPtr->encType);
758 case ENCODE_LOSSY_MULAW_11_8:
759 case ENCODE_LOSSY_MULAW_11_7:
760 case ENCODE_LOSSY_MULAW_11_6:
761 case ENCODE_LOSSY_MULAW_11_5:
762 case ENCODE_LOSSY_MULAW_11_4:
763 case ENCODE_LOSSY_MULAW_11_3:
764 case ENCODE_LOSSY_MULAW_10_8:
765 case ENCODE_LOSSY_MULAW_10_7:
766 case ENCODE_LOSSY_MULAW_10_6:
767 case ENCODE_LOSSY_MULAW_10_5:
768 case ENCODE_LOSSY_MULAW_10_4:
769 case ENCODE_LOSSY_MULAW_10_3:
770 case ENCODE_LOSSY_MULAW_9_7:
771 case ENCODE_LOSSY_MULAW_9_6:
772 case ENCODE_LOSSY_MULAW_9_5:
773 case ENCODE_LOSSY_MULAW_9_4:
774 case ENCODE_LOSSY_MULAW_9_3:
775 case ENCODE_LOSSY_MULAW_8_6:
776 case ENCODE_LOSSY_MULAW_8_5:
777 case ENCODE_LOSSY_MULAW_8_4:
778 case ENCODE_LOSSY_MULAW_8_3:
779 case ENCODE_LOSSY_MULAW_7_5:
780 case ENCODE_LOSSY_MULAW_7_4:
781 case ENCODE_LOSSY_MULAW_7_3:
782 case ENCODE_LOSSY_MULAW_6_4:
783 case ENCODE_LOSSY_MULAW_6_3:
784 retVal=decodePSWaveLossyMuLaw(input,numBytes,chanPtr,
785 encChanHdPtr->encType);
790 retVal=decodePSWaveNone(input,numBytes,chanPtr);
791 retVal=COMPRESS_E_BAD_CODE;
794 if(retVal==COMPRESS_E_OK) fillMinMaxMeanRMS(chanPtr);
801 int encSize=MAX_NUMBER_SAMPLES*
sizeof(short);
802 memcpy(buffer,chanPtr->
data,encSize);
811 int encSize=MAX_NUMBER_SAMPLES*
sizeof(
unsigned short);
813 if(numBytes!=encSize)
return COMPRESS_E_BADSIZE;
815 memcpy(chanPtr->
data,input,encSize);
819 return COMPRESS_E_OK;
822 #define OFFSET_VALUE 2048 825 int encSize=3*(MAX_NUMBER_SAMPLES/4)*
sizeof(
unsigned short);
826 int samp=0,charNum=0,valNum=0;
827 unsigned short value[4];
828 for(samp=0;samp<MAX_NUMBER_SAMPLES;samp+=4) {
830 for(valNum=0;valNum<4;valNum++)
831 value[valNum]=chanPtr->
data[samp+valNum]+OFFSET_VALUE;
833 pack12bit(value,&buffer[charNum]);
839 int encSize=3*(MAX_NUMBER_SAMPLES/4)*
sizeof(
unsigned short);
840 if(numBytes!=encSize)
return COMPRESS_E_BADSIZE;
841 unsigned short value[4];
842 int samp=0,charNum=0,valNum=0;
843 for(charNum=0;charNum<6*(MAX_NUMBER_SAMPLES/4);charNum+=6) {
845 unpack12bit(value,&input[charNum]);
846 for(valNum=0;valNum<4;valNum++)
847 chanPtr->
data[samp+valNum]=((
short)value[valNum])-OFFSET_VALUE;
849 return COMPRESS_E_OK;
859 unsigned char *currentChar=buffer;
861 unsigned short newVal=0;
863 short xMax=chanPtr->xMax;
864 short xMin=chanPtr->xMin;
865 short *input = chanPtr->
data;
876 int rangeTotal=xMax-xMin;
877 float logValue=(float)(log(rangeTotal+1)/log(2));
878 int bitSize=(int)logValue;
879 if((logValue-bitSize)>0) bitSize++;
881 *encTypePtr=getBinaryEncType(bitSize);
883 mean=xMin+rangeTotal/2;
887 short *meanPtr=(
short*)currentChar;
893 for(wordNum=0;wordNum<MAX_NUMBER_SAMPLES;wordNum++) {
894 newVal=bifurcate(input[wordNum]-mean);
901 if(numBitsLeft>(8-currentBit)) {
903 for(bitNum=0;bitNum<(8-currentBit);bitNum++)
904 bitMask|=(1<<bitNum);
905 (*currentChar)|= (newVal&bitMask)<<currentBit;
906 newVal=(newVal>>(8-currentBit));
907 numBitsLeft-=(8-currentBit);
913 for(bitNum=0;bitNum<numBitsLeft;bitNum++)
914 bitMask|=(1<<bitNum);
915 (*currentChar)|= (newVal&bitMask)<<currentBit;
916 currentBit+=numBitsLeft;
928 if(currentBit) currentChar++;
929 return (
int)(currentChar-buffer);
935 short *meanPtr=(
short*)input;
936 short mean=(short)(*meanPtr);
938 int bitSize=getBinaryBitSize(encType);
944 unsigned char *currentChar=&input[2];
946 unsigned short tempNum;
947 while(sampNum<MAX_NUMBER_SAMPLES) {
948 int fred = *( (
int*) currentChar);
952 for(bitNum=currentBit;bitNum<currentBit+bitSize;bitNum++) {
953 tempNum|= (((fred>>bitNum)&0x1)<<(bitNum-currentBit));
962 chanPtr->
data[sampNum]=mean+unbifurcate(tempNum);
967 while(currentBit>=8) {
971 if(((
int)(currentChar-input))>numBytes)
return COMPRESS_E_BADSIZE;
973 return COMPRESS_E_OK;
984 unsigned char *currentChar=buffer;
986 unsigned short newVal=0;
987 int mean=(int)chanPtr->
mean;
988 if(mean>127) mean=127;
989 if(mean<-127) mean=-127;
992 short *input = chanPtr->
data;
997 char *meanPtr=(
char*)currentChar;
998 (*meanPtr)=(char)(mean);
1002 for(wordNum=0;wordNum<MAX_NUMBER_SAMPLES;wordNum++) {
1003 newVal=bifurcate(input[wordNum]-mean);
1004 newVal=encodeFibonacci(newVal,&numBitsLeft);
1005 while(numBitsLeft) {
1007 if(numBitsLeft>(8-currentBit)) {
1009 for(bitNum=0;bitNum<(8-currentBit);bitNum++)
1010 bitMask|=(1<<bitNum);
1011 (*currentChar)|= (newVal&bitMask)<<currentBit;
1012 newVal=(newVal>>(8-currentBit));
1013 numBitsLeft-=(8-currentBit);
1019 for(bitNum=0;bitNum<numBitsLeft;bitNum++)
1020 bitMask|=(1<<bitNum);
1021 (*currentChar)|= (newVal&bitMask)<<currentBit;
1022 currentBit+=numBitsLeft;
1034 if(currentBit) currentChar++;
1035 return (
int)(currentChar-buffer);
1041 char *meanPtr=(
char*)input;
1042 short mean=(short)(*meanPtr);
1044 unsigned char *currentChar=&input[1];
1046 unsigned short fibNum;
1047 unsigned short unfibNum;
1049 while(sampNum<MAX_NUMBER_SAMPLES) {
1051 int fred = *( (
int*) currentChar);
1053 printf(
"samp %d, fred %#x\n",sampNum,fred);
1055 if( ((fred>>tempBit)&0x1) && ((fred>>(tempBit+1))&0x1)) {
1058 for(bitNum=currentBit;bitNum<=tempBit+1;bitNum++) {
1059 fibNum|= (((fred>>bitNum)&0x1)<<(bitNum-currentBit));
1061 unfibNum=unfibonacci(fibNum);
1062 chanPtr->
data[sampNum]=mean+unbifurcate(unfibNum);
1067 currentChar+=(tempBit/8);
1068 currentBit=(tempBit%8);
1076 if(((
int)(currentChar-input))>numBytes)
return COMPRESS_E_BADSIZE;
1079 return COMPRESS_E_OK;
1091 unsigned short fibVal=0;
1094 unsigned char *currentChar=buffer;
1096 unsigned char *overflowChar;
1098 unsigned short newVal=0;
1099 int mean=(int)chanPtr->
mean;
1100 if(mean>127) mean=127;
1101 if(mean<-127) mean=-127;
1102 float sigma=chanPtr->
rms;
1103 short xMax=chanPtr->xMax;
1104 short xMin=chanPtr->xMin;
1105 short *input = chanPtr->
data;
1106 int rangeTotal=(int)(numSigma*sigma);
1107 float logValue=(float)(log(rangeTotal+1)/log(2));
1108 int bitSize=(int)logValue;
1109 if((logValue-bitSize)>0) bitSize++;
1110 if(bitSize==1) bitSize++;
1114 xMin=mean-(1<<(bitSize-1));
1115 xMax=mean+(1<<(bitSize-1));
1119 char *meanPtr=(
char*)currentChar;
1120 (*meanPtr)=(char)(mean);
1122 *encTypePtr=getBinFibEncType(bitSize);
1127 overflowChar=currentChar+(MAX_NUMBER_SAMPLES*bitSize)/8;
1128 overflowBit=(MAX_NUMBER_SAMPLES*bitSize)%8;
1130 unsigned short flagVal=(1<<bitSize)-1;
1131 int countOverflows=0;
1133 for(wordNum=0;wordNum<MAX_NUMBER_SAMPLES;wordNum++) {
1135 if(input[wordNum]>xMin && input[wordNum]<xMax) {
1136 newVal=bifurcate(input[wordNum]-mean);
1142 if(input[wordNum]>=xMax) {
1143 fibVal=((input[wordNum]-xMax)<<1)+1;
1146 fibVal=((xMin-input[wordNum])<<1)+2;
1148 asFib=encodeFibonacci(fibVal,&fibBits);
1155 numBitsLeft=fibBits;
1156 while(numBitsLeft) {
1158 if(numBitsLeft>(8-overflowBit)) {
1160 for(bitNum=0;bitNum<(8-overflowBit);bitNum++)
1161 bitMask|=(1<<bitNum);
1162 (*overflowChar)|= (asFib&bitMask)<<overflowBit;
1163 asFib=(asFib>>(8-overflowBit));
1164 numBitsLeft-=(8-overflowBit);
1170 for(bitNum=0;bitNum<numBitsLeft;bitNum++)
1171 bitMask|=(1<<bitNum);
1172 (*overflowChar)|= (asFib&bitMask)<<overflowBit;
1173 overflowBit+=numBitsLeft;
1174 if(overflowBit==8) {
1184 numBitsLeft=bitSize;
1185 while(numBitsLeft) {
1187 if(numBitsLeft>(8-currentBit)) {
1189 for(bitNum=0;bitNum<(8-currentBit);bitNum++)
1190 bitMask|=(1<<bitNum);
1191 (*currentChar)|= (newVal&bitMask)<<currentBit;
1192 newVal=(newVal>>(8-currentBit));
1193 numBitsLeft-=(8-currentBit);
1199 for(bitNum=0;bitNum<numBitsLeft;bitNum++)
1200 bitMask|=(1<<bitNum);
1201 (*currentChar)|= (newVal&bitMask)<<currentBit;
1202 currentBit+=numBitsLeft;
1212 if(overflowBit) overflowChar++;
1214 return (
int)(overflowChar-buffer);
1220 char *meanPtr=(
char*)input;
1221 short mean=(*meanPtr);
1226 int bitSize=getBinFibBitSize(encType);
1227 short overFlowVals[256];
1228 short xMin=mean-(1<<(bitSize-1));
1229 short xMax=mean+(1<<(bitSize-1));
1231 unsigned short flagVal=(1<<bitSize)-1;
1233 unsigned char *currentChar=&input[1];
1235 unsigned char *overflowChar;
1237 overflowChar=currentChar+(MAX_NUMBER_SAMPLES*bitSize)/8;
1238 overflowBit=(MAX_NUMBER_SAMPLES*bitSize)%8;
1239 int numOverflows=numBytes-(int)(overflowChar-input);
1243 unsigned short tempNum;
1249 while(overflowNum<260) {
1250 tempBit=overflowBit;
1251 int fred = *( (
int*) overflowChar);
1255 if( ((fred>>tempBit)&0x1) && ((fred>>(tempBit+1))&0x1)) {
1258 for(bitNum=overflowBit;bitNum<=tempBit+1;bitNum++) {
1259 fibNum|= (((fred>>bitNum)&0x1)<<(bitNum-overflowBit));
1264 tempNum=unfibonacci(fibNum);
1270 overFlowVals[overflowNum]=xMax+((tempNum-1)>>1);
1274 overFlowVals[overflowNum]=xMin-((tempNum-2)>>1);
1279 overflowChar+=(tempBit/8);
1280 overflowBit=(tempBit%8);
1288 if(tempBit==32)
break;
1294 numOverflows=overflowNum;
1299 while(sampNum<MAX_NUMBER_SAMPLES) {
1300 int fred = *( (
int*) currentChar);
1303 for(bitNum=currentBit;bitNum<currentBit+bitSize;bitNum++) {
1304 tempNum|= (((fred>>bitNum)&0x1)<<(bitNum-currentBit));
1311 if(tempNum==flagVal) {
1312 chanPtr->
data[sampNum]=overFlowVals[overflowNum];
1316 chanPtr->
data[sampNum]=mean+unbifurcate(tempNum);
1319 currentBit+=bitSize;
1320 while(currentBit>=8) {
1325 return COMPRESS_E_OK;
1331 short xMax=chanPtr->xMax;
1332 short xMin=chanPtr->xMin;
1333 short rangeTotal=xMax-xMin;
1335 while(rangeTotal>(1<<numBits)) numBits++;
1336 int inputBits=numBits+1;
1337 if(inputBits<=mulawBits)
return encodePSWaveLosslessBinary(buffer,chanPtr,encTypePtr);
1338 if(inputBits<6) inputBits=6;
1339 if(inputBits<mulawBits+2) inputBits=mulawBits+2;
1340 *encTypePtr=getEncodingTypeFromInputAndMuLawBits(inputBits,mulawBits);
1341 return encodePSWaveLossyMuLaw(buffer,chanPtr,*encTypePtr);
1352 unsigned char *currentChar=buffer;
1354 unsigned char newVal=0;
1355 int inputBits=0,mulawBits=0;
1356 getInputAndMuLawBits(encType,&inputBits,&mulawBits);
1357 short maxVal=(1<<(inputBits-1));
1358 short minVal=-1*maxVal;
1360 short xMax=chanPtr->xMax;
1361 short xMin=chanPtr->xMin;
1362 short rangeTotal=xMax-xMin;
1363 short *input = chanPtr->
data;
1364 int mean=xMin+(int)rangeTotal/2;
1366 int bitSize=mulawBits;
1370 char *meanPtr=(
char*)currentChar;
1371 (*meanPtr)=(char)(mean);
1374 for(wordNum=0;wordNum<MAX_NUMBER_SAMPLES;wordNum++) {
1375 testVal=input[wordNum]-mean;
1376 if(testVal>maxVal) testVal=maxVal;
1377 if(testVal<minVal) testVal=minVal;
1378 newVal=convertToMuLawUC(testVal,inputBits,mulawBits);
1380 numBitsLeft=bitSize;
1381 while(numBitsLeft) {
1382 if(numBitsLeft>(8-currentBit)) {
1384 for(bitNum=0;bitNum<(8-currentBit);bitNum++)
1385 bitMask|=(1<<bitNum);
1386 (*currentChar)|= (newVal&bitMask)<<currentBit;
1387 newVal=(newVal>>(8-currentBit));
1388 numBitsLeft-=(8-currentBit);
1394 for(bitNum=0;bitNum<numBitsLeft;bitNum++)
1395 bitMask|=(1<<bitNum);
1396 (*currentChar)|= (newVal&bitMask)<<currentBit;
1397 currentBit+=numBitsLeft;
1409 if(currentBit) currentChar++;
1410 return (
int)(currentChar-buffer);
1420 char *meanPtr=(
char*)input;
1421 short mean=(short)(*meanPtr);
1422 int inputBits=0,mulawBits=0;
1423 getInputAndMuLawBits(encType,&inputBits,&mulawBits);
1424 int bitSize=mulawBits;
1427 unsigned char *currentChar=&input[1];
1429 unsigned char tempNum;
1434 while(sampNum<MAX_NUMBER_SAMPLES) {
1435 int fred = *( (
int*) currentChar);
1438 for(bitNum=currentBit;bitNum<currentBit+bitSize;bitNum++) {
1439 tempNum|= (((fred>>bitNum)&0x1)<<(bitNum-currentBit));
1446 newVal=convertFromMuLawUC(tempNum,inputBits,mulawBits);
1447 chanPtr->
data[sampNum]=mean+newVal;
1452 currentBit+=bitSize;
1453 while(currentBit>=8) {
1457 if(((
int)(currentChar-input))>numBytes)
return COMPRESS_E_BADSIZE;
1459 return COMPRESS_E_OK;
1468 case ENCODE_LOSSY_MULAW_11_8:
1472 case ENCODE_LOSSY_MULAW_11_7:
1476 case ENCODE_LOSSY_MULAW_11_6:
1480 case ENCODE_LOSSY_MULAW_11_5:
1484 case ENCODE_LOSSY_MULAW_11_4:
1488 case ENCODE_LOSSY_MULAW_11_3:
1492 case ENCODE_LOSSY_MULAW_10_8:
1496 case ENCODE_LOSSY_MULAW_10_7:
1500 case ENCODE_LOSSY_MULAW_10_6:
1504 case ENCODE_LOSSY_MULAW_10_5:
1508 case ENCODE_LOSSY_MULAW_10_4:
1512 case ENCODE_LOSSY_MULAW_10_3:
1516 case ENCODE_LOSSY_MULAW_9_7:
1520 case ENCODE_LOSSY_MULAW_9_6:
1524 case ENCODE_LOSSY_MULAW_9_5:
1528 case ENCODE_LOSSY_MULAW_9_4:
1532 case ENCODE_LOSSY_MULAW_9_3:
1536 case ENCODE_LOSSY_MULAW_8_6:
1540 case ENCODE_LOSSY_MULAW_8_5:
1544 case ENCODE_LOSSY_MULAW_8_4:
1548 case ENCODE_LOSSY_MULAW_8_3:
1552 case ENCODE_LOSSY_MULAW_7_5:
1556 case ENCODE_LOSSY_MULAW_7_4:
1560 case ENCODE_LOSSY_MULAW_7_3:
1564 case ENCODE_LOSSY_MULAW_6_4:
1568 case ENCODE_LOSSY_MULAW_6_3:
1586 switch (inputBits) {
1588 switch (mulawBits) {
1590 return ENCODE_LOSSY_MULAW_11_8;
1592 return ENCODE_LOSSY_MULAW_11_7;
1594 return ENCODE_LOSSY_MULAW_11_6;
1596 return ENCODE_LOSSY_MULAW_11_5;
1598 return ENCODE_LOSSY_MULAW_11_4;
1600 return ENCODE_LOSSY_MULAW_11_3;
1602 return ENCODE_LOSSY_MULAW_11_8;
1605 switch (mulawBits) {
1607 return ENCODE_LOSSY_MULAW_10_8;
1609 return ENCODE_LOSSY_MULAW_10_7;
1611 return ENCODE_LOSSY_MULAW_10_6;
1613 return ENCODE_LOSSY_MULAW_10_5;
1615 return ENCODE_LOSSY_MULAW_10_4;
1617 return ENCODE_LOSSY_MULAW_10_3;
1619 return ENCODE_LOSSY_MULAW_10_8;
1622 switch (mulawBits) {
1624 return ENCODE_LOSSY_MULAW_9_7;
1626 return ENCODE_LOSSY_MULAW_9_6;
1628 return ENCODE_LOSSY_MULAW_9_5;
1630 return ENCODE_LOSSY_MULAW_9_4;
1632 return ENCODE_LOSSY_MULAW_9_3;
1634 return ENCODE_LOSSY_MULAW_9_7;
1637 switch (mulawBits) {
1639 return ENCODE_LOSSY_MULAW_8_6;
1641 return ENCODE_LOSSY_MULAW_8_5;
1643 return ENCODE_LOSSY_MULAW_8_4;
1645 return ENCODE_LOSSY_MULAW_8_3;
1647 return ENCODE_LOSSY_MULAW_8_6;
1650 switch (mulawBits) {
1652 return ENCODE_LOSSY_MULAW_7_5;
1654 return ENCODE_LOSSY_MULAW_7_4;
1656 return ENCODE_LOSSY_MULAW_7_3;
1658 return ENCODE_LOSSY_MULAW_7_5;
1661 switch (mulawBits) {
1663 return ENCODE_LOSSY_MULAW_6_4;
1665 return ENCODE_LOSSY_MULAW_6_3;
1667 return ENCODE_LOSSY_MULAW_6_4;
1670 switch (mulawBits) {
1672 return ENCODE_LOSSY_MULAW_11_8;
1674 return ENCODE_LOSSY_MULAW_11_7;
1676 return ENCODE_LOSSY_MULAW_11_6;
1678 return ENCODE_LOSSY_MULAW_11_5;
1680 return ENCODE_LOSSY_MULAW_11_4;
1682 return ENCODE_LOSSY_MULAW_11_3;
1684 return ENCODE_LOSSY_MULAW_11_8;
1693 case 11:
return ENCODE_LOSSLESS_11BIT;
1694 case 10:
return ENCODE_LOSSLESS_10BIT;
1695 case 9:
return ENCODE_LOSSLESS_9BIT;
1696 case 8:
return ENCODE_LOSSLESS_8BIT;
1697 case 7:
return ENCODE_LOSSLESS_7BIT;
1698 case 6:
return ENCODE_LOSSLESS_6BIT;
1699 case 5:
return ENCODE_LOSSLESS_5BIT;
1700 case 4:
return ENCODE_LOSSLESS_4BIT;
1701 case 3:
return ENCODE_LOSSLESS_3BIT;
1702 case 2:
return ENCODE_LOSSLESS_2BIT;
1703 case 1:
return ENCODE_LOSSLESS_1BIT;
1714 case ENCODE_LOSSLESS_11BIT:
return 11;
1715 case ENCODE_LOSSLESS_10BIT:
return 10;
1716 case ENCODE_LOSSLESS_9BIT:
return 9;
1717 case ENCODE_LOSSLESS_8BIT:
return 8;
1718 case ENCODE_LOSSLESS_7BIT:
return 7;
1719 case ENCODE_LOSSLESS_6BIT:
return 6;
1720 case ENCODE_LOSSLESS_5BIT:
return 5;
1721 case ENCODE_LOSSLESS_4BIT:
return 4;
1722 case ENCODE_LOSSLESS_3BIT:
return 3;
1723 case ENCODE_LOSSLESS_2BIT:
return 2;
1724 case ENCODE_LOSSLESS_1BIT:
return 1;
1734 case 10:
return ENCODE_LOSSLESS_BINFIB_10BIT;
1735 case 9:
return ENCODE_LOSSLESS_BINFIB_9BIT;
1736 case 8:
return ENCODE_LOSSLESS_BINFIB_8BIT;
1737 case 7:
return ENCODE_LOSSLESS_BINFIB_7BIT;
1738 case 6:
return ENCODE_LOSSLESS_BINFIB_6BIT;
1739 case 5:
return ENCODE_LOSSLESS_BINFIB_5BIT;
1740 case 4:
return ENCODE_LOSSLESS_BINFIB_4BIT;
1741 case 3:
return ENCODE_LOSSLESS_BINFIB_3BIT;
1742 case 2:
return ENCODE_LOSSLESS_BINFIB_2BIT;
1743 case 1:
return ENCODE_LOSSLESS_BINFIB_1BIT;
1745 return ENCODE_LOSSLESS_BINFIB_10BIT;
1747 return ENCODE_LOSSLESS_BINFIB_10BIT;
1753 case ENCODE_LOSSLESS_BINFIB_10BIT:
return 10;
1754 case ENCODE_LOSSLESS_BINFIB_9BIT:
return 9;
1755 case ENCODE_LOSSLESS_BINFIB_8BIT:
return 8;
1756 case ENCODE_LOSSLESS_BINFIB_7BIT:
return 7;
1757 case ENCODE_LOSSLESS_BINFIB_6BIT:
return 6;
1758 case ENCODE_LOSSLESS_BINFIB_5BIT:
return 5;
1759 case ENCODE_LOSSLESS_BINFIB_4BIT:
return 4;
1760 case ENCODE_LOSSLESS_BINFIB_3BIT:
return 3;
1761 case ENCODE_LOSSLESS_BINFIB_2BIT:
return 2;
1762 case ENCODE_LOSSLESS_BINFIB_1BIT:
return 1;
1774 unsigned short AnitaCompress::simpleCrcShort(
unsigned short *p,
unsigned long n)
1777 unsigned short sum = 0;
1779 for (i=0L; i<n; i++) {
1782 return ((0xffff - sum) + 1);
1792 case COMPRESS_E_PACK:
1793 string =
"Error packing data";
1795 case COMPRESS_E_BADSIZE:
1796 string =
"Enocded data size wrong";
1798 case COMPRESS_E_UNPACK:
1799 string =
"Error unpacking data";
1801 case COMPRESS_E_NO_PEDS:
1802 string =
"Pedestals not available";
1804 case COMPRESS_E_BAD_PEDS:
1805 string =
"Pedestals malformed";
1807 case COMPRESS_E_TOO_BIG:
1808 string =
"Data overflow";
1810 case COMPRESS_E_BAD_CRC:
1811 string =
"Checksum mismatch";
1814 string =
"Unknown error code" ;
1822 #define MEMCPY memcpy 1825 void AnitaCompress::unpack12bit(
unsigned short *w,
void *srcp)
1827 char *dumPtr = (
char *) srcp;
1831 MEMCPY((
char *)&val, dumPtr,
sizeof(
short));
1832 w[0] = val & 0x0fff;
1833 w[3] += ((val & 0xf000) >> 12);
1835 MEMCPY((
char *)&val, dumPtr +
sizeof(
short),
sizeof(
short));
1836 w[1] = val & 0x0fff;
1837 w[3] += ((val & 0xf000) >> 8);
1839 MEMCPY((
char *)&val, dumPtr + (2 *
sizeof(
short)),
sizeof(
short));
1840 w[2] = val & 0x0fff;
1841 w[3] += ((val & 0xf000) >> 4);
1844 void AnitaCompress::pack12bit(
unsigned short *w,
unsigned char *destp)
1848 val = (w[0] & 0x0fff) + ((w[3] << 12) & 0xf000);
1849 MEMCPY(destp, (
char *)&val,
sizeof(
short));
1851 val = (w[1] & 0x0fff) + ((w[3] << 8) & 0xf000);
1852 MEMCPY(destp+2, (
char *)&val,
sizeof(
short));
1854 val = (w[2] & 0x0fff) + ((w[3] << 4) & 0xf000);
1855 MEMCPY(destp+4, (
char *)&val,
sizeof(
short));
1859 unsigned char AnitaCompress::convertToMuLawUC(
short input,
int inputBits,
1862 char val=convertToMuLaw(input,inputBits,mulawBits);
1864 return charbifurcate(val);
1867 char AnitaCompress::convertToMuLaw(
short input,
int inputBits,
int mulawBits)
1871 int index=input+(1<<(inputBits-1));
1872 switch (inputBits) {
1874 switch (mulawBits) {
1876 return linear11toMuLaw8[index];
1878 return linear11toMuLaw7[index];
1880 return linear11toMuLaw6[index];
1882 return linear11toMuLaw5[index];
1884 return linear11toMuLaw4[index];
1886 return linear11toMuLaw3[index];
1888 return linear11toMuLaw8[index];
1891 switch (mulawBits) {
1893 return linear10toMuLaw8[index];
1895 return linear10toMuLaw7[index];
1897 return linear10toMuLaw6[index];
1899 return linear10toMuLaw5[index];
1901 return linear10toMuLaw4[index];
1903 return linear10toMuLaw3[index];
1905 return linear10toMuLaw8[index];
1908 switch (mulawBits) {
1910 return linear9toMuLaw7[index];
1912 return linear9toMuLaw6[index];
1914 return linear9toMuLaw5[index];
1916 return linear9toMuLaw4[index];
1918 return linear9toMuLaw3[index];
1920 return linear9toMuLaw7[index];
1923 switch (mulawBits) {
1925 return linear8toMuLaw6[index];
1927 return linear8toMuLaw5[index];
1929 return linear8toMuLaw4[index];
1931 return linear8toMuLaw3[index];
1933 return linear8toMuLaw6[index];
1936 switch (mulawBits) {
1938 return linear7toMuLaw5[index];
1940 return linear7toMuLaw4[index];
1942 return linear7toMuLaw3[index];
1944 return linear7toMuLaw5[index];
1947 switch (mulawBits) {
1949 return linear6toMuLaw4[index];
1951 return linear6toMuLaw3[index];
1953 return linear6toMuLaw4[index];
1956 switch (mulawBits) {
1958 return linear11toMuLaw8[index];
1960 return linear11toMuLaw7[index];
1962 return linear11toMuLaw6[index];
1964 return linear11toMuLaw5[index];
1966 return linear11toMuLaw4[index];
1968 return linear11toMuLaw3[index];
1970 return linear11toMuLaw8[index];
1976 short AnitaCompress::convertFromMuLawUC(
unsigned char input,
int outputBits,
int mulawBits)
1979 return convertFromMuLaw(charunbifurcate(input),outputBits,mulawBits);
1982 short AnitaCompress::convertFromMuLaw(
char input,
int outputBits,
int mulawBits)
1984 int index=input+(1<<(mulawBits-1));
1985 switch (outputBits) {
1987 switch (mulawBits) {
1989 return mulaw8toLinear11[index];
1991 return mulaw7toLinear11[index];
1993 return mulaw6toLinear11[index];
1995 return mulaw5toLinear11[index];
1997 return mulaw4toLinear11[index];
1999 return mulaw3toLinear11[index];
2001 return mulaw8toLinear11[index];
2004 switch (mulawBits) {
2006 return mulaw8toLinear10[index];
2008 return mulaw7toLinear10[index];
2010 return mulaw6toLinear10[index];
2012 return mulaw5toLinear10[index];
2014 return mulaw4toLinear10[index];
2016 return mulaw3toLinear10[index];
2018 return mulaw8toLinear10[index];
2021 switch (mulawBits) {
2023 return mulaw7toLinear9[index];
2025 return mulaw6toLinear9[index];
2027 return mulaw5toLinear9[index];
2029 return mulaw4toLinear9[index];
2031 return mulaw3toLinear9[index];
2033 return mulaw7toLinear9[index];
2036 switch (mulawBits) {
2038 return mulaw6toLinear8[index];
2040 return mulaw5toLinear8[index];
2042 return mulaw4toLinear8[index];
2044 return mulaw3toLinear8[index];
2046 return mulaw6toLinear8[index];
2049 switch (mulawBits) {
2051 return mulaw5toLinear7[index];
2053 return mulaw4toLinear7[index];
2055 return mulaw3toLinear7[index];
2057 return mulaw5toLinear7[index];
2060 switch (mulawBits) {
2062 return mulaw4toLinear6[index];
2064 return mulaw3toLinear6[index];
2066 return mulaw4toLinear6[index];
2069 switch (mulawBits) {
2071 return mulaw8toLinear11[index];
2073 return mulaw7toLinear11[index];
2075 return mulaw6toLinear11[index];
2077 return mulaw5toLinear11[index];
2079 return mulaw4toLinear11[index];
2081 return mulaw3toLinear11[index];
2083 return mulaw8toLinear11[index];
2090 unsigned int fFibNums[24]={1,2,3,5,8,13,21,34,55,89,
2091 144,233,377,610,987,1597,2584,4181,6765,10946,
2092 17711,28657,46368,75025};
2096 unsigned int AnitaCompress::fibonacci(
unsigned short input){
2098 return encodeFibonacci(input,&numBits);
2101 unsigned int AnitaCompress::encodeFibonacci(
unsigned short input,
int *numBits){
2102 unsigned int output;
2106 while(input>=fFibNums[i]){
2115 if (input>=fFibNums[i]){
2117 input -= fFibNums[i];
2125 unsigned short AnitaCompress::unfibonacci(
unsigned int input)
2128 unsigned short output;
2129 unsigned int curbit, lastbit;
2132 for (i=0; i<23; i++){
2133 curbit=(input>>i) & 0x0001;
2134 if (curbit==1 && lastbit==1)
break;
2135 else if (curbit==1) output+=fFibNums[i];
2152 unsigned short AnitaCompress::bifurcate(
short input)
2154 unsigned short output;
2156 output=(2*(
unsigned short) input + 1);
2159 output=(2* (
unsigned short)abs(input));
2164 short AnitaCompress::unbifurcate(
unsigned short input)
2168 if ((input % 2) == 1){
2169 output=((input-1)/2);
2177 unsigned char AnitaCompress::charbifurcate(
char input)
2179 unsigned char output;
2181 output=(2*(
unsigned char) input + 1);
2185 output=(2* (
unsigned char)input);
2190 char AnitaCompress::charunbifurcate(
unsigned char input)
2194 if ((input % 2) == 1){
2195 output=((input-1)/2);
2207 void AnitaCompress::bitstrip(
unsigned short nbits,
unsigned short nwords,
unsigned short *data)
2210 for (i=0; i<nwords; i++){
2211 data[i]=data[i]>>nbits;
2219 unsigned short AnitaCompress::bitpack(
unsigned short nbits,
unsigned short nwords,
2220 unsigned short *in,
unsigned char *out)
2223 unsigned short scratch, mask1,mask2, byte, bit, nbitsleft;
2227 mask1= ~(0xffff << (
unsigned short) nbits);
2228 for (i=0; i<nwords; i++){
2229 scratch= in[i] & mask1;
2231 while (nbitsleft>0){
2232 if (nbitsleft>(8-bit)){
2233 mask2 = ~((0xffff)<<(8-bit));
2234 out[byte] |= (scratch & mask2) << bit;
2236 scratch = ((scratch & mask2) >> (8-bit));
2237 nbitsleft -= (8-bit);
2238 byte++; bit=0; out[byte]=0;
2241 out[byte] |= scratch << bit;
2242 bit = bit + nbitsleft;
2243 if (bit==8){ byte++; bit=0; out[byte]=0;}
2248 if (bit==0)
return byte;
2254 int AnitaCompress::codepack(
int n,
unsigned int *in,
unsigned char *out)
2258 unsigned char bit, nbits;
2259 unsigned int sbit,scratch,mask;
2265 for (i=0; i<n; i++){
2268 while (sbit<=in[i]) {sbit=sbit<<1; nbits++;}
2273 if (nbits>((
unsigned char)8-bit)){
2275 mask= ~((
unsigned int)(0xffffffff)<<(8-bit));
2276 out[byte] |= (scratch & mask) << bit;
2278 scratch=(scratch & mask) >> (8-bit);
2280 byte++; bit=0; out[byte]=0;
2283 out[byte] |= scratch << bit;
2285 if (bit==8){ byte++; bit=0; out[byte]=0;}
2290 if (bit==0)
return byte;
2296 int AnitaCompress::codeunpack(
int m,
unsigned char *in,
unsigned int *out)
2299 int outword, outbit;
2300 unsigned int curbit, lastbit;
2308 curbit=(in[inbyte]>>inbit) & 0x1;
2309 out[outword] |= curbit << outbit;
2311 if (inbit==8){ inbyte++; inbit=0;}
2312 if ((curbit==1 && lastbit==1)|| outbit==32){
2313 outword++; outbit=0; out[outword]=0;
2316 if (outbit!=0) lastbit=curbit;
EncodedPedSubbedChannelPacketHeader_t – Yes.
SS Hk Data Struct – Telemetered.
GpsAdu5PatStruct_t – Yes.
unsigned numBytes
Not including the EncodedEventWrapper_t;.
unsigned int whichPeds
whichPedestals did we subtract
void fillGenericHeader(void *thePtr, PacketCode_t code, unsigned short numBytes)
fillGenericHeader – utility function
SummedTurfRateStruct_t – yes.
ChannelEncodingType_t
The encoding enumeration.
int unzipZippedPacket(ZippedPacket_t *zipPacket, char *output, unsigned int numBytesOut)
unzipZippedPacket – utility function
ADU5 Satellite Info – Telemetered.
Gpsd Start Block – Telemetered.
Summed Turf Rates – Telemetered.
PedSubbedSurfPacket_t – Yes.
Slow Rate Block – Telemetered.
unsigned char getVersionId(PacketCode_t code)
getVersionId – utility function
EncodedPedSubbedSurfPacketHeader_t – Yes.
CompressErrorCode_t
CompressErrorCode_t – Enumeration for compression errors.
unsigned char chanId
Channel Id.
OtherMonitorStruct_t – Yes.
Pedestal subtracted event format.
Done is just a marker for below.
ADU5 course and speed info – Telemetered.
The Acqd Startup Struct – Telemetered.
G12 Satellite Info – Telemetered.
Done is just a marker for below.
Pedestal Block – Telemetered.
Hk Data Struct – Telemetered.
EncodedSurfPacketHeader_t – Yes.
float rms
Filled by pedestalLib.
RawWaveformPacket_t –Yes.
Monitor Block – Telemetered.
int getPacketSize(PacketCode_t code)
getPacketSize – utility function
const char * packetCodeAsString(PacketCode_t code)
packetCodeAsString – utility function
int checkPacket(void *thePtr)
checkPacket – utility function
ADU5 Postion and Attitude – Telemetered.
Zipped packet – Telemetered.
PacketCode_t
The Packet Code.
Average Surf Hk – Telemetered.
unsigned int simpleIntCrc(unsigned int *p, unsigned int n)
simpleIntCrc – utility function
EncodedEventWrapper_t – No.
Command Echo – Telemetered.
Wrapper for data that is written encoded.
unsigned char lastHitbus
Last sample of the hitbus.
PedSubbedEventBody_t – No too big.
G12 Position and speed info – Telemetered.
ADU5 Postion and Geoid – Telemetered.
unsigned char firstHitbus
First sample of the hitbus.
Done is just a marker for below.
AveragedSurfHkStruct_t – yes.
GpsAdu5VtgStruct_t – Yes.
PedestalStruct_t – No (Too Big)
GpuPhiSectorPowerSpectrum_t – Yes.
Run Start Block - Telemetered.
Pedestal subtracted SURF wavefom packet – Telemetered.
Turf Rates – Telemetered.
A complete pedestal subtracted SURF channel.
LogWatchd Start Block – Telemetered.
short data[MAX_NUMBER_SAMPLES]
Pedestal subtracted and 11bit data.
int unzipBuffer(char *input, char *output, unsigned int inputBytes, unsigned int *outputBytes)
unzipBuffer – utility function
PedSubbedWaveformPacket_t – Yes.
GpsAdu5SatStruct_t – Yes.
TurfRegisterContents_t – probably not.
FullLabChipPedStruct_t – Yes.
Raw SURF wavefom packet – Telemetered.
unsigned char chipIdFlag
chip id bitmask
int zipBuffer(char *input, char *output, unsigned int inputBytes, unsigned int *outputBytes)
zipBuffer – utility function
int simplePacketCheck(GenericHeader_t *gHdr, PacketCode_t code)
simplePacketCheck – utility function
float mean
Filled by pedestalLib.