diff options
Diffstat (limited to 'src/3rdparty/libwebp/src/enc')
-rw-r--r-- | src/3rdparty/libwebp/src/enc/histogram.c | 13 | ||||
-rw-r--r-- | src/3rdparty/libwebp/src/enc/picture_rescale.c | 14 | ||||
-rw-r--r-- | src/3rdparty/libwebp/src/enc/vp8enci.h | 2 |
3 files changed, 14 insertions, 15 deletions
diff --git a/src/3rdparty/libwebp/src/enc/histogram.c b/src/3rdparty/libwebp/src/enc/histogram.c index 7c6abb4..a2266b4 100644 --- a/src/3rdparty/libwebp/src/enc/histogram.c +++ b/src/3rdparty/libwebp/src/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; } diff --git a/src/3rdparty/libwebp/src/enc/picture_rescale.c b/src/3rdparty/libwebp/src/enc/picture_rescale.c index de52848..9e45551 100644 --- a/src/3rdparty/libwebp/src/enc/picture_rescale.c +++ b/src/3rdparty/libwebp/src/enc/picture_rescale.c @@ -175,17 +175,13 @@ static void RescalePlane(const uint8_t* src, int src_width, int src_height, int src_stride, uint8_t* dst, int dst_width, int dst_height, int dst_stride, - int32_t* const work, + rescaler_t* const work, int num_channels) { WebPRescaler rescaler; int y = 0; WebPRescalerInit(&rescaler, src_width, src_height, dst, dst_width, dst_height, dst_stride, - num_channels, - src_width, dst_width, - src_height, dst_height, - work); - memset(work, 0, 2 * dst_width * num_channels * sizeof(*work)); + num_channels, work); while (y < src_height) { y += WebPRescalerImport(&rescaler, src_height - y, src + y * src_stride, src_stride); @@ -209,7 +205,7 @@ static void AlphaMultiplyY(WebPPicture* const pic, int inverse) { int WebPPictureRescale(WebPPicture* pic, int width, int height) { WebPPicture tmp; int prev_width, prev_height; - int32_t* work; + rescaler_t* work; if (pic == NULL) return 0; prev_width = pic->width; @@ -231,7 +227,7 @@ int WebPPictureRescale(WebPPicture* pic, int width, int height) { if (!WebPPictureAlloc(&tmp)) return 0; if (!pic->use_argb) { - work = (int32_t*)WebPSafeMalloc(2ULL * width, sizeof(*work)); + work = (rescaler_t*)WebPSafeMalloc(2ULL * width, sizeof(*work)); if (work == NULL) { WebPPictureFree(&tmp); return 0; @@ -259,7 +255,7 @@ int WebPPictureRescale(WebPPicture* pic, int width, int height) { tmp.v, HALVE(width), HALVE(height), tmp.uv_stride, work, 1); } else { - work = (int32_t*)WebPSafeMalloc(2ULL * width * 4, sizeof(*work)); + work = (rescaler_t*)WebPSafeMalloc(2ULL * width * 4, sizeof(*work)); if (work == NULL) { WebPPictureFree(&tmp); return 0; diff --git a/src/3rdparty/libwebp/src/enc/vp8enci.h b/src/3rdparty/libwebp/src/enc/vp8enci.h index 74c8f70..20f58c6 100644 --- a/src/3rdparty/libwebp/src/enc/vp8enci.h +++ b/src/3rdparty/libwebp/src/enc/vp8enci.h @@ -30,7 +30,7 @@ extern "C" { // version numbers #define ENC_MAJ_VERSION 0 #define ENC_MIN_VERSION 4 -#define ENC_REV_VERSION 3 +#define ENC_REV_VERSION 4 // intra prediction modes enum { B_DC_PRED = 0, // 4x4 modes |