亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? adaptivehuffman.m

?? 用visual C++實現的huffman編碼程序 很實用的哦
?? M
?? 第 1 頁 / 共 2 頁
字號:
function huffstream = adaptivehuffman(stream,type)
%
%==========================================================================
%                    Matt Clarkson - University of Bath
%
%                             Copyleft 2008
%==========================================================================
%
% huffstream = adaptivehuffman(stream,type)
%
% Adaptively encodes or decodes an integer stream.  If type is not defined
% the program inspects the input stream and failing to find a suitable
% adaptively encoded huffman stream the program defaults to compression.
%
% The stream has a two bit header containing the bit depth of the symbols.
% This is easily removed if a constant bit depth is always going to be
% used.
%
% To help visualise the huffman tree a function "treedetails" can be called
% at any point to display the values of each node.
% 
% Examples:
%
% huffstream = adaptivehuffman(stream) returns a adaptively huffman encoded
% stream or a decompressed string depending on the input.  For compression 
% the input must be a one dimensional horizontal unsigned integer  
% array.  8 and 16 bit depths are accepted.  For decompression the
% input must be a previously encoded string
%
% huffstream = adaptivehuffman(stream,'enc') returns compressed stream.
% Also the compression percentage is printed.
%
% huffstream  = adaptivehuffman(stream,'dec') returns the result of
% decompressing a previously compressed huffman stream.
%
%==========================================================================

%==========================================================================
%Insect input stream
%==========================================================================
if nargin < 2;    %Inspects input stream
    if isinteger(stream)...    %If integer...
       && (size((unique(stream)),2) == 2)...     %and has two symbols...
       && isa(stream,'uint8')...    %and a usigned 8 bit integer stream...
       && ~(size(size(stream),2)~=2)...     %and is 2D...
       && (size(stream,1) == 1 && size(stream,2) > 0)...    %and is 1D horizontal...
       && sum(unique(stream)) == 1     %and is binary stream   
        type = 'dec';
    else
        type = 'enc';
    end
end
if ~strcmp(type,'dec')     %If not decoding, encode
    
%==========================================================================
%Adaptive Huffman Encoding
%==========================================================================
clear type
%--------------------------------------------------------------------------
%Check stream structure
%--------------------------------------------------------------------------
    if ~isinteger(stream);error('Input must be unsigned integer stream');end
    for i = 3:6;if isa(stream, num2str(2^i,'int%i'));error('Input must be unsigned integer stream');end;end
    if size(size(stream),2)~=2 || ~(size(stream,1) == 1 && size(stream,2) > 0)
        error('Input must be a one dimensional horizontal stream');
    end
%--------------------------------------------------------------------------
%Find bit depth of stream and check for accepted bit depths
%--------------------------------------------------------------------------
    for i = 3:6
        if isa(stream, num2str(2^i,'uint%i'));bitdepth = 2^i;end;
    end
    if ~exist('bitdepth','var');error('Input stream must be a unsigned integer');end;
    if bitdepth == 64 || bitdepth == 32;error('Bit depth must be 8 or 16');end;
%--------------------------------------------------------------------------
%Set up the Not Yet Transmitted (NYT) Node and Tree Structure
%--------------------------------------------------------------------------
    huffstream = uint8([]);     %Initialise outputstream
    NYT = unique(stream);     %Find unique symbols and create NYT list
    NYTlocation = double(max(NYT))+2;     %Set the NYT location
    n = length(stream);     %Find length of stream
    nodenumber = (2*n);     %Find the amount of nodes
    tree(1).number = nodenumber;     %Total number of nodes
    tree(1).parent = 0;     %Node parent
    tree(1).left = 0;     %Node left child
    tree(1).right = 0;     %Node right child
    tree(1).symbol = NYTlocation;     %Node symbol
    tree(1).weight = 0;     %Node Weight
    location = zeros(1,NYTlocation);     %Location of the symbols in the tree
    location(NYTlocation) = 1;     %Location of the NYT node
%--------------------------------------------------------------------------
%Add a one bit header to the huffman stream where 0 and 1 represent
%8 and 16 bit depths respectively.  If the function is going to be used
%with only one bit depth the following line can be commented out.  Make
%sure, the bit depth in the decoding section is changed accordingly
%--------------------------------------------------------------------------
    huffstream = [huffstream uint8(bitget((log2(bitdepth)-3),1))];
%--------------------------------------------------------------------------
%Huffman Tree loop
%--------------------------------------------------------------------------
    wb = waitbar(0,'Please Wait...','Name','Encoding');     %Creates progress bar
    for index = 1:n     %For whole stream
        symbol = stream(index);     %Read in symbol
        if sum(NYT == symbol)     %Symbol seen before?
            nodecode(NYTlocation-1)     %Add NYT code to the output stream
            treeloop(symbol);      %Start the huffman tree loop for symbol
            huffstream(length(huffstream)+1:length(huffstream)+bitdepth) = uint8(bitget(symbol,bitdepth:-1:1));     %Output symbol
        else        
            nodecode(symbol);     %Add NYT code to the output stream
            treeloop(symbol);      %Start the huffman tree loop for symbol
        end
        waitbar(index/n,wb);     %Update progress bar
    end
    close(wb)     %Close progress bar
    if nargin==2;fprintf(['Compressed: ' num2str((length(huffstream)/(length(stream)*bitdepth))*100,'%6.2f') '%%\n']);end;
