#This work is licensed under the
#Creative Commons Attribution-Share Alike 3.0 United States License.
#To view a copy of this license, visit
#http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to
#Creative Commons,
#171 Second Street, Suite 300,
#San Francisco, California, 94105, USA.

INPUT "WavPack file stream",sub_block_size;
OUTPUT "the number of decorrelation terms, a list of signed decorrelation terms, a list of unsigned decorrelation deltas";
VAR sub_block_size "sub block size";
VAR decorrelation_term_count "term count";
VAR decorrelation_terms "decorrelation terms";
VAR decorrelation_deltas "decorrelation deltas";
decorrelation_term_count <- sub_block_size;
for p <- decorrelation_term_count downto 0 /*populate in reverse order*/ {
    decorrelation_terms[p] <- (read 5 unsigned) - 5;
    decorrelation_deltas[p] <- read 3 unsigned;
    assert (-3 <= decorrelation_terms[p] <= -1) or
           (1 <= decorrelation_terms[p] <= 8) or
           (17 <= decorrelation_terms[p] <= 18);
}
return decorrelation_term_count,decorrelation_terms,decorrelation_deltas;
