Skip to content

H.263 decoder + initial video support #2173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 21, 2021
Prev Previous commit
Next Next commit
video: Move software decoding into core now that we don't need to spe…
…cialize per-renderer
  • Loading branch information
kmeisthax committed Aug 21, 2021
commit df90e031d354e4147a20fe49f43840064a88487e
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 16 additions & 5 deletions core/src/backend/video/software.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)?
Expand Down Expand Up @@ -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,
})
}
}
}
Expand Down