dpcmdeco.m

来自「数字通信第四版原书的例程」· M 代码 · 共 50 行

M
50
字号
function [sig, quant] = dpcmdeco(indx, codebook, predictor)
%DPCMDECO Decodes a DPCM encoded signal.
%       SIG = DPCMDECO(INDX, CODEBOOK, PREDICTOR) decodes a differential pulse
%       code modulation (CPCM) encoded index INDX signal. The predictive
%       transfer function is provided in PREDICTOR. The predictive-error
%       quantization codebook is given in CODEBOOK. In general, an M-th
%       order transfer function has the form of [0, n1, n2, ... nM]. To
%       obtain a correct decode result, the parameters must match the encode
%       parameters.
%
%       [SIG, QUANT] = DPCMDECO(INDX, CODEBOOK, PREDICTOR) outputs the
%       quantized predictive error in QUANT.
%
%       The input parameters CODEBOOK and PREDICTOR can be estimated by using
%       DPCMOPT.
%
%       See also QUANTIZ, DPCMOPT, DPCMENCO.

%       Wes Wang 10/13/94, 10/5/95
%       Copyright (c) 1995-96 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 17:56:59 $

if nargin < 3
    error('Not enough input variable for DPCMENCO.');
end;

% The structure of the DPCM is as follows:
%             e                   quant
%   INDX   -->------Quantization------+-----------------------|--->sig
%                                     ^                       V
%                                 out |<----Predictor<--------| inp

len_predictor = length(predictor) - 1;
predictor = predictor(2:len_predictor+1);
predictor = predictor(:)';
len_sig = length(indx);

quant = indx;
quant = codebook(indx+1);

x = zeros(len_predictor, 1);
for i = 1 : len_sig;
    out = predictor * x;
    sig(i) = quant(i) + out;
    % renew the estimated output
    x = [sig(i); x(1:len_predictor-1)];
end;

% -- end of dpcmdeco --

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?