Skip to content

Commit 226eb18

Browse files
committed
Allow up to 4096 bits per band (32767>>BITRES)
Further simplifies the split delta
1 parent be68f89 commit 226eb18

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

celt/bands.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int oaci_bitexact_delta(int itheta) {
9898
sign = -1;
9999
}
100100
/* log2(tan(pi/4*x)) ~= log2(x) -.343 - .061*x + .404*x.^2. */
101-
return IMIN(16384, IMAX(-16384, sign*(oaci_bitexact_log2(itheta) - 703 - FRAC_MUL16(itheta, (500 - FRAC_MUL16(itheta, 13238))))));
101+
return sign*(oaci_bitexact_log2(itheta) - 703 - FRAC_MUL16(itheta, (500 - FRAC_MUL16(itheta, 13238))));
102102
}
103103

104104

@@ -608,7 +608,7 @@ void oaci_haar1(celt_norm *X, int N0, int stride) {
608608
}
609609
}
610610

611-
static int oaci_compute_qn(int N, int b, int offset, int pulse_cap, int stereo) {
611+
static int oaci_compute_qn(int N, oac_int32 b, int offset, int pulse_cap, int stereo) {
612612
static const oac_int16 exp2_table8[8] =
613613
{16384, 17866, 19483, 21247, 23170, 25267, 27554, 30048};
614614
int qn, qb;
@@ -653,13 +653,13 @@ struct band_ctx {
653653

654654
struct split_ctx {
655655
int inv;
656-
int delta;
656+
oac_int32 delta;
657657
int itheta;
658658
int itheta_q30;
659659
};
660660

661661
static void oaci_compute_theta(struct band_ctx *ctx, struct split_ctx *sctx,
662-
celt_norm *X, celt_norm *Y, int N, int *b, int B, int B0,
662+
celt_norm *X, celt_norm *Y, int N, oac_int32 *b, int B, int B0,
663663
int LM,
664664
int stereo, int *fill) {
665665
int qn;
@@ -1090,7 +1090,7 @@ unsigned oaci_cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, i
10901090

10911091
/* This function is responsible for encoding and decoding a band for the mono case. */
10921092
static unsigned oaci_quant_band(struct band_ctx *ctx, celt_norm *X,
1093-
int N, int b, int B, celt_norm *lowband,
1093+
int N, oac_int32 b, int B, celt_norm *lowband,
10941094
int LM, celt_norm *lowband_out,
10951095
oac_val32 gain, celt_norm *lowband_scratch, int fill) {
10961096
int N0 = N;
@@ -1211,7 +1211,7 @@ static unsigned oaci_quant_band(struct band_ctx *ctx, celt_norm *X,
12111211

12121212
/* This function is responsible for encoding and decoding a band for the stereo case. */
12131213
static unsigned oaci_quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm *Y,
1214-
int N, int b, int B, celt_norm *lowband,
1214+
int N, oac_int32 b, int B, celt_norm *lowband,
12151215
int LM, celt_norm *lowband_out,
12161216
celt_norm *lowband_scratch, int fill) {
12171217
int inv = 0;
@@ -1443,7 +1443,7 @@ void oaci_quant_all_bands(int encode, const CELTMode *m, int start, int end,
14431443
ctx.avoid_split_noise = B > 1;
14441444
for (i = start; i < end; i++) {
14451445
oac_int32 tell;
1446-
int b;
1446+
oac_int32 b;
14471447
int N;
14481448
oac_int32 curr_balance;
14491449
int effective_lowband = -1;
@@ -1472,7 +1472,7 @@ void oaci_quant_all_bands(int encode, const CELTMode *m, int start, int end,
14721472
ctx.total_bits = total_bits;
14731473
if (i <= codedBands - 1) {
14741474
curr_balance = oaci_celt_sudiv(balance, IMIN(3, codedBands - i));
1475-
b = IMAX(0, IMIN(16383, IMIN(remaining_bits, pulses[i] + curr_balance)));
1475+
b = IMAX(0, IMIN(32767, IMIN(remaining_bits, pulses[i] + curr_balance)));
14761476
} else {
14771477
b = 0;
14781478
}

celt/tests/test_unit_mathops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int oaci_delta_ground_truth(int itheta) {
9595
void testbitexactlog2tan(void) {
9696
int i, fail;
9797
fail = 0;
98-
for (i = 42; i < 16340; i++) {
98+
for (i = 1; i <= 8192; i++) {
9999
oac_int32 q = oaci_bitexact_delta(i);
100100
#ifndef DISABLE_FLOAT_API
101101
if (abs(q - oaci_delta_ground_truth(i)) > 16) fail=1;

0 commit comments

Comments
 (0)