lpxlsfq.m
来自「ITU-T G.723.1 Speech Coder: Matlab imple」· M 代码 · 共 73 行
M
73 行
function LSFC = LPxLSFQ (a, lsfQP, LSFpar)% Convert LP parameters to LSFs, quantize the LSFs.% $Id: LPxLSFQ.m 1.3 2004/07/05 G.723.1-v2r1a $% Convert to LSFsap = a .* LSFpar.ECWin;lsf = poly2lsf (ap); % lsf's are in radians% Quantize the LSFsLSFC = QLSF (lsf, lsfQP, LSFpar);return%--------------------function LSFC = QLSF (lsf, lsfQP, LSFpar)% Quantize LSFs% - Weighting inversely proportional to LSF spacings% - Form the LSFs less the mean LSFs% - Calculate the prediction error from the LSFs from the% previous frameNp = length (lsf);% Form the weight vector% W(i) = 1 / min (lsf(i+1)-lsf(i),lsf(i)-lsf(i-1))Slsf = diff (lsf);W = 1 ./ min ([Slsf(1); Slsf], [Slsf; Slsf(end)]);% Calculate the prediction errorPval = LSFpar.Pcof * (lsfQP - LSFpar.Mean);Dlsf = (lsf - LSFpar.Mean) - Pval;IQ = SVQLSF (Dlsf, W, LSFpar.VQ);LSFC = IQ - 1;return%--------------------function IQ = SVQLSF (Dlsf, W, YQ)% Returns a vector of codebook indicesNsplit = length (YQ);i1 = 1;for (k = 1:Nsplit) i2 = i1 + size (YQ{k}, 1) - 1; IQ(k) = VQ (Dlsf(i1:i2), W(i1:i2), YQ{k}); i1 = i2 + 1;endreturn%--------------------function Index = VQ (x, W, YQ)% Returns the codebook index minimizing the weighted error% We want to minimize (where W is a diagonal matrix)% (x-y)'W (x-y) = x'Wx - 2 y'W x + y'W y% = x'Wx + y'W (y - 2 x)Ny = size (YQ, 2);ErrMin = inf;for (k = 1:Ny) Err = (W .* YQ(:,k))' * (YQ(:,k) - 2 * x); if (Err < ErrMin) ErrMin = Err; Index = k; endendreturn
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?