--- quant_h263.c 2002/11/17 00:41:19 1.4 +++ quant_h263.c 2002/12/15 01:21:12 1.6 @@ -48,7 +48,7 @@ * exception also makes it possible to release a modified version which * carries forward this exception. * - * $Id: quant_h263.c,v 1.4 2002/11/17 00:41:19 edgomez Exp $ + * $Id: quant_h263.c,v 1.6 2002/12/15 01:21:12 edgomez Exp $ * *************************************************************************/ @@ -75,7 +75,7 @@ #define DIV_DIV(a, b) ((a)>0) ? ((a)+((b)>>1))/(b) : ((a)-((b)>>1))/(b) -// function pointers +/* function pointers */ quanth263_intraFuncPtr quant_intra; quanth263_intraFuncPtr dequant_intra; @@ -95,10 +95,10 @@ const uint32_t dcscalar) { const uint32_t mult = multipliers[quant]; - const uint16_t quant_m_2 = quant << 1; + const uint16_t quant_m_2 = (uint16_t)(quant << 1); uint32_t i; - coeff[0] = DIV_DIV(data[0], (int32_t) dcscalar); + coeff[0] = (int16_t)(DIV_DIV(data[0], (int32_t) dcscalar)); for (i = 1; i < 64; i++) { int16_t acLevel = data[i]; @@ -109,14 +109,14 @@ coeff[i] = 0; continue; } - acLevel = (acLevel * mult) >> SCALEBITS; + acLevel = (int16_t)(((uint32_t)acLevel * mult) >> SCALEBITS); coeff[i] = -acLevel; } else { if (acLevel < quant_m_2) { coeff[i] = 0; continue; } - acLevel = (acLevel * mult) >> SCALEBITS; + acLevel = (int16_t)(((uint32_t)acLevel * mult) >> SCALEBITS); coeff[i] = acLevel; } } @@ -132,8 +132,8 @@ const uint32_t quant) { const uint32_t mult = multipliers[quant]; - const uint16_t quant_m_2 = quant << 1; - const uint16_t quant_d_2 = quant >> 1; + const uint16_t quant_m_2 = (uint16_t)(quant << 1); + const uint16_t quant_d_2 = (uint16_t)(quant >> 1); int sum = 0; uint32_t i; @@ -147,8 +147,8 @@ continue; } - acLevel = (acLevel * mult) >> SCALEBITS; - sum += acLevel; // sum += |acLevel| + acLevel = (int16_t)(((uint32_t)acLevel * mult) >> SCALEBITS); + sum += acLevel; /* sum += |acLevel| */ coeff[i] = -acLevel; } else { acLevel -= quant_d_2; @@ -156,7 +156,7 @@ coeff[i] = 0; continue; } - acLevel = (acLevel * mult) >> SCALEBITS; + acLevel = (int16_t)(((uint32_t)acLevel * mult) >> SCALEBITS); sum += acLevel; coeff[i] = acLevel; } @@ -179,7 +179,7 @@ const int32_t quant_add = (quant & 1 ? quant : quant - 1); uint32_t i; - data[0] = coeff[0] * dcscalar; + data[0] = (int16_t)(coeff[0] * dcscalar); if (data[0] < -2048) { data[0] = -2048; } else if (data[0] > 2047) { @@ -195,7 +195,7 @@ } else if (acLevel < 0) { acLevel = quant_m_2 * -acLevel + quant_add; data[i] = (acLevel <= 2048 ? -acLevel : -2048); - } else // if (acLevel > 0) { + } else /* if (acLevel > 0) { */ { acLevel = quant_m_2 * acLevel + quant_add; data[i] = (acLevel <= 2047 ? acLevel : 2047); @@ -213,8 +213,8 @@ const int16_t * coeff, const uint32_t quant) { - const uint16_t quant_m_2 = quant << 1; - const uint16_t quant_add = (quant & 1 ? quant : quant - 1); + const uint16_t quant_m_2 = (uint16_t)(quant << 1); + const uint16_t quant_add = (uint16_t)(quant & 1 ? quant : quant - 1); uint32_t i; for (i = 0; i < 64; i++) { @@ -225,7 +225,7 @@ } else if (acLevel < 0) { acLevel = acLevel * quant_m_2 - quant_add; data[i] = (acLevel >= -2048 ? acLevel : -2048); - } else // if (acLevel > 0) + } else /* if (acLevel > 0) */ { acLevel = acLevel * quant_m_2 + quant_add; data[i] = (acLevel <= 2047 ? acLevel : 2047);