轉載,原文地址:http://blog.csdn.net/minbiao880224/article/details/17685935,結合我的第一篇HM編碼的使用,自己完全可以理解他的MATLAB代碼和打印思路,作者原文中給了5張,其實有多少幀最後會出來多少個CU劃分圖。
相比於H.264,HEVC中特別採用了Coding Unit(CU)的概念。爲了查看編碼過程中, LCU的最終劃分,因此簡單做了一個LCU分割劃分的查看的代碼。雖然做得比較粗糙,但是勉強能用。因爲Matlab進行圖片顯示和操作比較容易,這裏用了Matlab。
1、首先,在HEVC的測試代碼HM中的函數,加入一段代碼,講LCU劃分的信息保存下來。在Void TEncCu::compressCU( TComDataCU*& rpcCU ) 函數中加入
{
.........
xCompressCU( m_ppcBestCU[0], m_ppcTempCU[0], 0 );
// Add the code from here
ofstream DepthInfo;
TComDataCU* DepthCU = m_ppcBestCU[0];
DepthInfo.open("BestDepth.txt", ios::app);
for(UInt iPartitionNum = 0; iPartitionNum < DepthCU->getTotalNumPart(); iPartitionNum++)
{
DepthInfo << DepthCU->getDepth()[iPartitionNum];
}
DepthInfo.close();
}
當運行完HM代碼後,就會產生 BestDepth.txt文件。
2、講BestDepth.txt文件 拷貝到 Matlab的工作目錄下, 從以下鏈接中下載Matlab代碼:
http://download.csdn.net/detail/minbiao880224/6789725
Matlab代碼其實是一個這樣的函數:
function LCU_View(YUV_FileName, LCU_FileName, Width, Height, NumFrame)
YUV_FileName : 爲測試序列YUV的路徑和文件名,
LCU_FileName: 爲BestDepth.txt文件的路徑和文件名,
Width : 爲測試序列的Width
Height : 爲測試序列的Height
NumFrame : 爲測試的幀數
這裏,給出本人做的一個例子: