📄 cvsd_decode.m
字号:
% 07.11.5
% lidongshi
% cvsd decode
%
function [cvsd_decode_data,sw_enc_bit_dly_1,sw_enc_bit_dly_2,sw_step,sw_rcnstrct_dly_1,sw_rcnstrct_dly_2] = cvsd_decode(sw_enc_bit,sw_enc_bit_dly_1,sw_enc_bit_dly_2,sw_step,sw_rcnstrct_dly_1,sw_rcnstrct_dly_2)
DELTA_MIN = 0.0002;%4; % 0.0002 Scaled to 2 ^ 14
DELTA_MAX = 0.0078;%128; % 0.0078 Scaled to 2 ^ 14
SYLLABIC_CONST = 0.9845;%32260; % 0.9845 Scaled to 2 ^ 15
INTEG_B1 = 1.2708;%20821; % 1.2708 Scaled to 2 ^ 14
INTEG_B2 = 0.3202;%10492; % 0.3202 Scaled to 2 ^ 15
INTEG_G2D = 1.5092;%24726; % 1.5092 Scaled to 2 ^ 14
% sw_enc_bit_dly_1 = 0;
% sw_enc_bit_dly_2 = 0;
% sw_step = 0;
% sw_rcnstrct_dly_1 = 0;
% sw_rcnstrct_dly_2 = 0;
% int sw_acc;
% int sw_rcnstrct;
%
% long int tmp1;
% long int tmp2;
% long int tmp3;
% int tmp4;
tmp_lds_1 = 0;
tmp_lds_2 = 0;
tmp_lds_3 = 0;
% Judging continuous three bit identity and syllablic filter
sw_enc_bit = 2 * sw_enc_bit - 1; % 0 --> -1; 1 --> 1
sw_acc = sw_enc_bit + sw_enc_bit_dly_1 + sw_enc_bit_dly_2;
tmp_lds_1 = sw_step;
tmp1 = SYLLABIC_CONST * tmp_lds_1;
% //tmp1 = (SYLLABIC_CONST * sw_step);
% tmp1 >>= 15;
if abs(sw_acc) == 3
sw_step = tmp1 + DELTA_MAX;
else
sw_step = tmp1 + DELTA_MIN;
end
% Primary reconstruction integration
tmp_lds_2 = sw_rcnstrct_dly_1;
tmp1 = INTEG_B1 * tmp_lds_2;
% //tmp1 = INTEG_B1 * sw_rcnstrct_dly_1;
% tmp1 >>= 14;
tmp_lds_2 = sw_rcnstrct_dly_2;
tmp2 = INTEG_B2 * tmp_lds_2;
% //tmp2 = INTEG_B2 * sw_rcnstrct_dly_2;
% tmp2 >>= 15;
tmp_lds_1 = sw_step;
tmp3 = INTEG_G2D * tmp_lds_1;
% //tmp3 = INTEG_G2D * sw_step;
% tmp4 = tmp3 >> (14 + 1); % '14' add '1' for normalization
tmp3 = tmp3 * sw_enc_bit;
tmp1 = tmp1 - tmp2 + tmp3;
% Saturation process
if (tmp1 >= 32767) % up overflow
sw_rcnstrct = 32767;
elseif (tmp1 <= -32768) % down overflow
sw_rcnstrct = -32768;
else % no overflow
sw_rcnstrct = tmp1;
end
% Shift register shift
sw_enc_bit_dly_2 = sw_enc_bit_dly_1;
sw_enc_bit_dly_1 = sw_enc_bit;
sw_rcnstrct_dly_2 = sw_rcnstrct_dly_1;
sw_rcnstrct_dly_1 = sw_rcnstrct;
% return (sw_rcnstrct);
cvsd_decode_data = sw_rcnstrct;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -