1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00
serenity/Userland/Libraries/LibVideo/VP9/TreeParser.h

59 lines
1.4 KiB
C++

/*
* Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "BitStream.h"
#include "Enums.h"
#include "ProbabilityTables.h"
#include "SyntaxElementCounter.h"
namespace Video::VP9 {
class Decoder;
class TreeParser {
public:
explicit TreeParser(Decoder& decoder)
: m_decoder(decoder)
{
}
class TreeSelection {
public:
union TreeSelectionValue {
const int* m_tree;
int m_value;
};
TreeSelection(const int* values);
TreeSelection(int value);
bool is_single_value() const { return m_is_single_value; }
int get_single_value() const { return m_value.m_value; }
const int* get_tree_value() const { return m_value.m_tree; }
private:
bool m_is_single_value;
TreeSelectionValue m_value;
};
template<typename T = int>
T parse_tree(SyntaxElementType type);
TreeSelection select_tree(SyntaxElementType type);
u8 select_tree_probability(SyntaxElementType type, u8 node);
void count_syntax_element(SyntaxElementType type, int value);
private:
u8 calculate_partition_probability(u8 node);
u8 calculate_skip_probability();
Decoder& m_decoder;
// m_ctx is a member variable because it is required for syntax element counting (section 9.3.4)
u8 m_ctx { 0 };
};
}