diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2023-02-02 23:32:12 -0600 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-02-03 09:10:14 +0100 |
commit | 0f45153bbb5b0f0c8a4b9d891a0dce0537ee76c6 (patch) | |
tree | 04ac5a0120ea0c0eb7154ab1bd071d521f89430f /Userland | |
parent | 7b92eff4a6b85398407ebc1c3ecac94cdaf975a6 (diff) | |
download | serenity-0f45153bbb5b0f0c8a4b9d891a0dce0537ee76c6.zip |
LibVideo/VP9: Use proper indices for updating inter_mode probabilities
I previously changed it to use the absolute inter-prediction mode
values instead of the ones relative to NearestMv. That caused the
probability adaption to take invalid indices from the counts and broke
certain videos.
Now it will just convert to the PredictionMode enum when returning from
parse_inter_mode, which allows us to still use it the same as before.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/LookupTables.h | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/TreeParser.cpp | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/LookupTables.h b/Userland/Libraries/LibVideo/VP9/LookupTables.h index 67c58e334b..0756719465 100644 --- a/Userland/Libraries/LibVideo/VP9/LookupTables.h +++ b/Userland/Libraries/LibVideo/VP9/LookupTables.h @@ -132,10 +132,14 @@ static constexpr int tx_size_16_tree[4] = { -Transform_8x8, -Transform_16x16 }; static constexpr int tx_size_8_tree[2] = { -Transform_4x4, -Transform_8x8 }; +inline constexpr int inter_mode(PredictionMode mode) +{ + return to_underlying(mode) - to_underlying(PredictionMode::NearestMv); +} static constexpr int inter_mode_tree[6] = { - -to_underlying(PredictionMode::ZeroMv), 2, - -to_underlying(PredictionMode::NearestMv), 4, - -to_underlying(PredictionMode::NearMv), -to_underlying(PredictionMode::NewMv) + -inter_mode(PredictionMode::ZeroMv), 2, + -inter_mode(PredictionMode::NearestMv), 4, + -inter_mode(PredictionMode::NearMv), -inter_mode(PredictionMode::NewMv) }; static constexpr int interp_filter_tree[4] = { -EightTap, 2, diff --git a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp index 2af73aeb89..c0e9337e3e 100644 --- a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp +++ b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp @@ -215,9 +215,9 @@ ErrorOr<PredictionMode> TreeParser::parse_inter_mode(BitStream& bit_stream, Prob // Probabilities u8 const* probabilities = probability_table.inter_mode_probs()[mode_context_for_ref_frame_0]; - auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; })); - counter.m_counts_inter_mode[mode_context_for_ref_frame_0][to_underlying(value) - to_underlying(PredictionMode::NearestMv)]++; - return value; + auto value = TRY(parse_tree<u8>(bit_stream, tree, [&](u8 node) { return probabilities[node]; })); + counter.m_counts_inter_mode[mode_context_for_ref_frame_0][value]++; + return static_cast<PredictionMode>(value + to_underlying(PredictionMode::NearestMv)); } ErrorOr<InterpolationFilter> TreeParser::parse_interpolation_filter(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, FrameBlockContext above, FrameBlockContext left) |