mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-08-04 15:18:17 +00:00
refactor(session): decode RFX to RgbX
Decode to the desired format, instead of converting from BgrX to the DecodedImage format (typically RgbA) when applying the tile / drawing. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
bb41724147
commit
5555c7b9dd
4 changed files with 11 additions and 9 deletions
|
@ -2,7 +2,7 @@ use std::io;
|
|||
|
||||
use yuvutils_rs::{
|
||||
rdp_abgr_to_yuv444, rdp_argb_to_yuv444, rdp_bgra_to_yuv444, rdp_rgba_to_yuv444, rdp_yuv444_to_argb,
|
||||
rdp_yuv444_to_bgra, BufferStoreMut, YuvPlanarImage, YuvPlanarImageMut,
|
||||
rdp_yuv444_to_rgba, BufferStoreMut, YuvPlanarImage, YuvPlanarImageMut,
|
||||
};
|
||||
|
||||
use crate::image_processing::PixelFormat;
|
||||
|
@ -24,7 +24,7 @@ pub fn ycbcr_to_argb(input: YCbCrBuffer<'_>, output: &mut [u8]) -> io::Result<()
|
|||
rdp_yuv444_to_argb(&planar, output, len).map_err(io::Error::other)
|
||||
}
|
||||
|
||||
pub fn ycbcr_to_bgra(input: YCbCrBuffer<'_>, output: &mut [u8]) -> io::Result<()> {
|
||||
pub fn ycbcr_to_rgba(input: YCbCrBuffer<'_>, output: &mut [u8]) -> io::Result<()> {
|
||||
let len = u32::try_from(output.len()).map_err(io::Error::other)?;
|
||||
let width = len / 4;
|
||||
let planar = YuvPlanarImage {
|
||||
|
@ -37,7 +37,7 @@ pub fn ycbcr_to_bgra(input: YCbCrBuffer<'_>, output: &mut [u8]) -> io::Result<()
|
|||
width,
|
||||
height: 1,
|
||||
};
|
||||
rdp_yuv444_to_bgra(&planar, output, len).map_err(io::Error::other)
|
||||
rdp_yuv444_to_rgba(&planar, output, len).map_err(io::Error::other)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
|
|
@ -9,8 +9,6 @@ use ironrdp_pdu::geometry::{InclusiveRectangle, Rectangle as _};
|
|||
use crate::SessionResult;
|
||||
|
||||
const TILE_SIZE: u16 = 64;
|
||||
const SOURCE_PIXEL_FORMAT: PixelFormat = PixelFormat::BgrX32;
|
||||
const SOURCE_STRIDE: u16 = TILE_SIZE * SOURCE_PIXEL_FORMAT.bytes_per_pixel() as u16;
|
||||
|
||||
pub struct DecodedImage {
|
||||
pixel_format: PixelFormat,
|
||||
|
@ -470,6 +468,7 @@ impl DecodedImage {
|
|||
pub(crate) fn apply_tile(
|
||||
&mut self,
|
||||
tile_output: &[u8],
|
||||
pixel_format: PixelFormat,
|
||||
clipping_rectangles: &Region,
|
||||
update_rectangle: &InclusiveRectangle,
|
||||
) -> SessionResult<InclusiveRectangle> {
|
||||
|
@ -481,6 +480,7 @@ impl DecodedImage {
|
|||
for region_rectangle in &update_region.rectangles {
|
||||
let source_x = region_rectangle.left - update_rectangle.left;
|
||||
let source_y = region_rectangle.top - update_rectangle.top;
|
||||
let stride = u16::from(pixel_format.bytes_per_pixel()) * TILE_SIZE;
|
||||
let source_image_region = ImageRegion {
|
||||
region: InclusiveRectangle {
|
||||
left: source_x,
|
||||
|
@ -488,9 +488,9 @@ impl DecodedImage {
|
|||
right: source_x + region_rectangle.width() - 1,
|
||||
bottom: source_y + region_rectangle.height() - 1,
|
||||
},
|
||||
step: SOURCE_STRIDE,
|
||||
pixel_format: SOURCE_PIXEL_FORMAT,
|
||||
data: tile_output,
|
||||
step: stride,
|
||||
pixel_format,
|
||||
};
|
||||
|
||||
let mut destination_image_region = ImageRegionMut {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use core::cmp::min;
|
||||
|
||||
use ironrdp_graphics::color_conversion::{self, YCbCrBuffer};
|
||||
use ironrdp_graphics::image_processing::PixelFormat;
|
||||
use ironrdp_graphics::rectangle_processing::Region;
|
||||
use ironrdp_graphics::{dwt, quantization, rlgr, subband_reconstruction};
|
||||
use ironrdp_pdu::codecs::rfx::{self, EntropyAlgorithm, Headers, Quant, RfxRectangle, Tile};
|
||||
|
@ -150,6 +151,7 @@ impl DecodingContext {
|
|||
|
||||
let current_update_rectangle = image.apply_tile(
|
||||
&self.decoding_tiles.tile_output,
|
||||
PixelFormat::RgbA32,
|
||||
&clipping_rectangles,
|
||||
&update_rectangle,
|
||||
)?;
|
||||
|
@ -195,7 +197,7 @@ fn decode_tile(
|
|||
cr: ycbcr_temp[2].as_slice(),
|
||||
};
|
||||
|
||||
color_conversion::ycbcr_to_bgra(ycbcr_buffer, output).map_err(|e| custom_err!("decode_tile", e))?;
|
||||
color_conversion::ycbcr_to_rgba(ycbcr_buffer, output).map_err(|e| custom_err!("decode_tile", e))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ fn ycbcr_to_rgb_converts_one_element_buffer() {
|
|||
let expected = [128, 127, 128, 255];
|
||||
|
||||
let mut actual = vec![0; 4];
|
||||
ycbcr_to_bgra(ycbcr, actual.as_mut()).unwrap();
|
||||
ycbcr_to_rgba(ycbcr, actual.as_mut()).unwrap();
|
||||
assert_eq!(expected.as_ref(), actual.as_slice());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue