mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:57:44 +00:00
LibVideo/VP9: Fix rounding of components in the motion vector selection
The division in the `round_mv_...()` functions contained in the motion vector selection process was done by bit shifting right. However, since bit shifting negative values will truncate towards the negative end, it was flooring instead of rounding. This changes it to match the spec and rely on the compiler to simplify down to a bit shift.
This commit is contained in:
parent
7b10c8048c
commit
57c7389200
1 changed files with 4 additions and 4 deletions
|
@ -693,15 +693,15 @@ MotionVector Decoder::select_motion_vector(u8 plane, BlockContext const& block_c
|
|||
auto round_mv_comp_q2 = [&](MotionVector in) {
|
||||
// return (value < 0 ? value - 1 : value + 1) / 2
|
||||
return MotionVector {
|
||||
(in.row() < 0 ? in.row() - 1 : in.row() + 1) >> 1,
|
||||
(in.column() < 0 ? in.column() - 1 : in.column() + 1) >> 1
|
||||
(in.row() < 0 ? in.row() - 1 : in.row() + 1) / 2,
|
||||
(in.column() < 0 ? in.column() - 1 : in.column() + 1) / 2
|
||||
};
|
||||
};
|
||||
auto round_mv_comp_q4 = [&](MotionVector in) {
|
||||
// return (value < 0 ? value - 2 : value + 2) / 4
|
||||
return MotionVector {
|
||||
(in.row() < 0 ? in.row() - 2 : in.row() + 2) >> 2,
|
||||
(in.column() < 0 ? in.column() - 2 : in.column() + 2) >> 2
|
||||
(in.row() < 0 ? in.row() - 2 : in.row() + 2) / 4,
|
||||
(in.column() < 0 ? in.column() - 2 : in.column() + 2) / 4
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue