Codec Factory

概述

Codec Factory是提供了编解码统一入口的组件,根据上层调用的codec类型决定使用到的编解码算法。

功能特性

  • 提供aac解码,sbc解码,msbc编解码和cvsd编解码功能。

资源依赖

  • aac解码算法库

  • sbc解码算法库

  • msbc编解码算法库

  • cvsd编解码算法库

模式说明

  1. pipeline使用模式

上层应用使用pipeline模式创建音频流时,需要调用到audio_decoder.c/audio_encoder.c里的probe函数,根据音频流里注册的processor节点会调用到不同codec的probe函数,继而在处理音频流时会调用不同的编解码算法。

pipeline使用方法请参考pipeline相关介绍文档。

  1. 非pipeline使用模式

上层应用未使用pipeline模式创建音频流时,可以直接调用decode_factory.c里decode_create函数,根据传入的codec类型会初始化不同的编解码算法,后续process函数里也会调用不同的编解码函数。

pipeline使用模式参考示例

examples/pipeline_demo

非pipeline使用模式参考示例

examples/decode_demo

API 介绍

struct wq_decoder_config_t

Public Members

wq_pipeline_processor_t *sub_processor

Sub processor called by decoder processor

void *sub_processor_config

Sub processor configure

struct wq_encoder_config_t

Public Members

wq_pipeline_processor_t *sub_processor

Sub processor called by encoder processor

void *sub_processor_config

Sub processor configure

Functions

struct decode_handle *decode_create(WQ_DECODE_TYPE type)

Init decode modlue.

参数:

type -- [in] The audio data codec type

返回:

Decode handler point for process audio data

Defines

MAX_LOSS_PATTERN_LENGTH

Max loss pattern buffer length

MAX_MEM_ALLOCS

Max num of decode buffer

SBC_FRAME_NORMAL

Magic number for sbc frame normal

MAX_ERROR_TIMES

Max decode error times

Typedefs

typedef struct decode_handle_s decode_handle_t

Enums

enum WQ_DECODE_TYPE

Values:

enumerator WQ_DECODE_AAC

AAC codec type

enumerator WQ_DECODE_SBC

SBC codec type

enumerator WQ_DECODE_MSBC

MSBC codec type

enumerator WQ_DECODE_CVSD

CVSD codec type

enum xa_frame_type_t

Values:

enumerator XA_BAD_FRAME

Bad frame data

enumerator XA_GOOD_FRAME

Good frame data

Functions

static inline wq_heap_caps_t heap_caps_get_by_align_value(const uint32_t align)
struct decode_handle_s

Public Members

uint32_t ui_dec_format

Decode type

void *g_pv_arr_alloc_memory[MAX_MEM_ALLOCS]

Memory for decode process

int32_t g_w_malloc_count

Malloc memory count

int8_t *pb_dec_inp_buf

Decode input buffer

int8_t *pb_dec_out_buf

Decode output buffer

uint32_t ui_dec_inp_size

Decode input buffer size

uint32_t ui_dec_init_done

Decode init done flag

uint32_t ui_dec_in_index

Decode input buffer index

uint32_t ui_dec_out_index

Decode output buffer index

int32_t loss_pattern_length

Loss data length

int32_t loss_pattern_idx

Loss data index

int16_t *loss_pattern

Loss data buffer point

void *scratch_decoder

For CVSD && LC3, scratch memory

xa_frame_type_t frame_type

Good frame or bad frame

xa_codec_handle_t xa_process_handle

Decode process handler

xa_codec_func_t *p_xa_process_api

Decode function point

struct decode_handle

Public Members

decode_handle_t *dec_handle

Decode handler

uint32_t (*process)(void*, char*, uint32_t, char*)

Run processor

void (*destory)()

Destory decode handler

void *scratch_buff

Scratch mem for decode algorithm