summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVideo
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2022-11-24 21:53:24 -0600
committerAndreas Kling <kling@serenityos.org>2022-11-30 08:28:30 +0100
commit396972bb695d14ac76a6fdd007c4578fc2d3a5cd (patch)
tree37ab0dc8ad608b4c1936e879f2473650947c6158 /Userland/Libraries/LibVideo
parentea7a6f343b30146adff271e93fb58e3460a35dc4 (diff)
downloadserenity-396972bb695d14ac76a6fdd007c4578fc2d3a5cd.zip
LibVideo/VP9: Retain adjacent block contexts storage between frames
Re-allocating the storage is unnecessary, since the size will rarely change during playback.
Diffstat (limited to 'Userland/Libraries/LibVideo')
-rw-r--r--Userland/Libraries/LibVideo/VP9/Context.h7
-rw-r--r--Userland/Libraries/LibVideo/VP9/Parser.cpp5
-rw-r--r--Userland/Libraries/LibVideo/VP9/Parser.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/Context.h b/Userland/Libraries/LibVideo/VP9/Context.h
index 69e6f06080..9e8d10a2af 100644
--- a/Userland/Libraries/LibVideo/VP9/Context.h
+++ b/Userland/Libraries/LibVideo/VP9/Context.h
@@ -253,6 +253,11 @@ struct ColorConfig {
struct FrameContext {
public:
+ FrameContext(Vector2D<FrameBlockContext>& contexts)
+ : m_block_contexts(contexts)
+ {
+ }
+
u8 profile { 0 };
FrameType type { FrameType::KeyFrame };
@@ -338,7 +343,7 @@ private:
// arrays instead.
// I think should also apply to other fields that are only accessed relative to the current block. Worth looking
// into how much of this context needs to be stored for the whole frame vs a row or column from the current tile.
- Vector2D<FrameBlockContext> m_block_contexts;
+ Vector2D<FrameBlockContext>& m_block_contexts;
};
struct TileContext {
diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp
index fc735d1f55..34f5950a9f 100644
--- a/Userland/Libraries/LibVideo/VP9/Parser.cpp
+++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp
@@ -147,7 +147,10 @@ DecoderErrorOr<ColorRange> Parser::read_color_range()
/* (6.2) */
DecoderErrorOr<FrameContext> Parser::uncompressed_header()
{
- FrameContext frame_context;
+ // NOTE: m_reusable_frame_block_contexts does not need to retain any data between frame decodes.
+ // This is only stored so that we don't need to allocate a frame's block contexts on each
+ // call to this function, since it will rarely change sizes.
+ FrameContext frame_context { m_reusable_frame_block_contexts };
frame_context.color_config = m_previous_color_config;
auto frame_marker = TRY_READ(m_bit_stream->read_bits(2));
diff --git a/Userland/Libraries/LibVideo/VP9/Parser.h b/Userland/Libraries/LibVideo/VP9/Parser.h
index 9a2c513383..b572508530 100644
--- a/Userland/Libraries/LibVideo/VP9/Parser.h
+++ b/Userland/Libraries/LibVideo/VP9/Parser.h
@@ -175,6 +175,7 @@ private:
ReferenceFramePair m_comp_var_ref;
bool m_use_prev_frame_mvs;
+ Vector2D<FrameBlockContext> m_reusable_frame_block_contexts;
Vector2D<PersistentBlockContext> m_previous_block_contexts;
// Indexed by ReferenceFrame enum.
u8 m_mode_context[4] { INVALID_CASE };