video: Add software video crate, moved VideoDecoder to it
This commit is contained in:
parent
91ae384682
commit
7c839ef8ae
|
@ -3082,6 +3082,7 @@ dependencies = [
|
|||
"ruffle_macros",
|
||||
"ruffle_render",
|
||||
"ruffle_video",
|
||||
"ruffle_video_software",
|
||||
"ruffle_wstr",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -3228,6 +3229,16 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruffle_video_software"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"generational-arena",
|
||||
"ruffle_video",
|
||||
"swf",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruffle_web"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -17,6 +17,7 @@ members = [
|
|||
"render/webgl",
|
||||
|
||||
"video",
|
||||
"video/software",
|
||||
|
||||
"tests",
|
||||
"tests/input-format",
|
||||
|
|
|
@ -17,6 +17,7 @@ log = "0.4"
|
|||
minimp3 = { version = "0.5.1", optional = true }
|
||||
ruffle_render = { path = "../render" }
|
||||
ruffle_video = { path = "../video" }
|
||||
ruffle_video_software = { path = "../video/software" }
|
||||
ruffle_macros = { path = "macros" }
|
||||
ruffle_wstr = { path = "../wstr" }
|
||||
swf = { path = "../swf" }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::backend::video::software::VideoDecoder;
|
||||
use h263_rs::parser::H263Reader;
|
||||
use h263_rs::{DecoderOption, H263State, PictureTypeCode};
|
||||
use h263_rs_yuv::bt601::yuv420_to_rgba;
|
||||
use ruffle_video::error::Error;
|
||||
use ruffle_video::frame::{DecodedFrame, EncodedFrame, FrameDependency};
|
||||
use ruffle_video_software::decoder::VideoDecoder;
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum H263Error {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// This module is heavily based on flashsv.rs from NihAV,
|
||||
// written by Kostya Shishkov, with permission.
|
||||
|
||||
use crate::backend::video::software::VideoDecoder;
|
||||
use ruffle_video::error::Error;
|
||||
use ruffle_video_software::decoder::VideoDecoder;
|
||||
|
||||
use flate2::Decompress;
|
||||
use ruffle_video::frame::{DecodedFrame, EncodedFrame, FrameDependency};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::backend::video::software::VideoDecoder;
|
||||
use ruffle_video::error::Error;
|
||||
use ruffle_video_software::decoder::VideoDecoder;
|
||||
|
||||
use h263_rs_yuv::bt601::yuv420_to_rgba;
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ use ruffle_render::backend::RenderBackend;
|
|||
use ruffle_render::bitmap::{Bitmap, BitmapFormat, BitmapHandle, BitmapInfo};
|
||||
use ruffle_video::backend::VideoBackend;
|
||||
use ruffle_video::error::Error;
|
||||
use ruffle_video::frame::{DecodedFrame, EncodedFrame, FrameDependency};
|
||||
use ruffle_video::frame::{EncodedFrame, FrameDependency};
|
||||
use ruffle_video::VideoStreamHandle;
|
||||
use ruffle_video_software::decoder::VideoDecoder;
|
||||
use swf::{VideoCodec, VideoDeblocking};
|
||||
|
||||
pub mod decoders;
|
||||
|
@ -125,33 +126,3 @@ impl VideoStream {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for video decoders.
|
||||
/// This should be implemented for each video codec.
|
||||
trait VideoDecoder {
|
||||
/// Preload a frame.
|
||||
///
|
||||
/// No decoding is intended to happen at this point in time. Instead, the
|
||||
/// video data should be inspected to determine inter-frame dependencies
|
||||
/// between this and any previous frames in the stream.
|
||||
///
|
||||
/// Frames should be preloaded in the order that they are recieved.
|
||||
///
|
||||
/// Any dependencies listed here are inherent to the video bitstream. The
|
||||
/// containing video stream is also permitted to introduce additional
|
||||
/// interframe dependencies.
|
||||
fn preload_frame(&mut self, encoded_frame: EncodedFrame<'_>) -> Result<FrameDependency, Error>;
|
||||
|
||||
/// Decode a frame of a given video stream.
|
||||
///
|
||||
/// This function is provided the external index of the frame, the codec
|
||||
/// used to decode the data, and what codec to decode it with. The codec
|
||||
/// provided here must match the one used to register the video stream.
|
||||
///
|
||||
/// Frames may be decoded in any order that does not violate the frame
|
||||
/// dependencies declared by the output of `preload_video_stream_frame`.
|
||||
///
|
||||
/// The decoded frame should be returned. An `Error` can be returned if
|
||||
/// a drawable bitmap can not be produced.
|
||||
fn decode_frame(&mut self, encoded_frame: EncodedFrame<'_>) -> Result<DecodedFrame, Error>;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "ruffle_video_software"
|
||||
version = "0.1.0"
|
||||
authors = ["Ruffle LLC <ruffle@ruffle.rs>"]
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
ruffle_video = { path = ".." }
|
||||
swf = { path = "../../swf" }
|
||||
generational-arena = "0.2.8"
|
||||
thiserror = "1.0"
|
|
@ -0,0 +1,32 @@
|
|||
use ruffle_video::error::Error;
|
||||
use ruffle_video::frame::{DecodedFrame, EncodedFrame, FrameDependency};
|
||||
|
||||
/// Trait for video decoders.
|
||||
/// This should be implemented for each video codec.
|
||||
pub trait VideoDecoder {
|
||||
/// Preload a frame.
|
||||
///
|
||||
/// No decoding is intended to happen at this point in time. Instead, the
|
||||
/// video data should be inspected to determine inter-frame dependencies
|
||||
/// between this and any previous frames in the stream.
|
||||
///
|
||||
/// Frames should be preloaded in the order that they are recieved.
|
||||
///
|
||||
/// Any dependencies listed here are inherent to the video bitstream. The
|
||||
/// containing video stream is also permitted to introduce additional
|
||||
/// interframe dependencies.
|
||||
fn preload_frame(&mut self, encoded_frame: EncodedFrame<'_>) -> Result<FrameDependency, Error>;
|
||||
|
||||
/// Decode a frame of a given video stream.
|
||||
///
|
||||
/// This function is provided the external index of the frame, the codec
|
||||
/// used to decode the data, and what codec to decode it with. The codec
|
||||
/// provided here must match the one used to register the video stream.
|
||||
///
|
||||
/// Frames may be decoded in any order that does not violate the frame
|
||||
/// dependencies declared by the output of `preload_video_stream_frame`.
|
||||
///
|
||||
/// The decoded frame should be returned. An `Error` can be returned if
|
||||
/// a drawable bitmap can not be produced.
|
||||
fn decode_frame(&mut self, encoded_frame: EncodedFrame<'_>) -> Result<DecodedFrame, Error>;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
pub mod decoder;
|
Loading…
Reference in New Issue