换个昵称都难头像
关注

webrtc音频调参(WebRTC M153/7985 APM + NetEq 100+ 参数表)

标记说明
P0 = 最值得调
P1 = 有明显场景价值
P2 = 高级/特定场景
I = Internal Config
FT = FieldTrial
RT = Runtime 状态
HC = Hard-coded 常量
API = Public API


1. APM 总体参数

#模块参数/对象类型主要作用调参重点
1APMAudioProcessing::ConfigAPIAPM总配置P0
2APMhigh_pass_filter.enabledAPI高通滤波P1
3APMecho_canceller.enabledAPIAEC开关P0
4APMnoise_suppression.enabledAPINS开关P0
5APMgain_controller1.enabledAPI旧AGCP2
6APMgain_controller2.enabledAPIAGC2P0
7APMpre_amplifier.enabledAPI前级增益P1
8APMtransient_suppression.enabledAPI瞬态抑制P1
9APMvoice_detection.enabledAPIVADP1
10APMAPM capture sample rateRT采样率P0
11APMAPM render sample rateRTRender采样率P0
12APMinput frame sizeRT输入帧长度P0
13APMoutput frame sizeRT输出帧长度P0
14APMcapture channelsRT采集通道数P1
15APMrender channelsRT播放通道数P1

2. AEC3 Buffering

AEC3 的 EchoCanceller3Config 本身就包含 bufferingdelayfilterecho_modelsuppressor 等大型配置结构。

#参数类型作用调大通常调小通常优先级
16excess_render_detection_interval_blocksIRender过量检测周期检测更慢检测更快P1
17max_allowed_excess_render_blocksI允许Render积压容忍更多buffer更敏感P1
18render buffer sizeRTRender缓存稳定性↑/延迟↑延迟↓/风险↑P0
19render block sizeRTAEC处理块CPU↓响应快P1
20render alignmentRTCapture/Render对齐对齐稳定可能抖动P0

源码当前默认结构中可以看到 excess_render_detection_interval_blocks = 250max_allowed_excess_render_blocks = 8,但这里再次强调:不要把当前 HEAD 数字直接当 M153/7985 数字。


3. AEC3 Delay —— 核心区

#参数类型作用主要影响优先级
21default_delayI初始delay估计AEC启动P0
22down_sampling_factorIDelay搜索采样率CPU/精度P1
23num_filtersIDelay搜索filter数量delay范围P0
24delay_headroom_samplesIdelay余量抗delay变化P1
25hysteresis_limit_blocksIdelay切换滞回稳定性P1
26fixed_capture_delay_samplesI固定capture delay硬件延迟补偿P0
27delay_estimate_smoothingIdelay平滑稳定性P0
28delay_estimate_smoothing_delay_foundI找到delay后的平滑收敛速度P1
29delay_candidate_detection_thresholdIdelay候选阈值delay检测灵敏度P1
30delay_selection_thresholds.initialI初始delay选择启动收敛P1
31delay_selection_thresholds.convergedI收敛后选择稳定性P1
32use_external_delay_estimatorI外部delay估计系统集成P2
33log_warning_on_delay_changesIdelay变化日志DebugP2
34render_alignment_mixing.downmixIRender downmix多通道P1
35render_alignment_mixing.adaptive_selectionI自动选择channel多麦克风P1
36render_alignment_mixing.activity_power_thresholdIchannel活动阈值channel选择P2
37render_alignment_mixing.prefer_first_two_channelsI优先channel多声道P2
38capture_alignment_mixing.downmixICapture downmix多通道P1
39capture_alignment_mixing.adaptive_selectionICapture channel选择多通道P1
40capture_alignment_mixing.activity_power_thresholdICapture活动阈值channel检测P2
41capture_alignment_mixing.prefer_first_two_channelsIchannel偏好多通道P2
42detect_pre_echoIPre-echo检测AEC质量P1

当前 AEC3 配置源码明确包含上述 Delay 字段;例如当前代码的默认结构中可见 default_delaydown_sampling_factornum_filtersdelay_headroom_samplesfixed_capture_delay_samples、两个 smoothing 参数以及 delay selection thresholds。


4. AEC3 Filter —— 非常重要

