Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-12-19 16:19:54 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-12-23 04:28:36 +0400
commitdfe3bf9650617ff09eb6598e8296e4631ca85887 (patch)
tree96d238ef9250b3844127996e59d63a7695747b57
parentd683c76b882224cb331268438c001ac46fe8e3ab (diff)
First step in quant_band() cleanup: N=1 case.
-rw-r--r--celt/bands.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/celt/bands.c b/celt/bands.c
index 6d135475..412e37f7 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -648,6 +648,41 @@ static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo)
return qn;
}
+static unsigned quant_band_n1(int encode, celt_norm *X, celt_norm *Y, int b,
+ opus_int32 *remaining_bits, ec_ctx *ec, celt_norm *lowband_out)
+{
+#ifdef RESYNTH
+ int resynth = 1;
+#else
+ int resynth = !encode;
+#endif
+ int c;
+ int stereo;
+ celt_norm *x = X;
+ stereo = Y != NULL;
+ c=0; do {
+ int sign=0;
+ if (*remaining_bits>=1<<BITRES)
+ {
+ if (encode)
+ {
+ sign = x[0]<0;
+ ec_enc_bits(ec, sign, 1);
+ } else {
+ sign = ec_dec_bits(ec, 1);
+ }
+ *remaining_bits -= 1<<BITRES;
+ b-=1<<BITRES;
+ }
+ if (resynth)
+ x[0] = sign ? -NORM_SCALING : NORM_SCALING;
+ x = Y;
+ } while (++c<1+stereo);
+ if (lowband_out)
+ lowband_out[0] = SHR16(X[0],4);
+ return 1;
+}
+
/* This function is responsible for encoding and decoding a band for both
the mono and stereo case. Even in the mono case, it can split the band
in two and transmit the energy difference with the two half-bands. It
@@ -688,29 +723,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
/* Special case for one sample */
if (N==1)
{
- int c;
- celt_norm *x = X;
- c=0; do {
- int sign=0;
- if (*remaining_bits>=1<<BITRES)
- {
- if (encode)
- {
- sign = x[0]<0;
- ec_enc_bits(ec, sign, 1);
- } else {
- sign = ec_dec_bits(ec, 1);
- }
- *remaining_bits -= 1<<BITRES;
- b-=1<<BITRES;
- }
- if (resynth)
- x[0] = sign ? -NORM_SCALING : NORM_SCALING;
- x = Y;
- } while (++c<1+stereo);
- if (lowband_out)
- lowband_out[0] = SHR16(X[0],4);
- return 1;
+ return quant_band_n1(encode, X, Y, b, remaining_bits, ec, lowband_out);
}
if (!stereo && level == 0)