shithub: opus

Download patch

ref: 1b36d6c8b6f540f45e5258ae8864738d5b8e0a06
parent: 020ef4f810ce441a79abdbe9cd0840a462d888ac
author: Jean-Marc Valin <[email protected]>
date: Tue Aug 31 13:21:52 EDT 2010

Complexity setting now controls two-pass coarse energy quantization

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -743,7 +743,8 @@
    ALLOC(error, C*st->mode->nbEBands, celt_word16);
    quant_coarse_energy(st->mode, st->start, st->end, effEnd, bandLogE,
          oldBandE, nbCompressedBytes*8, st->mode->prob,
-         error, enc, C, LM, nbAvailableBytes, st->force_intra, &st->delayedIntra);
+         error, enc, C, LM, nbAvailableBytes, st->force_intra,
+         &st->delayedIntra, st->complexity >= 4);
 
    ec_enc_bit_prob(enc, shortBlocks!=0, 8192);
 
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -183,7 +183,7 @@
 void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
       const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
       const celt_int16 *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
-      int nbAvailableBytes, int force_intra, int *delayedIntra)
+      int nbAvailableBytes, int force_intra, int *delayedIntra, int two_pass)
 {
    const int C = CHANNELS(_C);
    int intra;
@@ -216,8 +216,11 @@
    ALLOC(error_intra, C*m->nbEBands, celt_word16);
    CELT_COPY(oldEBands_intra, oldEBands, C*end);
 
-   quant_coarse_energy_impl(m, start, end, eBands, oldEBands_intra, budget,
-         prob, error_intra, enc, C, LM, 1, max_decay);
+   if (two_pass || intra)
+   {
+      quant_coarse_energy_impl(m, start, end, eBands, oldEBands_intra, budget,
+            prob, error_intra, enc, C, LM, 1, max_decay);
+   }
 
    if (!intra)
    {
@@ -241,7 +244,7 @@
       quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budget,
             prob, error, enc, C, LM, 0, max_decay);
 
-      if (ec_enc_tell(enc, 3) > tell_intra)
+      if (two_pass && ec_enc_tell(enc, 3) > tell_intra)
       {
          *enc = enc_intra_state;
          *(enc->buf) = buf_intra_state;
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -51,7 +51,7 @@
 void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
       const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
       const celt_int16 *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
-      int nbAvailableBytes, int force_intra, int *delayedIntra);
+      int nbAvailableBytes, int force_intra, int *delayedIntra, int two_pass);
 
 void quant_fine_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, ec_enc *enc, int _C);