#参数类型作用调大通常优先级
43filter.refined.length_blocksIRefined filter长度Echo path覆盖↑P0
44filter.refined.leakage_convergedI收敛leakage稳定/收敛特性变化P1
45filter.refined.leakage_divergedI发散leakage发散后恢复P1
46filter.refined.error_floorIerror下限稳定性P1
47filter.refined.error_ceilIerror上限异常控制P2
48filter.refined.noise_gateI噪声门限更新抑制P1
49filter.coarse.length_blocksICoarse filter长度覆盖更长echoP0
50filter.coarse.rateICoarse adaptation rate收敛快P0
51filter.coarse.noise_gateICoarse noise gate更新控制P1
52filter.refined_initial.length_blocksI初始refined长度启动阶段P1
53filter.refined_initial.leakage_convergedI初始收敛启动速度P1
54filter.refined_initial.leakage_divergedI初始发散处理启动稳定P2
55filter.refined_initial.error_floorI初始error floor启动稳定P2
56filter.refined_initial.error_ceilI初始error ceiling启动稳定P2
57filter.refined_initial.noise_gateI初始noise gate启动学习P2
58filter.coarse_initial.length_blocksI初始coarse长度启动P1
59filter.coarse_initial.rateI初始coarse速率收敛速度P0
60filter.coarse_initial.noise_gateI初始noise gate学习P2
61config_change_duration_blocksI参数变化过渡期平滑性P1
62initial_state_secondsI初始AEC状态时间启动收敛P1
63coarse_reset_hangover_blocksIcoarse reset保护防抖P2
64conservative_initial_phaseI初始保守模式启动质量P2
65enable_coarse_filter_output_usageI是否使用coarse输出AEC路径P1
66use_linear_filterILinear filter算法路径P1
67high_pass_filter_echo_referenceIEcho reference HPF低频处理P1

当前源码明确可以看到 coarse/refined 以及 initial 两套 filter 参数,同时存在 config_change_duration_blocksinitial_state_secondscoarse_reset_hangover_blocksconservative_initial_phase 等配置。


5. AEC3 Echo Model

#参数/区域类型作用优先级
68echo model gainIEcho幅度模型P0
69echo model decayIEcho衰减P1
70echo model spectral characteristicsIEcho频谱P1
71echo model comfort noiseIEcho/CNG处理P2
72echo path change detectionRTEcho路径变化P0
73echo path gain estimateRTEcho路径增益P0
74render energy estimateRTRender能量P0
75capture energy estimateRTCapture能量P0

这一部分很多不是简单的 public parameter,而是内部状态,所以真正调优时要结合 echo_model 源码和 metrics 看。


6. AEC3 Suppressor

#参数类型作用优先级
76subband_nearend_detectionI近端语音检测P0
77subband2.lowI子带范围低端P2
78subband2.highI子带范围高端P2
79nearend_thresholdINear-end门限P0
80snr_thresholdISNR门限P0
81high_bands_suppression.enr_thresholdI高频echo阈值P1
82max_gain_during_echoIEcho期间最大gainP0
83anti_howling_activation_thresholdIAnti-howling触发P1
84anti_howling_gainIAnti-howling gainP1
85high_frequency_suppression.limiting_gain_bandI高频限制起始bandP1
86bands_in_limiting_gainI高频限制band数P1
87floor_first_increaseIsuppression floorP2
88mask_lf.enr_transparentILF透明阈值P0
89mask_lf.enr_suppressILF suppress阈值P0
90mask_lf.emr_transparentILF residual阈值P1
91mask_hf.enr_transparentIHF透明阈值P1
92mask_hf.enr_suppressIHF suppress阈值P0
93mask_hf.emr_transparentIHF residual阈值P1
94max_inc_factorI最大增益变化P1
95max_dec_factor_lfILF最大衰减P0

AEC3 的 Validate() 也明确对 suppressor 的 near-end、SNR、高频 suppression、anti-howling 等参数进行范围约束,说明这些确实是算法配置入口,而不是单纯的测试变量。


7. AEC3 Multi-channel

#参数/状态作用优先级
96render channel countRender通道数P0
97capture channel countCapture通道数P0
98multichannel default config多通道AEC配置P1
99multichannel coarse filter length多通道收敛P1
100multichannel coarse filter rate多通道适应速度P1
101channel downmix通道降混P1
102channel selection通道选择P1

当前 AEC3 对多通道有专门的 CreateDefaultMultichannelConfig(),并针对多 Render channel 调整 coarse filter 长度和 adaptation rate。


8. NS / Noise Suppression

#参数/区域作用优先级
103NS enabledNS总开关P0
104NS level抑制等级P0
105NS speech probabilitySpeech判断P1
106NS noise estimateNoise估计P0
107NS spectral suppression频谱抑制P0
108NS low-frequency suppression低频抑制P1
109NS high-frequency suppression高频抑制P1
110NS transient handling瞬态处理P1
111NS comfort noise残余噪声处理P2

9. AGC2

#参数/区域作用优先级
112AGC2 enabled总开关P0
113adaptive digital gain自动数字增益P0
114fixed digital gain固定数字增益P1
115analog gain controller硬件增益P0
116target level目标音量P0
117gain change rate增益变化速度P1
118limiter防爆音P0
119limiter thresholdLimiter阈值P1
120saturation protection饱和保护P1
121RMS/peak level estimator音量估计P1
122speech level estimator语音音量P1

10. HPF / Transient / VAD

#参数作用优先级
123HPF enable去低频噪声P1
124HPF cutoff截止频率P1
125transient suppression enable去突发噪声P1
126transient detection threshold瞬态检测P2
127transient suppression strength抑制强度P1
128VAD enableVADP1
129VAD speech threshold语音阈值P1
130VAD hangover语音保持P1
131VAD probability smoothing概率平滑P2

11. NetEq Public Config

NetEq 的核心调参入口包括 sample_rate_hz、buffer容量、最小/最大delay以及 time-scale 等能力;NetEq内部还组合了 DelayManager、PacketBuffer、DecisionLogic、Expand、Accelerate、PreemptiveExpand 等组件。

#参数类型作用优先级
132sample_rate_hzAPINetEq采样率P0
133max_packets_in_bufferAPIPacketBuffer容量P0
134min_delay_msAPI/Config最小目标delayP0
135max_delay_msAPI/Config最大目标delayP0
136enable_fast_accelerateAPI/Config快速追赶P0
137enable_muted_stateAPI/Configmuted stateP2
138enable_rtx_handlingAPI/ConfigRTX处理P0
139for_test_no_time_stretchingTest禁用time-scaleP2
140base_min_delay_msInternal基础delay下限P0
141allow_time_stretchingInternal是否允许时间伸缩P0

12. DelayManager —— NetEq 最值得调的部分

当前源码中的 DelayManagerConfig 明确包含 quantileforget_factorstart_forget_weightresample_interval_msmax_history_ms 等。

#参数类型作用调大调小优先级
142quantileFT/IJitter目标分位数延迟↑稳定↑延迟↓风险↑P0
143forget_factorFT/I历史权重记忆长适应快P0
144start_forget_weightFT/I启动权重初期更稳定初期更敏感P1
145resample_interval_msFT/I重采样周期更新慢更新快P0
146max_history_msFT/Ijitter历史窗口稳定快适应P1
147max_packets_in_bufferIDelayManager容量抗burst↑latency↓P0
148base_minimum_delay_msI最低delaylatency↑latency↓P0
149kDelayBucketsHChistogram bucket数分辨率分辨率P2
150kBucketSizeMsHChistogram bucket大小P2
151kStartDelayMsHC初始delay初始稳定低延迟P1
152kMaxNumReorderedPacketsHC重排序容忍抗reorder↑更快处理P1

当前源码还可以看到例如 kDelayBucketskBucketSizeMskStartDelayMskMaxNumReorderedPackets 这些算法常量,因此“参数表”不能只列 Config;这些 HC 也会改变实际行为。


13. DecisionLogic

