1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 03:07:35 +00:00

LibVideo/VP9: Pre-calculate the quantizers at the start of each frame

Quantizers are a constant for the whole frame, except when segment
features override them, in which case they are a constant per segment
ID. We take advantage of this by pre-calculating those after reading
the quantization parameters and segmentation features for a frame.
This results in a small 1.5% improvement (~12.9s -> ~12.7s).
This commit is contained in:
Zaggy1024 2023-04-17 00:27:13 -05:00 committed by Tim Flynn
parent 094b0d8a78
commit 90c0e1ad8f
6 changed files with 104 additions and 70 deletions

View file

@ -32,6 +32,14 @@ enum class FrameShowMode {
DoNotShowFrame,
};
struct Quantizers {
u16 y_ac_quantizer { 0 };
u16 uv_ac_quantizer { 0 };
u16 y_dc_quantizer { 0 };
u16 uv_dc_quantizer { 0 };
};
struct FrameContext {
public:
static ErrorOr<FrameContext> create(ReadonlyBytes data,
@ -126,15 +134,9 @@ public:
Array<i8, MAX_REF_FRAMES> loop_filter_reference_deltas;
Array<i8, 2> loop_filter_mode_deltas;
u8 base_quantizer_index { 0 };
i8 y_dc_quantizer_index_delta { 0 };
i8 uv_dc_quantizer_index_delta { 0 };
i8 uv_ac_quantizer_index_delta { 0 };
bool is_lossless() const
{
// From quantization_params( ) in the spec.
return base_quantizer_index == 0 && y_dc_quantizer_index_delta == 0 && uv_dc_quantizer_index_delta == 0 && uv_ac_quantizer_index_delta == 0;
}
// Set based on quantization_params( ) in the spec.
bool lossless { false };
Array<Quantizers, MAX_SEGMENTS> segment_quantizers;
bool segmentation_enabled { false };
// Note: We can use Optional<Array<...>> for these tree probabilities, but unfortunately it seems to have measurable performance overhead.