Save and Dispaly VTM CTU partition info.
Johnny_1280x720_60_0.yuv, Johnny_1280x720_60_VTM.h266 and CTU/CTU_x.txt is only used for test.
This Project Usage:
First, install numpy, PIL, matplotlib for your Python3.
And then:
git clone https://github.com/codec2021/VTM_CTU_partition.git
python3 Draw_CTU_Partition.py
You will get the result picture:
![image](https://private-user-images.githubusercontent.com/13790178/316229524-7bea13b7-30b7-4025-80a7-6f1197ed5cbf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExNjQ2NDUsIm5iZiI6MTcyMTE2NDM0NSwicGF0aCI6Ii8xMzc5MDE3OC8zMTYyMjk1MjQtN2JlYTEzYjctMzBiNy00MDI1LTgwYTctNmYxMTk3ZWQ1Y2JmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDIxMTIyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA1YzMxNzEwYTYyY2I4OTE3ZTUyMTczZmVhYTE2ZGMzNTI1NWQ2ZTM2NmJlZGFmYzU1MDkwYzEzMmFhMzE1NDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.W6FOcxU60Rl1A3qy_IbbK8qVObNMc8mch7LtMLW_nmw)
VTM Code is here: https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM.git
At the end of function void EncCu::compressCtu in EncCu.cpp file, Please add the following code:
std::string ctuNum = std::to_string(ctuRsAddr);
std::ofstream ctuPartitionFile;
std::cout << ctuNum << std::endl;
ctuPartitionFile.open("./CTU_" + ctuNum + ".txt");
for (auto &currCU : cs.traverseCUs(CS::getArea(cs, area, ChannelType::LUMA), ChannelType::LUMA))
{
const CompArea& lumaArea = currCU.block(COMPONENT_Y);
int cuX = lumaArea.x;
int cuY = lumaArea.y;
int cuH = lumaArea.height;
int cuW = lumaArea.width;
std::string cuInfo = "";
cuInfo = std::to_string(cuX) + " " + std::to_string(cuY) + " " + std::to_string(cuH) + " " + std::to_string(cuW) +"\n";
ctuPartitionFile << cuInfo;
}
ctuPartitionFile.close();
Then build VTM22.0 Project to get the EncoderApp binary
Prepare your test yuv and cfg file, then run
for example:
./EncoderApp -c ./encoder_randomaccess_vtm.cfg -i Johnny_1280x720_60.yuv -wdt 1280 -hgt 720 -fr 30 -f 1 -q 30 -b Johnny_1280x720_60_VTM.h266
you will get some file named as CTU_0.txt, CTU_1.txt ... file in your local dir.
mkdir CTU
mv *.txt ./CTU
![image](https://private-user-images.githubusercontent.com/13790178/316228571-60fd7d6c-5c6b-42a5-adb6-f60f44e070f0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExNjQ2NDUsIm5iZiI6MTcyMTE2NDM0NSwicGF0aCI6Ii8xMzc5MDE3OC8zMTYyMjg1NzEtNjBmZDdkNmMtNWM2Yi00MmE1LWFkYjYtZjYwZjQ0ZTA3MGYwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDIxMTIyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIwZTIwYWZiNmVjNDY5ZmM2NzMxNDk0NGNkOGJjMzAxYzc3YThmNmQ0MmRjZTA2OTQ2N2Y1ZDdkMDNjODU0MDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.nQkFd-2wKGfkO1FQhaWblBV4CbBwxSVzakVRk1sGFLg)
set the encoded yuv name, width, height, ctu_size in the Draw_CTU_Partition.py:
and then run:
python3 Draw_CTU_Partition.py