估算每像素比特数 (Bits Per Pixel),用于计算带宽
(&self)
| 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 | |
| 130 | impl From<u32> for PixelFormat { |
no outgoing calls
no test coverage detected