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

Method calculate_buffer_size

rustcv-backend-msmf/src/stream.rs:280–300  ·  view source on GitHub ↗

Calculates buffer size based on pixel format. Returns a tuple of (stride, total_size) where: - stride: bytes per row - total_size: total buffer size in bytes

(width: u32, height: u32, format: PixelFormat)

Source from the content-addressed store, hash-verified

278 /// - stride: bytes per row
279 /// - total_size: total buffer size in bytes
280 fn calculate_buffer_size(width: u32, height: u32, format: PixelFormat) -> (usize, usize) {
281 let h = height as usize;
282 let w = width as usize;
283
284 match format {
285 PixelFormat::Known(FourCC::NV12) | PixelFormat::Known(FourCC::YV12) => {
286 let y_plane = w * h;
287 let uv_plane = w * h.div_ceil(2);
288 (w, y_plane + uv_plane)
289 }
290 PixelFormat::Known(FourCC::YUYV) | PixelFormat::Known(FourCC::UYVY) => {
291 let stride = w * 2;
292 (stride, stride * h)
293 }
294 _ => {
295 let bpp = format.bpp_estimate() as usize;
296 let stride = w * bpp / 8;
297 (stride, stride * h)
298 }
299 }
300 }
301
302 /// Copies frame data from an IMFSample to the linear buffer.
303 fn copy_sample_to_linear_buffer(&mut self, sample: &IMFSample) -> Result<()> {

Callers

nothing calls this directly

Calls 1

bpp_estimateMethod · 0.80

Tested by

no test coverage detected