Copies planar format data (NV12, YV12).
(
&mut self,
scanline0: *mut u8,
pitch: i32,
src_pitch: usize,
row_bytes: usize,
)
| 332 | |
| 333 | /// Copies planar format data (NV12, YV12). |
| 334 | unsafe fn copy_planar_data( |
| 335 | &mut self, |
| 336 | scanline0: *mut u8, |
| 337 | pitch: i32, |
| 338 | src_pitch: usize, |
| 339 | row_bytes: usize, |
| 340 | ) -> Result<()> { |
| 341 | let y_height = self.height as usize; |
| 342 | let uv_height = y_height.div_ceil(2); |
| 343 | let total_height = y_height + uv_height; |
| 344 | |
| 345 | let src = self.get_src_ptr(scanline0, pitch, src_pitch, total_height); |
| 346 | |
| 347 | for row in 0..y_height { |
| 348 | self.copy_row(src, row, src_pitch, row_bytes, 0); |
| 349 | } |
| 350 | |
| 351 | let y_plane_size = row_bytes * y_height; |
| 352 | let uv_src = src.add(y_height * src_pitch); |
| 353 | |
| 354 | for row in 0..uv_height { |
| 355 | let src_row = uv_src.add(row * src_pitch); |
| 356 | let dest_row = self |
| 357 | .linear_buffer |
| 358 | .as_mut_ptr() |
| 359 | .add(y_plane_size + row * row_bytes); |
| 360 | std::ptr::copy_nonoverlapping(src_row, dest_row, row_bytes); |
| 361 | } |
| 362 | |
| 363 | Ok(()) |
| 364 | } |
| 365 | |
| 366 | /// Copies packed format data |
| 367 | unsafe fn copy_packed_data( |
no test coverage detected