資源簡介
相比于H.264,HEVC中特別采用了Coding Unit(CU)的概念。為了查看編碼過程中, LCU的最終劃分,因此簡單做了一個LCU分割劃分的查看的代碼。雖然做得比較粗糙,但是勉強能用。因為Matlab進行圖片顯示和操作比較容易,這里用了Matlab。

代碼片段和文件信息
function?LCU_View(YUV_FileName?LCU_FileName?Width?Height?Numframe)
clc;
%%????setting?parameter
LCU_Size?=?64;
MaxNumPartition?=?256;
NumLCU_Row?=?floor(?(Width?+?LCU_Size-1)?/?LCU_Size?);?????%?the?number?of?LCU?in?a?row
NumLCU_Col?=?floor(?(Height+?LCU_Size-1)?/?LCU_Size?);???%?the?number?of?LUC?in?a?column
Fid_YUV?????=?fopen(YUV_FileName‘rb‘);
Fid_LCU?????=?fopen(LCU_FileName‘rb‘);
for?uiframe?=?1?:?Numframe
????%%?????read?data?from?files
????ImgData???=?fread(Fid_YUV?[Width?Height]?‘uint8‘);??????%?image?data?Y
????ImgData_U?=?fread(Fid_YUV?[Width/2?Height/2]?‘uint8‘);??%?image?data?U
????ImgData_V?=?fread(Fid_YUV?[Width/2?Height/2]?‘uint8‘);??%?image?data?V
????ImgData?=?ImgData‘;
????LCUData?=?fread(Fid_LCU?[NumLCU_Row*NumLCU_Col*MaxNumPartition?1]?‘uint8‘);???????????????????%?LCU?data
????%%????draw?LCU?lines
????figure;?imshow(ImgData[]);
????%?[movimgRgb]?=?loadFileYuv(YUV_FileName?Width?Height?1);
????%?figure;imshow(imgRgb[]);?hold?on;
????for?i?=?1?:?Width/LCU_Size
????????line([i*LCU_Size?i*LCU_Size]?[1?Height]‘Color‘?‘r‘‘LineWidth‘2)
????end
????for?i?=?1?:?Height/LCU_Size
????????line([1?Width]?[i*LCU_Size?i*LCU_Size]‘Color‘?‘r‘‘LineWidth‘2)
????end
????for?i?=?1?:?NumLCU_Col
????????for?j?=?1?:?NumLCU_Row
????????????Idx?=?(i-1)?*?NumLCU_Row?+?j;
????????????uiPelX?=?(j-1)?*?LCU_Size?+?1;
????????????uiPelY?=?(i-1)?*?LCU_Size?+?1;
????????????LCUData_Blk?=?LCUData(?(Idx-1)*MaxNumPartition?+?1?:?(Idx)*MaxNumPartition);
????????????DrawCUDepthLine(LCUData_Blk?uiPelX?uiPelY?LCU_Size?LCU_Size?MaxNumPartition);
????????end
????end
end
fclose(Fid_YUV);
fclose(Fid_LCU);
function?DrawCUDepthLine(DepthCTU?uiPelX?uiPelY?uiSize_X?uiSize_Y?uiNumPartition)
%-----------------Drawing?the?CTU?partiton?line?-----------------
%?DepthCTU?:?the?depth?info?of?current?CU
%?uiPelX?:?the?start?x-position?of?current?LCU
%?uiPelY?:?the?start?y-position?of?current?LCU
%?uiSize_X?:?the?X-size?of?LCU
%?uiSize_Y?:?the?Y-Size?of?LCU
%?uiNumPartition?:?the?number?of?partition?for?current?CU
uiDepth?=?DepthCTU(11);
if?uiDepth?==0?
????return;
else
????DepthCTU?=?DepthCTU?-1?;
????
????line([uiPelX?+?uiSize_X/2?uiPelX?+?uiSize_X/2]?[uiPelY?uiPelY?+?uiSize_Y]?‘Color‘?‘b‘);
????line([uiPelX?uiPelX?+?uiSize_X]?[uiPelY?+?uiSize_Y/2?uiPelY?+?uiSize_Y/2]?‘Color‘?‘b‘);
????
????%further?drawing
????uiNextSize_X???=?uiSize_X?/2;
????uiNextSize_Y???=?uiSize_Y?/2;
????uiNumPartitionNext?=?uiNumPartition/4;
????for?iAbsPartY?=?1?:?2
????????for??iAbsPartX=?1?:?2
????????????iAbsPartIndex?=?(iAbsPartY-1)?*?2?+?(iAbsPartX-1);
????????????iNextDepth?????=?DepthCTU(iAbsPartIndex?*?uiNumPartitionNext?+?1?:?(iAbsPartIndex+1)?*uiNumPartitionNext?1);
????????????uiNextPelX?=?uiPelX?+?(iAbsPartX-1)?*?uiNextSize_X;
????????????uiNextPelY?=?uiPelY?+?(iAbsPartY-1)?*?uiNextSize_Y;
????????????DrawCUDepthLine(iNextDepth?uiNextPelX?uiNe
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-12-30?20:17??LCUView\
?????目錄???????????0??2013-12-30?20:30??LCUView\example\
?????文件???????36794??2013-12-30?20:27??LCUView\example\1.jpg
?????文件???????28262??2013-12-30?20:27??LCUView\example\2.jpg
?????文件???????29553??2013-12-30?20:27??LCUView\example\3.jpg
?????文件???????28468??2013-12-30?20:27??LCUView\example\4.jpg
?????文件???????30513??2013-12-30?20:28??LCUView\example\5.jpg
?????文件??????180736??2013-12-30?17:07??LCUView\example\BestDepth.txt
?????文件????????3089??2013-12-30?16:33??LCUView\LCU_View.m
?????文件????????1030??2013-12-30?20:18??LCUView\Readme.txt
- 上一篇:無約束最優化的matlab代碼
- 下一篇:MATLAB設計語音信號濾波器
評論
共有 條評論