diff options
author | Luc Trudeau <luc@trud.ca> | 2018-03-05 13:40:54 -0500 |
---|---|---|
committer | Luc Trudeau <luc@trud.ca> | 2018-03-06 16:49:45 +0000 |
commit | 7355e0a1716654070f0372c9b8e3e270b57f4663 (patch) | |
tree | db2c629ab0733498e66339f3076f11e18b268219 /tools | |
parent | 6a87583b2403c040083eb679ee1fdc0209c1dbf5 (diff) |
Remove malloc from counts_to_cdf
No need for a malloc in counts_to_cdf. This also removes the need to
return an unchecked error code. Also made round_shift const while I was
there. Lastly, I removed the dead code at the end of this function.
Change-Id: I3ef79955f014eb88a363f474f5d3b125384d86b4
Diffstat (limited to 'tools')
-rw-r--r-- | tools/aom_entropy_optimizer.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/tools/aom_entropy_optimizer.c b/tools/aom_entropy_optimizer.c index f84f7c84d..37062e106 100644 --- a/tools/aom_entropy_optimizer.c +++ b/tools/aom_entropy_optimizer.c @@ -145,19 +145,16 @@ static void optimize_entropy_table(aom_count_type *counts, fprintf(logfile, "\n"); } -static int counts_to_cdf(const aom_count_type *counts, aom_cdf_prob *cdf, - int modes) { - int64_t *csum = aom_malloc(sizeof(*csum) * modes); +static void counts_to_cdf(const aom_count_type *counts, aom_cdf_prob *cdf, + int modes) { + int64_t csum[16]; + assert(modes <= 16); - if (csum == NULL) { - fprintf(stderr, "Allocating csum array failed!\n"); - return 1; - } csum[0] = counts[0] + 1; for (int i = 1; i < modes; ++i) csum[i] = counts[i] + 1 + csum[i - 1]; int64_t sum = csum[modes - 1]; - int64_t round_shift = sum >> 1; + const int64_t round_shift = sum >> 1; for (int i = 0; i < modes; ++i) { if (sum <= 0) { cdf[i] = CDF_PROB_TOP - modes + i + 1; @@ -167,9 +164,6 @@ static int counts_to_cdf(const aom_count_type *counts, aom_cdf_prob *cdf, cdf[i] = (i == 0) ? AOMMAX(cdf[i], 4) : AOMMAX(cdf[i], cdf[i - 1] + 4); } } - // if (sum <= 0) cdf[0] = CDF_PROB_TOP - 1; - - return 0; } static int parse_counts_for_cdf_opt(aom_count_type **ct_ptr, |