Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: third_party/libwebp/enc/histogram.c

Issue 1422493004: libwebp: update to 0.4.4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libwebp/dsp/lossless_mips32.c ('k') | third_party/libwebp/enc/picture_rescale.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libwebp/enc/histogram.c
diff --git a/third_party/libwebp/enc/histogram.c b/third_party/libwebp/enc/histogram.c
index 7c6abb4d65aeb734e0b0fc3f1820a941f98aa7f6..a2266b418e60024809c09dae7f089b0671fdf68a 100644
--- a/third_party/libwebp/enc/histogram.c
+++ b/third_party/libwebp/enc/histogram.c
@@ -20,6 +20,9 @@
#include "../dsp/lossless.h"
#include "../utils/utils.h"
+#define ALIGN_CST 15
+#define DO_ALIGN(PTR) ((uintptr_t)((PTR) + ALIGN_CST) & ~ALIGN_CST)
+
#define MAX_COST 1.e38
// Number of partitions for the three dominant (literal, red and blue) symbol
@@ -101,9 +104,9 @@ VP8LHistogram* VP8LAllocateHistogram(int cache_bits) {
VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits) {
int i;
VP8LHistogramSet* set;
- const size_t total_size = sizeof(*set)
- + sizeof(*set->histograms) * size
- + (size_t)VP8LGetHistogramSize(cache_bits) * size;
+ const int histo_size = VP8LGetHistogramSize(cache_bits);
+ const size_t total_size =
+ sizeof(*set) + size * (sizeof(*set->histograms) + histo_size + ALIGN_CST);
uint8_t* memory = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*memory));
if (memory == NULL) return NULL;
@@ -114,12 +117,12 @@ VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits) {
set->max_size = size;
set->size = size;
for (i = 0; i < size; ++i) {
+ memory = (uint8_t*)DO_ALIGN(memory);
set->histograms[i] = (VP8LHistogram*)memory;
// literal_ won't necessary be aligned.
set->histograms[i]->literal_ = (uint32_t*)(memory + sizeof(VP8LHistogram));
VP8LHistogramInit(set->histograms[i], cache_bits);
- // There's no padding/alignment between successive histograms.
- memory += VP8LGetHistogramSize(cache_bits);
+ memory += histo_size;
}
return set;
}
« no previous file with comments | « third_party/libwebp/dsp/lossless_mips32.c ('k') | third_party/libwebp/enc/picture_rescale.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698