minor doc update
[opus.git] / libcelt / quant_bands.c
index 2e7e14d..9927a18 100644 (file)
@@ -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);
@@ -295,7 +295,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
 
    ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16);
    ALLOC(error_intra, C*m->nbEBands, opus_val16);
-   CELT_COPY(oldEBands_intra, oldEBands, C*m->nbEBands);
+   OPUS_COPY(oldEBands_intra, oldEBands, C*m->nbEBands);
 
    if (two_pass || intra)
    {
@@ -305,8 +305,9 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
 
    if (!intra)
    {
+      unsigned char *intra_buf;
       ec_enc enc_intra_state;
-      int tell_intra;
+      opus_int32 tell_intra;
       opus_uint32 nstart_bytes;
       opus_uint32 nintra_bytes;
       int badness2;
@@ -318,30 +319,28 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
 
       nstart_bytes = ec_range_bytes(&enc_start_state);
       nintra_bytes = ec_range_bytes(&enc_intra_state);
+      intra_buf = ec_get_buffer(&enc_intra_state) + nstart_bytes;
       ALLOC(intra_bits, nintra_bytes-nstart_bytes, unsigned char);
       /* Copy bits from intra bit-stream */
-      CELT_COPY(intra_bits,
-            ec_get_buffer(&enc_intra_state) + nstart_bytes,
-            nintra_bytes - nstart_bytes);
+      OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes);
 
       *enc = enc_start_state;
 
       badness2 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budget,
             tell, e_prob_model[LM][intra], error, enc, C, LM, 0, max_decay);
 
-      if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ec_tell_frac(enc)+intra_bias > tell_intra)))
+      if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ((opus_int32)ec_tell_frac(enc))+intra_bias > tell_intra)))
       {
          *enc = enc_intra_state;
          /* Copy intra bits to bit-stream */
-         CELT_COPY(ec_get_buffer(&enc_intra_state) + nstart_bytes,
-               intra_bits, nintra_bytes - nstart_bytes);
-         CELT_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
-         CELT_COPY(error, error_intra, C*m->nbEBands);
+         OPUS_COPY(intra_buf, intra_bits, nintra_bytes - nstart_bytes);
+         OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
+         OPUS_COPY(error, error_intra, C*m->nbEBands);
          intra = 1;
       }
    } else {
-      CELT_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
-      CELT_COPY(error, error_intra, C*m->nbEBands);
+      OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
+      OPUS_COPY(error, error_intra, C*m->nbEBands);
    }
 
    if (intra)
@@ -470,7 +469,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);