From 8cd72ad1ed00ea09133284d71e662429e5b21be3 Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Tue, 18 Apr 2023 03:55:09 -0500 Subject: [PATCH] LibVideo/VP9: Use the Y scale value in `predict_inter_block()` A typo caused the Y scale value to never be used, so if a reference frame's aspect ratio didn't match up with the current frame's, it would decode incorrectly. Some comments have been added to clarify the frame-constants used in the function as well. --- Userland/Libraries/LibVideo/VP9/Decoder.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.cpp b/Userland/Libraries/LibVideo/VP9/Decoder.cpp index d24decb0fb..b177b1ffcd 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.cpp +++ b/Userland/Libraries/LibVideo/VP9/Decoder.cpp @@ -793,6 +793,7 @@ DecoderErrorOr Decoder::prepare_referenced_frame(Gfx::Size frame_size // A variable yScale is set equal to (RefFrameHeight[ refIdx ] << REF_SCALE_SHIFT) / FrameHeight. // (xScale and yScale specify the size of the reference frame relative to the current frame in units where 16 is // equivalent to the reference frame having the same size.) + // NOTE: This spec note above seems to be incorrect. The 1:1 scale value would be 16,384. i32 x_scale = (reference_frame.size.width() << REF_SCALE_SHIFT) / frame_size.width(); i32 y_scale = (reference_frame.size.height() << REF_SCALE_SHIFT) / frame_size.height(); @@ -857,8 +858,11 @@ DecoderErrorOr Decoder::predict_inter_block(u8 plane, BlockContext const& auto reference_frame_index = block_context.frame_context.reference_frame_indices[block_context.reference_frame_types[reference_index] - ReferenceFrameType::LastFrame]; auto const& reference_frame = m_parser->m_reference_frames[reference_frame_index]; + // Scale values range from 8192 to 262144. + // 16384 = 1:1, higher values indicate the reference frame is larger than the current frame. auto x_scale = reference_frame.x_scale; - auto y_scale = reference_frame.x_scale; + auto y_scale = reference_frame.y_scale; + auto scaled_step_x = reference_frame.scaled_step_x; auto scaled_step_y = reference_frame.scaled_step_y;