From ec8008b086d39901c469386c0506c61ffd8a9ae4 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell <greg@xiph.org> Date: Tue, 30 Aug 2011 16:50:01 -0400 Subject: [PATCH] Adds many syntactically unnecessary casts to silence MSVC C4244; fix an MDCT encoder reset bug. st->tonal_average was being set to 1 instead of 256 on reset in floating point builds, otherwise the object code is unchanged. --- libcelt/bands.c | 2 +- libcelt/celt.c | 4 ++-- libcelt/quant_bands.c | 6 +++--- libcelt/vq.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libcelt/bands.c b/libcelt/bands.c index 75c32247b..77ac17044 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -1083,7 +1083,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c for (j=0;j<N;j++) { *seed = lcg_rand(*seed); - X[j] = (opus_int32)(*seed)>>20; + X[j] = (celt_norm)((opus_int32)*seed>>20); } cm = cm_mask; } else { diff --git a/libcelt/celt.c b/libcelt/celt.c index b3257926a..f85c21dec 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -1816,7 +1816,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) st->vbr_offset = 0; st->delayedIntra = 1; st->spread_decision = SPREAD_NORMAL; - st->tonal_average = QCONST16(1.f,8); + st->tonal_average = 256; } break; case CELT_SET_INPUT_CLIPPING_REQUEST: @@ -2063,7 +2063,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, opus_val16 * restrict pc for (j=0;j<blen;j++) { seed = lcg_rand(seed); - X[boffs+j] = (opus_int32)(seed)>>20; + X[boffs+j] = (celt_norm)((opus_int32)seed>>20); } renormalise_vector(X+boffs, blen, Q15ONE); } diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index 9a14314c2..7a71864b0 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -244,7 +244,7 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end, qi = -1; error[i+c*m->nbEBands] = PSHR32(f,7) - SHL16(qi,DB_SHIFT); badness += abs(qi0-qi); - q = SHL32(EXTEND32(qi),DB_SHIFT); + q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT); tmp = PSHR32(MULT16_16(coef,oldE),8) + prev[c] + SHL32(q,7); #ifdef FIXED_POINT @@ -275,7 +275,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, SAVE_STACK; intra = force_intra || (!two_pass && *delayedIntra>2*C*(end-start) && nbAvailableBytes > (end-start)*C); - intra_bias = ((budget**delayedIntra*loss_rate)/(C*512)); + intra_bias = (opus_int32)((budget**delayedIntra*loss_rate)/(C*512)); new_distortion = loss_distortion(eBands, oldEBands, start, effEnd, m->nbEBands, C); tell = ec_tell(enc); @@ -470,7 +470,7 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *ol } else qi = -1; - q = SHL32(EXTEND32(qi),DB_SHIFT); + q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT); oldEBands[i+c*m->nbEBands] = MAX16(-QCONST16(9.f,DB_SHIFT), oldEBands[i+c*m->nbEBands]); tmp = PSHR32(MULT16_16(coef,oldEBands[i+c*m->nbEBands]),8) + prev[c] + SHL32(q,7); diff --git a/libcelt/vq.c b/libcelt/vq.c index 05806ec3a..89b368736 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -239,7 +239,7 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, #else iy[j] = (int)floor(rcp*X[j]); #endif - y[j] = iy[j]; + y[j] = (celt_norm)iy[j]; yy = MAC16_16(yy, y[j],y[j]); xy = MAC16_16(xy, X[j],y[j]); y[j] *= 2; -- GitLab