Some work on index packing
This commit is contained in:
parent
bc5cedf26f
commit
29ccab8aac
5 changed files with 16 additions and 8 deletions
|
@ -146,7 +146,7 @@ void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains)
|
||||||
P[i] = 0;
|
P[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void quant_bands(const CELTMode *m, float *X, float *P)
|
void quant_bands(const CELTMode *m, float *X, float *P, ec_enc *enc)
|
||||||
{
|
{
|
||||||
int i, j, B;
|
int i, j, B;
|
||||||
const int *eBands = m->eBands;
|
const int *eBands = m->eBands;
|
||||||
|
@ -156,11 +156,12 @@ void quant_bands(const CELTMode *m, float *X, float *P)
|
||||||
|
|
||||||
for (i=0;i<m->nbEBands;i++)
|
for (i=0;i<m->nbEBands;i++)
|
||||||
{
|
{
|
||||||
int q;
|
int q, id;
|
||||||
q = m->nbPulses[i];
|
q = m->nbPulses[i];
|
||||||
if (q>0) {
|
if (q>0) {
|
||||||
float n = sqrt(B*(eBands[i+1]-eBands[i]));
|
float n = sqrt(B*(eBands[i+1]-eBands[i]));
|
||||||
alg_quant2(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i]);
|
id = alg_quant2(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i]);
|
||||||
|
ec_enc_uint(enc,id,ncwrs(B*(eBands[i+1]-eBands[i]), q));
|
||||||
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
||||||
norm[j] = X[j] * n;
|
norm[j] = X[j] * n;
|
||||||
//bits += log2(ncwrs(B*(eBands[i+1]-eBands[i]), q));
|
//bits += log2(ncwrs(B*(eBands[i+1]-eBands[i]), q));
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
#ifndef BANDS_H
|
#ifndef BANDS_H
|
||||||
#define BANDS_H
|
#define BANDS_H
|
||||||
|
|
||||||
|
|
||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
|
#include "entenc.h"
|
||||||
|
|
||||||
void compute_band_energies(const CELTMode *m, float *X, float *bands);
|
void compute_band_energies(const CELTMode *m, float *X, float *bands);
|
||||||
|
|
||||||
|
@ -44,7 +46,7 @@ void compute_pitch_gain(const CELTMode *m, float *X, float *P, float *gains, flo
|
||||||
|
|
||||||
void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains);
|
void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains);
|
||||||
|
|
||||||
void quant_bands(const CELTMode *m, float *X, float *P);
|
void quant_bands(const CELTMode *m, float *X, float *P, ec_enc *enc);
|
||||||
|
|
||||||
void pitch_renormalise_bands(const CELTMode *m, float *X, float *P);
|
void pitch_renormalise_bands(const CELTMode *m, float *X, float *P);
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ int celt_encode(CELTState *st, short *pcm)
|
||||||
sum += X[i]*X[i];
|
sum += X[i]*X[i];
|
||||||
printf ("%f\n", sum);*/
|
printf ("%f\n", sum);*/
|
||||||
/* Residual quantisation */
|
/* Residual quantisation */
|
||||||
quant_bands(st->mode, X, P);
|
quant_bands(st->mode, X, P, &st->enc);
|
||||||
|
|
||||||
/* Synthesis */
|
/* Synthesis */
|
||||||
denormalise_bands(st->mode, X, bandE);
|
denormalise_bands(st->mode, X, bandE);
|
||||||
|
@ -267,7 +267,7 @@ int celt_encode(CELTState *st, short *pcm)
|
||||||
pcm[i*N+j] = (short)floor(.5+tmp);
|
pcm[i*N+j] = (short)floor(.5+tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf ("%d\n", ec_byte_bytes(&st->buf));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "cwrs.h"
|
||||||
|
|
||||||
/* Algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
|
/* Algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
|
||||||
a combination of pulses such that its norm is still equal to 1 */
|
a combination of pulses such that its norm is still equal to 1 */
|
||||||
|
@ -94,7 +95,7 @@ void alg_quant(float *x, int N, int K, float *p)
|
||||||
/* Improved algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
|
/* Improved algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
|
||||||
a combination of pulses such that its norm is still equal to 1. The only difference with
|
a combination of pulses such that its norm is still equal to 1. The only difference with
|
||||||
the quantiser above is that the search is more complete. */
|
the quantiser above is that the search is more complete. */
|
||||||
void alg_quant2(float *x, int N, int K, float *p)
|
int alg_quant2(float *x, int N, int K, float *p)
|
||||||
{
|
{
|
||||||
int L = 5;
|
int L = 5;
|
||||||
//float tata[200];
|
//float tata[200];
|
||||||
|
@ -236,6 +237,10 @@ void alg_quant2(float *x, int N, int K, float *p)
|
||||||
for (i=0;i<N;i++)
|
for (i=0;i<N;i++)
|
||||||
x[i] *= E;
|
x[i] *= E;
|
||||||
}
|
}
|
||||||
|
int comb[K];
|
||||||
|
int signs[K];
|
||||||
|
pulse2comb(N, K, comb, signs, iy[0]);
|
||||||
|
return icwrs(N, K, comb, signs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just replace the band with noise of unit energy */
|
/* Just replace the band with noise of unit energy */
|
||||||
|
|
|
@ -39,7 +39,7 @@ void alg_quant(float *x, int N, int K, float *p);
|
||||||
/* Improved algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
|
/* Improved algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
|
||||||
a combination of pulses such that its norm is still equal to 1. The only difference with
|
a combination of pulses such that its norm is still equal to 1. The only difference with
|
||||||
the quantiser above is that the search is more complete. */
|
the quantiser above is that the search is more complete. */
|
||||||
void alg_quant2(float *x, int N, int K, float *p);
|
int alg_quant2(float *x, int N, int K, float *p);
|
||||||
|
|
||||||
/* Just replace the band with noise of unit energy */
|
/* Just replace the band with noise of unit energy */
|
||||||
void noise_quant(float *x, int N, int K, float *p);
|
void noise_quant(float *x, int N, int K, float *p);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue