ref: 012407760c0d0f05fc5b5d7b674af9057a255f47
parent: cb0956d06d4ff93e725296e2e0fbdca2ae599b00
author: Jean-Marc Valin <[email protected]>
date: Thu Feb 7 16:14:16 EST 2008
Re-enabled intra-frame prediction, which seems to have exposed a few issues with the entropy coder.
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -257,12 +257,11 @@
//q = m->nbPulses[i];
n = sqrt(B*(eBands[i+1]-eBands[i]));
theta = .007*(B*(eBands[i+1]-eBands[i]))/(.1f+abs(q));
-
- if (q<=0) {
- q = -q;
+
+ /* If pitch isn't available, use intra-frame prediction */
+ if (eBands[i] >= m->pitchEnd)
intra_prediction(X+B*eBands[i], W+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, norm, P+B*eBands[i], B, eBands[i], enc);
- }
-
+
if (q != 0)
{
exp_rotation(P+B*eBands[i], B*(eBands[i+1]-eBands[i]), theta, -1, B, 8);
@@ -305,10 +304,9 @@
n = sqrt(B*(eBands[i+1]-eBands[i]));
theta = .007*(B*(eBands[i+1]-eBands[i]))/(.1f+abs(q));
- if (q<=0) {
- q = -q;
+ /* If pitch isn't available, use intra-frame prediction */
+ if (eBands[i] >= m->pitchEnd)
intra_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, norm, P+B*eBands[i], B, eBands[i], dec);
- }
if (q != 0)
{
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -349,6 +349,7 @@
celt_warning("got too many bytes");
else
celt_warning("not enough bytes");
+ celt_warning_int ("output bytes:", nbBytes);
return CELT_INTERNAL_ERROR;
}
//printf ("%d\n", *nbBytes);
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -108,7 +108,7 @@
for (i=0;i<alloc->len;i++)
{
int N = BC*(eBands[i+1]-eBands[i]);
- if (N == prevN)
+ if (N == prevN && eBands[i] < m->pitchEnd)
{
alloc->bits[i] = alloc->bits[i-1];
} else {
@@ -117,9 +117,16 @@
alloc->bits[i] = celt_alloc(MAX_PULSES*sizeof(int));
for (j=0;j<MAX_PULSES;j++)
{
+ int done = 0;
alloc->bits[i][j] = log2_frac64(ncwrs64(N, j),BITRES);
- /* We could just update rev_bits here */
+ /* FIXME: Could there be a better test for the max number of pulses that fit in 64 bits? */
if (alloc->bits[i][j] > (60<<BITRES))
+ done = 1;
+ /* Add the intra-frame prediction bits */
+ if (eBands[i] >= m->pitchEnd)
+ alloc->bits[i][j] += (1<<BITRES) + log2_frac64(2*eBands[i]-eBands[i+1],BITRES);
+ /* We could just update rev_bits here */
+ if (done)
break;
}
for (;j<MAX_PULSES;j++)
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -66,9 +66,9 @@
}
bytes_per_packet = atoi(argv[2]);
- if (bytes_per_packet < 25 || bytes_per_packet > 120)
+ if (bytes_per_packet < 20 || bytes_per_packet > 120)
{
- fprintf (stderr, "bytes per packet must be between 25 and 120\n");
+ fprintf (stderr, "bytes per packet must be between 20 and 120\n");
return 1;
}
inFile = argv[3];