video: Move software decoding into core now that we don't need to specialize per-renderer
This commit is contained in:
parent
885805f887
commit
43f76de602
|
@ -1705,6 +1705,11 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h263-rs-yuv"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ruffle-rs/h263-rs?rev=837f075d280680abc8dd3fc3d47656d5a770c48e#837f075d280680abc8dd3fc3d47656d5a770c48e"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.1"
|
||||
|
@ -3039,6 +3044,7 @@ dependencies = [
|
|||
"generational-arena",
|
||||
"gif",
|
||||
"h263-rs",
|
||||
"h263-rs-yuv",
|
||||
"indexmap",
|
||||
"instant",
|
||||
"jpeg-decoder",
|
||||
|
|
|
@ -37,6 +37,7 @@ rand = { version = "0.8.4", features = ["std", "small_rng"], default-features =
|
|||
serde = { version = "1.0.127", features = ["derive"], optional = true }
|
||||
nellymoser-rs = { git = "https://github.com/ruffle-rs/nellymoser" }
|
||||
h263-rs = { git = "https://github.com/ruffle-rs/h263-rs", rev = "837f075d280680abc8dd3fc3d47656d5a770c48e" }
|
||||
h263-rs-yuv = { git = "https://github.com/ruffle-rs/h263-rs", rev = "837f075d280680abc8dd3fc3d47656d5a770c48e" }
|
||||
regress = "0.4"
|
||||
flash-lso = { git = "https://github.com/ruffle-rs/rust-flash-lso", rev = "19fecd07b9888c4bdaa66771c468095783b52bed" }
|
||||
json = "0.12.4"
|
||||
|
|
|
@ -7,6 +7,7 @@ use crate::backend::video::{
|
|||
use generational_arena::Arena;
|
||||
use h263_rs::parser::{decode_picture, H263Reader};
|
||||
use h263_rs::{DecoderOption, H263State, PictureTypeCode};
|
||||
use h263_rs_yuv::bt601::yuv420_to_rgba;
|
||||
use swf::{VideoCodec, VideoDeblocking};
|
||||
|
||||
/// A single preloaded video stream.
|
||||
|
@ -61,7 +62,7 @@ impl VideoBackend for SoftwareVideoBackend {
|
|||
.ok_or("Unregistered video stream")?;
|
||||
|
||||
match stream {
|
||||
VideoStream::H263(state) => {
|
||||
VideoStream::H263(_state) => {
|
||||
let mut reader = H263Reader::from_source(encoded_frame.data());
|
||||
let picture =
|
||||
decode_picture(&mut reader, DecoderOption::SORENSON_SPARK_BITSTREAM, None)?
|
||||
|
@ -98,10 +99,20 @@ impl VideoBackend for SoftwareVideoBackend {
|
|||
.get_last_picture()
|
||||
.expect("Decoding a picture should let us grab that picture");
|
||||
|
||||
//TODO: YUV 4:2:0 decoding
|
||||
//TODO: Construct a bitmap drawable for the renderer and hand
|
||||
//it back
|
||||
unimplemented!("oops");
|
||||
let (width, height) = picture
|
||||
.format()
|
||||
.into_width_and_height()
|
||||
.ok_or("H.263 decoder error!")?;
|
||||
let (y, b, r) = picture.as_yuv();
|
||||
let rgba = yuv420_to_rgba(y, b, r, width.into());
|
||||
|
||||
let handle = renderer.register_bitmap_raw(width.into(), height.into(), rgba)?;
|
||||
|
||||
Ok(BitmapInfo {
|
||||
handle,
|
||||
width,
|
||||
height,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue