#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 "number of decorrelation terms, a list of decorrelation terms, a list of decorrelation deltas";
OUTPUT "a decorrelation terms sub block, the sub block size";
VAR decorrelation_term_count "term count";
VAR decorrelation_terms "terms";
VAR decorrelation_deltas "deltas";
VAR sub_block "sub block";
FUNC write_sub_block_header "write sub block header"
"wavpack:write_sub_block_header";
write_sub_block_header(2, 0, decorrelation_term_count);
for p <- decorrelation_term_count downto 0 {
    (decorrelation_terms[p] + 5) -> write 5 unsigned;
    decorrelation_deltas[p] -> write 3 unsigned;
}
return sub_block, 2 + decorrelation_term_count;
