video: Wire up DefineVideoStream smoothing flag to the renderer

With all the weird logic for when it actually takes effect
This commit is contained in:
TÖRÖK Attila 2021-09-20 12:01:37 +02:00 committed by kmeisthax
parent 2aee3555ab
commit 0a2767fcb4
1 changed files with 22 additions and 2 deletions

View File

@ -19,6 +19,8 @@ use std::collections::{BTreeMap, BTreeSet};
use std::sync::Arc;
use swf::{CharacterId, DefineVideoStream, VideoFrame};
use super::StageQuality;
/// A Video display object is a high-level interface to a video player.
///
/// Video data may be embedded within a variety of container formats, including
@ -440,7 +442,9 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
context.transform_stack.push(&*self.base().transform());
if let Some((_frame_id, ref bitmap)) = self.0.read().decoded_frame {
let read = self.0.read();
if let Some((_frame_id, ref bitmap)) = read.decoded_frame {
let mut transform = context.transform_stack.transform().clone();
let bounds = self.self_bounds();
@ -451,9 +455,25 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
bounds.height().to_pixels() as f32 / bitmap.height as f32,
);
let (smoothed_flag, num_frames, version) = match &*read.source.read() {
VideoSource::Swf {
streamdef,
frames,
movie,
} => (streamdef.is_smoothed, frames.len(), movie.version()),
};
let smoothing = match (context.stage.quality(), version) {
(StageQuality::Low, _) => false,
(_, 8..) => smoothed_flag,
(StageQuality::Medium, _) => false,
(StageQuality::High, _) => num_frames == 1,
(_, _) => true,
};
context
.renderer
.render_bitmap(bitmap.handle, &transform, false);
.render_bitmap(bitmap.handle, &transform, smoothing);
} else {
log::warn!("Video has no decoded frame to render.");
}