MCPcopy Create free account
hub / github.com/RustCV/RustCV / bpp_estimate

Method bpp_estimate

rustcv-core/src/pixel_format.rs:111–127  ·  view source on GitHub ↗

估算每像素比特数 (Bits Per Pixel),用于计算带宽

(&self)

Source from the content-addressed store, hash-verified

109
110 /// 估算每像素比特数 (Bits Per Pixel),用于计算带宽
111 pub fn bpp_estimate(&self) -> u32 {
112 match self {
113 Self::Known(cc) => match *cc {
114 FourCC::YUYV | FourCC::UYVY => 16,
115 FourCC::BGR3 | FourCC::RGB3 => 24,
116 FourCC::RGBA | FourCC::BGRA => 32,
117 FourCC::NV12 | FourCC::YV12 => 12, // 平均 12 bpp
118 FourCC::Z16 => 16,
119 // Bayer 8-bit
120 FourCC::BA81 | FourCC::GBRG | FourCC::GRBG | FourCC::RGGB => 8,
121 // 压缩格式无法准确估算,给一个典型值
122 FourCC::MJPEG | FourCC::H264 => 4,
123 _ => 0,
124 },
125 _ => 0,
126 }
127 }
128}
129
130impl From<u32> for PixelFormat {

Callers 1

calculate_buffer_sizeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected