shithub: opus

Download patch

ref: 0527f3735209a70494a1d6894d8bf5a0597a37d8
parent: 34952f3e45888a5af2dcb9718891703095c9b3ac
author: Gregory Maxwell <[email protected]>
date: Tue Sep 23 15:28:35 EDT 2008

Fix support for 64 sample frames.

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -541,11 +541,14 @@
       has_pitch = quant_pitch(gains, st->mode->nbPBands, &st->enc);
       if (has_pitch)
          ec_enc_uint(&st->enc, pitch_index, MAX_PERIOD-(2*N-2*N4));
+      else if (st->mode->nbShortMdcts > 1)
+         ec_enc_bits(&st->enc, 0, 1); //Transient off
    } else {
       if (!shortBlocks)
       {
          ec_enc_bits(&st->enc, 0, 1); //Pitch off
-         ec_enc_bits(&st->enc, 0, 1); //Transient off
+         if (st->mode->nbShortMdcts > 1)
+           ec_enc_bits(&st->enc, 0, 1); //Transient off
       }
       /* No pitch, so we just pretend we found a gain of zero */
       for (i=0;i<st->mode->nbPBands;i++)
@@ -891,35 +894,26 @@
    ec_byte_readinit(&buf,data,len);
    ec_dec_init(&dec,&buf);
    
-   if (st->mode->nbShortMdcts > 1)
+   has_pitch = ec_dec_bits(&dec, 1);
+   if (has_pitch)
    {
-      has_pitch = ec_dec_bits(&dec, 1);
-      if (has_pitch)
-      {
-         has_fold = ec_dec_bits(&dec, 1);
-         shortBlocks = 0;
-      } else {
-         shortBlocks = ec_dec_bits(&dec, 1);
-         has_fold = 1;
-      }
-      if (shortBlocks)
-      {
-         transient_shift = ec_dec_bits(&dec, 2);
-         if (transient_shift)
-            transient_time = ec_dec_uint(&dec, N+st->mode->overlap);
-         else
-            transient_time = 0;
-      } else {
-         transient_time = -1;
-         transient_shift = 0;
-      }
+      has_fold = ec_dec_bits(&dec, 1);
+      shortBlocks = 0;
+   } else if (st->mode->nbShortMdcts > 1){
+      shortBlocks = ec_dec_bits(&dec, 1);
+      has_fold = 1;
    } else {
-      has_pitch = ec_dec_bits(&dec, 1);
-      if (has_pitch)
-         has_fold = ec_dec_bits(&dec, 1);
-      else
-         has_fold = 1;
       shortBlocks = 0;
+      has_fold = 1;
+   }
+   if (shortBlocks)
+   {
+      transient_shift = ec_dec_bits(&dec, 2);
+      if (transient_shift)
+         transient_time = ec_dec_uint(&dec, N+st->mode->overlap);
+      else
+         transient_time = 0;
+   } else {
       transient_time = -1;
       transient_shift = 0;
    }
--- a/libcelt/quant_pitch.c
+++ b/libcelt/quant_pitch.c
@@ -113,7 +113,6 @@
    if (id == 0)
    {
       ec_enc_bits(enc, 0, 1); //Pitch off
-      ec_enc_bits(enc, 0, 1); //Transient off
    } else {
       ec_enc_bits(enc, 1, 1); //Pitch on
       ec_enc_bits(enc, 1, 1); //Folding on