SBC APIs

[English]

重要

The SBC Driver is just only APIs for SBC decoding function. And the SBC API v1.0 is the lastest and stable SBC decoder APIs. All new applications should use SBC API v1.0.

SBC User Guide

The sbc and msbc are used as follow:

SBC User Guide Flow

SBC User Guide Flow

SBC Interface

The BK SBC Driver supports following functions:

  • sbc function

  • msbc function

The SBC Driver support msbc decoder function. If the application need to use msbc decoder function, Just use the bk_sbc_decoder_support msbc() to enable msbc function.

SBC API Categories

Most of SBC APIs can be categoried as:

  • Common or sbc APIs

    The common APIs are prefixed with bk_sbc, the APIs may be common for sbc and msbc interfaces, e.g. bk_sbc_decoder_init() etc.

  • MSBC function APIs.

    The APIs provide support for msbc function. e.g. bk_sbc_decoder_support msbc().

Common APIs:

API Reference

Header File

Functions

bk_err_t bk_sbc_decoder_frame_decode(sbcdecodercontext_t *sbc, const uint8_t *data, uint32_t length)

SBC decoder decode one frame.

This API decode one frame by sbc decoder.

Usage example:

sbcdecodercontext_t sbc_decoder; bk_sbc_decoder_frame_decode(&sbc_decoder, sbc_data, 512);

Attention

1. the output PCM data please refer to the follows variables:

  • sbc->pcm_sample: means output PCM data address

  • sbc->pcm_length: means output PCM data length in sample

  • sbc->channel_number: means output PCM data channels

参数

sbc, : – sbc decoder context pointer;

  • data: buffer to be decoded;

  • length: the length of input buffer;

返回

  • consumed: buffer length by decoder if no error ocurs, else error code (always small than 0) will be return.

bk_err_t bk_sbc_decoder_bit_allocation(sbccommoncontext_t *sbc)

SBC bit allocation calculate for both encoder and decoder.

This API calculate sbc bit allocation.

参数

sbc, : – sbc decoder context pointer

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_sbc_decoder_init(sbcdecodercontext_t *sbc)

SBC decoder initialize.

This API init the sbc decoder function.

参数

sbc, : – sbc decoder context pointer

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_sbc_decoder_deinit(void)

SBC decoder deinit.

This API deinit the sbc decoder function.

参数

None

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_sbc_decoder_interrupt_enable(bool enable)

enable/disable sbc interrupt

This API enable or disable sbc interrupt:

  • reigster interrupt service handle

  • enable or disable sbc interrupt

参数

enable, : – enable —— 1, disable —— 0

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_sbc_decoder_support_msbc(bool enable)

enable/disable msbc decoder

This API enable/disable msbc decoder.

参数

enable, : – enable —— 1, disable —— 0

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_sbc_decoder_register_sbc_isr(sbc_decoder_isr_t isr, void *param)

Register sbc decoder isr.

This API register sbc decoder isr.

参数

isr, : – sbc decoder isr callback;

  • param: sbc decoder isr callback parameter;

返回

  • BK_OK: succeed

  • others: other errors.

API Typedefs

Header File

Structures

struct sbccommoncontext_t

SBC decoder context.

Public Members

int8_t blocks

block number

int8_t subbands

subbands number

uint8_t join

bit number x set means joint stereo has been used in subband x

uint8_t bitpool

indicate the size of the bit allocation pool that has been used for encoding the stream

int8_t channel_mode

channel mode

int8_t sample_rate_index

sample rate index, 0:16000, 1:32000, 2:44100, 3:48000

int8_t allocation_method

allocation method

int8_t reserved8

dummy, reserved for byte align

int8_t bits[2][8]

calculate result by bit allocation

int8_t scale_factor[2][8]

only the lower 4 bits of every element are to be used

int32_t mem[2][8]

Memory used as bit need and levels

struct sbcdecodercontext_t

SBC decoder context.

Public Members

int8_t channel_number

channels number

uint8_t pcm_length

PCM length

uint16_t sample_rate

sample rate

int32_t pcm_sample[2][128]

PCM frame buffer

int32_t vfifo[2][170]

FIFO V for subbands synthesis calculation.

struct sbc_config_t

Public Members

sbc_channel_num_t channel_num

channels number

sbc_subband_number_t subbands

subband number

sbc_chn_comb_t chn_comb

pcm output struct

sbc_blocks_number_t blocks

block number

Macros

SBC_SYNCWORD

SBC synchronize word

MSBC_SYNCWORD

MSBC synchronize word

SBC_CHANNEL_MODE_MONO

SBC channel mode : MONO

SBC_CHANNEL_MODE_DUAL

SBC channel mode : Dual Channels

SBC_CHANNEL_MODE_STEREO

SBC channel mode : Stereo

SBC_CHANNEL_MODE_JOINT_STEREO

SBC channel mode : Joint Stereo

SBC_DECODER_ERRORS
SBC_DECODER_ERROR_BUFFER_OVERFLOW

buffer overflow

SBC_DECODER_ERROR_SYNC_INCORRECT

synchronize incorrect

SBC_DECODER_ERROR_BITPOOL_OUT_BOUNDS

bitpool out of bounds

SBC_DECODER_ERROR_STREAM_EMPTY

stream empty

SBC_DECODER_ERROR_OK

no error

Type Definitions

typedef void (*sbc_decoder_isr_t)(void *param)

Enumerations

enum sbc_sample_rates_t

Values:

enumerator SBC_SAMPLE_RATE_16000

SBC sampling frequency : 16.0KHz

enumerator SBC_SAMPLE_RATE_32000

SBC sampling frequency : 32.0KHz

enumerator SBC_SAMPLE_RATE_44100

SBC sampling frequency : 44.1KHz

enumerator SBC_SAMPLE_RATE_48000

SBC sampling frequency : 48.0KHz

enumerator SBC_SAMPLE_RATE_MAX
enum sbc_channel_num_t

Values:

enumerator SBC_CHANNEL_NUM_ONE

SBC channel number : 1 channel

enumerator SBC_CHANNEL_NUM_TWO

SBC channel number : 2 channels

enumerator SBC_CHANNEL_MODE_INVALID
enum sbc_subband_number_t

Values:

enumerator SBC_SUBBAND_NUMBER_4

SBC subbands number 4

enumerator SBC_SUBBAND_NUMBER_8

SBC subbands number 8

enumerator SBC_SUBBAND_MAX
enum sbc_chn_comb_t

Values:

enumerator SBC_DECODE_OUTPUT_SINGLE

SBC decoder output struct:{16’d0, pcm}

enumerator SBC_DECODE_OUTPUT_DOUBLE

SBC decoder output struct:{pcm_chn2, pcm_chn1}

enumerator SBC_DECODE_OUTPUT_INVALID
enum sbc_blocks_number_t

Values:

enumerator SBC_BLOCK_NUMBER_4

SBC blocks number 4

enumerator SBC_BLOCK_NUMBER_8

SBC blocks number 8

enumerator SBC_BLOCK_NUMBER_12

SBC blocks number 12

enumerator SBC_BLOCK_NUMBER_16

SBC blocks number 16

enumerator SBC_BLOCK_NUMBER_MAX
enum sbc_allocation_method_t

Values:

enumerator SBC_ALLOCATION_METHOD_LOUDNESS

SBC allocation method : Loudness

enumerator SBC_ALLOCATION_METHOD_SNR

SBC allocation method : SNR

enumerator SBC_ALLOCATION_METHOD_INVALID