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

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

?? huff06.m

?? 算術編碼
?? M
?? 第 1 頁 / 共 2 頁
字號:
function varargout = Huff06(xC, ArgLevel, ArgSpeed)
% Huff06      Huffman encoder/decoder with (or without) recursive splitting
% Vectors of integers are Huffman encoded, 
% these vectors are collected in a cell array, xC.
% If first argument is a cell array the function do encoding,
% else decoding is done.
%
% [y, Res] = Huff06(xC, Level, Speed);                    % encoding
% y = Huff06(xC);                                         % encoding
% xC = Huff06(y);                                         % decoding
% ------------------------------------------------------------------% Arguments:
%  y        a column vector of non-negative integers (bytes) representing 
%           the code, 0 <= y(i) <= 255. 
%  Res      a matrix that sum up the results, size is (NumOfX+1)x4
%           one line for each of the input sequences, the columns are
%           Res(:,1) - number of elements in the sequence
%           Res(:,2) - zero-order entropy of the sequence
%           Res(:,3) - bits needed to code the sequence
%           Res(:,4) - bit rate for the sequence, Res(:,3)/Res(:,1)
%           Then the last line is total (which include bits needed to store NumOfX)
%  xC       a cell array of column vectors of integers representing the
%           symbol sequences. (should not be to large integers)
%           If only one sequence is to be coded, we must make the cell array
%           like: xC=cell(2,1); xC{1}=x; % where x is the sequence
%  Level    How many levels of splitting that is allowed, legal values 1-8
%           If Level=1, no further splitting of the sequences will be done
%           and there will be no recursive splitting.
%  Speed    For complete coding set Speed to 0. Set Speed to 1 to cheat 
%           during encoding, y will then be a sequence of zeros only,
%           but it will be of correct length and the other output 
%           arguments will be correct. 
% ------------------------------------------------------------------
% SOME NOTES ON THE FUNCTION
% huff06 depends on other functions for Huffman code, and the functions in this file
%  HuffLen     - find length of codewords (HL)
%  HuffTabLen  - find bits needed to store Huffman table information (HL)
%  HuffCode    - find huffman codewords
%  HuffTree    - find huffman tree

%----------------------------------------------------------------------
% Copyright (c) 1999-2000.  Karl Skretting.  All rights reserved.
% Hogskolen in Stavanger (Stavanger University), Signal Processing Group
% Mail:  karl.skretting@tn.his.no   Homepage:  http://www.ux.his.no/~karlsk/
% 
% HISTORY:
% Ver. 1.0  13.06.2000  KS: Function made based on huff04
% Ver. 1.1  20.06.2000  KS: Handle some more exceptions
% Ver. 1.2  21.06.2000  KS: Handle also negative values
% Ver. 1.3  23.06.2000  KS: Use logarithms for some sequences (line 114)
% Ver. 1.4  31.07.2000  KS: If a sequence has many zeros, Run + Value coding
%   is done. (from line 255 and some more)
% Ver. 1.5  02.08.2000  KS: May have larger integers in PutVLIC and GetVLIC
% Ver. 1.6  18.01.2001  KS: MaxL in line 218 was reduced from 2^16 to 50000.
%   For some sequences we may have length of code word larger than 16, even
%   if probability was larger than 2^(-16). Ex: Hi=[12798,14241,7126,7159,3520,...
%   3512,1857,1799,1089,1092,681,680,424,431,320,304,201,204,115,118,77,83,45,...
%   40,24,26,18,14,4,12,3,3,4,2,2,0,1]', sum(Hi)=58029
% Ver. 1.7  21.08.2001  KS: MaxL in line 218 and 420 must be the same
%   We may now have long code words (also see HuffTabLen.m)
%----------------------------------------------------------------------

global y Byte BitPos Speed Level

Mfile='Huff06';
Debug=0;    % note Debug is defined in EncodeVector and DecodeVector too

% check input and output arguments, and assign values to arguments
if (nargin < 1); 
   error([Mfile,': function must have input arguments, see help.']); 
end
if (nargout < 1); 
   error([Mfile,': function must have output arguments, see help.']); 
end

if (~iscell(xC))
   Encode=0;Decode=1;
   y=xC(:);            % first argument is y
else
   Encode=1;Decode=0;
   if (nargin < 3); Speed=0; else Speed=ArgSpeed; end;
   if (nargin < 2); Level=8; else Level=ArgLevel; end;
   if ((length(Speed(:))~=1)); 
      error([Mfile,': Speed argument is not scalar, see help.']); 
   end
   if Speed; Speed=1; end;
   if ((length(Level(:))~=1)); 
      error([Mfile,': Level argument is not scalar, see help.']); 
   end
   Level=floor(Level);
   if (Level < 1); Level=1; end;
   if (Level > 8); Level=8; end;
   NumOfX = length(xC);
end
   
if Encode
   Res=zeros(NumOfX,4);
   % initalize the global variables
   y=zeros(10,1);    % put some zeros into y initially
   Byte=0;BitPos=1;  % ready to write into first position
   % start encoding, first write VLIC to give number of sequences
   PutVLIC(NumOfX);
   if Debug
      disp([Mfile,' (Encode): Level=',int2str(Level),'  Speed=',int2str(Speed),...
            '  NumOfX=',int2str(NumOfX)]);
   end
   % now encode each sequence continuously
   Ltot=0;
   for num=1:NumOfX
      x=xC{num};
      x=full(x(:));        % make sure x is a non-sparse column vector
      L=length(x);Ltot=Ltot+L;
      y=[y(1:Byte);zeros(50+2*L,1)];  % make more space available in y
      % now find some info about x to better code it
      maxx=max(x);
      minx=min(x);
      if (minx<0) 
         Negative=1; 
      else 
         Negative=0; 
      end
      if ( (((maxx*4)>L) | (maxx>1023)) & (L>1) & (maxx>minx))  
         % the test for LogCode could be better, I think, (ver. 1.3)
         LogCode=1;    % this could be 0 if LogCode is not wanted
      else
         LogCode=0;
      end
      PutBit(LogCode);
      PutBit(Negative);
      I=find(x);                      % non-zero entries in x
      Sg=(sign(x(I))+1)/2;            % the signs may be needed later, 0/1
      x=abs(x);   
      if LogCode
         xa=x;                        % additional bits
         x(I)=floor(log2(x(I)));
         xa(I)=xa(I)-2.^x(I);
         x(I)=x(I)+1;
      end
      [bits, ent]=EncodeVector(x);   % store the (abs and/or log) values
      if Negative                    % store the signs
         for i=1:length(Sg); PutBit(Sg(i)); end;   
         bits=bits+length(Sg);
         ent=ent+length(Sg)/L;
      end
      if LogCode                     % store the additional bits
         for i=1:L
            for ii=(x(i)-1):(-1):1
               PutBit(bitget(xa(i),ii));
            end
         end
         bits=bits+sum(x)-length(I);
         ent=ent+(sum(x)-length(I))/L;
      end
      if L>0; Res(num,1)=L; else Res(num,1)=1; end;
      Res(num,2)=ent;
      Res(num,3)=bits;
   end
   y=y(1:Byte);   
   varargout(1) = {y};
   if (nargout >= 2) 
      % now calculate results for the total
      if Ltot<1; Ltot=1; end;   % we do not want Ltot to be zero
      Res(NumOfX+1,3)=Byte*8;
      Res(NumOfX+1,1)=Ltot;
      Res(NumOfX+1,2)=sum(Res(1:NumOfX,1).*Res(1:NumOfX,2))/Ltot;
      Res(:,4)=Res(:,3)./Res(:,1);
      varargout(2) = {Res}; 
   end
end

if Decode
   % initalize the global variables, y is set earlier
   Byte=0;BitPos=1;  % ready to read from first position
   NumOfX=GetVLIC;   % first read number of sequences
   if Debug
      disp([Mfile,'(Decode):  NumOfX=',int2str(NumOfX),'  length(y)=',int2str(length(y))]);
   end
   xC=cell(NumOfX,1);
   for num=1:NumOfX
      LogCode=GetBit;
      Negative=GetBit;
      x=DecodeVector;   % get the (abs and/or log) values
      L=length(x);
      I=find(x);
      if Negative
         Sg=zeros(size(I));
         for i=1:length(I); Sg(i)=GetBit; end;   % and the signs   (0/1)
         Sg=Sg*2-1;                              % (-1/1)
      else
         Sg=ones(size(I));                    
      end
      if LogCode          % read additional bits too
         xa=zeros(L,1);
         for i=1:L
            for ii=2:x(i)
               xa(i)=2*xa(i)+GetBit;
            end
         end
         x(I)=2.^(x(I)-1);
         x=x+xa;
      end
      x(I)=x(I).*Sg;
      xC{num}=x;
   end
   varargout(1) = {xC}; 
end

return     % end of main function, huff06

% the EncodeVector and DecodeVector functions are the ones
% where actual coding is going on.
% This function calls itself recursively
function [bits, ent] = EncodeVector(x, bits, HL, Maxx, Meanx)
global y Byte BitPos Speed Level 
Debug=0;
Level = Level - 1;
MaxL=50000;         % longer sequences is split in the middle
L=length(x);
% first handle some special possible exceptions,
if L==0
   PutBit(0);       % indicate that a sequence is coded
   PutVLIC(L);      % with length 0 (0 is 6 bits)
   PutBit(0);       % 'confirm' this by a '0', Run + Value is indicated by a '1'
   bits=2+6;
   ent=0;
   Level = Level + 1;
   return    % end of EncodeVector
end
if L==1
   PutBit(0);       % indicate that a sequence is coded
   PutVLIC(L);      % with length 1 (6 bits) 
   PutVLIC(x(1));   % containing this integer    
   bits=1+2*6;
   if (x(1)>=16); bits=bits+4; end;
   if (x(1)>=272); bits=bits+4; end;
   if (x(1)>=4368); bits=bits+5; end;
   if (x(1)>=69904); bits=bits+5; end;
   if (x(1)>=1118480); bits=bits+4; end;
   ent=0;
   Level = Level + 1;
   return    % end of EncodeVector
end
if max(x)==min(x)
   PutBit(0);       % indicate that a sequence is coded
   PutVLIC(L);      % with length L
   for i=1:7; PutBit(1); end;   % write end of Huffman Table
   PutVLIC(x(1));   % containing this integer    
   bits=1+6+7+6;      
   if (x(1)>=16); bits=bits+4; end;
   if (x(1)>=272); bits=bits+4; end;
   if (x(1)>=4368); bits=bits+5; end;
   if (x(1)>=69904); bits=bits+5; end;
   if (x(1)>=1118480); bits=bits+4; end;
   if (L>=16); bits=bits+4; end;
   if (L>=272); bits=bits+4; end;
   if (L>=4368); bits=bits+5; end;
   if (L>=69904); bits=bits+5; end;
   if (L>=1118480); bits=bits+4; end;
   ent=0;
   Level = Level + 1;
   return    % end of EncodeVector
end
% here we test if Run + Value coding should be done
I=find(x);   % the non-zero indices of x
if (L/2-length(I))>50
   Maxx=max(x);
   Hi=IntHist(x,0,Maxx);  % find the histogram
   Hinz=nonzeros(Hi);
   ent=log2(L)-sum(Hinz.*log2(Hinz))/L;  % find entropy
   % there are few non-zero indices => Run+Value coding of x
   x2=x(I);  % the values  
   I=[I(:);L+1];   % include length of x
   for i=length(I):(-1):2; I(i)=I(i)-I(i-1); end;
   x1=I-1;   % the runs  
   % code this as an unconditional split (like if L is large)
   if Speed
      Byte=Byte+1;    % since we add 8 bits
   else
      PutBit(0);       % this is idicated like when a sequence 
      PutVLIC(0);      % of length 0 is coded, but we add one extra bit
      PutBit(1);       % Run + Value is indicated by a '1'
   end;
   [bits1, temp] = EncodeVector(x1);
   [bits2, temp] = EncodeVector(x2);
   bits=bits1+bits2+8;
   Level = Level + 1;
   return    % end of EncodeVector
end

if (nargin==1)
   Maxx=max(x);
   Meanx=mean(x);
   Hi=IntHist(x,0,Maxx);  % find the histogram
   Hinz=nonzeros(Hi);
   ent=log2(L)-sum(Hinz.*log2(Hinz))/L;  % find entropy
   HL=HuffLen(Hi);
   HLlen=HuffTabLen(HL);
   % find number of bits to use, store L, HL and x
   bits=6+HLlen+sum(HL.*Hi);
   if (L>=16); bits=bits+4; end;
   if (L>=272); bits=bits+4; end;
   if (L>=4368); bits=bits+5; end;
   if (L>=69904); bits=bits+5; end;
   if (L>=1118480); bits=bits+4; end;
   if Debug
      disp(['bits=',int2str(bits),'  HLlen=',int2str(HLlen),...
         '   HClen=',int2str(sum(HL.*Hi))]);
   end
else                % arguments are given, do not need to be calculated
   ent=0;
end
%
% Here we have: x, bits, L, HL, Maxx, Meanx, ent
if (L>MaxL)   % we split sequence anyway (and the easy way; in the middle)
   L1=ceil(L/2);L2=L-L1;
   x1=x(1:L1);x2=x((L1+1):L);
elseif ((Level > 0) & (L>10))      
   xm=median(x); % median in MatLab is slow, could be calulated faster by using the histogram
   x1=zeros(L,1);x2=zeros(L,1);
   x2(1)=x(1);i1=0;i2=1;
   for i=2:L
      if (x(i-1) <= xm) 
         i1=i1+1; x1(i1)=x(i);
      else
         i2=i2+1; x2(i2)=x(i);
      end
   end
   x1=x1(1:i1);x2=x2(1:i2);
   % find bits1 and bits2 for x1 and x2
   L1=length(x1);L2=length(x2);
   Maxx1=max(x1);Maxx2=max(x2);
   Meanx1=mean(x1);Meanx2=mean(x2);
   Hi1=IntHist(x1,0,Maxx1);  % find the histogram
   Hi2=IntHist(x2,0,Maxx2);  % find the histogram
   HL1=hufflen(Hi1);HL2=hufflen(Hi2);
   HLlen1=HuffTabLen(HL1);
   HLlen2=HuffTabLen(HL2);
   bits1=6+HLlen1+sum(HL1.*Hi1);
   bits2=6+HLlen2+sum(HL2.*Hi2);
   if (L1>=16); bits1=bits1+4; end;
   if (L1>=272); bits1=bits1+4; end;
   if (L1>=4368); bits1=bits1+5; end;
   if (L1>=69904); bits1=bits1+5; end;
   if (L1>=1118480); bits1=bits1+4; end;
   if (L2>=16); bits2=bits2+4; end;
   if (L2>=272); bits2=bits2+4; end;
   if (L2>=4368); bits2=bits2+5; end;
   if (L2>=69904); bits2=bits2+5; end;
   if (L2>=1118480); bits2=bits2+4; end;
else
   bits1=bits;bits2=bits;
end
% Here we may have: x1, bits1, L1, HL1, Maxx1, Meanx1
% and               x2, bits2, L2, HL2, Maxx2, Meanx2
% but at least we have bits1 and bits2  (and bits)
if Debug
   disp(['Level=',int2str(Level),'  bits=',int2str(bits),'  bits1=',int2str(bits1),...
         '  bits2=',int2str(bits2),'  sum=',int2str(bits1+bits2)]);
end

if (L>MaxL)
   if Speed
      BitPos=BitPos-1;
      if (~BitPos); Byte=Byte+1; BitPos=8; end; 
   else
      PutBit(1);       % indicate sequence is splitted into two
   end;
   [bits1, temp] = EncodeVector(x1);
   [bits2, temp] = EncodeVector(x2);
   bits=bits1+bits2+1;
elseif ((bits1+bits2) < bits) 
   if Speed
      BitPos=BitPos-1;
      if (~BitPos); Byte=Byte+1; BitPos=8; end; 
   else
      PutBit(1);       % indicate sequence is splitted into two

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲在线视频免费观看| 日韩成人免费电影| 亚洲线精品一区二区三区 | 国产一区二区伦理片| av在线不卡电影| 日韩一区二区三区在线| 一区二区三区在线不卡| 成人小视频在线| 日韩欧美国产麻豆| 亚洲午夜一区二区| 成人福利视频网站| 久久久久99精品国产片| 日本强好片久久久久久aaa| 成人久久18免费网站麻豆| 欧美成人一区二区| 日日噜噜夜夜狠狠视频欧美人 | 国产精品成人午夜| 国产精品中文有码| 欧美挠脚心视频网站| 亚洲综合色在线| av激情成人网| 中文av一区二区| 国产成人夜色高潮福利影视| www亚洲一区| 久久精品国产第一区二区三区| 欧美日韩精品一区二区天天拍小说| 亚洲欧美视频在线观看视频| 97精品国产露脸对白| 中文字幕一区二区三中文字幕| 国产91丝袜在线播放0| 久久久青草青青国产亚洲免观| 久久黄色级2电影| 91精品婷婷国产综合久久竹菊| 又紧又大又爽精品一区二区| 91啪亚洲精品| 亚洲一区成人在线| 欧美日韩久久久久久| 亚洲第一二三四区| 91精品国产综合久久久久久| 视频一区欧美日韩| 精品日韩在线一区| 国产91丝袜在线播放九色| 国产精品美女一区二区| 99精品视频在线观看免费| 亚洲视频免费在线| 欧美三级电影网站| 日本免费新一区视频| 精品欧美一区二区久久| 成人永久看片免费视频天堂| 中文字幕中文乱码欧美一区二区| 色综合一区二区三区| 亚洲国产一区二区三区青草影视| 91精品国产综合久久精品麻豆| 日本在线不卡一区| 欧美精品一区二区蜜臀亚洲| 成人av网站大全| 亚洲国产综合91精品麻豆| 日韩欧美国产午夜精品| a美女胸又www黄视频久久| 一区二区三区毛片| 精品电影一区二区| 91免费视频网| 免费成人性网站| 国产精品久久久久久久裸模| 欧美性色综合网| 国产精品综合一区二区三区| 国产精品伦一区二区三级视频| 欧美亚洲国产bt| 国产美女久久久久| 亚洲综合激情另类小说区| 日韩一本二本av| 99精品国产一区二区三区不卡| 日韩va欧美va亚洲va久久| 欧美国产日韩亚洲一区| 欧美日韩免费观看一区二区三区| 国产剧情一区二区三区| 亚洲专区一二三| 久久久欧美精品sm网站| 欧美三级乱人伦电影| 成人性生交大片免费看中文| 日韩精品免费专区| 国产精品久久久久久久久免费樱桃 | 成人免费在线视频| 日韩三级伦理片妻子的秘密按摩| 成人av小说网| 久久电影国产免费久久电影| 亚洲一区二区三区在线看| 国产人成一区二区三区影院| 日韩一区二区三区免费观看| 色婷婷av一区二区三区gif| 国产一区二区不卡在线| 喷水一区二区三区| 亚洲.国产.中文慕字在线| 综合激情成人伊人| 欧美国产精品一区二区| 精品国产一区二区国模嫣然| 欧美日本免费一区二区三区| 91老司机福利 在线| 成人av先锋影音| 国产不卡免费视频| 国产精品影视在线观看| 六月丁香婷婷色狠狠久久| 天天色综合天天| 亚洲国产精品久久久久婷婷884 | 欧美日韩一二三区| 在线免费观看日本一区| 972aa.com艺术欧美| www.视频一区| 成人高清免费观看| 99精品欧美一区二区三区小说 | 国产又黄又大久久| 久久国产三级精品| 极品美女销魂一区二区三区| 久久机这里只有精品| 久久精品免费看| 狠狠色丁香久久婷婷综合_中 | 日本高清不卡在线观看| 91色婷婷久久久久合中文| 91一区二区在线| 色综合色综合色综合色综合色综合 | 白白色亚洲国产精品| 国产成人午夜高潮毛片| 高清在线观看日韩| a级精品国产片在线观看| 色综合久久中文综合久久97| 色狠狠桃花综合| 欧美日韩精品免费| 欧美一区2区视频在线观看| 日韩欧美资源站| 久久精品在这里| 亚洲天天做日日做天天谢日日欢| 亚洲精品久久久蜜桃| 亚洲h动漫在线| 麻豆一区二区三区| 国产揄拍国内精品对白| 粉嫩久久99精品久久久久久夜| 99久久国产免费看| 欧美日韩久久久一区| 精品国免费一区二区三区| 欧美韩国一区二区| 一区二区在线看| 视频一区二区国产| 丁香婷婷综合色啪| 欧美手机在线视频| 久久久蜜桃精品| 亚洲国产视频在线| 国产精品资源网站| 欧美亚洲国产bt| 久久久久国产成人精品亚洲午夜| 亚洲欧美另类小说| 青青草原综合久久大伊人精品| 国产精品综合一区二区三区| 欧美综合色免费| 精品国产一区二区在线观看| 日韩美女久久久| 麻豆精品一区二区三区| 色综合色综合色综合| 日韩精品资源二区在线| 亚洲免费三区一区二区| 老司机免费视频一区二区三区| 91老司机福利 在线| 2020国产成人综合网| 亚洲午夜激情av| 粉嫩av一区二区三区在线播放| 欧美日韩精品二区第二页| 国产精品电影一区二区三区| 美女mm1313爽爽久久久蜜臀| 91高清视频在线| 中文字幕日韩av资源站| 国内偷窥港台综合视频在线播放| 欧美日韩一区二区三区视频| 国产精品电影一区二区| 国产在线视频一区二区三区| 欧美视频日韩视频在线观看| 中文乱码免费一区二区| 国产麻豆9l精品三级站| 欧美高清激情brazzers| 亚洲精品国产成人久久av盗摄| 国产精品白丝jk白祙喷水网站 | 免费观看在线色综合| 欧美日韩一区二区在线观看| 亚洲视频一二三区| 成人黄色a**站在线观看| 久久嫩草精品久久久精品| 日日嗨av一区二区三区四区| 在线观看亚洲a| 亚洲日本免费电影| 成人av午夜电影| 国产精品成人网| 99精品国产视频| 中文字幕亚洲在| 99热这里都是精品| 国产精品久久三区| 成人丝袜高跟foot| 欧美国产精品一区| 北条麻妃国产九九精品视频| 日本一区二区三区国色天香 | 日韩免费视频线观看| 麻豆成人久久精品二区三区红| 欧美一区在线视频|