summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVideo/VP9
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2022-10-08 23:03:31 -0500
committerAndrew Kaster <andrewdkaster@gmail.com>2022-10-09 20:32:40 -0600
commit50d4217dbcafe82c0ea1df914e6c5b73c4e2eeae (patch)
tree09ef48a01fadde85e384037b0557cf798a56e9c0 /Userland/Libraries/LibVideo/VP9
parent17107303f00a233da8a8f8dd37317e49bc272c93 (diff)
downloadserenity-50d4217dbcafe82c0ea1df914e6c5b73c4e2eeae.zip
LibVideo: Look up interpolation filter probability correctly
The above interpolation filter mode was being taken from the left side instead, causing some parsing errors. This also changes the magic number 3 to SWITCHABLE_FILTERS. Unfortunately, the spec uses the magic number, so this value was taken instead from the reference codec, libvpx.
Diffstat (limited to 'Userland/Libraries/LibVideo/VP9')
-rw-r--r--Userland/Libraries/LibVideo/VP9/TreeParser.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp
index 94d0ad698d..63179c3e70 100644
--- a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp
+++ b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp
@@ -575,18 +575,23 @@ u8 TreeParser::calculate_inter_mode_probability(u8 node)
u8 TreeParser::calculate_interp_filter_probability(u8 node)
{
+ // NOTE: SWITCHABLE_FILTERS is not used in the spec for this function. Therefore, the number
+ // was demystified by referencing the reference codec libvpx:
+ // https://github.com/webmproject/libvpx/blob/705bf9de8c96cfe5301451f1d7e5c90a41c64e5f/vp9/common/vp9_pred_common.h#L69
auto left_interp = (AVAIL_L && m_decoder.m_left_ref_frame[0] > IntraFrame)
- ? m_decoder.m_interp_filters[m_decoder.m_mi_row * m_decoder.m_mi_cols + m_decoder.m_mi_col - 1]
- : 3;
+ ? m_decoder.m_interp_filters[m_decoder.get_image_index(m_decoder.m_mi_row, m_decoder.m_mi_col - 1)]
+ : SWITCHABLE_FILTERS;
auto above_interp = (AVAIL_U && m_decoder.m_above_ref_frame[0] > IntraFrame)
- ? m_decoder.m_interp_filters[m_decoder.m_mi_row * m_decoder.m_mi_cols + m_decoder.m_mi_col - 1]
- : 3;
- if (left_interp == above_interp || (left_interp != 3 && above_interp == 3))
+ ? m_decoder.m_interp_filters[m_decoder.get_image_index(m_decoder.m_mi_row - 1, m_decoder.m_mi_col)]
+ : SWITCHABLE_FILTERS;
+ if (left_interp == above_interp)
m_ctx = left_interp;
- else if (left_interp == 3 && above_interp != 3)
+ else if (left_interp == SWITCHABLE_FILTERS)
m_ctx = above_interp;
+ else if (above_interp == SWITCHABLE_FILTERS)
+ m_ctx = left_interp;
else
- m_ctx = 3;
+ m_ctx = SWITCHABLE_FILTERS;
return m_decoder.m_probability_tables->interp_filter_probs()[m_ctx][node];
}