⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcodcbg.m

📁 实现fs1016w的CELP的低速率语音编解码功能的基于vc开发环境的原代码。
💻 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.
%
% ******************************************************************
% DCODCBG
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 8-4-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Decodes all stochastic codebook gains for a frame
%
% DESIGN NOTES
%
% Converts stochastic gain bits from the bit stream to actual gains,
% using table lookup.
%
% VARIABLES
%
% INPUTS
%   cbgbits    -     Number of bits allocated for cgain quantization
%   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
%
% OUTPUTS
%   cbg        -     Vector of stochastic codebook gains
%
% INTERNALS
%   i          -     Subframe counter
%   index      -     Unpacked index into stochastic codebook gain decoding table
%
% GLOBALS
%   gainlog5   -     Stochastic codebook gain decoding table
%
% ******************************************************************

function [ cbg, bitpointer ] = dcodcbg( cbgbits, bitsum1, bitsum2, ...
                                        bitpointer, nn, stream )

% DECLARE GLOBAL VARIABLES
global gainlog5

% INIT RETURN VECTOR
cbg = zeros( nn, 1 );

% ESTABLISH STARTING BIT STREAM POSITION
pointer = bitpointer;

% RUN DECODING FOR ALL SUBFRAMES
for i = 1:nn
    [ index, pointer ] = unpack( stream, cbgbits, pointer );
    if cbgbits == 5
         cbg(i) = gainlog5( index+1 );
    else
         fprintf( 'gaindecode:  Unquantized stochastic codebook gain.\n' );
    end

    % MAINTAIN BITSTREAM POINTER
    if any( [ 1 3 5 ] == i )
        pointer = pointer + bitsum2 - cbgbits;
    elseif any( [ 2 4 6 ] == i )
        pointer = pointer + bitsum1 - cbgbits;
    else
        fprintf( 'dcodcbg: Error in decoding stochastic codebook gain\n' );
    end
end

% UPDATE BIT STREAM INDEX
bitpointer = bitpointer + cbgbits;

⌨️ 快捷键说明

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