mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-16 09:41:01 +03:00
fix, mac hwcodec decoding align use dst_align (#8215)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@ pub mod record;
|
||||
mod vpx;
|
||||
|
||||
#[repr(usize)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ImageFormat {
|
||||
Raw,
|
||||
ABGR,
|
||||
@@ -65,17 +65,17 @@ pub struct ImageRgb {
|
||||
pub w: usize,
|
||||
pub h: usize,
|
||||
pub fmt: ImageFormat,
|
||||
pub stride: usize,
|
||||
pub align: usize,
|
||||
}
|
||||
|
||||
impl ImageRgb {
|
||||
pub fn new(fmt: ImageFormat, stride: usize) -> Self {
|
||||
pub fn new(fmt: ImageFormat, align: usize) -> Self {
|
||||
Self {
|
||||
raw: Vec::new(),
|
||||
w: 0,
|
||||
h: 0,
|
||||
fmt,
|
||||
stride,
|
||||
align,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,13 +85,13 @@ impl ImageRgb {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn stride(&self) -> usize {
|
||||
self.stride
|
||||
pub fn align(&self) -> usize {
|
||||
self.align
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_stride(&mut self, stride: usize) {
|
||||
self.stride = stride;
|
||||
pub fn set_align(&mut self, align: usize) {
|
||||
self.align = align;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,20 +378,20 @@ pub trait GoogleImage {
|
||||
fn stride(&self) -> Vec<i32>;
|
||||
fn planes(&self) -> Vec<*mut u8>;
|
||||
fn chroma(&self) -> Chroma;
|
||||
fn get_bytes_per_row(w: usize, fmt: ImageFormat, stride: usize) -> usize {
|
||||
fn get_bytes_per_row(w: usize, fmt: ImageFormat, align: usize) -> usize {
|
||||
let bytes_per_pixel = match fmt {
|
||||
ImageFormat::Raw => 3,
|
||||
ImageFormat::ARGB | ImageFormat::ABGR => 4,
|
||||
};
|
||||
// https://github.com/lemenkov/libyuv/blob/6900494d90ae095d44405cd4cc3f346971fa69c9/source/convert_argb.cc#L128
|
||||
// https://github.com/lemenkov/libyuv/blob/6900494d90ae095d44405cd4cc3f346971fa69c9/source/convert_argb.cc#L129
|
||||
(w * bytes_per_pixel + stride - 1) & !(stride - 1)
|
||||
(w * bytes_per_pixel + align - 1) & !(align - 1)
|
||||
}
|
||||
// rgb [in/out] fmt and stride must be set in ImageRgb
|
||||
fn to(&self, rgb: &mut ImageRgb) {
|
||||
rgb.w = self.width();
|
||||
rgb.h = self.height();
|
||||
let bytes_per_row = Self::get_bytes_per_row(rgb.w, rgb.fmt, rgb.stride());
|
||||
let bytes_per_row = Self::get_bytes_per_row(rgb.w, rgb.fmt, rgb.align());
|
||||
rgb.raw.resize(rgb.h * bytes_per_row, 0);
|
||||
let stride = self.stride();
|
||||
let planes = self.planes();
|
||||
|
||||
Reference in New Issue
Block a user