在VTM代码目录中有pyuv_format.pdf
题为 A Packed Planar RGB and YUV Format for Uncompressed Storage of High Dynamic Range Still Images and Videos
Motivation: The only common approach to convey uncompressed planar 4:2:0 YUV HDR image data is to write each 10 or 12-bit sample into a 16- bit word, which increases the required capacity by 33–60 %
找到了作者的博客:ecodis :: Video Codecs,里面这样写道:
At the Ljubljana meeting, I also suggested adding support for a new 10- and 12-bit packed YUV/RGB image and video storage format to the VVC code base (see the report), a description of which is given below.
在上面这段话提到的report: JVET-K0562: Report of BoG on Software development and CTC
Note: package also includes a packed YUV format output mode.
Recommendation: adopt changes into VTM (remains disabled by default). SW AHG to decide whether to enable macro (command line parameter would still be disabled by default).
PACKED RGB OR YUV DATA WITH 10 BIT PER SAMPLE
0xff = 1111 1111
0xfc = 1111 1100
这里慢慢看,逻辑运算,看懂了就行。5*8b=40=4*10b
即out[5*n]~out[5*n+4] = buf[4*n]~buf[4*n+3]
PACKED RGB OR YUV DATA WITH 12 BIT PER SAMPLE
3*8b=24=2*12b
PACKED RGB OR YUV DATA WITH 14 BIT PER SAMPLE
7*8b=56=4*14b
反过来
常识
还可以学习一下这篇博客:H.266/VVC代码学习34:视频属性杂谈 - 时间有泪 - CSDN博客
这篇博客里写了一段10位转8位的代码:
比特深度为10,而字节是存储空间的基本计量单位,10位要占用2字节。
10比特深度,高位的8位只有最后2位有值,将其左移8位得到的数值加上低位的8位即可得到真正的10比特深度像素值,那么接下来除以4就可以将其“下采样”成8比特深度的yuv图片。
YUVBitConvert(int width, int height, short *yuv)//10bit深度,像素值应使用short
{
unsigned char* yuv10 = new unsigned char[width * height * 3];
memcpy(yuv10, yuv, width * height * 3 * sizeof(unsigned char));
unsigned char* yuv8 = m_yuv;
for (int i = 0; i < height * width * 3 / 2; ++i) //由10变成8,每个像素值都少了一位
{
yuv8[i] = (yuv10[2 * i] + yuv10[2 * i + 1] << 8) >> 2;
}
delete yuv10;
yuv10= NULL;
}
这个函数是基本看得懂,不过不知道怎么用,怎么传yuv进去呢?现在我懂了,这个函数应该是某个类的成员函数,m_yuv是类的一个数据成员,直接对他操作就行,应该有其他成员函数实现读取yuv给m_yuv。
注意和YUV播放器PYUV不是一个东西。播放器 DSPLab: PYUV: raw video sequence player
EncAppCfg.cpp:
po::Options opts;
opts.addOptions()
("PYUV", m_packedYUVMode, false, "If true then output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data. Ignored for interlaced output.")
在配置文件中加上 PYUV : 1
即可(还没尝试)
不知道这样存的yuv文件,用什么播放器可以播~?