mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 20:07:35 +00:00
LibVideo/VP9: Implement unscaled fast paths in inter prediction
Inter-prediction convolution filters are selected based on the subpixel position determined for the motion vector relative to the block being predicted. The subpixel position 0 only uses one single sample in the center of the convolution, not averaging any other samples. Let's call this a copy. Reference frames can also be a different size relative to the frame being predicted, but in almost every case, that scale will be 1:1 for every single frame in a video. Taking into account these facts, we can create multiple fast paths for inter prediction. These fast paths are only active when scaling is 1:1. If we are doing a copy in both dimensions, then we can do a straight memcpy from the reference frame to the output block buffer. In videos where there is no motion, this is a dramatic speedup. If we are doing a copy in one dimension, we can just do one convolution and average directly into the output block buffer. If we aren't doing a copy in either dimension, we can still cut out a few operations from the convolution loops, since we only need to advance our samples by whole pixels instead of subpixels. These fast paths result in about a 34% improvement (~31.2s -> ~20.6s) in a video which relies heavily on intra-predicted blocks due to high motion. In videos with less motion, the improvement will be even greater. Also, note that the accumulators in these faster loops are only 16-bit. High bit-depth videos will overflow those, so for now the fast path is only used for 8-bit videos.
This commit is contained in:
parent
8cd72ad1ed
commit
8ad0dff5c2
3 changed files with 157 additions and 52 deletions
|
@ -336,7 +336,7 @@ static constexpr u8 counter_to_context[19] = {
|
|||
};
|
||||
|
||||
// Coefficients used by predict_inter
|
||||
static constexpr i32 subpel_filters[4][16][8] = {
|
||||
static constexpr i16 subpel_filters[4][16][8] = {
|
||||
{ { 0, 0, 0, 128, 0, 0, 0, 0 },
|
||||
{ 0, 1, -5, 126, 8, -3, 1, 0 },
|
||||
{ -1, 3, -10, 122, 18, -6, 2, 0 },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue