#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 samples,block_size;
OUTPUT "wasted bits-per-sample as unsigned integer";
VAR samples "samples";
VAR block_size "block size";
VAR wasted_bps "wasted BPS";

wasted_bps <- infinity /*maximum unsigned integer*/;
for i <- 0 to block_size {
    w[i] <- wasted(samples[i]);
    if w[i] < wasted_bps {
        wasted_bps <- w[i];
    }
}
return wasted_bps;
