/* Calculates the bitpool size for a given frame length  */
OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame, OI_UINT16 frameLen)
/* Calculates the bitpool size for a given frame length  */
OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame, OI_UINT16 frameLen)
{
    OI_UINT16 nrof_subbands = frame->nrof_subbands;
    OI_UINT16 nrof_blocks = frame->nrof_blocks;
    OI_UINT16 hdr;
    OI_UINT16 bits;
    if(frame->mode == SBC_JOINT_STEREO)
    {
        hdr = 9 * nrof_subbands;
    }
    else
    {
        if(frame->mode == SBC_MONO)
        {
            hdr = 4 * nrof_subbands;
        }
        else
        {
            hdr = 8 * nrof_subbands;
        }
        if(frame->mode == SBC_DUAL_CHANNEL)
        {
            nrof_blocks *= 2;
        }
    }
    bits = 8 * (frameLen - SBC_HEADER_LEN) - hdr;
    return DIVIDE(bits, nrof_blocks);
}