Address gcc -Wtype-limits errors.

- Fixes warnings in #19 and #16.
This commit is contained in:
Ari Koivula 2014-04-29 09:02:21 +03:00
parent 2a17e9a7aa
commit 27b94d4b45
3 changed files with 7 additions and 10 deletions

View file

@ -45,7 +45,7 @@ else
endif endif
CC = gcc -fopenmp CC = gcc -fopenmp
CCFLAGS = $(DFLAGS) -I. -Wall CCFLAGS = $(DFLAGS) -I. -Wall -Wtype-limits
LDFLAGS += -lm LDFLAGS += -lm
LD = gcc -fopenmp LD = gcc -fopenmp
YASM = yasm YASM = yasm

View file

@ -2050,7 +2050,7 @@ static void reconstruct_chroma(const encoder_state * const encoder_state, cu_inf
// without coeffs, we only use the prediction // without coeffs, we only use the prediction
for (y = 0; y < width_c; y++) { for (y = 0; y < width_c; y++) {
for (x = 0; x < width_c; x++) { for (x = 0; x < width_c; x++) {
recbase_u[x + y * (recbase_stride >> 1)] = (uint8_t)CLIP(0, 255, pred_u[x + y * (pred_stride >> 1)]); recbase_u[x + y * (recbase_stride >> 1)] = pred_u[x + y * (pred_stride >> 1)];
} }
} }
} }
@ -2331,7 +2331,7 @@ void encode_transform_tree(encoder_state * const encoder_state, int32_t x, int32
// Without coefficients, just copy the prediction as the reconstructed image. // Without coefficients, just copy the prediction as the reconstructed image.
for (y = 0; y < width; y++) { for (y = 0; y < width; y++) {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
recbase_y[x + y * recbase_stride] = (pixel)CLIP(0, 255, pred_y[x + y * pred_stride]); recbase_y[x + y * recbase_stride] = pred_y[x + y * pred_stride];
} }
} }
} }

View file

@ -758,7 +758,7 @@ void quant(const encoder_state * const encoder_state, int16_t *coef, int16_t *q_
void dequant(const encoder_state * const encoder_state, int16_t *q_coef, int16_t *coef, int32_t width, int32_t height,int8_t type, int8_t block_type) void dequant(const encoder_state * const encoder_state, int16_t *q_coef, int16_t *coef, int32_t width, int32_t height,int8_t type, int8_t block_type)
{ {
const encoder_control * const encoder = encoder_state->encoder_control; const encoder_control * const encoder = encoder_state->encoder_control;
int32_t shift,add,coeff_q,clip_q_coef; int32_t shift,add,coeff_q;
int32_t n; int32_t n;
int32_t transform_shift = 15 - encoder->bitdepth - (g_convert_to_bit[ width ] + 2); int32_t transform_shift = 15 - encoder->bitdepth - (g_convert_to_bit[ width ] + 2);
@ -778,15 +778,13 @@ void dequant(const encoder_state * const encoder_state, int16_t *q_coef, int16_t
add = 1 << (shift - qp_scaled/6 - 1); add = 1 << (shift - qp_scaled/6 - 1);
for (n = 0; n < width * height; n++) { for (n = 0; n < width * height; n++) {
clip_q_coef = CLIP(-32768, 32767, q_coef[n]); coeff_q = ((q_coef[n] * dequant_coef[n]) + add ) >> (shift - qp_scaled/6);
coeff_q = ((clip_q_coef * dequant_coef[n]) + add ) >> (shift - qp_scaled/6);
coef[n] = (int16_t)CLIP(-32768,32767,coeff_q); coef[n] = (int16_t)CLIP(-32768,32767,coeff_q);
} }
} else { } else {
for (n = 0; n < width * height; n++) { for (n = 0; n < width * height; n++) {
// Clip to avoid possible overflow in following shift left operation // Clip to avoid possible overflow in following shift left operation
clip_q_coef = CLIP(-32768, 32767, q_coef[n]); coeff_q = CLIP(-32768, 32767, q_coef[n] * dequant_coef[n]);
coeff_q = CLIP(-32768, 32767, clip_q_coef * dequant_coef[n]);
coef[n] = (int16_t)CLIP(-32768, 32767, coeff_q << (qp_scaled/6 - shift)); coef[n] = (int16_t)CLIP(-32768, 32767, coeff_q << (qp_scaled/6 - shift));
} }
} }
@ -795,8 +793,7 @@ void dequant(const encoder_state * const encoder_state, int16_t *q_coef, int16_t
add = 1 << (shift-1); add = 1 << (shift-1);
for (n = 0; n < width*height; n++) { for (n = 0; n < width*height; n++) {
clip_q_coef = CLIP(-32768, 32767, q_coef[n]); coeff_q = (q_coef[n] * scale + add) >> shift;
coeff_q = (clip_q_coef * scale + add) >> shift;
coef[n] = (int16_t)CLIP(-32768, 32767, coeff_q); coef[n] = (int16_t)CLIP(-32768, 32767, coeff_q);
} }
} }