else
    
%==========================================================================
%Adaptive Huffman Decoding
%==========================================================================
clear type
%--------------------------------------------------------------------------
%Finds bitdepth.  If the function is going to be used with only one bit
%depth alter the commenting of the following three assignments.  Make sure
%that, if a constant bit rate is going to be used, the header assignment in
%the encoding part of the function is commented out.
%--------------------------------------------------------------------------
    bitdepth = 2^((bits2dec(stream(1)))+3);stream(1)=[];
    %bitdepth = 8;
    %bitdepth = 16;
%--------------------------------------------------------------------------
%Set up the Not Yet Transmitted (NYT) Node and Tree Structure
%--------------------------------------------------------------------------
    huffstream = eval(num2str(bitdepth,'uint%i([])'));     %Initialise outputstream
    NYT = 0:(2^bitdepth)-1;     %Find unique symbols and create NYT list
    NYTlocation = max(NYT)+2;     %Set the NYT location
    n = length(stream);     %Find length of stream
    nodenumber = max(2*NYT)+1;     %Find the amount of nodes
    tree(1).number = nodenumber;     %Total number of nodes
    tree(1).parent = 0;     %Node parent
    tree(1).left = 0;     %Node left child
    tree(1).right = 0;     %Node right child
    tree(1).symbol = NYTlocation;     %Node symbol
    tree(1).weight = 0;     %Node Weight
    location = zeros(1,NYTlocation);     %Location of the symbols in the tree
    location(NYTlocation) = 1;     %Location of the NYT node
