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