core: Rename the video dependency enums to better describe their meaning.

This commit is contained in:
David Wendt 2021-02-11 22:06:16 -05:00 committed by Mike Welsh
parent 4d0b73feeb
commit 5fcdb79528
2 changed files with 22 additions and 9 deletions

View File

@ -33,15 +33,28 @@ impl<'a> EncodedFrame<'a> {
}
/// What dependencies a given video frame has on any previous frames.
#[derive(Copy, Clone, Debug)]
pub enum FrameDependency {
/// This frame has no reference frames and can be seeked to at any time.
Keyframe,
None,
/// This frame has one reference frame which must be completely decoded
/// before this frame can be decoded.
/// This frame has some number of reference frames that prohibit any
/// out-of-order decoding.
///
/// The reference frame is the previous frame in the video stream.
LastFrame,
/// The only legal way to decode a `Past` frame is to decode every prior
/// frame from the last `None` frame. In the event that there is no prior
/// `None` frame, then video decoding should start from the beginning.
Past,
}
impl FrameDependency {
/// Determine if this given frame is a keyframe.
///
/// A keyframe is a frame that can be independently seeked to without
/// decoding any prior or future frames.
pub fn is_keyframe(self) -> bool {
matches!(self, FrameDependency::None)
}
}
/// A backend that provides access to some number of video decoders.
@ -112,7 +125,7 @@ pub struct NullVideoBackend {
/// Specifically:
///
/// * Registering a video stream succeeds but does nothing
/// * All video frames are silently marked as keyframes
/// * All video frames are silently marked as keyframes (`None` dependency)
/// * Video stream decoding fails with an error that video decoding is
/// unimplemented
impl NullVideoBackend {
@ -145,7 +158,7 @@ impl VideoBackend for NullVideoBackend {
_stream: VideoStreamHandle,
_encoded_frame: EncodedFrame<'_>,
) -> Result<FrameDependency, Error> {
Ok(FrameDependency::Keyframe)
Ok(FrameDependency::None)
}
fn decode_video_stream_frame(

View File

@ -3,7 +3,7 @@
use crate::avm1::{Object as Avm1Object, StageObject as Avm1StageObject};
use crate::avm2::{Object as Avm2Object, StageObject as Avm2StageObject};
use crate::backend::render::BitmapHandle;
use crate::backend::video::{EncodedFrame, FrameDependency, VideoStreamHandle};
use crate::backend::video::{EncodedFrame, VideoStreamHandle};
use crate::bounding_box::BoundingBox;
use crate::collect::CollectWrapper;
use crate::context::{RenderContext, UpdateContext};
@ -267,7 +267,7 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
);
match dep {
Ok(FrameDependency::Keyframe) => {
Ok(d) if d.is_keyframe() => {
keyframes.insert(*frame_id);
}
Ok(_) => {}