remove some -Wshadow warnings

these are quite noisy, but it's not a big deal to remove
them.

Change-Id: I5deb08f10263feb77e2cc8a70be44ad4f725febd
This commit is contained in:
skal 2013-01-21 17:20:14 +01:00
parent 8189feda50
commit 0d19fbff51
12 changed files with 92 additions and 85 deletions

View File

@ -310,8 +310,8 @@ static void SaveOutput(const WebPDecBuffer* const buffer,
if (ok) { if (ok) {
printf("Saved file %s\n", out_file); printf("Saved file %s\n", out_file);
if (verbose) { if (verbose) {
const double time = StopwatchReadAndReset(&stop_watch); const double write_time = StopwatchReadAndReset(&stop_watch);
printf("Time to write output: %.3fs\n", time); printf("Time to write output: %.3fs\n", write_time);
} }
} else { } else {
fprintf(stderr, "Error writing file %s !!\n", out_file); fprintf(stderr, "Error writing file %s !!\n", out_file);
@ -462,8 +462,8 @@ int main(int argc, const char *argv[]) {
status = WebPDecode(data, data_size, &config); status = WebPDecode(data, data_size, &config);
if (verbose) { if (verbose) {
const double time = StopwatchReadAndReset(&stop_watch); const double decode_time = StopwatchReadAndReset(&stop_watch);
printf("Time to decode picture: %.3fs\n", time); printf("Time to decode picture: %.3fs\n", decode_time);
} }
end: end:
free((void*)data); free((void*)data);

View File

@ -801,12 +801,11 @@ static int Process(const WebPMuxConfig* config) {
WebPMux* mux = NULL; WebPMux* mux = NULL;
WebPData chunk; WebPData chunk;
WebPMuxError err = WEBP_MUX_OK; WebPMuxError err = WEBP_MUX_OK;
int index = 0;
int ok = 1; int ok = 1;
const Feature* const feature = &config->feature_; const Feature* const feature = &config->feature_;
switch (config->action_type_) { switch (config->action_type_) {
case ACTION_GET: case ACTION_GET: {
ok = CreateMux(config->input_, &mux); ok = CreateMux(config->input_, &mux);
if (!ok) goto Err2; if (!ok) goto Err2;
switch (feature->type_) { switch (feature->type_) {
@ -832,21 +831,22 @@ static int Process(const WebPMuxConfig* config) {
break; break;
} }
break; break;
}
case ACTION_SET: case ACTION_SET: {
switch (feature->type_) { switch (feature->type_) {
case FEATURE_ANMF: { case FEATURE_ANMF: {
int i;
WebPMuxAnimParams params = { 0xFFFFFFFF, 0 }; WebPMuxAnimParams params = { 0xFFFFFFFF, 0 };
mux = WebPMuxNew(); mux = WebPMuxNew();
if (mux == NULL) { if (mux == NULL) {
ERROR_GOTO2("ERROR (%s): Could not allocate a mux object.\n", ERROR_GOTO2("ERROR (%s): Could not allocate a mux object.\n",
ErrorString(WEBP_MUX_MEMORY_ERROR), Err2); ErrorString(WEBP_MUX_MEMORY_ERROR), Err2);
} }
for (index = 0; index < feature->arg_count_; ++index) { for (i = 0; i < feature->arg_count_; ++i) {
switch (feature->args_[index].subtype_) { switch (feature->args_[i].subtype_) {
case SUBTYPE_BGCOLOR: { case SUBTYPE_BGCOLOR: {
uint32_t bgcolor; uint32_t bgcolor;
ok = ParseBgcolorArgs(feature->args_[index].params_, &bgcolor); ok = ParseBgcolorArgs(feature->args_[i].params_, &bgcolor);
if (!ok) { if (!ok) {
ERROR_GOTO1("ERROR: Could not parse the background color \n", ERROR_GOTO1("ERROR: Could not parse the background color \n",
Err2); Err2);
@ -856,7 +856,7 @@ static int Process(const WebPMuxConfig* config) {
} }
case SUBTYPE_LOOP: { case SUBTYPE_LOOP: {
const long loop_count = const long loop_count =
strtol(feature->args_[index].params_, NULL, 10); strtol(feature->args_[i].params_, NULL, 10);
if (loop_count != (int)loop_count) { if (loop_count != (int)loop_count) {
// Note: This is only a 'necessary' condition for loop_count // Note: This is only a 'necessary' condition for loop_count
// to be valid. The 'sufficient' conditioned in checked in // to be valid. The 'sufficient' conditioned in checked in
@ -870,10 +870,10 @@ static int Process(const WebPMuxConfig* config) {
case SUBTYPE_ANMF: { case SUBTYPE_ANMF: {
WebPMuxFrameInfo frame; WebPMuxFrameInfo frame;
frame.id = WEBP_CHUNK_ANMF; frame.id = WEBP_CHUNK_ANMF;
ok = ReadFileToWebPData(feature->args_[index].filename_, ok = ReadFileToWebPData(feature->args_[i].filename_,
&frame.bitstream); &frame.bitstream);
if (!ok) goto Err2; if (!ok) goto Err2;
ok = ParseFrameArgs(feature->args_[index].params_, &frame); ok = ParseFrameArgs(feature->args_[i].params_, &frame);
if (!ok) { if (!ok) {
WebPDataClear(&frame.bitstream); WebPDataClear(&frame.bitstream);
ERROR_GOTO1("ERROR: Could not parse frame properties.\n", ERROR_GOTO1("ERROR: Could not parse frame properties.\n",
@ -883,7 +883,7 @@ static int Process(const WebPMuxConfig* config) {
WebPDataClear(&frame.bitstream); WebPDataClear(&frame.bitstream);
if (err != WEBP_MUX_OK) { if (err != WEBP_MUX_OK) {
ERROR_GOTO3("ERROR (%s): Could not add a frame at index %d." ERROR_GOTO3("ERROR (%s): Could not add a frame at index %d."
"\n", ErrorString(err), index, Err2); "\n", ErrorString(err), i, Err2);
} }
break; break;
} }
@ -901,19 +901,20 @@ static int Process(const WebPMuxConfig* config) {
break; break;
} }
case FEATURE_FRGM: case FEATURE_FRGM: {
int i;
mux = WebPMuxNew(); mux = WebPMuxNew();
if (mux == NULL) { if (mux == NULL) {
ERROR_GOTO2("ERROR (%s): Could not allocate a mux object.\n", ERROR_GOTO2("ERROR (%s): Could not allocate a mux object.\n",
ErrorString(WEBP_MUX_MEMORY_ERROR), Err2); ErrorString(WEBP_MUX_MEMORY_ERROR), Err2);
} }
for (index = 0; index < feature->arg_count_; ++index) { for (i = 0; i < feature->arg_count_; ++i) {
WebPMuxFrameInfo frgm; WebPMuxFrameInfo frgm;
frgm.id = WEBP_CHUNK_FRGM; frgm.id = WEBP_CHUNK_FRGM;
ok = ReadFileToWebPData(feature->args_[index].filename_, ok = ReadFileToWebPData(feature->args_[i].filename_,
&frgm.bitstream); &frgm.bitstream);
if (!ok) goto Err2; if (!ok) goto Err2;
ok = ParseFragmentArgs(feature->args_[index].params_, &frgm); ok = ParseFragmentArgs(feature->args_[i].params_, &frgm);
if (!ok) { if (!ok) {
WebPDataClear(&frgm.bitstream); WebPDataClear(&frgm.bitstream);
ERROR_GOTO1("ERROR: Could not parse fragment properties.\n", ERROR_GOTO1("ERROR: Could not parse fragment properties.\n",
@ -923,14 +924,15 @@ static int Process(const WebPMuxConfig* config) {
WebPDataClear(&frgm.bitstream); WebPDataClear(&frgm.bitstream);
if (err != WEBP_MUX_OK) { if (err != WEBP_MUX_OK) {
ERROR_GOTO3("ERROR (%s): Could not add a fragment at index %d.\n", ERROR_GOTO3("ERROR (%s): Could not add a fragment at index %d.\n",
ErrorString(err), index, Err2); ErrorString(err), i, Err2);
} }
} }
break; break;
}
case FEATURE_ICCP: case FEATURE_ICCP:
case FEATURE_EXIF: case FEATURE_EXIF:
case FEATURE_XMP: case FEATURE_XMP: {
ok = CreateMux(config->input_, &mux); ok = CreateMux(config->input_, &mux);
if (!ok) goto Err2; if (!ok) goto Err2;
ok = ReadFileToWebPData(feature->args_[0].filename_, &chunk); ok = ReadFileToWebPData(feature->args_[0].filename_, &chunk);
@ -942,15 +944,16 @@ static int Process(const WebPMuxConfig* config) {
ErrorString(err), kDescriptions[feature->type_], Err2); ErrorString(err), kDescriptions[feature->type_], Err2);
} }
break; break;
}
default: default: {
ERROR_GOTO1("ERROR: Invalid feature for action 'set'.\n", Err2); ERROR_GOTO1("ERROR: Invalid feature for action 'set'.\n", Err2);
break; break;
} }
}
ok = WriteWebP(mux, config->output_); ok = WriteWebP(mux, config->output_);
break; break;
}
case ACTION_STRIP: case ACTION_STRIP: {
ok = CreateMux(config->input_, &mux); ok = CreateMux(config->input_, &mux);
if (!ok) goto Err2; if (!ok) goto Err2;
if (feature->type_ == FEATURE_ICCP || feature->type_ == FEATURE_EXIF || if (feature->type_ == FEATURE_ICCP || feature->type_ == FEATURE_EXIF ||
@ -966,17 +969,18 @@ static int Process(const WebPMuxConfig* config) {
} }
ok = WriteWebP(mux, config->output_); ok = WriteWebP(mux, config->output_);
break; break;
}
case ACTION_INFO: case ACTION_INFO: {
ok = CreateMux(config->input_, &mux); ok = CreateMux(config->input_, &mux);
if (!ok) goto Err2; if (!ok) goto Err2;
ok = (DisplayInfo(mux) == WEBP_MUX_OK); ok = (DisplayInfo(mux) == WEBP_MUX_OK);
break; break;
}
default: default: {
assert(0); // Invalid action. assert(0); // Invalid action.
break; break;
} }
}
Err2: Err2:
WebPMuxDelete(mux); WebPMuxDelete(mux);

View File

@ -62,6 +62,7 @@ EXTRA_FLAGS += -Wextra -Wold-style-definition
EXTRA_FLAGS += -Wmissing-prototypes EXTRA_FLAGS += -Wmissing-prototypes
EXTRA_FLAGS += -Wmissing-declarations EXTRA_FLAGS += -Wmissing-declarations
EXTRA_FLAGS += -Wdeclaration-after-statement EXTRA_FLAGS += -Wdeclaration-after-statement
EXTRA_FLAGS += -Wshadow
# EXTRA_FLAGS += -Wvla # EXTRA_FLAGS += -Wvla
#### Nothing should normally be changed below this line #### #### Nothing should normally be changed below this line ####

View File

@ -327,10 +327,10 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
hdr->huffman_subsample_bits_ = huffman_precision; hdr->huffman_subsample_bits_ = huffman_precision;
for (i = 0; i < huffman_pixs; ++i) { for (i = 0; i < huffman_pixs; ++i) {
// The huffman data is stored in red and green bytes. // The huffman data is stored in red and green bytes.
const int index = (huffman_image[i] >> 8) & 0xffff; const int group = (huffman_image[i] >> 8) & 0xffff;
huffman_image[i] = index; huffman_image[i] = group;
if (index >= num_htree_groups) { if (group >= num_htree_groups) {
num_htree_groups = index + 1; num_htree_groups = group + 1;
} }
} }
} }

View File

@ -278,14 +278,14 @@ static void TransformSSE2(const int16_t* in, uint8_t* dst, int do_two) {
#define GET_NOTHEV(p1, p0, q0, q1, hev_thresh, not_hev) { \ #define GET_NOTHEV(p1, p0, q0, q1, hev_thresh, not_hev) { \
const __m128i zero = _mm_setzero_si128(); \ const __m128i zero = _mm_setzero_si128(); \
const __m128i t1 = MM_ABS(p1, p0); \ const __m128i t_1 = MM_ABS(p1, p0); \
const __m128i t2 = MM_ABS(q1, q0); \ const __m128i t_2 = MM_ABS(q1, q0); \
\ \
const __m128i h = _mm_set1_epi8(hev_thresh); \ const __m128i h = _mm_set1_epi8(hev_thresh); \
const __m128i t3 = _mm_subs_epu8(t1, h); /* abs(p1 - p0) - hev_tresh */ \ const __m128i t_3 = _mm_subs_epu8(t_1, h); /* abs(p1 - p0) - hev_tresh */ \
const __m128i t4 = _mm_subs_epu8(t2, h); /* abs(q1 - q0) - hev_tresh */ \ const __m128i t_4 = _mm_subs_epu8(t_2, h); /* abs(q1 - q0) - hev_tresh */ \
\ \
not_hev = _mm_or_si128(t3, t4); \ not_hev = _mm_or_si128(t_3, t_4); \
not_hev = _mm_cmpeq_epi8(not_hev, zero); /* not_hev <= t1 && not_hev <= t2 */\ not_hev = _mm_cmpeq_epi8(not_hev, zero); /* not_hev <= t1 && not_hev <= t2 */\
} }
@ -314,13 +314,13 @@ static void TransformSSE2(const int16_t* in, uint8_t* dst, int do_two) {
// Updates values of 2 pixels at MB edge during complex filtering. // Updates values of 2 pixels at MB edge during complex filtering.
// Update operations: // Update operations:
// q = q - a and p = p + a; where a = [(a_hi >> 7), (a_lo >> 7)] // q = q - delta and p = p + delta; where delta = [(a_hi >> 7), (a_lo >> 7)]
#define UPDATE_2PIXELS(pi, qi, a_lo, a_hi) { \ #define UPDATE_2PIXELS(pi, qi, a_lo, a_hi) { \
const __m128i a_lo7 = _mm_srai_epi16(a_lo, 7); \ const __m128i a_lo7 = _mm_srai_epi16(a_lo, 7); \
const __m128i a_hi7 = _mm_srai_epi16(a_hi, 7); \ const __m128i a_hi7 = _mm_srai_epi16(a_hi, 7); \
const __m128i a = _mm_packs_epi16(a_lo7, a_hi7); \ const __m128i delta = _mm_packs_epi16(a_lo7, a_hi7); \
pi = _mm_adds_epi8(pi, a); \ pi = _mm_adds_epi8(pi, delta); \
qi = _mm_subs_epi8(qi, a); \ qi = _mm_subs_epi8(qi, delta); \
} }
static void NeedsFilter(const __m128i* p1, const __m128i* p0, const __m128i* q0, static void NeedsFilter(const __m128i* p1, const __m128i* p0, const __m128i* q0,

View File

@ -51,12 +51,12 @@ extern "C" {
// pack and store two alterning pixel rows // pack and store two alterning pixel rows
#define PACK_AND_STORE(a, b, da, db, out) do { \ #define PACK_AND_STORE(a, b, da, db, out) do { \
const __m128i ta = _mm_avg_epu8(a, da); /* (9a + 3b + 3c + d + 8) / 16 */ \ const __m128i t_a = _mm_avg_epu8(a, da); /* (9a + 3b + 3c + d + 8) / 16 */ \
const __m128i tb = _mm_avg_epu8(b, db); /* (3a + 9b + c + 3d + 8) / 16 */ \ const __m128i t_b = _mm_avg_epu8(b, db); /* (3a + 9b + c + 3d + 8) / 16 */ \
const __m128i t1 = _mm_unpacklo_epi8(ta, tb); \ const __m128i t_1 = _mm_unpacklo_epi8(t_a, t_b); \
const __m128i t2 = _mm_unpackhi_epi8(ta, tb); \ const __m128i t_2 = _mm_unpackhi_epi8(t_a, t_b); \
_mm_store_si128(((__m128i*)(out)) + 0, t1); \ _mm_store_si128(((__m128i*)(out)) + 0, t_1); \
_mm_store_si128(((__m128i*)(out)) + 1, t2); \ _mm_store_si128(((__m128i*)(out)) + 1, t_2); \
} while (0) } while (0)
// Loads 17 pixels each from rows r1 and r2 and generates 32 pixels. // Loads 17 pixels each from rows r1 and r2 and generates 32 pixels.
@ -128,7 +128,7 @@ static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
const uint8_t* top_u, const uint8_t* top_v, \ const uint8_t* top_u, const uint8_t* top_v, \
const uint8_t* cur_u, const uint8_t* cur_v, \ const uint8_t* cur_u, const uint8_t* cur_v, \
uint8_t* top_dst, uint8_t* bottom_dst, int len) { \ uint8_t* top_dst, uint8_t* bottom_dst, int len) { \
int b; \ int block; \
/* 16 byte aligned array to cache reconstructed u and v */ \ /* 16 byte aligned array to cache reconstructed u and v */ \
uint8_t uv_buf[4 * 32 + 15]; \ uint8_t uv_buf[4 * 32 + 15]; \
uint8_t* const r_uv = (uint8_t*)((uintptr_t)(uv_buf + 15) & ~15); \ uint8_t* const r_uv = (uint8_t*)((uintptr_t)(uv_buf + 15) & ~15); \
@ -154,11 +154,11 @@ static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
FUNC(bottom_y[0], u0, v0, bottom_dst); \ FUNC(bottom_y[0], u0, v0, bottom_dst); \
} \ } \
\ \
for (b = 0; b < num_blocks; ++b) { \ for (block = 0; block < num_blocks; ++block) { \
UPSAMPLE_32PIXELS(top_u, cur_u, r_uv + 0 * 32); \ UPSAMPLE_32PIXELS(top_u, cur_u, r_uv + 0 * 32); \
UPSAMPLE_32PIXELS(top_v, cur_v, r_uv + 1 * 32); \ UPSAMPLE_32PIXELS(top_v, cur_v, r_uv + 1 * 32); \
CONVERT2RGB(FUNC, XSTEP, top_y, bottom_y, r_uv, top_dst, bottom_dst, \ CONVERT2RGB(FUNC, XSTEP, top_y, bottom_y, r_uv, top_dst, bottom_dst, \
32 * b + 1, 32) \ 32 * block + 1, 32) \
top_u += 16; \ top_u += 16; \
cur_u += 16; \ cur_u += 16; \
top_v += 16; \ top_v += 16; \

View File

@ -88,9 +88,9 @@ static int EncodeLossless(const uint8_t* const data, int width, int height,
ok = ok && (VP8LEncodeStream(&config, &picture, &tmp_bw) == VP8_ENC_OK); ok = ok && (VP8LEncodeStream(&config, &picture, &tmp_bw) == VP8_ENC_OK);
WebPPictureFree(&picture); WebPPictureFree(&picture);
if (ok) { if (ok) {
const uint8_t* const data = VP8LBitWriterFinish(&tmp_bw); const uint8_t* const buffer = VP8LBitWriterFinish(&tmp_bw);
const size_t data_size = VP8LBitWriterNumBytes(&tmp_bw); const size_t buffer_size = VP8LBitWriterNumBytes(&tmp_bw);
VP8BitWriterAppend(bw, data, data_size); VP8BitWriterAppend(bw, buffer, buffer_size);
} }
VP8LBitWriterDestroy(&tmp_bw); VP8LBitWriterDestroy(&tmp_bw);
return ok && !bw->error_; return ok && !bw->error_;

View File

@ -157,18 +157,19 @@ static void GetParamsForHashChainFindCopy(int quality, int xsize,
} }
static int HashChainFindCopy(const HashChain* const p, static int HashChainFindCopy(const HashChain* const p,
int index, int xsize, int base_position, int xsize,
const uint32_t* const argb, int maxlen, const uint32_t* const argb, int maxlen,
int window_size, int iter_pos, int iter_limit, int window_size, int iter_pos, int iter_limit,
int* const distance_ptr, int* const distance_ptr,
int* const length_ptr) { int* const length_ptr) {
const uint64_t hash_code = GetPixPairHash64(&argb[index]); const uint64_t hash_code = GetPixPairHash64(&argb[base_position]);
int prev_length = 0; int prev_length = 0;
int64_t best_val = 0; int64_t best_val = 0;
int best_length = 0; int best_length = 0;
int best_distance = 0; int best_distance = 0;
const uint32_t* const argb_start = argb + index; const uint32_t* const argb_start = argb + base_position;
const int min_pos = (index > window_size) ? index - window_size : 0; const int min_pos =
(base_position > window_size) ? base_position - window_size : 0;
int pos; int pos;
assert(xsize > 0); assert(xsize > 0);
@ -193,9 +194,9 @@ static int HashChainFindCopy(const HashChain* const p,
} }
val = 65536 * curr_length; val = 65536 * curr_length;
// Favoring 2d locality here gives savings for certain images. // Favoring 2d locality here gives savings for certain images.
if (index - pos < 9 * xsize) { if (base_position - pos < 9 * xsize) {
const int y = (index - pos) / xsize; const int y = (base_position - pos) / xsize;
int x = (index - pos) % xsize; int x = (base_position - pos) % xsize;
if (x > xsize / 2) { if (x > xsize / 2) {
x = xsize - x; x = xsize - x;
} }
@ -211,7 +212,7 @@ static int HashChainFindCopy(const HashChain* const p,
prev_length = curr_length; prev_length = curr_length;
best_val = val; best_val = val;
best_length = curr_length; best_length = curr_length;
best_distance = index - pos; best_distance = base_position - pos;
if (curr_length >= MAX_LENGTH) { if (curr_length >= MAX_LENGTH) {
break; break;
} }

View File

@ -65,11 +65,11 @@ static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
#endif #endif
static WEBP_INLINE int VP8LBitsLog2Ceiling(uint32_t n) { static WEBP_INLINE int VP8LBitsLog2Ceiling(uint32_t n) {
const int floor = BitsLog2Floor(n); const int log_floor = BitsLog2Floor(n);
if (n == (n & ~(n - 1))) // zero or a power of two. if (n == (n & ~(n - 1))) // zero or a power of two.
return floor; return log_floor;
else else
return floor + 1; return log_floor + 1;
} }
// Splitting of distance and length codes into prefixes and // Splitting of distance and length codes into prefixes and

View File

@ -281,11 +281,11 @@ static void SetResidualCoeffs(const int16_t* const coeffs,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Mode costs // Mode costs
static int GetResidualCost(int ctx, const VP8Residual* const res) { static int GetResidualCost(int ctx0, const VP8Residual* const res) {
int n = res->first; int n = res->first;
// should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1 // should be prob[VP8EncBands[n]], but it's equivalent for n=0 or 1
int p0 = res->prob[n][ctx][0]; int p0 = res->prob[n][ctx0][0];
const uint16_t* t = res->cost[n][ctx]; const uint16_t* t = res->cost[n][ctx0];
int cost; int cost;
if (res->last < 0) { if (res->last < 0) {
@ -320,8 +320,8 @@ static int GetResidualCost(int ctx, const VP8Residual* const res) {
if (n < 15) { if (n < 15) {
const int b = VP8EncBands[n + 1]; const int b = VP8EncBands[n + 1];
const int ctx = (v == 1) ? 1 : 2; const int ctx = (v == 1) ? 1 : 2;
const int p0 = res->prob[b][ctx][0]; const int last_p0 = res->prob[b][ctx][0];
cost += VP8BitCost(0, p0); cost += VP8BitCost(0, last_p0);
} }
} }
return cost; return cost;

View File

@ -806,11 +806,11 @@ int WebPPictureYUVAToARGB(WebPPicture* picture) {
// Insert alpha values if needed, in replacement for the default 0xff ones. // Insert alpha values if needed, in replacement for the default 0xff ones.
if (picture->colorspace & WEBP_CSP_ALPHA_BIT) { if (picture->colorspace & WEBP_CSP_ALPHA_BIT) {
for (y = 0; y < height; ++y) { for (y = 0; y < height; ++y) {
uint32_t* const dst = picture->argb + y * picture->argb_stride; uint32_t* const argb_dst = picture->argb + y * picture->argb_stride;
const uint8_t* const src = picture->a + y * picture->a_stride; const uint8_t* const src = picture->a + y * picture->a_stride;
int x; int x;
for (x = 0; x < width; ++x) { for (x = 0; x < width; ++x) {
dst[x] = (dst[x] & 0x00ffffffu) | (src[x] << 24); argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | (src[x] << 24);
} }
} }
} }
@ -926,17 +926,17 @@ static float AccumulateLSIM(const uint8_t* src, int src_stride,
int x, y; int x, y;
double total_sse = 0.; double total_sse = 0.;
for (y = 0; y < h; ++y) { for (y = 0; y < h; ++y) {
const int y0 = (y - RADIUS < 0) ? 0 : y - RADIUS; const int y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS;
const int y1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1; const int y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1;
for (x = 0; x < w; ++x) { for (x = 0; x < w; ++x) {
const int x0 = (x - RADIUS < 0) ? 0 : x - RADIUS; const int x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS;
const int x1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1; const int x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1;
double best_sse = 255. * 255.; double best_sse = 255. * 255.;
const double value = (double)ref[y * ref_stride + x]; const double value = (double)ref[y * ref_stride + x];
int i, j; int i, j;
for (j = y0; j < y1; ++j) { for (j = y_0; j < y_1; ++j) {
const uint8_t* s = src + j * src_stride; const uint8_t* s = src + j * src_stride;
for (i = x0; i < x1; ++i) { for (i = x_0; i < x_1; ++i) {
const double sse = (double)(s[i] - value) * (s[i] - value); const double sse = (double)(s[i] - value) * (s[i] - value);
if (sse < best_sse) best_sse = sse; if (sse < best_sse) best_sse = sse;
} }

View File

@ -407,9 +407,10 @@ static int StoreHuffmanCode(VP8LBitWriter* const bw,
} }
static void WriteHuffmanCode(VP8LBitWriter* const bw, static void WriteHuffmanCode(VP8LBitWriter* const bw,
const HuffmanTreeCode* const code, int index) { const HuffmanTreeCode* const code,
const int depth = code->code_lengths[index]; int code_index) {
const int symbol = code->codes[index]; const int depth = code->code_lengths[code_index];
const int symbol = code->codes[code_index];
VP8LWriteBits(bw, depth, symbol); VP8LWriteBits(bw, depth, symbol);
} }
@ -577,10 +578,10 @@ static int EncodeImageInternal(VP8LBitWriter* const bw,
uint32_t i; uint32_t i;
if (histogram_argb == NULL) goto Error; if (histogram_argb == NULL) goto Error;
for (i = 0; i < histogram_image_xysize; ++i) { for (i = 0; i < histogram_image_xysize; ++i) {
const int index = histogram_symbols[i] & 0xffff; const int symbol_index = histogram_symbols[i] & 0xffff;
histogram_argb[i] = 0xff000000 | (index << 8); histogram_argb[i] = 0xff000000 | (symbol_index << 8);
if (index >= max_index) { if (symbol_index >= max_index) {
max_index = index + 1; max_index = symbol_index + 1;
} }
} }
histogram_image_size = max_index; histogram_image_size = max_index;