video: Make DecodedFrame an alias of render::Bitmap
This commit is contained in:
parent
493971ab8a
commit
0fab8b3ece
|
@ -82,20 +82,20 @@ impl VideoBackend for SoftwareVideoBackend {
|
|||
renderer.update_texture(
|
||||
&bitmap,
|
||||
Bitmap::new(
|
||||
frame.width.into(),
|
||||
frame.height.into(),
|
||||
frame.width(),
|
||||
frame.height(),
|
||||
BitmapFormat::Rgba,
|
||||
frame.rgba,
|
||||
frame.data().to_vec(),
|
||||
),
|
||||
PixelRegion::for_whole_size(frame.width.into(), frame.height.into()),
|
||||
PixelRegion::for_whole_size(frame.width(), frame.height()),
|
||||
)?;
|
||||
bitmap
|
||||
} else {
|
||||
let bitmap = Bitmap::new(
|
||||
frame.width.into(),
|
||||
frame.height.into(),
|
||||
frame.width(),
|
||||
frame.height(),
|
||||
BitmapFormat::Rgba,
|
||||
frame.rgba,
|
||||
frame.data().to_vec(),
|
||||
);
|
||||
renderer.register_bitmap(bitmap)?
|
||||
};
|
||||
|
@ -103,8 +103,8 @@ impl VideoBackend for SoftwareVideoBackend {
|
|||
|
||||
Ok(BitmapInfo {
|
||||
handle,
|
||||
width: frame.width,
|
||||
height: frame.height,
|
||||
width: frame.width() as u16,
|
||||
height: frame.height() as u16,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::decoder::VideoDecoder;
|
|||
use h263_rs::parser::H263Reader;
|
||||
use h263_rs::{DecoderOption, H263State, PictureTypeCode};
|
||||
use h263_rs_yuv::bt601::yuv420_to_rgba;
|
||||
use ruffle_render::bitmap::BitmapFormat;
|
||||
use ruffle_video::error::Error;
|
||||
use ruffle_video::frame::{DecodedFrame, EncodedFrame, FrameDependency};
|
||||
|
||||
|
@ -72,11 +73,12 @@ impl VideoDecoder for H263Decoder {
|
|||
debug_assert_eq!(chroma_width, (width as usize + 1) / 2);
|
||||
let (y, b, r) = picture.as_yuv();
|
||||
let rgba = yuv420_to_rgba(y, b, r, width.into());
|
||||
Ok(DecodedFrame {
|
||||
width,
|
||||
height,
|
||||
Ok(DecodedFrame::new(
|
||||
width as u32,
|
||||
height as u32,
|
||||
BitmapFormat::Rgba,
|
||||
rgba,
|
||||
})
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// written by Kostya Shishkov, with permission.
|
||||
|
||||
use crate::decoder::VideoDecoder;
|
||||
use ruffle_render::bitmap::BitmapFormat;
|
||||
use ruffle_video::error::Error;
|
||||
|
||||
use flate2::Decompress;
|
||||
|
@ -203,11 +204,15 @@ impl VideoDecoder for ScreenVideoDecoder {
|
|||
|
||||
self.last_frame = Some(data);
|
||||
|
||||
Ok(DecodedFrame {
|
||||
width: w as u16,
|
||||
height: h as u16,
|
||||
// NOTE: We could get away with only storing RGB data (saving some memory), as there is no
|
||||
// alpha support in Screen V1, but since the render backends always want RGBA right now,
|
||||
// it's better to do the pixel format conversion here, all at once.
|
||||
Ok(DecodedFrame::new(
|
||||
w as u32,
|
||||
h as u32,
|
||||
BitmapFormat::Rgba,
|
||||
rgba,
|
||||
})
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::decoder::VideoDecoder;
|
||||
use ruffle_render::bitmap::BitmapFormat;
|
||||
use ruffle_video::error::Error;
|
||||
|
||||
use h263_rs_yuv::bt601::yuv420_to_rgba;
|
||||
|
@ -229,11 +230,12 @@ impl VideoDecoder for Vp6Decoder {
|
|||
height = usize::min(height, bounds.1 as usize);
|
||||
rgba.truncate(width * height * 4);
|
||||
|
||||
Ok(DecodedFrame {
|
||||
width: width as u16,
|
||||
height: height as u16,
|
||||
Ok(DecodedFrame::new(
|
||||
width as u32,
|
||||
height as u32,
|
||||
BitmapFormat::Rgba,
|
||||
rgba,
|
||||
})
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use ruffle_render::bitmap::Bitmap;
|
||||
use swf::VideoCodec;
|
||||
|
||||
/// An encoded video frame of some video codec.
|
||||
|
@ -20,12 +21,8 @@ impl<'a> EncodedFrame<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A decoded frame of video in RGBA format.
|
||||
pub struct DecodedFrame {
|
||||
pub width: u16,
|
||||
pub height: u16,
|
||||
pub rgba: Vec<u8>,
|
||||
}
|
||||
/// A decoded frame of video. It can be in whichever format the decoder chooses.
|
||||
pub type DecodedFrame = Bitmap;
|
||||
|
||||
/// What dependencies a given video frame has on any previous frames.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
|
Loading…
Reference in New Issue