#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 PCM samples per channel";
OUTPUT "encoded block size as a 4 bit value";
VAR block_size "sample count";
switch block_size {
    case 192 {return 1;}
    case 256 {return 8;}
    case 512 {return 9;}
    case 576 {return 2;}
    case 1024 {return 10;}
    case 1152 {return 3;}
    case 2048 {return 11;}
    case 2304 {return 4;}
    case 4096 {return 12;}
    case 4608 {return 5;}
    case 8192 {return 13;}
    case 16384 {return 14;}
    case 32768 {return 15;}
    default {
        if block_size <= 256 {
            return 6;
        } elif block_size <= 65536 {
            return 7;
        } else {
            return 0;
        }
    }
}
