Skip to content

Commit

Permalink
Fix static overflow warning.
Browse files Browse the repository at this point in the history
In practice, this can never happen because:
- 'streak' is at most as long as a histogram
- 'count' counts the number of streaks

'streak' and 'count' are therefore at most as big as the histogram
length which is at most the max of VP8LHistogramNumCodes,
which is 256+24+(1<<10).

Change-Id: I31c8834543479c8a9260732313ea26b045519515
  • Loading branch information
vrabaud committed Aug 28, 2024
1 parent 615e587 commit 8e0cc14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/enc/histogram_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static uint64_t FinalHuffmanCost(const VP8LStreaks* const stats) {
uint64_t retval = InitialHuffmanCost();
// Second coefficient: Many zeros in the histogram are covered efficiently
// by a run-length encode. Originally 2/8.
uint64_t retval_extra = stats->counts[0] * 1600 + 240 * stats->streaks[0][1];
uint32_t retval_extra = stats->counts[0] * 1600 + 240 * stats->streaks[0][1];
// Second coefficient: Constant values are encoded less efficiently, but still
// RLE'ed. Originally 6/8.
retval_extra += stats->counts[1] * 2640 + 720 * stats->streaks[1][1];
Expand All @@ -296,7 +296,7 @@ static uint64_t FinalHuffmanCost(const VP8LStreaks* const stats) {
retval_extra += 1840 * stats->streaks[0][0];
// Originally 26/8.
retval_extra += 3360 * stats->streaks[1][0];
return retval + (retval_extra << (LOG_2_PRECISION_BITS - 10));
return retval + ((uint64_t)retval_extra << (LOG_2_PRECISION_BITS - 10));
}

// Get the symbol entropy for the distribution 'population'.
Expand Down

0 comments on commit 8e0cc14

Please sign in to comment.