mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
LibVideo/VP9: Refactor how above & left contexts are stored & cleared
These make more sense as Vectors, and it makes it much easier to manage their sizing.
This commit is contained in:
parent
91572a49c4
commit
cbff7c386a
2 changed files with 27 additions and 35 deletions
|
@ -719,20 +719,25 @@ bool Decoder::decode_tiles()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
void Decoder::clear_context(Vector<u8>& context, size_t size)
|
||||||
void clear_context(T* context, size_t size)
|
|
||||||
{
|
{
|
||||||
if (!(*context))
|
context.resize_and_keep_capacity(size);
|
||||||
*context = static_cast<T>(malloc(size));
|
__builtin_memset(context.data(), 0, sizeof(u8) * size);
|
||||||
else
|
}
|
||||||
__builtin_memset(*context, 0, size);
|
|
||||||
|
void Decoder::clear_context(Vector<Vector<u8>>& context, size_t outer_size, size_t inner_size)
|
||||||
|
{
|
||||||
|
if (context.size() < outer_size)
|
||||||
|
context.resize(outer_size);
|
||||||
|
for (auto& sub_vector : context)
|
||||||
|
clear_context(sub_vector, inner_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Decoder::clear_above_context()
|
bool Decoder::clear_above_context()
|
||||||
{
|
{
|
||||||
clear_context(&m_above_nonzero_context, sizeof(u8) * 3 * m_mi_cols * 2);
|
clear_context(m_above_nonzero_context, 2 * m_mi_cols, 3);
|
||||||
clear_context(&m_above_seg_pred_context, sizeof(u8) * m_mi_cols);
|
clear_context(m_above_seg_pred_context, m_mi_cols);
|
||||||
clear_context(&m_above_partition_context, sizeof(u8) * m_sb64_cols * 8);
|
clear_context(m_above_partition_context, m_sb64_cols * 8);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,9 +763,9 @@ bool Decoder::decode_tile()
|
||||||
|
|
||||||
bool Decoder::clear_left_context()
|
bool Decoder::clear_left_context()
|
||||||
{
|
{
|
||||||
clear_context(&m_left_nonzero_context, sizeof(u8) * 3 * m_mi_rows * 2);
|
clear_context(m_left_nonzero_context, 2 * m_mi_rows, 3);
|
||||||
clear_context(&m_left_seg_pred_context, sizeof(u8) * m_mi_rows);
|
clear_context(m_left_seg_pred_context, m_mi_rows);
|
||||||
clear_context(&m_left_partition_context, sizeof(u8) * m_sb64_rows * 8);
|
clear_context(m_left_partition_context, m_sb64_rows * 8);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,20 +1130,4 @@ void Decoder::dump_info()
|
||||||
dbgln("Interpolation filter: {}", (u8)m_interpolation_filter);
|
dbgln("Interpolation filter: {}", (u8)m_interpolation_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Decoder::~Decoder()
|
|
||||||
{
|
|
||||||
if (m_above_nonzero_context)
|
|
||||||
free(m_above_nonzero_context);
|
|
||||||
if (m_left_nonzero_context)
|
|
||||||
free(m_left_nonzero_context);
|
|
||||||
if (m_above_seg_pred_context)
|
|
||||||
free(m_above_seg_pred_context);
|
|
||||||
if (m_left_seg_pred_context)
|
|
||||||
free(m_left_seg_pred_context);
|
|
||||||
if (m_above_partition_context)
|
|
||||||
free(m_above_partition_context);
|
|
||||||
if (m_left_partition_context)
|
|
||||||
free(m_left_partition_context);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ class Decoder {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Decoder();
|
Decoder();
|
||||||
~Decoder();
|
|
||||||
bool parse_frame(ByteBuffer const&);
|
bool parse_frame(ByteBuffer const&);
|
||||||
void dump_info();
|
void dump_info();
|
||||||
|
|
||||||
|
@ -40,6 +39,10 @@ private:
|
||||||
return StudioSwing;
|
return StudioSwing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Utilities */
|
||||||
|
void clear_context(Vector<u8>& context, size_t size);
|
||||||
|
void clear_context(Vector<Vector<u8>>& context, size_t outer_size, size_t inner_size);
|
||||||
|
|
||||||
/* (6.2) Uncompressed Header Syntax */
|
/* (6.2) Uncompressed Header Syntax */
|
||||||
bool uncompressed_header();
|
bool uncompressed_header();
|
||||||
bool frame_sync_code();
|
bool frame_sync_code();
|
||||||
|
@ -158,12 +161,12 @@ private:
|
||||||
i8 m_loop_filter_ref_deltas[MAX_REF_FRAMES];
|
i8 m_loop_filter_ref_deltas[MAX_REF_FRAMES];
|
||||||
i8 m_loop_filter_mode_deltas[2];
|
i8 m_loop_filter_mode_deltas[2];
|
||||||
|
|
||||||
u8** m_above_nonzero_context { nullptr };
|
Vector<Vector<u8>> m_above_nonzero_context;
|
||||||
u8** m_left_nonzero_context { nullptr };
|
Vector<Vector<u8>> m_left_nonzero_context;
|
||||||
u8* m_above_seg_pred_context { nullptr };
|
Vector<u8> m_above_seg_pred_context;
|
||||||
u8* m_left_seg_pred_context { nullptr };
|
Vector<u8> m_left_seg_pred_context;
|
||||||
u8* m_above_partition_context { nullptr };
|
Vector<u8> m_above_partition_context;
|
||||||
u8* m_left_partition_context { nullptr };
|
Vector<u8> m_left_partition_context;
|
||||||
u32 m_mi_row_start { 0 };
|
u32 m_mi_row_start { 0 };
|
||||||
u32 m_mi_row_end { 0 };
|
u32 m_mi_row_end { 0 };
|
||||||
u32 m_mi_col_start { 0 };
|
u32 m_mi_col_start { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue