first
This commit is contained in:
112
include_lib/media/media_develop/media/drc_api.h
Normal file
112
include_lib/media/media_develop/media/drc_api.h
Normal file
@ -0,0 +1,112 @@
|
||||
#ifndef DRC_API_H
|
||||
#define DRC_API_H
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#define AT_DRC(x)
|
||||
#define AT_DRC_CODE
|
||||
#define AT_DRC_CONST
|
||||
#define AT_DRC_SPARSE_CODE
|
||||
#define AT_DRC_SPARSE_CONST
|
||||
|
||||
#else
|
||||
#define AT_DRC(x) __attribute((section(#x)))
|
||||
#define AT_DRC_CODE AT_DRC(.drc_code)
|
||||
#define AT_DRC_CONST AT_DRC(.drc_const)
|
||||
#define AT_DRC_SPARSE_CODE AT_DRC(.drc_sparse_code)
|
||||
#define AT_DRC_SPARSE_CONST AT_DRC(.drc_sparse_const)
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
DATA_IN_SHORT = 0, //输入数据类型,输入short时,输出不能为int
|
||||
DATA_IN_INT,
|
||||
};
|
||||
enum {
|
||||
DATA_OUT_SHORT = 0, //输出数据类型,输入short时,输出不能为int
|
||||
DATA_OUT_INT
|
||||
};
|
||||
|
||||
enum {
|
||||
PEAK = 0, //算法类型
|
||||
RMS
|
||||
};
|
||||
|
||||
enum {
|
||||
PERPOINT = 0, //mode 模式
|
||||
TWOPOINT
|
||||
};
|
||||
|
||||
int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
void DrcInit(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int *rmsTime, int channel, int sampleRate, int algorithm, int mode, int intype, int outtype);
|
||||
void DrcUpdate(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int mode);
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
获取buf大小
|
||||
参数说明:
|
||||
algorithm:算法类型,PEAK或者RMS
|
||||
rmsTime:
|
||||
rms时间ms,算法类型为RMS时有效
|
||||
channel: 通道数
|
||||
sampleRate:
|
||||
采样率
|
||||
/* float *threshold[5]; */
|
||||
struct threshold {
|
||||
float x ;
|
||||
float y ;
|
||||
}
|
||||
struct threshold ttt[2][5] //+ 90.3;
|
||||
|
||||
void DrcInit(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int *rmsTime, int channel, int sampleRate, int algorithm, int mode, int intype, int outtype);
|
||||
初始化
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
rmsTime:
|
||||
rms时间ms
|
||||
channel:
|
||||
通道
|
||||
sampleRate:采样率
|
||||
algorithm:算法类型
|
||||
mode:模式
|
||||
intype:输入数据类型,DATA_IN_SHORT或者DATA_IN_INT
|
||||
outtype:
|
||||
输出数据类型,DATA_OUT_SHOR或者DATA_OUT_INT;若输入数据类型为DATA_IN_SHORT,输出类型只能设置为DATA_OUT_SHOR
|
||||
|
||||
void DrcUpdate(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int channel, int sampleRate);
|
||||
更新参数:使用rms算法时,当rmsTime fs变化时因为buf会产生变化,只能初始化更新
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
运行:输入输出数据类型,要跟初始化配置的数据类型对应
|
||||
WorkBuf:
|
||||
运行buf
|
||||
indata:输入数据
|
||||
outdata:输出数据
|
||||
per_channel_npoint:每个通道的样点数
|
||||
#endif
|
||||
|
||||
#endif // !DRC_API_H
|
||||
|
||||
112
include_lib/media/media_develop/media/sw_drc.h
Normal file
112
include_lib/media/media_develop/media/sw_drc.h
Normal file
@ -0,0 +1,112 @@
|
||||
#ifdef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "media/sw_drc.h"
|
||||
#else
|
||||
|
||||
#ifndef __SW_DRC_H
|
||||
#define __SW_DRC_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "os/os_api.h"
|
||||
#include "drc_api.h"
|
||||
|
||||
#define DRC_TYPE_LIMITER 1
|
||||
#define DRC_TYPE_COMPRESSOR 2
|
||||
#define WDRC_TYPE 3 //wdc 要求,硬件输出24bit、32bit
|
||||
|
||||
|
||||
struct drc_limiter {
|
||||
int attacktime; //启动时间
|
||||
int releasetime; //释放时间
|
||||
int threshold[2]; //threshold[1]是固定值32768, threshold[0]为界面参数
|
||||
};
|
||||
|
||||
struct drc_compressor {
|
||||
int attacktime; //启动时间
|
||||
int releasetime; //释放时间
|
||||
int threshold[3]; //threshold[2]是固定值32768
|
||||
int ratio[3]; //ratio[0]为固定值100, ratio[1] ratio[2]为界面参数
|
||||
};
|
||||
|
||||
struct threshold_group {
|
||||
float in_threshold;
|
||||
float out_threshold;
|
||||
};
|
||||
|
||||
struct wdrc_struct {
|
||||
u16 attacktime; //启动时间
|
||||
u16 releasetime; //释放时间
|
||||
struct threshold_group threshold[7];
|
||||
u8 threshold_num;
|
||||
u8 rms_time;
|
||||
u8 algorithm;//0:PEAK 1:RMS
|
||||
u8 mode;//0:PERPOINT 1:TWOPOINT
|
||||
u16 holdtime; //预留位置
|
||||
u8 reverved[2];//预留位置
|
||||
};
|
||||
|
||||
//对耳wdrc处理,区分左右声道
|
||||
#define L_wdrc 0x10
|
||||
#define LL_wdrc 0x20
|
||||
#define R_wdrc 0x40
|
||||
#define RR_wdrc 0x80
|
||||
|
||||
struct drc_ch_org {
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器 3:wdrc
|
||||
u8 reserved[2]; //reserved[1]保留,未用, reserved[0]记录了 多带限幅时,是否再开启一次全带限幅
|
||||
int low_freq; //中低频分频点
|
||||
int high_freq; //中高频分频点
|
||||
int order; //分频器阶数, 2或者4
|
||||
union {
|
||||
struct drc_limiter limiter[4]; //限幅器
|
||||
struct drc_compressor compressor[3];//压缩器
|
||||
} _p;
|
||||
};
|
||||
|
||||
struct drc_ch {
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器 3:wdrc
|
||||
u8 reserved[2]; //reserved[1]保留,未用, reserved[0]记录了 多带限幅时,是否再开启一次全带限幅
|
||||
int low_freq; //中低频分频点
|
||||
int high_freq; //中高频分频点
|
||||
int order; //分频器阶数, 2或者4
|
||||
union {
|
||||
struct drc_limiter limiter[4]; //限幅器
|
||||
struct drc_compressor compressor[3];//压缩器
|
||||
struct wdrc_struct wdrc[4][2];// [][0]wdrc左声道,[][1]wdrc右声道
|
||||
} _p;
|
||||
};
|
||||
struct sw_drc {
|
||||
void *work_buf[4]; //drc内部驱动句柄
|
||||
void *crossoverBuf; //分频器句柄
|
||||
int *run_tmp[3]; //多带限幅器或压缩器,运行buf
|
||||
int run_tmp_len; //多带限幅器或压缩器,运行buf 长度
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器
|
||||
u8 channel; //通道数
|
||||
u8 run32bit; //drc处理输入输出数据位宽是否是32bit 1:32bit 0:16bit
|
||||
struct audio_eq *crossover[3];//多带分频器eq句柄
|
||||
u32 sample_rate; //采样率
|
||||
u8 nsection; //分频器eq段数
|
||||
u8 other_band_en; //多带限幅器之后,是否需要再做一次全带的限幅器 1:需要,0:不需要
|
||||
};
|
||||
extern void *get_low_sosmatrix();
|
||||
extern void *get_high_sosmatrix();
|
||||
extern void *get_band_sosmatrix();
|
||||
extern int get_crossover_nsection();
|
||||
|
||||
|
||||
extern void *audio_sw_drc_open(struct drc_ch *ch_tmp, u32 sample_rate, u8 channel, u8 drc_name, u8 run32bit);
|
||||
extern void audio_sw_drc_close(void *hdl);
|
||||
extern int audio_sw_drc_update(void *hdl, struct drc_ch *ch_tmp, u32 sample_rate, u8 channel);
|
||||
extern int audio_sw_drc_run(void *hdl, s16 *in_buf, s16 *out_buf, int npoint_per_channel);
|
||||
|
||||
|
||||
void audio_hw_crossover_open(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
void audio_hw_crossover_close(struct sw_drc *drc);
|
||||
void audio_hw_crossover_run(struct sw_drc *drc, s16 *data, int len);
|
||||
void audio_hw_crossover_update(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
Reference in New Issue
Block a user