#参数类型作用优先级
153estimate_dtx_delayFTDTX期间delay估计P1
154time_stretch_cnFTCNG time stretchP1
155target_level_window_msFTbuffer目标窗口P0
156deceleration_target_level_offset_msFT/HC加速/减速判定P0
157reinit_after_expandsFT/HC连续Expand后重初始化P1
158packet_history_size_msFT/HCpacket历史P1
159cng_timeout_msFT/HCCNG timeoutP2
160enable_stable_playout_delayFT稳定playoutP1
161combine_concealment_decisionFTconcealment决策P2
162kPostponeDecodingLevelHC延迟解码阈值P1
163kDefaultTargetLevelWindowMsHC默认target窗口P0
164kDecelerationTargetLevelOffsetMsHCdeceleration offsetP0
165kReinitAfterExpandsHCExpand重初始化P1
166kMaxWaitForPacketHC等待packet上限P1
167kMinTimescaleIntervalHCtime-scale最小间隔P1

当前 DecisionLogic 源码可以确认 kPostponeDecodingLevel = 50kDefaultTargetLevelWindowMs = 100kDecelerationTargetLevelOffsetMs = 85 这类常量,以及 estimate_dtx_delaytime_stretch_cntarget_level_window 等运行时参数;但这些具体数值不要直接覆盖到你的 7985 源码


14. BufferLevelFilter

#参数/状态作用优先级
168filtered buffer level平滑bufferP0
169buffer level historybuffer历史P1
170filter update interval更新频率P1
171target level目标bufferP0
172level deviationbuffer偏差P0
173filter reset conditionreset条件P2

15. NetEq Normal / Expand / PLC

#模块参数/状态作用优先级
174Normalnormal decode正常解码P0
175Expandexpand length丢包隐藏P0
176Expandexpand mutefactorconcealment淡入P1
177Expandrandom attenuationPLC随机性P2
178PLCcodec PLCOpus PLCP0
179PLCpacket loss estimateloss估计P0
180PLCconsecutive loss连续丢包P0
181PLCconcealment duration隐藏时长P0
182CNGRFC3389 CNG舒适噪声P1
183CNGcodec internal CNGCodec CNGP1
184CNGCNG timeoutCNG状态切换P2

16. Accelerate / PreemptiveExpand

#参数/状态作用优先级
185Accelerate enablebuffer过大追赶P0
186FastAccelerate激进追赶P0
187Accelerate factor加速程度P1
188PreemptiveExpand enablebuffer过低补偿P0
189PreemptiveExpand threshold触发阈值P0
190PreemptiveExpand low-energy mode低能量模式P1
191timescale countdowntime-scale间隔P1
192previous time-scale state上一次操作P2
193consecutive accelerate连续加速次数P1
194consecutive preemptive expand连续PE次数P1

NetEq 当前实现确实是由 Normal、Expand、Accelerate、PreemptiveExpand、Merge 等不同处理对象共同组成,而不是单一 jitter buffer。


17. PacketBuffer

#参数/状态作用优先级
195max packets最大packet数P0
196max buffer duration最大buffer时间P0
197packet orderingRTP排序P0
198packet discard过期包丢弃P0
199packet duplicate detection重复包P1
200timestamp orderingtimestamp排序P0
201sequence number continuitySeq连续性P0
202RED packet handlingRED拆包P1
203RTX packet handlingRTX解包P0

18. RTP / 网络相关参数

虽然这些不是严格意义上的 APM/NetEq 参数,但如果你真的要优化“弱网 + 低延迟”,必须一起考虑。

#参数/机制作用优先级
204RTP timestamp音频时间轴P0
205RTP sequence number丢包判断P0
206SSRCstream标识P1
207NACK请求重传P0
208RTX重传P0
209TWCC网络反馈P0
210RTT网络延迟P0
211jitter抖动P0
212packet loss丢包P0
213packet reordering重排序P1
214burst loss连续丢包P0
215pacing发送平滑P0
216BWE带宽估计P0
217audio bitrate adaptation音频码率自适应P0

19. Opus 参数

这一层建议单独建立实验矩阵。

#参数作用优先级
218bitrate音质/带宽P0
219packetization/ptime包时长P0
220frame duration编码帧P0
221in-band FEC丢包恢复P0
222expected packet loss编码器loss优化P0
223DTX静音省带宽P1
224complexityCPU/质量P1
225bandwidth编解码带宽P0
226stereo单/双声道P1
227applicationVOIP/音频P0
228signal typevoice/musicP1
229packet loss percentageFEC策略P0
230max average bitrate码率上限P0
231min bitrate码率下限P1

20. Audio Device / Clock

#参数/状态作用优先级
232capture callback period采集周期P0
233render callback period播放周期P0
234hardware buffer size硬件bufferP0
235capture latency采集延迟P0
236render latency播放延迟P0
237device sample rate硬件采样率P0
238resampling重采样P1
239clock drift时钟漂移P0
240capture/render clock offset时钟偏移P0
241timestamp accuracytimestamp精度P0
242callback jittercallback抖动P1

21. 最重要的 30 个参数

如果你不想一次改 200 多个,我建议先盯这 30 个:


1.  Audio frame size
2.  Capture buffer
3.  Render buffer

4.  AEC3 default_delay
5.  AEC3 fixed_capture_delay_samples
6.  AEC3 num_filters
7.  AEC3 delay_estimate_smoothing
8.  AEC3 delay_candidate_detection_threshold
9.  AEC3 coarse.length_blocks
10. AEC3 coarse.rate
11. AEC3 refined.length_blocks
12. AEC3 suppressor nearend_threshold
13. AEC3 suppressor snr_threshold
14. AEC3 max_gain_during_echo

15. NS level
16. AGC2 target level
17. AGC2 digital gain
18. AGC2 limiter

19. Opus bitrate
20. Opus ptime
21. Opus FEC
22. Opus expected packet loss
23. Opus DTX

24. NetEq min_delay_ms
25. NetEq max_delay_ms
26. DelayManager quantile
27. DelayManager forget_factor
28. resample_interval_ms
29. target_level_window_ms
30. FastAccelerate

22. 不要“乱调”

对于这种目标:

低延迟 + 弱网 + 语音质量 + AEC

分成四阶段。

第一阶段:只调 NetEq


min_delay
max_delay
quantile
forget_factor
resample_interval
target_level_window
FastAccelerate
PreemptiveExpand

目标:


Latency ↓
Expand 不明显增加
Accelerate 不爆发

第二阶段:调 Opus


ptime
bitrate
FEC
expected loss
DTX

目标:


Packet Loss ↑
语音质量仍然稳定

第三阶段:调 AEC3

重点:


fixed_capture_delay
delay estimator
num_filters
coarse filter
refined filter
suppressor

目标:


ERLE ↑
Residual Echo ↓
Double Talk质量 ↑

第四阶段:设备/时钟

最后解决:


Audio callback
hardware buffer
timestamp
clock drift
capture/render delay

这一层经常才是:

“为什么参数明明都对,但是实际延迟还是很高?”

的真正原因。


23. 建议

如果有 M153/7985 的 WebRTC 源码目录,建议不要继续靠“通用 WebRTC 参数表”猜。

直接在源码执行:


grep -R "EchoCanceller3Config" modules api
grep -R "DelayManagerConfig" modules
grep -R "DecisionLogic" modules/audio_coding/neteq
grep -R "WebRTC-Audio-NetEq" .
grep -R "WebRTC-Aec3" .

然后把结果和这张表对应起来。

因为当前 AEC3 源码已经能证明配置数量非常多,而 NetEq 又存在 Config + FieldTrial + Hard-coded constants + Runtime state 四层参数;只看 NetEq::Config 会漏掉大量真正影响行为的变量。

下一步最适合直接做的是:把这 240+ 项继续整理成一份“可直接修改源码的 Excel/CSV 参数字典”,字段做成:


编号
模块
参数名
C++结构体
源码文件
M153默认值
7985默认值
FieldTrial名称
参数类型
单位
最小值
最大值
调大效果
调小效果
延迟影响
音质影响
弱网影响
CPU影响
推荐测试值
风险等级

转载自 CSDN-专业IT技术社区

原文链接:https://blog.csdn.net/qazwsxwtc/article/details/165613054

文章来源转载

评论

赞0

评论列表

微信小程序
QQ小程序

关于作者

点赞数:0
关注数:0
粉丝:0
文章:0
关注标签:0
加入于:--