1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:07:45 +00:00

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.
This commit is contained in:
Zaggy1024 2023-04-18 03:55:09 -05:00 committed by Tim Flynn
parent 7a58577fee
commit 8cd72ad1ed

View file

@ -793,6 +793,7 @@ DecoderErrorOr<void> Decoder::prepare_referenced_frame(Gfx::Size<u32> frame_size
// A variable yScale is set equal to (RefFrameHeight[ refIdx ] << REF_SCALE_SHIFT) / FrameHeight. // 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 // (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.) // 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 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(); i32 y_scale = (reference_frame.size.height() << REF_SCALE_SHIFT) / frame_size.height();
@ -857,8 +858,11 @@ DecoderErrorOr<void> 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 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]; 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 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_x = reference_frame.scaled_step_x;
auto scaled_step_y = reference_frame.scaled_step_y; auto scaled_step_y = reference_frame.scaled_step_y;