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:
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
set the encoded yuv name, width, height, ctu_size in the Draw_CTU_Partition.py:
and then run:
python3 Draw_CTU_Partition.py