1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:57:44 +00:00

LibVideo/VP9: Store data used between decode_block calls in a struct

All state that needed to persist between calls to decode_block was
previously stored in plain Vector fields. This moves them into a struct
which sets a more explicit lifetime on that data. It may be possible to
store this data on the stack of a function with the appropriate
lifetime now that it is split into its own struct.
This commit is contained in:
Zaggy1024 2022-11-18 13:56:14 -06:00 committed by Andreas Kling
parent 9b6ab1d4e5
commit 44413c31a9
6 changed files with 258 additions and 316 deletions

View file

@ -7,6 +7,8 @@
#pragma once
#include <AK/Array.h>
#include "Enums.h"
#include "MotionVector.h"
@ -17,7 +19,7 @@ struct Pair {
T a;
T b;
T& operator[](size_t index)
T& operator[](u8 index)
{
if (index == 0)
return a;
@ -25,6 +27,11 @@ struct Pair {
return b;
VERIFY_NOT_REACHED();
}
T const& operator[](u8 index) const
{
return const_cast<Pair<T>&>(*this)[index];
}
};
typedef Pair<ReferenceFrameType> ReferenceFramePair;
@ -38,4 +45,21 @@ struct TokensContext {
u8 m_context_index;
};
// Block context that is kept for the lifetime of a frame.
struct FrameBlockContext {
bool is_intra_predicted() const { return ref_frames[0] == ReferenceFrameType::None; }
bool is_single_reference() const { return ref_frames[1] == ReferenceFrameType::None; }
MotionVectorPair primary_motion_vector_pair() const { return { sub_block_motion_vectors[0][3], sub_block_motion_vectors[1][3] }; }
bool is_available { false };
bool skip_coefficients { false };
TXSize tx_size { TXSize::TX_4x4 };
PredictionMode y_mode { PredictionMode::DcPred };
Array<PredictionMode, 4> sub_modes { PredictionMode::DcPred, PredictionMode::DcPred, PredictionMode::DcPred, PredictionMode::DcPred };
InterpolationFilter interpolation_filter { InterpolationFilter::EightTap };
ReferenceFramePair ref_frames { ReferenceFrameType::None, ReferenceFrameType::None };
Array<Array<MotionVector, 4>, 2> sub_block_motion_vectors {};
u8 segment_id { 0 };
};
}