Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Handle bottom-up camera frame orientation on Windows
Richie McIlroy10d584aee91f
diff --git a/crates/camera-ffmpeg/src/windows.rs b/crates/camera-ffmpeg/src/windows.rsindex 8f255269a..a4accd2fc 100644--- a/crates/camera-ffmpeg/src/windows.rs+++ b/crates/camera-ffmpeg/src/windows.rs@@ -198,11 +198,16 @@ pub fn reset_h264_decoder() {});}+fn src_y(y: usize, height: usize, is_bottom_up: bool) -> usize {+ if is_bottom_up { height - y - 1 } else { y }+}+impl CapturedFrameExt for CapturedFrame {fn as_ffmpeg(&self) -> Result<ffmpeg::frame::Video, AsFFmpegError> {let native = self.native();let width = native.width;let height = native.height;+ let is_bottom_up = native.is_bottom_up;if width == 0 || height == 0 {return Err(AsFFmpegError::Empty);@@ -219,32 +224,30 @@ impl CapturedFrameExt for CapturedFrame {let mut ff_frame = FFVideo::new(Pixel::YUV420P, width as u32, height as u32);let stride = ff_frame.stride(0);-for y in 0..height {let row_width = width;- let src_row = &bytes[y * row_width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}let stride = ff_frame.stride(1);-- for y in 0..height / 2 {+ let half_height = height / 2;+ for y in 0..half_height {let row_width = width / 2;- let src_row = &bytes[width * height + y * row_width..];+ let src_row =+ &bytes[width * height + src_y(y, half_height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(1)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}let stride = ff_frame.stride(2);-- for y in 0..height / 2 {+ for y in 0..half_height {let row_width = width / 2;- let src_row = &bytes[width * height + width * height / 4 + y * row_width..];+ let src_row = &bytes[width * height+ + width * height / 4+ + src_y(y, half_height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(2)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -255,20 +258,18 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);for y in 0..height {- let src_row = &bytes[y * width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];-dest_row[0..width].copy_from_slice(&src_row[0..width]);}let stride = ff_frame.stride(1);- let src_row = &bytes[width * height..];-- for y in 0..height / 2 {+ let uv_base = &bytes[width * height..];+ let half_height = height / 2;+ for y in 0..half_height {let row_width = width;- let src_row = &src_row[y * row_width..];+ let src_row = &uv_base[src_y(y, half_height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(1)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -278,12 +279,10 @@ impl CapturedFrameExt for CapturedFrame {let mut ff_frame = FFVideo::new(Pixel::BGRA, width as u32, height as u32);let stride = ff_frame.stride(0);-for y in 0..height {let row_width = width * 4;- let src_row = &bytes[(height - y - 1) * row_width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -294,11 +293,9 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);let src_stride = width * 3;-for y in 0..height {- let src_row = &bytes[(height - y - 1) * src_stride..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * src_stride..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];-dest_row[0..src_stride].copy_from_slice(&src_row[0..src_stride]);}@@ -308,12 +305,10 @@ impl CapturedFrameExt for CapturedFrame {let mut ff_frame = FFVideo::new(Pixel::BGRA, width as u32, height as u32);let stride = ff_frame.stride(0);-for y in 0..height {let row_width = width * 4;- let src_row = &bytes[(height - y - 1) * row_width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -323,12 +318,10 @@ impl CapturedFrameExt for CapturedFrame {let mut ff_frame = FFVideo::new(Pixel::YUYV422, width as u32, height as u32);let stride = ff_frame.stride(0);-for y in 0..height {let row_width = width * 2;- let src_row = &bytes[y * row_width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -338,12 +331,10 @@ impl CapturedFrameExt for CapturedFrame {let mut ff_frame = FFVideo::new(Pixel::UYVY422, width as u32, height as u32);let stride = ff_frame.stride(0);-for y in 0..height {let row_width = width * 2;- let src_row = &bytes[y * row_width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];-dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -356,7 +347,7 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);for y in 0..height {let row_width = width;- let src_row = &bytes[y * row_width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -365,11 +356,13 @@ impl CapturedFrameExt for CapturedFrame {let u_offset = v_offset + (width / 2) * (height / 2);let stride_u = ff_frame.stride(1);let stride_v = ff_frame.stride(2);+ let half_height = height / 2;- for y in 0..height / 2 {+ for y in 0..half_height {let row_width = width / 2;- let src_v = &bytes[v_offset + y * row_width..];- let src_u = &bytes[u_offset + y * row_width..];+ let sy = src_y(y, half_height, is_bottom_up);+ let src_v = &bytes[v_offset + sy * row_width..];+ let src_u = &bytes[u_offset + sy * row_width..];ff_frame.data_mut(1)[y * stride_u..][0..row_width].copy_from_slice(&src_u[0..row_width]);ff_frame.data_mut(2)[y * stride_v..][0..row_width]@@ -383,9 +376,8 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);let src_stride = width * 3;-for y in 0..height {- let src_row = &bytes[(height - y - 1) * src_stride..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * src_stride..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];dest_row[0..src_stride].copy_from_slice(&src_row[0..src_stride]);}@@ -396,10 +388,9 @@ impl CapturedFrameExt for CapturedFrame {let mut ff_frame = FFVideo::new(Pixel::GRAY8, width as u32, height as u32);let stride = ff_frame.stride(0);-for y in 0..height {let row_width = width;- let src_row = &bytes[y * row_width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];dest_row[0..row_width].copy_from_slice(&src_row[0..row_width]);}@@ -411,9 +402,8 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);let src_stride = width * 2;-for y in 0..height {- let src_row = &bytes[y * src_stride..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * src_stride..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];dest_row[0..src_stride].copy_from_slice(&src_row[0..src_stride]);}@@ -425,17 +415,18 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);for y in 0..height {- let src_row = &bytes[y * width..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * width..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];dest_row[0..width].copy_from_slice(&src_row[0..width]);}let stride = ff_frame.stride(1);let src_uv = &bytes[width * height..];+ let half_height = height / 2;- for y in 0..height / 2 {+ for y in 0..half_height {let row_width = width;- let src_row = &src_uv[y * row_width..];+ let src_row = &src_uv[src_y(y, half_height, is_bottom_up) * row_width..];let dest_row = &mut ff_frame.data_mut(1)[y * stride..];for x in 0..width / 2 {dest_row[x * 2] = src_row[x * 2 + 1];@@ -450,9 +441,8 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);let src_stride = width * 2;-for y in 0..height {- let src_row = &bytes[(height - y - 1) * src_stride..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * src_stride..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];dest_row[0..src_stride].copy_from_slice(&src_row[0..src_stride]);}@@ -464,9 +454,8 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(0);let src_stride = width * 2;-for y in 0..height {- let src_row = &bytes[y * src_stride..];+ let src_row = &bytes[src_y(y, height, is_bottom_up) * src_stride..];let dest_row = &mut ff_frame.data_mut(0)[y * stride..];dest_row[0..src_stride].copy_from_slice(&src_row[0..src_stride]);}@@ -474,9 +463,11 @@ impl CapturedFrameExt for CapturedFrame {let stride = ff_frame.stride(1);let uv_offset = width * height * 2;let src_stride = width * 2;+ let half_height = height / 2;- for y in 0..height / 2 {- let src_row = &bytes[uv_offset + y * src_stride..];+ for y in 0..half_height {+ let src_row =+ &bytes[uv_offset + src_y(y, half_height, is_bottom_up) * src_stride..];let dest_row = &mut ff_frame.data_mut(1)[y * stride..];dest_row[0..src_stride].copy_from_slice(&src_row[0..src_stride]);}diff --git a/crates/camera-windows/src/lib.rs b/crates/camera-windows/src/lib.rsindex e3fac3c88..9588cb6b0 100644--- a/crates/camera-windows/src/lib.rs+++ b/crates/camera-windows/src/lib.rs@@ -58,6 +58,7 @@ const VIRTUAL_CAMERA_PATTERNS: &[&str] = &["camo","avatarify","facerig",+ "nvidia broadcast",];const CAPTURE_CARD_PATTERNS: &[&str] = &[@@ -339,10 +340,10 @@ impl VideoDeviceInfo {inner: FrameInner::MediaFoundation(buffer),width: format.width() as usize,height: format.height() as usize,+ is_bottom_up: false,pixel_format: format.pixel_format,timestamp: data.timestamp,perf_counter: data.perf_counter,- // capture_begin_time: Some(data.capture_begin_time),})}}),@@ -365,14 +366,18 @@ impl VideoDeviceInfo {return;};+ let bi_height = video_info.bmiHeader.biHeight;+ let is_bottom_up = bi_height > 0;+ let height = bi_height.unsigned_abs() as usize;+callback(Frame {inner: FrameInner::DirectShow(sample.clone()),pixel_format: format,width: video_info.bmiHeader.biWidth as usize,- height: video_info.bmiHeader.biHeight as usize,+ height,+ is_bottom_up,timestamp: data.timestamp,perf_counter: data.perf_counter,- // capture_begin_time: None,});}),)?;@@ -421,6 +426,7 @@ pub struct Frame {pub pixel_format: PixelFormat,pub width: usize,pub height: usize,+ pub is_bottom_up: bool,// pub reference_time: Instant,pub timestamp: Duration,pub perf_counter: i64,diff --git a/crates/recording/src/feeds/camera.rs b/crates/recording/src/feeds/camera.rsindex 812baeb9d..b10518db9 100644--- a/crates/recording/src/feeds/camera.rs+++ b/crates/recording/src/feeds/camera.rs@@ -575,6 +575,7 @@ async fn setup_camera(pixel_format: frame.native().pixel_format,width: frame.native().width as u32,height: frame.native().height as u32,+ is_bottom_up: frame.native().is_bottom_up,timestamp,})).try_send();diff --git a/crates/recording/src/output_pipeline/win.rs b/crates/recording/src/output_pipeline/win.rsindex cb26f0b3b..39dee3e8c 100644--- a/crates/recording/src/output_pipeline/win.rs+++ b/crates/recording/src/output_pipeline/win.rs@@ -627,6 +627,7 @@ pub struct NativeCameraFrame {pub pixel_format: cap_camera_windows::PixelFormat,pub width: u32,pub height: u32,+ pub is_bottom_up: bool,pub timestamp: Timestamp,}@@ -1234,51 +1235,112 @@ pub fn camera_frame_to_ffmpeg(frame: &NativeCameraFrame) -> anyhow::Result<ffmpe};let mut ffmpeg_frame = ffmpeg::frame::Video::new(final_format, frame.width, frame.height);+ let flip = frame.is_bottom_up;+ let width = frame.width as usize;+ let height = frame.height as usize;match frame.pixel_format {cap_camera_windows::PixelFormat::NV12 => {- let y_size = (frame.width * frame.height) as usize;+ let y_size = width * height;let uv_size = y_size / 2;if final_data.len() >= y_size + uv_size {- ffmpeg_frame.data_mut(0)[..y_size].copy_from_slice(&final_data[..y_size]);- ffmpeg_frame.data_mut(1)[..uv_size].copy_from_slice(&final_data[y_size..]);+ let stride_y = ffmpeg_frame.stride(0);+ let stride_uv = ffmpeg_frame.stride(1);+ copy_plane(+ &final_data[..y_size],+ ffmpeg_frame.data_mut(0),+ width,+ height,+ stride_y,+ flip,+ );+ copy_plane(+ &final_data[y_size..y_size + uv_size],+ ffmpeg_frame.data_mut(1),+ width,+ height / 2,+ stride_uv,+ flip,+ );}}cap_camera_windows::PixelFormat::NV21 => {- let y_size = (frame.width * frame.height) as usize;+ let y_size = width * height;let uv_size = y_size / 2;if final_data.len() >= y_size + uv_size {- ffmpeg_frame.data_mut(0)[..y_size].copy_from_slice(&final_data[..y_size]);+ let stride_y = ffmpeg_frame.stride(0);+ let stride_uv = ffmpeg_frame.stride(1);+ copy_plane(+ &final_data[..y_size],+ ffmpeg_frame.data_mut(0),+ width,+ height,+ stride_y,+ flip,+ );let uv_data = &final_data[y_size..y_size + uv_size];+ let uv_height = height / 2;let dest = ffmpeg_frame.data_mut(1);- for i in (0..uv_size).step_by(2) {- if i + 1 < uv_data.len() && i + 1 < dest.len() {- dest[i] = uv_data[i + 1];- dest[i + 1] = uv_data[i];+ for row in 0..uv_height {+ let src_row = if flip { uv_height - 1 - row } else { row };+ for x in 0..width / 2 {+ let src_idx = src_row * width + x * 2;+ let dst_idx = row * stride_uv + x * 2;+ if src_idx + 1 < uv_data.len() && dst_idx + 1 < dest.len() {+ dest[dst_idx] = uv_data[src_idx + 1];+ dest[dst_idx + 1] = uv_data[src_idx];+ }}}}}cap_camera_windows::PixelFormat::YUYV422 | cap_camera_windows::PixelFormat::UYVY422 => {- let size = (frame.width * frame.height * 2) as usize;+ let row_bytes = width * 2;+ let size = row_bytes * height;if final_data.len() >= size {- ffmpeg_frame.data_mut(0)[..size].copy_from_slice(&final_data[..size]);+ let stride = ffmpeg_frame.stride(0);+ copy_plane(+ final_data,+ ffmpeg_frame.data_mut(0),+ row_bytes,+ height,+ stride,+ flip,+ );}}cap_camera_windows::PixelFormat::ARGB | cap_camera_windows::PixelFormat::RGB32 => {- let size = (frame.width * frame.height * 4) as usize;+ let row_bytes = width * 4;+ let size = row_bytes * height;if final_data.len() >= size {- ffmpeg_frame.data_mut(0)[..size].copy_from_slice(&final_data[..size]);+ let stride = ffmpeg_frame.stride(0);+ copy_plane(+ final_data,+ ffmpeg_frame.data_mut(0),+ row_bytes,+ height,+ stride,+ flip,+ );}}cap_camera_windows::PixelFormat::RGB24 | cap_camera_windows::PixelFormat::BGR24 => {- let size = (frame.width * frame.height * 3) as usize;+ let row_bytes = width * 3;+ let size = row_bytes * height;if final_data.len() >= size {- ffmpeg_frame.data_mut(0)[..size].copy_from_slice(&final_data[..size]);+ let stride = ffmpeg_frame.stride(0);+ copy_plane(+ final_data,+ ffmpeg_frame.data_mut(0),+ row_bytes,+ height,+ stride,+ flip,+ );}}cap_camera_windows::PixelFormat::YUV420P => {- let y_size = (frame.width * frame.height) as usize;+ let y_size = width * height;let uv_size = y_size / 4;if final_data.len() >= y_size + uv_size * 2 {let stride_y = ffmpeg_frame.stride(0);@@ -1287,28 +1349,31 @@ pub fn camera_frame_to_ffmpeg(frame: &NativeCameraFrame) -> anyhow::Result<ffmpecopy_plane(&final_data[..y_size],ffmpeg_frame.data_mut(0),- frame.width as usize,- frame.height as usize,+ width,+ height,stride_y,+ flip,);copy_plane(&final_data[y_size..y_size + uv_size],ffmpeg_frame.data_mut(1),- (frame.width / 2) as usize,- (frame.height / 2) as usize,+ width / 2,+ height / 2,stride_u,+ flip,);copy_plane(&final_data[y_size + uv_size..],ffmpeg_frame.data_mut(2),- (frame.width / 2) as usize,- (frame.height / 2) as usize,+ width / 2,+ height / 2,stride_v,+ flip,);}}cap_camera_windows::PixelFormat::YV12 => {- let y_size = (frame.width * frame.height) as usize;+ let y_size = width * height;let uv_size = y_size / 4;if final_data.len() >= y_size + uv_size * 2 {let stride_y = ffmpeg_frame.stride(0);@@ -1317,23 +1382,26 @@ pub fn camera_frame_to_ffmpeg(frame: &NativeCameraFrame) -> anyhow::Result<ffmpecopy_plane(&final_data[..y_size],ffmpeg_frame.data_mut(0),- frame.width as usize,- frame.height as usize,+ width,+ height,stride_y,+ flip,);copy_plane(&final_data[y_size + uv_size..],ffmpeg_frame.data_mut(1),- (frame.width / 2) as usize,- (frame.height / 2) as usize,+ width / 2,+ height / 2,stride_u,+ flip,);copy_plane(&final_data[y_size..y_size + uv_size],ffmpeg_frame.data_mut(2),- (frame.width / 2) as usize,- (frame.height / 2) as usize,+ width / 2,+ height / 2,stride_v,+ flip,);}}@@ -1343,9 +1411,10 @@ pub fn camera_frame_to_ffmpeg(frame: &NativeCameraFrame) -> anyhow::Result<ffmpeOk(ffmpeg_frame)}-fn copy_plane(src: &[u8], dst: &mut [u8], width: usize, height: usize, stride: usize) {+fn copy_plane(src: &[u8], dst: &mut [u8], width: usize, height: usize, stride: usize, flip: bool) {for row in 0..height {- let src_start = row * width;+ let src_row = if flip { height - 1 - row } else { row };+ let src_start = src_row * width;let dst_start = row * stride;let copy_len = width.min(src.len().saturating_sub(src_start));if copy_len > 0 && dst_start + copy_len <= dst.len() {@@ -1389,6 +1458,89 @@ fn decode_mjpeg_frame(frame: &NativeCameraFrame) -> anyhow::Result<ffmpeg::frameOk(decoded_frame)}+fn flip_camera_buffer(+ data: &[u8],+ width: usize,+ height: usize,+ pixel_format: cap_camera_windows::PixelFormat,+) -> Vec<u8> {+ match pixel_format {+ cap_camera_windows::PixelFormat::NV12 => {+ let y_size = width * height;+ let uv_size = y_size / 2;+ let mut flipped = vec![0u8; y_size + uv_size];++ for row in 0..height {+ let src_row = height - 1 - row;+ let src_start = src_row * width;+ let dst_start = row * width;+ if src_start + width <= data.len() && dst_start + width <= flipped.len() {+ flipped[dst_start..dst_start + width]+ .copy_from_slice(&data[src_start..src_start + width]);+ }+ }++ let uv_height = height / 2;+ let uv_row_size = width;+ for row in 0..uv_height {+ let src_row = uv_height - 1 - row;+ let src_start = y_size + src_row * uv_row_size;+ let dst_start = y_size + row * uv_row_size;+ if src_start + uv_row_size <= data.len() && dst_start + uv_row_size <= flipped.len()+ {+ flipped[dst_start..dst_start + uv_row_size]+ .copy_from_slice(&data[src_start..src_start + uv_row_size]);+ }+ }++ flipped+ }+ cap_camera_windows::PixelFormat::YUYV422 | cap_camera_windows::PixelFormat::UYVY422 => {+ let row_size = width * 2;+ let mut flipped = vec![0u8; row_size * height];+ for row in 0..height {+ let src_row = height - 1 - row;+ let src_start = src_row * row_size;+ let dst_start = row * row_size;+ if src_start + row_size <= data.len() && dst_start + row_size <= flipped.len() {+ flipped[dst_start..dst_start + row_size]+ .copy_from_slice(&data[src_start..src_start + row_size]);+ }+ }+ flipped+ }+ cap_camera_windows::PixelFormat::ARGB | cap_camera_windows::PixelFormat::RGB32 => {+ let row_size = width * 4;+ let mut flipped = vec![0u8; row_size * height];+ for row in 0..height {+ let src_row = height - 1 - row;+ let src_start = src_row * row_size;+ let dst_start = row * row_size;+ if src_start + row_size <= data.len() && dst_start + row_size <= flipped.len() {+ flipped[dst_start..dst_start + row_size]+ .copy_from_slice(&data[src_start..src_start + row_size]);+ }+ }+ flipped+ }+ cap_camera_windows::PixelFormat::RGB24 => {+ let row_size = width * 3;+ let mut flipped = vec![0u8; row_size * height];+ for row in 0..height {+ let src_row = height - 1 - row;+ let src_start = src_row * row_size;+ let dst_start = row * row_size;+ if src_start + row_size <= data.len() && dst_start + row_size <= flipped.len() {+ flipped[dst_start..dst_start + row_size]+ .copy_from_slice(&data[src_start..src_start + row_size]);+ }+ }+ flipped+ }+ _ => data.to_vec(),+ }+}+pub fn upload_mf_buffer_to_texture(device: &ID3D11Device,frame: &NativeCameraFrame,@@ -1416,14 +1568,27 @@ pub fn upload_mf_buffer_to_texture(let lock = buffer_guard.lock()?;let original_data = &*lock;- let converted_buffer_storage;- let data: &[u8] = if frame.pixel_format == cap_camera_windows::PixelFormat::UYVY422 {- converted_buffer_storage = convert_uyvy_to_yuyv(original_data, frame.width, frame.height);- converted_buffer_storage.as_slice()+ let uyvy_converted_storage;+ let after_uyvy: &[u8] = if frame.pixel_format == cap_camera_windows::PixelFormat::UYVY422 {+ uyvy_converted_storage = convert_uyvy_to_yuyv(original_data, frame.width, frame.height);+ uyvy_converted_storage.as_slice()} else {original_data};+ let flipped_storage;+ let data: &[u8] = if frame.is_bottom_up {+ flipped_storage = flip_camera_buffer(+ after_uyvy,+ frame.width as usize,+ frame.height as usize,+ frame.pixel_format,+ );+ flipped_storage.as_slice()+ } else {+ after_uyvy+ };+let row_pitch = frame.width * bytes_per_pixel;let texture_desc = D3D11_TEXTURE2D_DESC {