summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVideo
diff options
context:
space:
mode:
authorFalseHonesty <thefalsehonesty@gmail.com>2021-06-05 16:28:08 -0400
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-06-12 22:48:28 +0430
commit18759ff56ddc2b789d1c19ac676861b17d167397 (patch)
tree2f8225e9b3203ba6be316d37ace95ea817a7fda9 /Userland/Libraries/LibVideo
parent8dd9d1bbdb4b98dd1488bfe80561b9be31cab805 (diff)
downloadserenity-18759ff56ddc2b789d1c19ac676861b17d167397.zip
LibVideo/VP9: Implement syntax element counter
Diffstat (limited to 'Userland/Libraries/LibVideo')
-rw-r--r--Userland/Libraries/LibVideo/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.cpp37
-rw-r--r--Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h74
3 files changed, 112 insertions, 0 deletions
diff --git a/Userland/Libraries/LibVideo/CMakeLists.txt b/Userland/Libraries/LibVideo/CMakeLists.txt
index 49e6b94c90..ac59a71380 100644
--- a/Userland/Libraries/LibVideo/CMakeLists.txt
+++ b/Userland/Libraries/LibVideo/CMakeLists.txt
@@ -4,6 +4,7 @@ set(SOURCES
VP9/Enums.h
VP9/ProbabilityTables.cpp
VP9/Symbols.h
+ VP9/SyntaxElementCounter.cpp
)
serenity_lib(LibVideo video)
diff --git a/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.cpp b/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.cpp
new file mode 100644
index 0000000000..f6ad6bd820
--- /dev/null
+++ b/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include "SyntaxElementCounter.h"
+
+namespace Video::VP9 {
+
+void SyntaxElementCounter::clear_counts()
+{
+ __builtin_memset(counts_intra_mode, 0, BLOCK_SIZE_GROUPS * INTRA_MODES);
+ __builtin_memset(counts_uv_mode, 0, INTRA_MODES * INTRA_MODES);
+ __builtin_memset(counts_partition, 0, PARTITION_CONTEXTS * PARTITION_TYPES);
+ __builtin_memset(counts_interp_filter, 0, INTERP_FILTER_CONTEXTS * SWITCHABLE_FILTERS);
+ __builtin_memset(counts_inter_mode, 0, INTER_MODE_CONTEXTS * INTER_MODES);
+ __builtin_memset(counts_tx_size, 0, TX_SIZES * TX_SIZE_CONTEXTS * TX_SIZES);
+ __builtin_memset(counts_is_inter, 0, IS_INTER_CONTEXTS * 2);
+ __builtin_memset(counts_comp_mode, 0, COMP_MODE_CONTEXTS * 2);
+ __builtin_memset(counts_single_ref, 0, REF_CONTEXTS * 2 * 2);
+ __builtin_memset(counts_comp_ref, 0, REF_CONTEXTS * 2);
+ __builtin_memset(counts_skip, 0, SKIP_CONTEXTS * 2);
+ __builtin_memset(counts_mv_joint, 0, MV_JOINTS);
+ __builtin_memset(counts_mv_sign, 0, 2 * 2);
+ __builtin_memset(counts_mv_class, 0, 2 * MV_CLASSES);
+ __builtin_memset(counts_mv_class0_bit, 0, 2 * CLASS0_SIZE);
+ __builtin_memset(counts_mv_class0_fr, 0, 2 * CLASS0_SIZE * MV_FR_SIZE);
+ __builtin_memset(counts_mv_class0_hp, 0, 2 * 2);
+ __builtin_memset(counts_mv_bits, 0, 2 * MV_OFFSET_BITS * 2);
+ __builtin_memset(counts_mv_fr, 0, 2 * MV_FR_SIZE);
+ __builtin_memset(counts_mv_hp, 0, 2 * 2);
+ __builtin_memset(counts_token, 0, TX_SIZES * BLOCK_TYPES * REF_TYPES * COEF_BANDS * PREV_COEF_CONTEXTS * UNCONSTRAINED_NODES);
+ __builtin_memset(counts_more_coefs, 0, TX_SIZES * BLOCK_TYPES * REF_TYPES * COEF_BANDS * PREV_COEF_CONTEXTS * 2);
+}
+
+}
diff --git a/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h b/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h
new file mode 100644
index 0000000000..78ec1c2865
--- /dev/null
+++ b/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include "Symbols.h"
+#include <AK/Types.h>
+
+namespace Video::VP9 {
+
+enum class SyntaxElementType {
+ Partition,
+ DefaultIntraMode,
+ DefaultUVMode,
+ IntraMode,
+ SubIntraMode,
+ UVMode,
+ SegmentID,
+ Skip,
+ SegIDPredicted,
+ IsInter,
+ CompMode,
+ CompRef,
+ SingleRefP1,
+ SingleRefP2,
+ MVSign,
+ MVClass0Bit,
+ MVBit,
+ TXSize,
+ InterMode,
+ InterpFilter,
+ MVJoint,
+ MVClass,
+ MVClass0FR,
+ MVClass0HP,
+ MVFR,
+ MVHP,
+ Token,
+ MoreCoefs,
+};
+
+class SyntaxElementCounter final {
+public:
+ void clear_counts();
+
+private:
+ u8 counts_intra_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
+ u8 counts_uv_mode[INTRA_MODES][INTRA_MODES];
+ u8 counts_partition[PARTITION_CONTEXTS][PARTITION_TYPES];
+ u8 counts_interp_filter[INTERP_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
+ u8 counts_inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
+ u8 counts_tx_size[TX_SIZES][TX_SIZE_CONTEXTS][TX_SIZES];
+ u8 counts_is_inter[IS_INTER_CONTEXTS][2];
+ u8 counts_comp_mode[COMP_MODE_CONTEXTS][2];
+ u8 counts_single_ref[REF_CONTEXTS][2][2];
+ u8 counts_comp_ref[REF_CONTEXTS][2];
+ u8 counts_skip[SKIP_CONTEXTS][2];
+ u8 counts_mv_joint[MV_JOINTS];
+ u8 counts_mv_sign[2][2];
+ u8 counts_mv_class[2][MV_CLASSES];
+ u8 counts_mv_class0_bit[2][CLASS0_SIZE];
+ u8 counts_mv_class0_fr[2][CLASS0_SIZE][MV_FR_SIZE];
+ u8 counts_mv_class0_hp[2][2];
+ u8 counts_mv_bits[2][MV_OFFSET_BITS][2];
+ u8 counts_mv_fr[2][MV_FR_SIZE];
+ u8 counts_mv_hp[2][2];
+ u8 counts_token[TX_SIZES][BLOCK_TYPES][REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES];
+ u8 counts_more_coefs[TX_SIZES][BLOCK_TYPES][REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][2];
+};
+
+}