Remove some errors when compiling the code as C++.

This fixes some cases from
https://bugs.chromium.org/p/webp/issues/detail?id=137

Change-Id: I58f3a617bf973dbe4c5794004a01e2aea39ba53a
This commit is contained in:
Vincent Rabaud 2016-10-05 09:39:08 +02:00
parent b34abcb8b1
commit 28ce304344
8 changed files with 19 additions and 18 deletions

View File

@ -67,7 +67,7 @@ static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
} }
dec->method_ = (data[0] >> 0) & 0x03; dec->method_ = (data[0] >> 0) & 0x03;
dec->filter_ = (data[0] >> 2) & 0x03; dec->filter_ = (WEBP_FILTER_TYPE)((data[0] >> 2) & 0x03);
dec->pre_processing_ = (data[0] >> 4) & 0x03; dec->pre_processing_ = (data[0] >> 4) & 0x03;
rsrv = (data[0] >> 6) & 0x03; rsrv = (data[0] >> 6) & 0x03;
if (dec->method_ < ALPHA_NO_COMPRESSION || if (dec->method_ < ALPHA_NO_COMPRESSION ||

View File

@ -113,10 +113,10 @@ WebPAnimDecoder* WebPAnimDecoderNewInternal(
dec->info_.frame_count = WebPDemuxGetI(dec->demux_, WEBP_FF_FRAME_COUNT); dec->info_.frame_count = WebPDemuxGetI(dec->demux_, WEBP_FF_FRAME_COUNT);
// Note: calloc() because we fill frame with zeroes as well. // Note: calloc() because we fill frame with zeroes as well.
dec->curr_frame_ = WebPSafeCalloc( dec->curr_frame_ = (uint8_t*)WebPSafeCalloc(
dec->info_.canvas_width * NUM_CHANNELS, dec->info_.canvas_height); dec->info_.canvas_width * NUM_CHANNELS, dec->info_.canvas_height);
if (dec->curr_frame_ == NULL) goto Error; if (dec->curr_frame_ == NULL) goto Error;
dec->prev_frame_disposed_ = WebPSafeCalloc( dec->prev_frame_disposed_ = (uint8_t*)WebPSafeCalloc(
dec->info_.canvas_width * NUM_CHANNELS, dec->info_.canvas_height); dec->info_.canvas_width * NUM_CHANNELS, dec->info_.canvas_height);
if (dec->prev_frame_disposed_ == NULL) goto Error; if (dec->prev_frame_disposed_ == NULL) goto Error;

View File

@ -239,7 +239,7 @@ VP8PredFunc VP8PredLuma16[NUM_B_DC_MODES];
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// 4x4 // 4x4
#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2) #define AVG3(a, b, c) ((uint8_t)(((a) + 2 * (b) + (c) + 2) >> 2))
#define AVG2(a, b) (((a) + (b) + 1) >> 1) #define AVG2(a, b) (((a) + (b) + 1) >> 1)
static void VE4(uint8_t* dst) { // vertical static void VE4(uint8_t* dst) { // vertical

View File

@ -335,7 +335,7 @@ static void Intra16Preds(uint8_t* dst,
// luma 4x4 prediction // luma 4x4 prediction
#define DST(x, y) dst[(x) + (y) * BPS] #define DST(x, y) dst[(x) + (y) * BPS]
#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2) #define AVG3(a, b, c) ((uint8_t)(((a) + 2 * (b) + (c) + 2) >> 2))
#define AVG2(a, b) (((a) + (b) + 1) >> 1) #define AVG2(a, b) (((a) + (b) + 1) >> 1)
static void VE4(uint8_t* dst, const uint8_t* top) { // vertical static void VE4(uint8_t* dst, const uint8_t* top) { // vertical

View File

@ -624,8 +624,8 @@ static int HistoQueueInit(HistoQueue* const histo_queue, const int max_index) {
histo_queue->max_size = max_index * max_index; histo_queue->max_size = max_index * max_index;
// We allocate max_size + 1 because the last element at index "size" is // We allocate max_size + 1 because the last element at index "size" is
// used as temporary data (and it could be up to max_size). // used as temporary data (and it could be up to max_size).
histo_queue->queue = WebPSafeMalloc(histo_queue->max_size + 1, histo_queue->queue = (HistogramPair*)WebPSafeMalloc(
sizeof(*histo_queue->queue)); histo_queue->max_size + 1, sizeof(*histo_queue->queue));
return histo_queue->queue != NULL; return histo_queue->queue != NULL;
} }
@ -691,7 +691,8 @@ static int HistogramCombineGreedy(VP8LHistogramSet* const image_histo) {
int i, j; int i, j;
VP8LHistogram** const histograms = image_histo->histograms; VP8LHistogram** const histograms = image_histo->histograms;
// Indexes of remaining histograms. // Indexes of remaining histograms.
int* const clusters = WebPSafeMalloc(image_histo_size, sizeof(*clusters)); int* const clusters =
(int*)WebPSafeMalloc(image_histo_size, sizeof(*clusters));
// Priority queue of histogram pairs. // Priority queue of histogram pairs.
HistoQueue histo_queue; HistoQueue histo_queue;

View File

@ -88,8 +88,9 @@ int WebPPictureAllocARGB(WebPPicture* const picture, int width, int height) {
} }
int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height) { int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height) {
const WebPEncCSP uv_csp = picture->colorspace & WEBP_CSP_UV_MASK; const WebPEncCSP uv_csp =
const int has_alpha = picture->colorspace & WEBP_CSP_ALPHA_BIT; (WebPEncCSP)((int)picture->colorspace & WEBP_CSP_UV_MASK);
const int has_alpha = (int)picture->colorspace & WEBP_CSP_ALPHA_BIT;
const int y_stride = width; const int y_stride = width;
const int uv_width = (width + 1) >> 1; const int uv_width = (width + 1) >> 1;
const int uv_height = (height + 1) >> 1; const int uv_height = (height + 1) >> 1;

View File

@ -35,8 +35,8 @@
// Palette reordering for smaller sum of deltas (and for smaller storage). // Palette reordering for smaller sum of deltas (and for smaller storage).
static int PaletteCompareColorsForQsort(const void* p1, const void* p2) { static int PaletteCompareColorsForQsort(const void* p1, const void* p2) {
const uint32_t a = WebPMemToUint32(p1); const uint32_t a = WebPMemToUint32((uint8_t*)p1);
const uint32_t b = WebPMemToUint32(p2); const uint32_t b = WebPMemToUint32((uint8_t*)p2);
assert(a != b); assert(a != b);
return (a < b) ? -1 : 1; return (a < b) ? -1 : 1;
} }
@ -232,9 +232,8 @@ static int AnalyzeEntropy(const uint32_t* argb,
{ {
double entropy_comp[kHistoTotal]; double entropy_comp[kHistoTotal];
double entropy[kNumEntropyIx]; double entropy[kNumEntropyIx];
EntropyIx k; int k;
EntropyIx last_mode_to_analyze = int last_mode_to_analyze = use_palette ? kPalette : kSpatialSubGreen;
use_palette ? kPalette : kSpatialSubGreen;
int j; int j;
// Let's add one zero to the predicted histograms. The zeros are removed // Let's add one zero to the predicted histograms. The zeros are removed
// too efficiently by the pix_diff == 0 comparison, at least one of the // too efficiently by the pix_diff == 0 comparison, at least one of the
@ -271,7 +270,7 @@ static int AnalyzeEntropy(const uint32_t* argb,
*min_entropy_ix = kDirect; *min_entropy_ix = kDirect;
for (k = kDirect + 1; k <= last_mode_to_analyze; ++k) { for (k = kDirect + 1; k <= last_mode_to_analyze; ++k) {
if (entropy[*min_entropy_ix] > entropy[k]) { if (entropy[*min_entropy_ix] > entropy[k]) {
*min_entropy_ix = k; *min_entropy_ix = (EntropyIx)k;
} }
} }
*red_and_blue_always_zero = 1; *red_and_blue_always_zero = 1;

View File

@ -16,7 +16,7 @@
#include "./muxi.h" #include "./muxi.h"
#include "../utils/utils.h" #include "../utils/utils.h"
#define UNDEFINED_CHUNK_SIZE (-1) #define UNDEFINED_CHUNK_SIZE ((uint32_t)(-1))
const ChunkInfo kChunks[] = { const ChunkInfo kChunks[] = {
{ MKFOURCC('V', 'P', '8', 'X'), WEBP_CHUNK_VP8X, VP8X_CHUNK_SIZE }, { MKFOURCC('V', 'P', '8', 'X'), WEBP_CHUNK_VP8X, VP8X_CHUNK_SIZE },
@ -436,7 +436,7 @@ static int IsNotCompatible(int feature, int num_items) {
return (feature != 0) != (num_items > 0); return (feature != 0) != (num_items > 0);
} }
#define NO_FLAG 0 #define NO_FLAG ((WebPFeatureFlags)0)
// Test basic constraints: // Test basic constraints:
// retrieval, maximum number of chunks by index (use -1 to skip) // retrieval, maximum number of chunks by index (use -1 to skip)