mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
LibVideo/VP9: Use u32 to store the parsed value counts
There were rare cases in which u8 was not large enough for the total count of values read, and increasing this to u32 should have no real effect on performance (hopefully).
This commit is contained in:
parent
69e9f9ff63
commit
7b92eff4a6
5 changed files with 74 additions and 79 deletions
|
@ -228,7 +228,7 @@ u8 Decoder::merge_prob(u8 pre_prob, u32 count_0, u32 count_1, u8 count_sat, u8 m
|
||||||
return round_2(pre_prob * (256 - factor) + (prob * factor), 8);
|
return round_2(pre_prob * (256 - factor) + (prob * factor), 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Decoder::merge_probs(int const* tree, int index, u8* probs, u8* counts, u8 count_sat, u8 max_update_factor)
|
u32 Decoder::merge_probs(int const* tree, int index, u8* probs, u32* counts, u8 count_sat, u8 max_update_factor)
|
||||||
{
|
{
|
||||||
auto s = tree[index];
|
auto s = tree[index];
|
||||||
auto left_count = (s <= 0) ? counts[-s] : merge_probs(tree, s, probs, counts, count_sat, max_update_factor);
|
auto left_count = (s <= 0) ? counts[-s] : merge_probs(tree, s, probs, counts, count_sat, max_update_factor);
|
||||||
|
@ -329,12 +329,12 @@ DecoderErrorOr<void> Decoder::adapt_non_coef_probs(FrameContext const& frame_con
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decoder::adapt_probs(int const* tree, u8* probs, u8* counts)
|
void Decoder::adapt_probs(int const* tree, u8* probs, u32* counts)
|
||||||
{
|
{
|
||||||
merge_probs(tree, 0, probs, counts, COUNT_SAT, MAX_UPDATE_FACTOR);
|
merge_probs(tree, 0, probs, counts, COUNT_SAT, MAX_UPDATE_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Decoder::adapt_prob(u8 prob, u8 counts[2])
|
u8 Decoder::adapt_prob(u8 prob, u32 counts[2])
|
||||||
{
|
{
|
||||||
return merge_prob(prob, counts[0], counts[1], COUNT_SAT, MAX_UPDATE_FACTOR);
|
return merge_prob(prob, counts[0], counts[1], COUNT_SAT, MAX_UPDATE_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,11 @@ private:
|
||||||
|
|
||||||
/* (8.4) Probability Adaptation Process */
|
/* (8.4) Probability Adaptation Process */
|
||||||
u8 merge_prob(u8 pre_prob, u32 count_0, u32 count_1, u8 count_sat, u8 max_update_factor);
|
u8 merge_prob(u8 pre_prob, u32 count_0, u32 count_1, u8 count_sat, u8 max_update_factor);
|
||||||
u32 merge_probs(int const* tree, int index, u8* probs, u8* counts, u8 count_sat, u8 max_update_factor);
|
u32 merge_probs(int const* tree, int index, u8* probs, u32* counts, u8 count_sat, u8 max_update_factor);
|
||||||
DecoderErrorOr<void> adapt_coef_probs(bool is_inter_predicted_frame);
|
DecoderErrorOr<void> adapt_coef_probs(bool is_inter_predicted_frame);
|
||||||
DecoderErrorOr<void> adapt_non_coef_probs(FrameContext const&);
|
DecoderErrorOr<void> adapt_non_coef_probs(FrameContext const&);
|
||||||
void adapt_probs(int const* tree, u8* probs, u8* counts);
|
void adapt_probs(int const* tree, u8* probs, u32* counts);
|
||||||
u8 adapt_prob(u8 prob, u8 counts[2]);
|
u8 adapt_prob(u8 prob, u32 counts[2]);
|
||||||
|
|
||||||
/* (8.5) Prediction Processes */
|
/* (8.5) Prediction Processes */
|
||||||
// (8.5.1) Intra prediction process
|
// (8.5.1) Intra prediction process
|
||||||
|
|
|
@ -10,28 +10,28 @@ namespace Video::VP9 {
|
||||||
|
|
||||||
void SyntaxElementCounter::clear_counts()
|
void SyntaxElementCounter::clear_counts()
|
||||||
{
|
{
|
||||||
__builtin_memset(m_counts_intra_mode, 0, BLOCK_SIZE_GROUPS * INTRA_MODES);
|
__builtin_memset(m_counts_intra_mode, 0, sizeof(m_counts_intra_mode));
|
||||||
__builtin_memset(m_counts_uv_mode, 0, INTRA_MODES * INTRA_MODES);
|
__builtin_memset(m_counts_uv_mode, 0, sizeof(m_counts_uv_mode));
|
||||||
__builtin_memset(m_counts_partition, 0, PARTITION_CONTEXTS * PARTITION_TYPES);
|
__builtin_memset(m_counts_partition, 0, sizeof(m_counts_partition));
|
||||||
__builtin_memset(m_counts_interp_filter, 0, INTERP_FILTER_CONTEXTS * SWITCHABLE_FILTERS);
|
__builtin_memset(m_counts_interp_filter, 0, sizeof(m_counts_interp_filter));
|
||||||
__builtin_memset(m_counts_inter_mode, 0, INTER_MODE_CONTEXTS * INTER_MODES);
|
__builtin_memset(m_counts_inter_mode, 0, sizeof(m_counts_inter_mode));
|
||||||
__builtin_memset(m_counts_tx_size, 0, TX_SIZES * TX_SIZE_CONTEXTS * TX_SIZES);
|
__builtin_memset(m_counts_tx_size, 0, sizeof(m_counts_tx_size));
|
||||||
__builtin_memset(m_counts_is_inter, 0, IS_INTER_CONTEXTS * 2);
|
__builtin_memset(m_counts_is_inter, 0, sizeof(m_counts_is_inter));
|
||||||
__builtin_memset(m_counts_comp_mode, 0, COMP_MODE_CONTEXTS * 2);
|
__builtin_memset(m_counts_comp_mode, 0, sizeof(m_counts_comp_mode));
|
||||||
__builtin_memset(m_counts_single_ref, 0, REF_CONTEXTS * 2 * 2);
|
__builtin_memset(m_counts_single_ref, 0, sizeof(m_counts_single_ref));
|
||||||
__builtin_memset(m_counts_comp_ref, 0, REF_CONTEXTS * 2);
|
__builtin_memset(m_counts_comp_ref, 0, sizeof(m_counts_comp_ref));
|
||||||
__builtin_memset(m_counts_skip, 0, SKIP_CONTEXTS * 2);
|
__builtin_memset(m_counts_skip, 0, sizeof(m_counts_skip));
|
||||||
__builtin_memset(m_counts_mv_joint, 0, MV_JOINTS);
|
__builtin_memset(m_counts_mv_joint, 0, sizeof(m_counts_mv_joint));
|
||||||
__builtin_memset(m_counts_mv_sign, 0, 2 * 2);
|
__builtin_memset(m_counts_mv_sign, 0, sizeof(m_counts_mv_sign));
|
||||||
__builtin_memset(m_counts_mv_class, 0, 2 * MV_CLASSES);
|
__builtin_memset(m_counts_mv_class, 0, sizeof(m_counts_mv_class));
|
||||||
__builtin_memset(m_counts_mv_class0_bit, 0, 2 * CLASS0_SIZE);
|
__builtin_memset(m_counts_mv_class0_bit, 0, sizeof(m_counts_mv_class0_bit));
|
||||||
__builtin_memset(m_counts_mv_class0_fr, 0, 2 * CLASS0_SIZE * MV_FR_SIZE);
|
__builtin_memset(m_counts_mv_class0_fr, 0, sizeof(m_counts_mv_class0_fr));
|
||||||
__builtin_memset(m_counts_mv_class0_hp, 0, 2 * 2);
|
__builtin_memset(m_counts_mv_class0_hp, 0, sizeof(m_counts_mv_class0_hp));
|
||||||
__builtin_memset(m_counts_mv_bits, 0, 2 * MV_OFFSET_BITS * 2);
|
__builtin_memset(m_counts_mv_bits, 0, sizeof(m_counts_mv_bits));
|
||||||
__builtin_memset(m_counts_mv_fr, 0, 2 * MV_FR_SIZE);
|
__builtin_memset(m_counts_mv_fr, 0, sizeof(m_counts_mv_fr));
|
||||||
__builtin_memset(m_counts_mv_hp, 0, 2 * 2);
|
__builtin_memset(m_counts_mv_hp, 0, sizeof(m_counts_mv_hp));
|
||||||
__builtin_memset(m_counts_token, 0, TX_SIZES * BLOCK_TYPES * REF_TYPES * COEF_BANDS * PREV_COEF_CONTEXTS * UNCONSTRAINED_NODES);
|
__builtin_memset(m_counts_token, 0, sizeof(m_counts_token));
|
||||||
__builtin_memset(m_counts_more_coefs, 0, TX_SIZES * BLOCK_TYPES * REF_TYPES * COEF_BANDS * PREV_COEF_CONTEXTS * 2);
|
__builtin_memset(m_counts_more_coefs, 0, sizeof(m_counts_more_coefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,28 +16,28 @@ public:
|
||||||
/* (8.3) Clear Counts Process */
|
/* (8.3) Clear Counts Process */
|
||||||
void clear_counts();
|
void clear_counts();
|
||||||
|
|
||||||
u8 m_counts_intra_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
|
u32 m_counts_intra_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
|
||||||
u8 m_counts_uv_mode[INTRA_MODES][INTRA_MODES];
|
u32 m_counts_uv_mode[INTRA_MODES][INTRA_MODES];
|
||||||
u8 m_counts_partition[PARTITION_CONTEXTS][PARTITION_TYPES];
|
u32 m_counts_partition[PARTITION_CONTEXTS][PARTITION_TYPES];
|
||||||
u8 m_counts_interp_filter[INTERP_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
|
u32 m_counts_interp_filter[INTERP_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
|
||||||
u8 m_counts_inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
|
u32 m_counts_inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
|
||||||
u8 m_counts_tx_size[TX_SIZES][TX_SIZE_CONTEXTS][TX_SIZES];
|
u32 m_counts_tx_size[TX_SIZES][TX_SIZE_CONTEXTS][TX_SIZES];
|
||||||
u8 m_counts_is_inter[IS_INTER_CONTEXTS][2];
|
u32 m_counts_is_inter[IS_INTER_CONTEXTS][2];
|
||||||
u8 m_counts_comp_mode[COMP_MODE_CONTEXTS][2];
|
u32 m_counts_comp_mode[COMP_MODE_CONTEXTS][2];
|
||||||
u8 m_counts_single_ref[REF_CONTEXTS][2][2];
|
u32 m_counts_single_ref[REF_CONTEXTS][2][2];
|
||||||
u8 m_counts_comp_ref[REF_CONTEXTS][2];
|
u32 m_counts_comp_ref[REF_CONTEXTS][2];
|
||||||
u8 m_counts_skip[SKIP_CONTEXTS][2];
|
u32 m_counts_skip[SKIP_CONTEXTS][2];
|
||||||
u8 m_counts_mv_joint[MV_JOINTS];
|
u32 m_counts_mv_joint[MV_JOINTS];
|
||||||
u8 m_counts_mv_sign[2][2];
|
u32 m_counts_mv_sign[2][2];
|
||||||
u8 m_counts_mv_class[2][MV_CLASSES];
|
u32 m_counts_mv_class[2][MV_CLASSES];
|
||||||
u8 m_counts_mv_class0_bit[2][CLASS0_SIZE];
|
u32 m_counts_mv_class0_bit[2][CLASS0_SIZE];
|
||||||
u8 m_counts_mv_class0_fr[2][CLASS0_SIZE][MV_FR_SIZE];
|
u32 m_counts_mv_class0_fr[2][CLASS0_SIZE][MV_FR_SIZE];
|
||||||
u8 m_counts_mv_class0_hp[2][2];
|
u32 m_counts_mv_class0_hp[2][2];
|
||||||
u8 m_counts_mv_bits[2][MV_OFFSET_BITS][2];
|
u32 m_counts_mv_bits[2][MV_OFFSET_BITS][2];
|
||||||
u8 m_counts_mv_fr[2][MV_FR_SIZE];
|
u32 m_counts_mv_fr[2][MV_FR_SIZE];
|
||||||
u8 m_counts_mv_hp[2][2];
|
u32 m_counts_mv_hp[2][2];
|
||||||
u8 m_counts_token[TX_SIZES][BLOCK_TYPES][REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES];
|
u32 m_counts_token[TX_SIZES][BLOCK_TYPES][REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES];
|
||||||
u8 m_counts_more_coefs[TX_SIZES][BLOCK_TYPES][REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][2];
|
u32 m_counts_more_coefs[TX_SIZES][BLOCK_TYPES][REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][2];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,11 +67,6 @@ inline ErrorOr<OutputType> parse_tree(BitStream& bit_stream, TreeSelection tree_
|
||||||
return static_cast<OutputType>(-n);
|
return static_cast<OutputType>(-n);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void increment_counter(u8& counter)
|
|
||||||
{
|
|
||||||
counter = min(static_cast<u32>(counter) + 1, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<Partition> TreeParser::parse_partition(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, bool has_rows, bool has_columns, BlockSubsize block_subsize, u8 num_8x8, PartitionContextView above_partition_context, PartitionContextView left_partition_context, u32 row, u32 column, bool frame_is_intra)
|
ErrorOr<Partition> TreeParser::parse_partition(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, bool has_rows, bool has_columns, BlockSubsize block_subsize, u8 num_8x8, PartitionContextView above_partition_context, PartitionContextView left_partition_context, u32 row, u32 column, bool frame_is_intra)
|
||||||
{
|
{
|
||||||
// Tree array
|
// Tree array
|
||||||
|
@ -110,7 +105,7 @@ ErrorOr<Partition> TreeParser::parse_partition(BitStream& bit_stream, Probabilit
|
||||||
};
|
};
|
||||||
|
|
||||||
auto value = TRY(parse_tree<Partition>(bit_stream, tree, probability_getter));
|
auto value = TRY(parse_tree<Partition>(bit_stream, tree, probability_getter));
|
||||||
increment_counter(counter.m_counts_partition[context][value]);
|
counter.m_counts_partition[context][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +162,7 @@ ErrorOr<PredictionMode> TreeParser::parse_intra_mode(BitStream& bit_stream, Prob
|
||||||
u8 const* probabilities = probability_table.y_mode_probs()[context];
|
u8 const* probabilities = probability_table.y_mode_probs()[context];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
||||||
increment_counter(counter.m_counts_intra_mode[context][to_underlying(value)]);
|
counter.m_counts_intra_mode[context][to_underlying(value)]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +175,7 @@ ErrorOr<PredictionMode> TreeParser::parse_sub_intra_mode(BitStream& bit_stream,
|
||||||
u8 const* probabilities = probability_table.y_mode_probs()[0];
|
u8 const* probabilities = probability_table.y_mode_probs()[0];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
||||||
increment_counter(counter.m_counts_intra_mode[0][to_underlying(value)]);
|
counter.m_counts_intra_mode[0][to_underlying(value)]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +188,7 @@ ErrorOr<PredictionMode> TreeParser::parse_uv_mode(BitStream& bit_stream, Probabi
|
||||||
u8 const* probabilities = probability_table.uv_mode_probs()[to_underlying(y_mode)];
|
u8 const* probabilities = probability_table.uv_mode_probs()[to_underlying(y_mode)];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
||||||
increment_counter(counter.m_counts_uv_mode[to_underlying(y_mode)][to_underlying(value)]);
|
counter.m_counts_uv_mode[to_underlying(y_mode)][to_underlying(value)]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +216,7 @@ ErrorOr<PredictionMode> TreeParser::parse_inter_mode(BitStream& bit_stream, Prob
|
||||||
u8 const* probabilities = probability_table.inter_mode_probs()[mode_context_for_ref_frame_0];
|
u8 const* probabilities = probability_table.inter_mode_probs()[mode_context_for_ref_frame_0];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
auto value = TRY(parse_tree<PredictionMode>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
||||||
increment_counter(counter.m_counts_inter_mode[mode_context_for_ref_frame_0][to_underlying(value) - to_underlying(PredictionMode::NearestMv)]);
|
counter.m_counts_inter_mode[mode_context_for_ref_frame_0][to_underlying(value) - to_underlying(PredictionMode::NearestMv)]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +241,7 @@ ErrorOr<InterpolationFilter> TreeParser::parse_interpolation_filter(BitStream& b
|
||||||
u8 const* probabilities = probability_table.interp_filter_probs()[context];
|
u8 const* probabilities = probability_table.interp_filter_probs()[context];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<InterpolationFilter>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
auto value = TRY(parse_tree<InterpolationFilter>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
||||||
increment_counter(counter.m_counts_interp_filter[context][to_underlying(value)]);
|
counter.m_counts_interp_filter[context][to_underlying(value)]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +254,7 @@ ErrorOr<bool> TreeParser::parse_skip(BitStream& bit_stream, ProbabilityTables co
|
||||||
u8 probability = probability_table.skip_prob()[context];
|
u8 probability = probability_table.skip_prob()[context];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
||||||
increment_counter(counter.m_counts_skip[context][value]);
|
counter.m_counts_skip[context][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +285,7 @@ ErrorOr<TransformSize> TreeParser::parse_tx_size(BitStream& bit_stream, Probabil
|
||||||
u8 const* probabilities = probability_table.tx_probs()[max_tx_size][context];
|
u8 const* probabilities = probability_table.tx_probs()[max_tx_size][context];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<TransformSize>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
auto value = TRY(parse_tree<TransformSize>(bit_stream, tree, [&](u8 node) { return probabilities[node]; }));
|
||||||
increment_counter(counter.m_counts_tx_size[max_tx_size][context][value]);
|
counter.m_counts_tx_size[max_tx_size][context][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +302,7 @@ ErrorOr<bool> TreeParser::parse_block_is_inter_predicted(BitStream& bit_stream,
|
||||||
u8 probability = probability_table.is_inter_prob()[context];
|
u8 probability = probability_table.is_inter_prob()[context];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
||||||
increment_counter(counter.m_counts_is_inter[context][value]);
|
counter.m_counts_is_inter[context][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +342,7 @@ ErrorOr<ReferenceMode> TreeParser::parse_comp_mode(BitStream& bit_stream, Probab
|
||||||
u8 probability = probability_table.comp_mode_prob()[context];
|
u8 probability = probability_table.comp_mode_prob()[context];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<ReferenceMode>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
auto value = TRY(parse_tree<ReferenceMode>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
||||||
increment_counter(counter.m_counts_comp_mode[context][value]);
|
counter.m_counts_comp_mode[context][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +425,7 @@ ErrorOr<ReferenceIndex> TreeParser::parse_comp_ref(BitStream& bit_stream, Probab
|
||||||
u8 probability = probability_table.comp_ref_prob()[context];
|
u8 probability = probability_table.comp_ref_prob()[context];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<ReferenceIndex>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
auto value = TRY(parse_tree<ReferenceIndex>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
||||||
increment_counter(counter.m_counts_comp_ref[context][to_underlying(value)]);
|
counter.m_counts_comp_ref[context][to_underlying(value)]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +492,7 @@ ErrorOr<bool> TreeParser::parse_single_ref_part_1(BitStream& bit_stream, Probabi
|
||||||
u8 probability = probability_table.single_ref_prob()[context][0];
|
u8 probability = probability_table.single_ref_prob()[context][0];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
||||||
increment_counter(counter.m_counts_single_ref[context][0][value]);
|
counter.m_counts_single_ref[context][0][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,21 +578,21 @@ ErrorOr<bool> TreeParser::parse_single_ref_part_2(BitStream& bit_stream, Probabi
|
||||||
u8 probability = probability_table.single_ref_prob()[context][1];
|
u8 probability = probability_table.single_ref_prob()[context][1];
|
||||||
|
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
||||||
increment_counter(counter.m_counts_single_ref[context][1][value]);
|
counter.m_counts_single_ref[context][1][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<MvJoint> TreeParser::parse_motion_vector_joint(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter)
|
ErrorOr<MvJoint> TreeParser::parse_motion_vector_joint(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter)
|
||||||
{
|
{
|
||||||
auto value = TRY(parse_tree<MvJoint>(bit_stream, { mv_joint_tree }, [&](u8 node) { return probability_table.mv_joint_probs()[node]; }));
|
auto value = TRY(parse_tree<MvJoint>(bit_stream, { mv_joint_tree }, [&](u8 node) { return probability_table.mv_joint_probs()[node]; }));
|
||||||
increment_counter(counter.m_counts_mv_joint[value]);
|
counter.m_counts_mv_joint[value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<bool> TreeParser::parse_motion_vector_sign(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component)
|
ErrorOr<bool> TreeParser::parse_motion_vector_sign(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component)
|
||||||
{
|
{
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability_table.mv_sign_prob()[component]; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability_table.mv_sign_prob()[component]; }));
|
||||||
increment_counter(counter.m_counts_mv_sign[component][value]);
|
counter.m_counts_mv_sign[component][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,21 +601,21 @@ ErrorOr<MvClass> TreeParser::parse_motion_vector_class(BitStream& bit_stream, Pr
|
||||||
// Spec doesn't mention node, but the probabilities table has an extra dimension
|
// Spec doesn't mention node, but the probabilities table has an extra dimension
|
||||||
// so we will use node for that.
|
// so we will use node for that.
|
||||||
auto value = TRY(parse_tree<MvClass>(bit_stream, { mv_class_tree }, [&](u8 node) { return probability_table.mv_class_probs()[component][node]; }));
|
auto value = TRY(parse_tree<MvClass>(bit_stream, { mv_class_tree }, [&](u8 node) { return probability_table.mv_class_probs()[component][node]; }));
|
||||||
increment_counter(counter.m_counts_mv_class[component][value]);
|
counter.m_counts_mv_class[component][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<bool> TreeParser::parse_motion_vector_class0_bit(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component)
|
ErrorOr<bool> TreeParser::parse_motion_vector_class0_bit(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component)
|
||||||
{
|
{
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability_table.mv_class0_bit_prob()[component]; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability_table.mv_class0_bit_prob()[component]; }));
|
||||||
increment_counter(counter.m_counts_mv_class0_bit[component][value]);
|
counter.m_counts_mv_class0_bit[component][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<u8> TreeParser::parse_motion_vector_class0_fr(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component, bool class_0_bit)
|
ErrorOr<u8> TreeParser::parse_motion_vector_class0_fr(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component, bool class_0_bit)
|
||||||
{
|
{
|
||||||
auto value = TRY(parse_tree<u8>(bit_stream, { mv_fr_tree }, [&](u8 node) { return probability_table.mv_class0_fr_probs()[component][class_0_bit][node]; }));
|
auto value = TRY(parse_tree<u8>(bit_stream, { mv_fr_tree }, [&](u8 node) { return probability_table.mv_class0_fr_probs()[component][class_0_bit][node]; }));
|
||||||
increment_counter(counter.m_counts_mv_class0_fr[component][class_0_bit][value]);
|
counter.m_counts_mv_class0_fr[component][class_0_bit][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,21 +625,21 @@ ErrorOr<bool> TreeParser::parse_motion_vector_class0_hp(BitStream& bit_stream, P
|
||||||
if (use_hp)
|
if (use_hp)
|
||||||
tree = { binary_tree };
|
tree = { binary_tree };
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, tree, [&](u8) { return probability_table.mv_class0_hp_prob()[component]; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, tree, [&](u8) { return probability_table.mv_class0_hp_prob()[component]; }));
|
||||||
increment_counter(counter.m_counts_mv_class0_hp[component][value]);
|
counter.m_counts_mv_class0_hp[component][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<bool> TreeParser::parse_motion_vector_bit(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component, u8 bit_index)
|
ErrorOr<bool> TreeParser::parse_motion_vector_bit(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component, u8 bit_index)
|
||||||
{
|
{
|
||||||
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability_table.mv_bits_prob()[component][bit_index]; }));
|
auto value = TRY(parse_tree<bool>(bit_stream, { binary_tree }, [&](u8) { return probability_table.mv_bits_prob()[component][bit_index]; }));
|
||||||
increment_counter(counter.m_counts_mv_bits[component][bit_index][value]);
|
counter.m_counts_mv_bits[component][bit_index][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<u8> TreeParser::parse_motion_vector_fr(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component)
|
ErrorOr<u8> TreeParser::parse_motion_vector_fr(BitStream& bit_stream, ProbabilityTables const& probability_table, SyntaxElementCounter& counter, u8 component)
|
||||||
{
|
{
|
||||||
auto value = TRY(parse_tree<u8>(bit_stream, { mv_fr_tree }, [&](u8 node) { return probability_table.mv_fr_probs()[component][node]; }));
|
auto value = TRY(parse_tree<u8>(bit_stream, { mv_fr_tree }, [&](u8 node) { return probability_table.mv_fr_probs()[component][node]; }));
|
||||||
increment_counter(counter.m_counts_mv_fr[component][value]);
|
counter.m_counts_mv_fr[component][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +649,7 @@ ErrorOr<bool> TreeParser::parse_motion_vector_hp(BitStream& bit_stream, Probabil
|
||||||
if (use_hp)
|
if (use_hp)
|
||||||
tree = { binary_tree };
|
tree = { binary_tree };
|
||||||
auto value = TRY(parse_tree<u8>(bit_stream, tree, [&](u8) { return probability_table.mv_hp_prob()[component]; }));
|
auto value = TRY(parse_tree<u8>(bit_stream, tree, [&](u8) { return probability_table.mv_hp_prob()[component]; }));
|
||||||
increment_counter(counter.m_counts_mv_hp[component][value]);
|
counter.m_counts_mv_hp[component][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,7 +712,7 @@ ErrorOr<bool> TreeParser::parse_more_coefficients(BitStream& bit_stream, Probabi
|
||||||
{
|
{
|
||||||
auto probability = probability_table.coef_probs()[context.m_tx_size][context.m_is_uv_plane][context.m_is_inter][context.m_band][context.m_context_index][0];
|
auto probability = probability_table.coef_probs()[context.m_tx_size][context.m_is_uv_plane][context.m_is_inter][context.m_band][context.m_context_index][0];
|
||||||
auto value = TRY(parse_tree<u8>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
auto value = TRY(parse_tree<u8>(bit_stream, { binary_tree }, [&](u8) { return probability; }));
|
||||||
increment_counter(counter.m_counts_more_coefs[context.m_tx_size][context.m_is_uv_plane][context.m_is_inter][context.m_band][context.m_context_index][value]);
|
counter.m_counts_more_coefs[context.m_tx_size][context.m_is_uv_plane][context.m_is_inter][context.m_band][context.m_context_index][value]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,7 +730,7 @@ ErrorOr<Token> TreeParser::parse_token(BitStream& bit_stream, ProbabilityTables
|
||||||
};
|
};
|
||||||
|
|
||||||
auto value = TRY(parse_tree<Token>(bit_stream, { token_tree }, probability_getter));
|
auto value = TRY(parse_tree<Token>(bit_stream, { token_tree }, probability_getter));
|
||||||
increment_counter(counter.m_counts_token[context.m_tx_size][context.m_is_uv_plane][context.m_is_inter][context.m_band][context.m_context_index][min(2, value)]);
|
counter.m_counts_token[context.m_tx_size][context.m_is_uv_plane][context.m_is_inter][context.m_band][context.m_context_index][min(2, value)]++;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue