#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 "a WavPack file stream";
OUTPUT "relevant block header fields";
VAR block_ID "block ID";
VAR block_data_size "block data size";
VAR version "version";
VAR track_number "track number";
VAR index_number "index number";
VAR total_samples "total samples";
VAR block_index "block index";
VAR block_samples "block samples";
VAR bits_per_sample "bits-per-sample";
VAR mono_output "mono output";
VAR hybrid_mode "hybrid mode";
VAR joint_stereo "joint stereo";
VAR channel_decorrelation "channel decorrelation";
VAR hybrid_noise_shaping "hybrid noise shaping";
VAR floating_point_data "floating point data";
VAR extended_size_integers "extended size integers";
VAR hybrid_controls_bitrate "hybrid controls bitrate";
VAR hybrid_noise_balanced "hybrid noise balanced";
VAR initial_block "initial block";
VAR final_block "final block";
VAR left_shift_data "left shift data";
VAR maximum_magnitude "maximum magnitude";
VAR sample_rate "sample rate";
VAR use_IIR "use IIR";
VAR false_stereo "false stereo";
VAR reserved "reserved";
VAR CRC "CRC";
FUNC decode_sample_rate "decode sample rate" "wavpack:decode_sample_rate";
block_ID <- read 4 bytes;
assert block_ID == bytes(119, 118, 112, 107);
block_data_size <- (read 32 unsigned) - 24;
version <- read 16 unsigned;
track_number <- read 8 unsigned;
index_number <- read 8 unsigned;
total_samples <- read 32 unsigned;
block_index <- read 32 unsigned;
block_samples <- read 32 unsigned;
bits_per_sample <- ((read 2 unsigned) + 1) * 8;
mono_output <- read 1 unsigned;
hybrid_mode <- read 1 unsigned;
joint_stereo <- read 1 unsigned;
channel_decorrelation <- read 1 unsigned;
hybrid_noise_shaping <- read 1 unsigned;
floating_point_data <- read 1 unsigned;
extended_size_integers <- read 1 unsigned;
hybrid_controls_bitrate <- read 1 unsigned;
hybrid_noise_balanced <- read 1 unsigned;
initial_block <- read 1 unsigned;
final_block <- read 1 unsigned;
left_shift_data <- read 5 unsigned;
maximum_magnitude <- read 5 unsigned;
sample_rate <- decode_sample_rate(read 4 unsigned);
skip 2;
use_IIR <- read 1 unsigned;
false_stereo <- read 1 unsigned;
reserved <- read 1 unsigned;
assert reserved == 0;
CRC <- read 32 unsigned;
return block_data_size,
total_samples,
block_index,
block_samples,
mono_output,
joint_stereo,
channel_decorrelation,
extended_size_integers,
final_block,
false_stereo,
CRC;
