bitdepth与bpp的区别
bitdepth 和 bpp(bits per pixel) 的区别; ffmpeg中所有支持的图片存储格式(pixel format)
最近在用ffmepg做各种图片格式的转码,现总结一下这两个概念的区别。(以下假设图片宽为W,高为H)
bitdepth是指每个通道的每个像素分量的有效比特数,它越高,表示该图片格式能表示的总颜色数上限越高。bitdepth = 总有效比特数/(所有通道的总像素分量数目).
bpp(bits per pixel)是指每个像素所占用的有效比特数(忽略通道),bpp = 总有效比特数/总像素数目 = 总有效比特数/(W*H).
bpp也用于压缩域的表示,即图片压缩后所占用的bit数/总像素数目。本文不讨论这个概念,只讨论在原始域的区别。
是否忽略通道是两者最重要的区别,前者描述的单位是像素分量,后者描述的单位是像素。
因此在原始域也总有bitdepth<bpp
另外,在windows中右键图片→属性→详细信息里显示的“位深度”是指bpp
下面举几个例子:
①对于YUV420(bitdepth=8)的图片,
图片的总像素数为W*H,其中Y通道有W*H个像素分量,U通道有W*H/4个像素分量,V通道有W*H/4个像素分量,
因此,总有效比特数= W*H*8+W*H/4*8+W*H/4*8 = W*H*12,
bpp = 总有效比特数/总像素数目 = (W*H*12)/(W*H) = 12.
②对于YUV420(bitdepth=10)的图片,
图片的总像素数为W*H,其中Y通道有W*H个像素分量,U通道有W*H/4个像素分量,V通道有W*H/4个像素分量,
虽然每个像素占10bit(有效比特数),但是需要用16bit即2字节(实际占用的比特数)来存储,
因此,总有效比特数= W*H*10+W*H/4*10+W*H/4*10 = W*H*15,
bpp = 总有效比特数/总像素数目 = (W*H*15)/(W*H) = 15.
③对于RGB24格式(bitdepth=8)的图片,
图片的总像素数为W*H,而R/G/B三个通道都是W*H个像素分量,
因此,总有效比特数= W*H*8*3,
bpp = 总有效比特数/总像素数目 = (W*H*8*3)/(W*H) = 24
④对于RGB555格式(bitdepth=5)的图片,
每个像素15bit = 5bit的R+5bit的G+5bit的B,
总有效比特数= W*H*5*3,
bpp = 总有效比特数/总像素数目 = (W*H*5*3)/(W*H) = 15
下面附上ffmpeg中所有的pixel format.
在命令行中使用 ffmpeg -pix_fmts 可以得到所有的格式(其中第四列显示的是bpp而非bitdepth):
Pixel formats:
I.... = Supported Input format for conversion
.O... = Supported Output format for conversion
..H.. = Hardware accelerated format
...P. = Paletted format
....B = Bitstream format
FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL
-----
IO... yuv420p 3 12
IO... yuyv422 3 16
IO... rgb24 3 24
IO... bgr24 3 24
IO... yuv422p 3 16
IO... yuv444p 3 24
IO... yuv410p 3 9
IO... yuv411p 3 12
IO... gray 1 8
IO..B monow 1 1
IO..B monob 1 1
I..P. pal8 1 8
IO... yuvj420p 3 12
IO... yuvj422p 3 16
IO... yuvj444p 3 24
IO... uyvy422 3 16
..... uyyvyy411 3 12
IO... bgr8 3 8
.O..B bgr4 3 4
IO... bgr4_byte 3 4
IO... rgb8 3 8
.O..B rgb4 3 4
IO... rgb4_byte 3 4
IO... nv12 3 12
IO... nv21 3 12
IO... argb 4 32
IO... rgba 4 32
IO... abgr 4 32
IO... bgra 4 32
IO... gray16be 1 16
IO... gray16le 1 16
IO... yuv440p 3 16
IO... yuvj440p 3 16
IO... yuva420p 4 20
IO... rgb48be 3 48
IO... rgb48le 3 48
IO... rgb565be 3 16
IO... rgb565le 3 16
IO... rgb555be 3 15
IO... rgb555le 3 15
IO... bgr565be 3 16
IO... bgr565le 3 16
IO... bgr555be 3 15
IO... bgr555le 3 15
..H.. vaapi_moco 0 0
..H.. vaapi_idct 0 0
..H.. vaapi_vld 0 0
IO... yuv420p16le 3 24
IO... yuv420p16be 3 24
IO... yuv422p16le 3 32
IO... yuv422p16be 3 32
IO... yuv444p16le 3 48
IO... yuv444p16be 3 48
..H.. dxva2_vld 0 0
IO... rgb444le 3 12
IO... rgb444be 3 12
IO... bgr444le 3 12
IO... bgr444be 3 12
IO... ya8 2 16
IO... bgr48be 3 48
IO... bgr48le 3 48
IO... yuv420p9be 3 13
IO... yuv420p9le 3 13
IO... yuv420p10be 3 15
IO... yuv420p10le 3 15
IO... yuv422p10be 3 20
IO... yuv422p10le 3 20
IO... yuv444p9be 3 27
IO... yuv444p9le 3 27
IO... yuv444p10be 3 30
IO... yuv444p10le 3 30
IO... yuv422p9be 3 18
IO... yuv422p9le 3 18
IO... gbrp 3 24
IO... gbrp9be 3 27
IO... gbrp9le 3 27
IO... gbrp10be 3 30
IO... gbrp10le 3 30
IO... gbrp16be 3 48
IO... gbrp16le 3 48
IO... yuva422p 4 24
IO... yuva444p 4 32
IO... yuva420p9be 4 22
IO... yuva420p9le 4 22
IO... yuva422p9be 4 27
IO... yuva422p9le 4 27
IO... yuva444p9be 4 36
IO... yuva444p9le 4 36
IO... yuva420p10be 4 25
IO... yuva420p10le 4 25
IO... yuva422p10be 4 30
IO... yuva422p10le 4 30
IO... yuva444p10be 4 40
IO... yuva444p10le 4 40
IO... yuva420p16be 4 40
IO... yuva420p16le 4 40
IO... yuva422p16be 4 48
IO... yuva422p16le 4 48
IO... yuva444p16be 4 64
IO... yuva444p16le 4 64
..H.. vdpau 0 0
IO... xyz12le 3 36
IO... xyz12be 3 36
..... nv16 3 16
..... nv20le 3 20
..... nv20be 3 20
IO... rgba64be 4 64
IO... rgba64le 4 64
IO... bgra64be 4 64
IO... bgra64le 4 64
IO... yvyu422 3 16
IO... ya16be 2 32
IO... ya16le 2 32
IO... gbrap 4 32
IO... gbrap16be 4 64
IO... gbrap16le 4 64
..H.. qsv 0 0
..H.. mmal 0 0
..H.. d3d11va_vld 0 0
..H.. cuda 0 0
IO... 0rgb 3 24
IO... rgb0 3 24
IO... 0bgr 3 24
IO... bgr0 3 24
IO... yuv420p12be 3 18
IO... yuv420p12le 3 18
IO... yuv420p14be 3 21
IO... yuv420p14le 3 21
IO... yuv422p12be 3 24
IO... yuv422p12le 3 24
IO... yuv422p14be 3 28
IO... yuv422p14le 3 28
IO... yuv444p12be 3 36
IO... yuv444p12le 3 36
IO... yuv444p14be 3 42
IO... yuv444p14le 3 42
IO... gbrp12be 3 36
IO... gbrp12le 3 36
IO... gbrp14be 3 42
IO... gbrp14le 3 42
IO... yuvj411p 3 12
I.... bayer_bggr8 3 8
I.... bayer_rggb8 3 8
I.... bayer_gbrg8 3 8
I.... bayer_grbg8 3 8
I.... bayer_bggr16le 3 16
I.... bayer_bggr16be 3 16
I.... bayer_rggb16le 3 16
I.... bayer_rggb16be 3 16
I.... bayer_gbrg16le 3 16
I.... bayer_gbrg16be 3 16
I.... bayer_grbg16le 3 16
I.... bayer_grbg16be 3 16
..H.. xvmc 0 0
IO... yuv440p10le 3 20
IO... yuv440p10be 3 20
IO... yuv440p12le 3 24
IO... yuv440p12be 3 24
IO... ayuv64le 4 64
..... ayuv64be 4 64
..H.. videotoolbox_vld 0 0
IO... p010le 3 15
IO... p010be 3 15
IO... gbrap12be 4 48
IO... gbrap12le 4 48
IO... gbrap10be 4 40
IO... gbrap10le 4 40
..H.. mediacodec 0 0
IO... gray12be 1 12
IO... gray12le 1 12
IO... gray10be 1 10
IO... gray10le 1 10
IO... p016le 3 24
IO... p016be 3 24
..H.. d3d11 0 0
IO... gray9be 1 9
IO... gray9le 1 9
..... gbrpf32be 3 96
..... gbrpf32le 3 96
..... gbrapf32be 4 128
..... gbrapf32le 4 128
..H.. drm_prime 0 0
..H.. opencl 0 0
IO... gray14be 1 14
IO... gray14le 1 14
IO... grayf32be 1 32
IO... grayf32le 1 32
————————————————
版权声明:本文为CSDN博主「_沥川往事」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/yuejisuo1948/article/details/83617359
如果这篇文章帮助到了你,你可以请作者喝一杯咖啡