diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2023-01-29 17:17:24 -0600 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-08 18:56:42 +0000 |
commit | c18728989e79260278567c9bfd3c5f47ba9b8636 (patch) | |
tree | 6d3afc41922cc2b40f86fdba029c6c654a7a0205 /Userland/Libraries/LibVideo/VP9 | |
parent | 24f30691292b355940e6b3541dd4179e2acca5db (diff) | |
download | serenity-c18728989e79260278567c9bfd3c5f47ba9b8636.zip |
LibVideo/VP9: Remove magic numbers for the uncompressed ref frames
This also adds a fixme to Symbols.h to group and rename the definitions
in the file.
Diffstat (limited to 'Userland/Libraries/LibVideo/VP9')
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Parser.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Symbols.h | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp index 77854b0e0d..02d6880356 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.cpp +++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp @@ -221,9 +221,9 @@ DecoderErrorOr<FrameContext> Parser::uncompressed_header() frame_size = TRY(parse_frame_size()); render_size = TRY(parse_render_size(frame_size)); } else { - reference_frames_to_update_flags = TRY_READ(m_bit_stream->read_f8()); - for (auto i = 0; i < 3; i++) { - frame_context.reference_frame_indices[i] = TRY_READ(m_bit_stream->read_bits(3)); + reference_frames_to_update_flags = TRY_READ(m_bit_stream->read_bits(NUM_REF_FRAMES)); + for (auto i = 0; i < REFS_PER_FRAME; i++) { + frame_context.reference_frame_indices[i] = TRY_READ(m_bit_stream->read_bits(LOG2_OF_NUM_REF_FRAMES)); frame_context.reference_frame_sign_biases[ReferenceFrameType::LastFrame + i] = TRY_READ(m_bit_stream->read_bit()); } frame_size = TRY(parse_frame_size_with_refs(frame_context.reference_frame_indices)); diff --git a/Userland/Libraries/LibVideo/VP9/Symbols.h b/Userland/Libraries/LibVideo/VP9/Symbols.h index 2f2d6af4ad..434b3a186c 100644 --- a/Userland/Libraries/LibVideo/VP9/Symbols.h +++ b/Userland/Libraries/LibVideo/VP9/Symbols.h @@ -9,6 +9,12 @@ namespace Video::VP9 { +// FIXME: These should be placed in logical groupings based on the +// context they are used in, and perhaps split into multiple +// files. While doing so, as many of these as possible should be +// renamed to be more human-readable, and most if not all should +// be constexpr variables rather than preprocessor definitions. + #define REFS_PER_FRAME 3 #define MV_FR_SIZE 4 #define MVREF_NEIGHBOURS 8 @@ -20,7 +26,8 @@ namespace Video::VP9 { #define MIN_TILE_WIDTH_B64 4 #define MAX_TILE_WIDTH_B64 64 #define MAX_MV_REF_CANDIDATES 2 -#define NUM_REF_FRAMES 8 +#define LOG2_OF_NUM_REF_FRAMES 3 +#define NUM_REF_FRAMES 1 << LOG2_OF_NUM_REF_FRAMES #define MAX_REF_FRAMES 4 #define IS_INTER_CONTEXTS 4 #define COMP_MODE_CONTEXTS 5 |