📄 dpcmenco.m
字号:
function [indx, quant] = dpcmenco(sig, codebook, partition, predictor)
%DPCMENCO Encodes a signal using differential pulse code modulation method.
% INDX = DPCMENCO(SIG, CODEBOOK, PARTITOIN, PREDICTOR) produces
% differential pulse code modulation (DPCM) encoded index INDX. The
% signal to be encoded is SIG. The predictive transfer function is
% provided in PREDICTOR. The predictive-error quantization partition
% and code book are given in PARTITION and CODEBOOK respectively. In
% general, a M-th order transfer function numerator has the form of
% [0, n1, n2, ... nM].
%
% [INDX, QUANT] = DPCMENCO(SIG, CODEBOOK, PARTITION, PREDICTOR) outputs
% the quantized value in QUANT.
%
% The input parameters CODEBOOK, PARTITION, and PREDICTOR can be
% estimated by using DPCMOPT.
%
% See also QUANTIZ, DPCMOPT, DPCMDECO.
% Wes Wang 10/13/94, 10/5/95
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 17:57:06 $
if nargin < 4
error('Not enough input variable for DPCMENCO.');
end;
% The structure of the DPCM is as follows:
% e quant
% Input signal -->+-----Quantization------|-------
% ^- V
% |---------------------->+
% out |<----Predictor<--------| inp
len_predictor = length(predictor) - 1;
predictor = predictor(2:len_predictor+1);
predictor = predictor(:)';
len_sig = length(sig);
x = zeros(len_predictor, 1);
for i = 1 : len_sig;
out = predictor * x;
e = sig(i) - out;
% index
indx(i) = sum(partition < e);
% quantized value
quant(i) = codebook(indx(i) + 1) + out;
% renew the estimated output
x = [quant(i); x(1:len_predictor-1)];
end;
% -- end of dpcmenco --
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -