📄 dcodtau.m
字号:
% MATLAB SIMULATION OF NSA FS-1016 CELP v3.2
% COPYRIGHT (C) 1995-99 ANDREAS SPANIAS AND TED PAINTER
%
% This Copyright applies only to this particular MATLAB implementation
% of the FS-1016 CELP coder. The MATLAB software is intended only for educational
% purposes. No other use is intended or authorized. This is not a public
% domain program and distribution to individuals or networks is strictly
% prohibited. Be aware that use of the standard in any form is goverened
% by rules of the US DoD. Therefore patents and royalties may apply to
% authors, companies, or committees associated with this standard, FS-1016. For
% questions regarding the MATLAB implementation please contact Andreas
% Spanias at (602) 965-1837. For questions on rules,
% royalties, or patents associated with the standard, please contact the DoD.
%
% ALL DERIVATIVE WORKS MUST INCLUDE THIS COPYRIGHT NOTICE.
%
% ******************************************************************
% DCODTAU
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 8-4-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Decodes all pitch tau values for a frame
%
% DESIGN NOTES
%
% Converts pitch delay bits from the bit stream to actual pitch delays,
% using table lookups and delay calculations.
%
% VARIABLES
%
% INPUTS
% taubits - Number of bits allocated for odd frame tau quantization
% taudelta - Number of bits allocated for even frame delta coding
% bitsum1 - Number of bits for odd subframes
% bitsum2 - Number of bits for even subframes
% bitpointer - Number of bits used
% nn - Number of subframes
% stream - Bit stream
% pddecode - Pitch delay permutation table
% pdtabi - Pitch delay table index
%
% OUTPUTS
% taus - Vector of pitch delays
% bitpointer - Number of bits used
%
% INTERNALS
% pointer - Current position in the bit stream
% tptr - Tau decode table index
% mnptr - Pitch delay table index lower limit
% mxptr - Pitch delay table index upper limit
% i - Loop index
%
% GLOBALS
% plevel1 - Number of full search pitch delays
% plevel2 - Number of delta search pitch delays
% lptrDT - Delta decoding temporary
% pdelay - Adaptive codebook pitch delays
%
% ******************************************************************
function [ taus, bitpointer ] = dcodtau( taubits, taudelta, bitsum1, ...
bitsum2, bitpointer, nn, ...
stream, pddecode, pdtabi )
% DECLARE GLOBAL VARIABLES
global plevel1 plevel2 lptrDT pdelay
% INIT RETURN VECTOR
taus = zeros( nn, 1 );
% ESTABLISH STARTING BIT STREAM POSITION
pointer = bitpointer;
% RUN DECODING FOR ALL SUBFRAMES
for i = 1:nn
if rem( i,2 ) ~= 0
% ODD SUBFRAME DELAY DECODE
[ tptr, pointer ] = unpack( stream, taubits, pointer );
taus(i) = pddecode( tptr+1 );
pointer = pointer + bitsum1 - taubits;
else
% EVEN SUBFRAME DELTA DELAY DECODE
[ tptr, pointer ] = unpack( stream, taudelta, pointer );
pointer = pointer + bitsum2 - taudelta;
mnptr = lptrDT - ( (plevel2/2) - 1 );
mxptr = lptrDT + (plevel2/2);
if mnptr < 0
mnptr = 0;
end
if mxptr > ( plevel1-1 )
mnptr = plevel1 - plevel2;
end
taus(i) = pdelay( tptr + mnptr + 1 );
end
lptrDT = pdtabi( tptr+1 );
end
% UPDATE BIT STREAM INDEX
bitpointer = bitpointer + taubits;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -