jp1_add_cod.m

来自「用matlab实现的JPEG算法」· M 代码 · 共 57 行

M
57
字号
% ------------------------------------------
%  nom : 
%  jp1_add_COD(fid,g_NL,xcb,ycb,g_wave,xxxxxxx)
%
% ------------------------------------------

function jp1_add_COD(fid,g_NL,txcb,tycb,g_wave)


txcb= double(txcb) ;
tycb= double(tycb) ;
marker_COD = hex2dec('FF52') ;

fwrite(fid,marker_COD,'uint16'); % Lcod
m_deb = ftell(fid) ;

fwrite(fid,30,'short'); % Lcod
v_partition = 0 ;
fwrite(fid,v_partition,'int8'); % Scod PARITION +0 ou 1 entropie coder

% ---------- // SPcod  //-------------------------
fwrite(fid,g_NL,'uint8');		% Level decomp (8bits)
% ---------- // Progression style // -------------
% voir tableau A-15
% --- Layer progressive 					0000 0000
% --- Resolution_layer progessive		0000 0001
% --- Resolution-position progressive	0000 0010
% --- Position-component progressive	0000 0011
% --- Component-position progressive	0000 0100

fwrite(fid,0,'uint8');				% Progression style (8bits)
fwrite(fid,0,'uint16');				% number of layers  (16bits)

% ---------- // taille des blocs // -------------
% voir tableau A-16
vx = uint8(log2(txcb)-2) ;
vy = uint8(log2(tycb)-2);
fwrite(fid,vx,'uint8');	% xcb = 2^(valeur+2) (8bits)
fwrite(fid,vy,'uint8');	% ycb = 2^(valeur+2) (8bits)

% ---------- // Code-blocks style // -------------
% voir tableau A-17
fwrite(fid,0,'uint8');				% Code-blocks context (8bits)
% --------------- // transform // -----------------
% voir tableau A-18
fwrite(fid,g_wave,'uint8');				% YTsiz (8bits)

% ----// taille des partitions de paquets // ------
% voir tableau A-19
if (v_partition~=0),
   for i=0:g_NL
      fwrite(fid,128+8,'uint8');		% Packet partition size (8bits)
   end
   
end

% mise 

⌨️ 快捷键说明

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