%--------------------------------------------------------------------------
%Perform Decoding
%--------------------------------------------------------------------------
    wb = waitbar(0,'Please Wait...','Name','Decoding');     %Creates progress bar
    progress = length(stream);     %Value to update progress bar
    while ~isempty(stream);     %While stream is not empty
        position = 1;      %Go to root node
        while isempty(tree(position).symbol);     %If position is not a leaf
            if stream(1)     %If bit is 1
                position = tree(position).right;     %Go right
                stream(1) = [];     %Remove bit from stream
            else     %If bit is 0
                position = tree(position).left;     %Go left
                stream(1) = [];     %Remove bit from stream
            end                
        end
        if tree(position).symbol == NYTlocation     %If node is NYT
            symbol = bits2dec(stream(1:bitdepth));     %Finds first symbol
            stream(1:bitdepth) = [];     %Removes symbol from bit stream
            huffstream = [huffstream symbol];    %Adds to output stream
        else
            symbol = tree(position).symbol;     %Output known symbol
            huffstream = [huffstream symbol];    %Adds to output stream
        end
        treeloop(symbol)    %Updates the tree
        waitbar((progress-length(stream))/progress,wb);     %Update progress bar        

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国女主播一区二区三区| 国产亚洲欧洲一区高清在线观看| 精品一区二区成人精品| 丝袜国产日韩另类美女| 亚洲综合色视频| 亚洲人成在线播放网站岛国| 18涩涩午夜精品.www| 亚洲天堂av老司机| 国产精品麻豆视频| 亚洲婷婷国产精品电影人久久| 国产精品视频观看| 成人免费在线视频| 一区二区三区在线不卡| 亚洲成国产人片在线观看| 亚洲最大成人综合| 亚洲电影在线播放| 天天色综合成人网| 精品亚洲国产成人av制服丝袜| 九九国产精品视频| 国产乱码精品一区二区三| 成熟亚洲日本毛茸茸凸凹| 99久久精品免费看国产免费软件| 99国产麻豆精品| 欧美三级在线播放| 欧美成人综合网站| 亚洲国产精品v| 亚洲一二三四久久| 青青草成人在线观看| 国产乱一区二区| eeuss鲁片一区二区三区| 欧洲一区二区av| 日韩免费视频线观看| 国产精品卡一卡二卡三| 亚洲一区二区三区在线播放| 伦理电影国产精品| 99视频精品在线| 欧美精品色一区二区三区| 精品成人佐山爱一区二区| 91在线视频免费91| 中文字幕的久久| 午夜婷婷国产麻豆精品| 国产精品亚洲第一| 欧美日韩亚洲综合在线| 国产三级精品三级在线专区| 一区二区国产盗摄色噜噜| 激情久久五月天| 欧美日韩在线播放| 国产精品毛片大码女人| 久久精品国产在热久久| 色综合天天综合| 久久久影院官网| 婷婷国产v国产偷v亚洲高清| 成人avav在线| 精品欧美一区二区三区精品久久 | 欧美极品少妇xxxxⅹ高跟鞋| 亚洲伦理在线精品| 国产成人高清在线| 欧美成人乱码一区二区三区| 一区二区不卡在线视频 午夜欧美不卡在| 精品亚洲porn| 91精品国产高清一区二区三区| 亚洲欧美一区二区不卡| 国产福利91精品| 精品成人一区二区| 看片的网站亚洲| 欧美一区二区视频在线观看| 一区二区三区影院| 91免费国产在线| 一区在线观看免费| 成人黄色网址在线观看| 国产喂奶挤奶一区二区三区| 奇米777欧美一区二区| 欧美无乱码久久久免费午夜一区| 国产精品久久久久久久久动漫 | 91麻豆成人久久精品二区三区| 精品国产不卡一区二区三区| 免费欧美日韩国产三级电影| 欧美三级日本三级少妇99| 亚洲与欧洲av电影| 欧美综合天天夜夜久久| 亚洲香肠在线观看| 欧美日韩一区成人| 青草国产精品久久久久久| 69堂成人精品免费视频| 日韩av电影天堂| 欧美一区二区三区免费| 久久国产视频网| 久久久久久免费网| 成人午夜免费视频| 亚洲人精品一区| 欧美日韩在线精品一区二区三区激情| 亚洲妇熟xx妇色黄| 日韩欧美国产一二三区| 国产精品资源在线观看| 中文字幕视频一区二区三区久| 91丨porny丨中文| 亚洲一区成人在线| 日韩欧美在线不卡| 国产精品一线二线三线| 国产精品美女久久久久久久久久久 | 欧美一级久久久久久久大片| 亚洲无人区一区| 在线91免费看| 狠狠色丁香九九婷婷综合五月| 久久精品视频在线看| 99国产精品久久久久久久久久久 | 色老头久久综合| 亚洲国产精品久久艾草纯爱| 在线播放国产精品二区一二区四区| 婷婷丁香激情综合| 国产午夜久久久久| 91蝌蚪porny九色| 日韩精品免费视频人成| 久久精品人人做人人爽人人| 色噜噜狠狠一区二区三区果冻| 欧美国产日韩精品免费观看| 成人影视亚洲图片在线| 亚洲最新视频在线观看| 久久久久97国产精华液好用吗| 色悠悠久久综合| 国产一区二区三区蝌蚪| 一区二区成人在线视频| 精品第一国产综合精品aⅴ| 色综合久久88色综合天天| 精彩视频一区二区三区| 亚洲香蕉伊在人在线观| 欧美激情综合在线| 日韩三级高清在线| 欧美艳星brazzers| 成人精品视频一区二区三区| 蜜桃av噜噜一区| 亚洲国产一区二区在线播放| 中文无字幕一区二区三区 | 亚洲福利一区二区| 国产精品毛片久久久久久| 精品国产伦理网| 欧美精品日韩综合在线| 欧美综合欧美视频| 欧美日韩国产另类不卡| 日本高清视频一区二区| 久久国产综合精品| 亚洲bt欧美bt精品777| 中文字幕成人网| 精品日韩欧美在线| 欧美精品自拍偷拍动漫精品| 色网综合在线观看| 99视频精品免费视频| 成人在线一区二区三区| 国产一区二区剧情av在线| 久久激情综合网| 国产欧美日本一区视频| 精品国产免费久久| 久久久久久久久伊人| 日韩欧美国产精品| 日韩精品一区二区三区三区免费| 欧美日韩精品一区视频| 欧美色涩在线第一页| 91激情在线视频| 色av成人天堂桃色av| 91黄视频在线观看| 欧美天堂亚洲电影院在线播放| 色哟哟日韩精品| 欧美亚洲综合色| 欧美午夜片在线观看| 欧美高清你懂得| 日韩三级免费观看| 久久综合色播五月| 国产视频在线观看一区二区三区| 国产无一区二区| 中文字幕亚洲精品在线观看| 亚洲激情网站免费观看| 亚洲伦理在线免费看| 石原莉奈在线亚洲三区| 看片的网站亚洲| 国产成人一区二区精品非洲| 99精品国产热久久91蜜凸| 欧美男生操女生| 国产精品精品国产色婷婷| 国产日韩综合av| 亚洲欧美在线aaa| 一区二区三区国产精品| 日韩精品福利网| 国产另类ts人妖一区二区| 99re热视频这里只精品| 欧美精品xxxxbbbb| 久久久久久免费网| 亚洲精品欧美在线| 久久激情综合网| 91女厕偷拍女厕偷拍高清| 日韩三级高清在线| 国产精品久久久久久久久免费丝袜| 亚洲一区二区视频| 国产精品综合网| 欧美色图片你懂的| 中文字幕欧美激情| 亚洲日本一区二区| 亚洲视频1区2区| 日韩和欧美一区二区三区| 国模无码大尺度一区二区三区| 92国产精品观看|