Merge "Add fbounds-safety annotations for bit_depths." into main

This commit is contained in:
James Zern
2025-08-14 12:50:36 -07:00
committed by Gerrit Code Review
2 changed files with 8 additions and 5 deletions

View File

@@ -139,7 +139,7 @@ static int CompareHuffmanTrees(const void* ptr1, const void* ptr2) {
static void SetBitDepths(const HuffmanTree* const tree, static void SetBitDepths(const HuffmanTree* const tree,
const HuffmanTree* const pool, const HuffmanTree* const pool,
uint8_t* const bit_depths, int level) { uint8_t* WEBP_INDEXABLE const bit_depths, int level) {
if (tree->pool_index_left >= 0) { if (tree->pool_index_left >= 0) {
SetBitDepths(&pool[tree->pool_index_left], pool, bit_depths, level + 1); SetBitDepths(&pool[tree->pool_index_left], pool, bit_depths, level + 1);
SetBitDepths(&pool[tree->pool_index_right], pool, bit_depths, level + 1); SetBitDepths(&pool[tree->pool_index_right], pool, bit_depths, level + 1);
@@ -170,7 +170,8 @@ static void SetBitDepths(const HuffmanTree* const tree,
static void GenerateOptimalTree(const uint32_t* const histogram, static void GenerateOptimalTree(const uint32_t* const histogram,
int histogram_size, HuffmanTree* tree, int histogram_size, HuffmanTree* tree,
int tree_depth_limit, int tree_depth_limit,
uint8_t* const bit_depths) { uint8_t* WEBP_COUNTED_BY(histogram_size)
const bit_depths) {
uint32_t count_min; uint32_t count_min;
HuffmanTree* tree_pool; HuffmanTree* tree_pool;
int tree_size_orig = 0; int tree_size_orig = 0;

View File

@@ -31,9 +31,11 @@ typedef struct {
// Struct to represent the tree codes (depth and bits array). // Struct to represent the tree codes (depth and bits array).
typedef struct { typedef struct {
int num_symbols; // Number of symbols. int num_symbols; // Number of symbols.
uint8_t* code_lengths; // Code lengths of the symbols. // Code lengths of the symbols.
uint16_t* codes; // Symbol Codes. uint8_t* WEBP_COUNTED_BY(num_symbols) code_lengths;
// Symbol Codes.
uint16_t* WEBP_COUNTED_BY(num_symbols) codes;
} HuffmanTreeCode; } HuffmanTreeCode;
// Struct to represent the Huffman tree. // Struct to represent the Huffman tree.