#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 "subframe's type and order",wasted_BPS;
OUTPUT "a FLAC subframe header";
VAR type_order "subframe type/order";
VAR wasted_BPS "wasted BPS";
VAR subframe_header "subframe header";
0 -> write 1 unsigned /*pad*/;
type_order -> write 6 unsigned;
if wasted_BPS == 0 {
   0 -> write 1 unsigned;
} else {
   1 -> write 1 unsigned;
   (wasted_BPS - 1) -> write unary 1;
}
return subframe_header;
