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

📄 encode_symbol.m

📁 这是一个基于c++的算术编码源代码
💻 M
字号:
function encode_symbol(symbol,cum_freq)

global top_value first_qtr half third_qtr high low bits_to_follow code_value_bits no_of_symbols no_of_chars

format long ;

top_value=2^code_value_bits-1;
first_qtr=fix(top_value / 4) +1;
half=fix(2*first_qtr);
third_qtr=fix(3*first_qtr);
no_of_chars=256;
eof_symbol=no_of_chars+1;
no_of_symbols=no_of_chars+1;

range=fix(high-low)+1;
xy=cum_freq(symbol-1);
yx=cum_freq(symbol);
high=low+(fix((range*xy)/cum_freq(1)))-1;
low=low+(fix((range*yx)/cum_freq(1)));
while 1
    if(high<half)
        bit_plus_follow(0);
    elseif (low>=half)
        bit_plus_follow(1);
        low=low-half;
        high=high-half;
    elseif (low>=first_qtr & high<third_qtr)
        bits_to_follow=bits_to_follow+1;
        low=low-first_qtr;
        high=high-first_qtr;
    else
        break;
    end
    low=fix(2*low);
    high=fix(2*high)+1;    
end

⌨️ 快捷键说明

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