ГОСТ Р 53556.4—2013
Декодирование переупорядоченныхспектральныхданных не может быть сделано напрямую. Следу
ющее описание в стиле языка С показывает процессдекодирования:
/* helper functions 7
voidInitRoordering(void);
/* Initializes variables used by the reordering functions like the segment
widths and the used offsets in segments and codewords V
voidInitRemainingBitsInSegmentfvoid);
/* Initializes remainingBitslnSegmont[] array for each segment with the
total size of the segment V
int DecodeCodeword(codewordNr segmentNr. direction).
Г Try to decode the codewordindexed by codowordNrusing data alreadyread
forthis codeword and using data from the segment index by segmentNr.
The read direction in the segment is given by direction. DecodeCodeword
returns the number ofbits read from the indexed segment. V
voidMoveFromsegmentToCodewordfcodewordNr. segmentNr. bitLen, direction);/’
Move bitLen bits from the segment indexed by segmentNrto the codeword indexed
by codowordNrusing direction as read direction in the segment.
The bits are appended to existing bits for the codeword and the codeword length is adjusted. У
voidAdjustOffsetslnSegment(segmentNr. bitLen. direction);
/* Like MoveFromsegmentToCodev/ord(). but no bits are moved. Only the offsets
for the segment indexed by segmentNrare adjusted according bitLen and direction. V
voidMarkCodewordAsDecodcd(codewordNr):
Г Marks the codewordindexed by codewordNras decoded. 7
boolCodewordlsNotDecoded(codewordNr):
/* Rotums TRUEif the codeword indexed by codowordNris not decoded. V
void ToggleReadDirectioii(void):
/* Toggles the read direction in the segments between forward and backward. V
/* (input) variables V
numberOfCodewords:
numberOfSegments:
numborOfSets:
DccodeReorderedSpectralDataO
{
InitReorderingO;
InitRemainingBitsInSegmentO;
Г first step: decode PCWs (set О) V
readDirection = forward:
for(codeword =0; codeword <numberOfSegments. codeword**) {
cwLen =DccodeCodeword(codcword. codeword. readDirection):
if(cwLen <=remainingBitslnSogment[codewordj) {
AdjustOffsetsInSegmentfcodeword. cwLen. readDirection):
MarkCodewordAsDecoded(codeword);
remainingBitslnSegment[codeword] -= cwLen;
}
else {
/* error!!! (PCWs do always fit into segments) V
}
}
/* second step: decode nonPCWs V
for (set = 1; set < numberOfSets: set+*) {
ToggleReadDirectionO;
for (trial = 0; trial < numberOfSegments; trial**) {
for(codewordBase - 0: codev/ordBase <numberOfSegments; codewordBase**) {
segment = (trial * codewordBase) % numberOfSegments:
codeword =codewordBase * set’numberOfSogments:
128