F
freeskying_sy
Unregistered / Unconfirmed
GUEST, unregistred user!
#define OFFSET 0x30
void encode(byte *Histogram, Byte *ASMTOutput, int HistSize)
{
int HistIdx, OutIdx;
long BitArray;
HistIdx = OutIdx = 0;
/*Convert the histogram 3 bytes at a time*/
while (HistIdx < HistSize - 2)
{
BitArray = Histogram[HistIdx];
BitArray = (BitArray << 8) + Histogram[HistIdx+1];
BitArray = (BitArray << 8) + Histogram[HistIdx+2];
ASTMOutput[OutIdx] = ((BitArray &
0xFC0000) >> 18) + OFFSET;
ASTMOutput[OutIdx+1] = ((BitArray &
0x03F0000) >> 12) + OFFSET;
ASTMOutput[OutIdx+2] = ((BitArray &
0x000FC0) >> 6) + OFFSET;
ASTMOutput[OutIdx+3] (BitArray &
0x00003F) + OFFSET;
HistIdx +=3;
OutIdx +=4;
}
if (HistIdx == HistSize - 2)
{
/* 2 bytes left in histogram */
BitArray = Histogram[HistIdx];
BitArray = (BitArray << 8) + Histogram[HistIdx+1];
ASTMOutput[OutIdx] = ((BitArray &
0x03F0000 >> 12) + OFFSET;
ASTMOutput[OutIdx+1] = ((BitArray &
0x000FC0) >> 6) + OFFSET;
ASTMOutput[OutIdx+2] = (BitArray &
0x00003F) + OFFSET;
}
else
if (HistIdx == HistSize - 1)
{
/* 1 byte left in histogram */
BitArray = Histogram[HistIdx];
ASTMOutput[OutIdx] = ((BitArray &
0x000FC0) >> 6) + OFFSET;
ASTMOutput[OutIdx+1] = (BitArray &
0x00003F) + OFFSET;
}
}
void decode(byte *ASTMField, byte *Histogram, int FieldSize)
{
int FieldIdx, HistIdx:
long BitArray;
FieldIdx = HistIdx = 0;
/* Decode four characters at a time */
while (FieldIdx < FieldSize - 3)
{
BitArray = ASTMField[FieldIdx] - OFFSET;
BitArray = (BitArray << 6)+ (ASTMField[FieldIdx+1] - OFFSET);
BitArray = (BitArray << 6) + (ASTMField[FieldIdx+2] - OFFSET;
BitArray = (BitArray6 << 6) + (ASTMField[FieldIdx+3] - OFFSET;
Histogram[HistIdx] = (BitArray &
0xFF0000) >> 16;
Histogram[HistIdx+1] = (BitArray &
0x00FF00) >> 8;
Histogram[HistIdx+2] = (BitArray &
0x0000FF);
FieldIdx +=4;
HistIdx +=3;
}
if (FieldIdx == FieldSize -3)
{
/* Three bytes left to convert */
BitArray = ASTMField[FieldIdx] - OFFSET;
BitArray = (BitArray << 6) + (ASTMField[FieldIdx+1] - OFFSET;
BitArray = (BitArray << 6) = ASTMField[FieldIdx+1] - OFFSET;
Histogram[HistIdx] = (BitArray &
0x00FF00) >> 8;
Histogram[HistIdx+1] = (BitArray &
0x0000FF0;
}
else
if (FieldIdx == FieldSize - 2)
{
/* Two bytes left to convert */
BitArray = ASTMField[FieldIdx] - OFFSET;
BitArray = (BitArray << 6) + (ASTMField[FieldIdx+1] - OFFSET;
Histogram[HistIdx] = (BitArray &
0x0000FF);
}
}
void encode(byte *Histogram, Byte *ASMTOutput, int HistSize)
{
int HistIdx, OutIdx;
long BitArray;
HistIdx = OutIdx = 0;
/*Convert the histogram 3 bytes at a time*/
while (HistIdx < HistSize - 2)
{
BitArray = Histogram[HistIdx];
BitArray = (BitArray << 8) + Histogram[HistIdx+1];
BitArray = (BitArray << 8) + Histogram[HistIdx+2];
ASTMOutput[OutIdx] = ((BitArray &
0xFC0000) >> 18) + OFFSET;
ASTMOutput[OutIdx+1] = ((BitArray &
0x03F0000) >> 12) + OFFSET;
ASTMOutput[OutIdx+2] = ((BitArray &
0x000FC0) >> 6) + OFFSET;
ASTMOutput[OutIdx+3] (BitArray &
0x00003F) + OFFSET;
HistIdx +=3;
OutIdx +=4;
}
if (HistIdx == HistSize - 2)
{
/* 2 bytes left in histogram */
BitArray = Histogram[HistIdx];
BitArray = (BitArray << 8) + Histogram[HistIdx+1];
ASTMOutput[OutIdx] = ((BitArray &
0x03F0000 >> 12) + OFFSET;
ASTMOutput[OutIdx+1] = ((BitArray &
0x000FC0) >> 6) + OFFSET;
ASTMOutput[OutIdx+2] = (BitArray &
0x00003F) + OFFSET;
}
else
if (HistIdx == HistSize - 1)
{
/* 1 byte left in histogram */
BitArray = Histogram[HistIdx];
ASTMOutput[OutIdx] = ((BitArray &
0x000FC0) >> 6) + OFFSET;
ASTMOutput[OutIdx+1] = (BitArray &
0x00003F) + OFFSET;
}
}
void decode(byte *ASTMField, byte *Histogram, int FieldSize)
{
int FieldIdx, HistIdx:
long BitArray;
FieldIdx = HistIdx = 0;
/* Decode four characters at a time */
while (FieldIdx < FieldSize - 3)
{
BitArray = ASTMField[FieldIdx] - OFFSET;
BitArray = (BitArray << 6)+ (ASTMField[FieldIdx+1] - OFFSET);
BitArray = (BitArray << 6) + (ASTMField[FieldIdx+2] - OFFSET;
BitArray = (BitArray6 << 6) + (ASTMField[FieldIdx+3] - OFFSET;
Histogram[HistIdx] = (BitArray &
0xFF0000) >> 16;
Histogram[HistIdx+1] = (BitArray &
0x00FF00) >> 8;
Histogram[HistIdx+2] = (BitArray &
0x0000FF);
FieldIdx +=4;
HistIdx +=3;
}
if (FieldIdx == FieldSize -3)
{
/* Three bytes left to convert */
BitArray = ASTMField[FieldIdx] - OFFSET;
BitArray = (BitArray << 6) + (ASTMField[FieldIdx+1] - OFFSET;
BitArray = (BitArray << 6) = ASTMField[FieldIdx+1] - OFFSET;
Histogram[HistIdx] = (BitArray &
0x00FF00) >> 8;
Histogram[HistIdx+1] = (BitArray &
0x0000FF0;
}
else
if (FieldIdx == FieldSize - 2)
{
/* Two bytes left to convert */
BitArray = ASTMField[FieldIdx] - OFFSET;
BitArray = (BitArray << 6) + (ASTMField[FieldIdx+1] - OFFSET;
Histogram[HistIdx] = (BitArray &
0x0000FF);
}
}