rgb [in/out] fmt and stride must be set in ImageRgb
(&self, rgb: &mut ImageRgb, i420: &mut Vec<u8>)
| 357 | impl HwRamDecoderImage<'_> { |
| 358 | // rgb [in/out] fmt and stride must be set in ImageRgb |
| 359 | pub fn to_fmt(&self, rgb: &mut ImageRgb, i420: &mut Vec<u8>) -> ResultType<()> { |
| 360 | let frame = self.frame; |
| 361 | rgb.w = frame.width as _; |
| 362 | rgb.h = frame.height as _; |
| 363 | // take dst_stride into account when you convert |
| 364 | let dst_stride = rgb.stride(); |
| 365 | match frame.pixfmt { |
| 366 | AVPixelFormat::AV_PIX_FMT_NV12 => hw::hw_nv12_to( |
| 367 | rgb.fmt(), |
| 368 | frame.width as _, |
| 369 | frame.height as _, |
| 370 | &frame.data[0], |
| 371 | &frame.data[1], |
| 372 | frame.linesize[0] as _, |
| 373 | frame.linesize[1] as _, |
| 374 | &mut rgb.raw as _, |
| 375 | i420, |
| 376 | HW_STRIDE_ALIGN, |
| 377 | )?, |
| 378 | AVPixelFormat::AV_PIX_FMT_YUV420P => { |
| 379 | hw::hw_i420_to( |
| 380 | rgb.fmt(), |
| 381 | frame.width as _, |
| 382 | frame.height as _, |
| 383 | &frame.data[0], |
| 384 | &frame.data[1], |
| 385 | &frame.data[2], |
| 386 | frame.linesize[0] as _, |
| 387 | frame.linesize[1] as _, |
| 388 | frame.linesize[2] as _, |
| 389 | &mut rgb.raw as _, |
| 390 | )?; |
| 391 | } |
| 392 | } |
| 393 | Ok(()) |
| 394 | } |
| 395 | |
| 396 | pub fn bgra(&self, bgra: &mut Vec<u8>, i420: &mut Vec<u8>) -> ResultType<()> { |
| 397 | let mut rgb = ImageRgb::new(ImageFormat::ARGB, 1); |
no test coverage detected