Don't use the VQ codebooks when building Opus

This commit is contained in:
Jean-Marc Valin 2023-06-06 23:01:00 -04:00
parent d749351ae5
commit 47bcd4a7f5
4 changed files with 18 additions and 1 deletions

View file

@ -45,6 +45,7 @@
#include "lpcnet_private.h"
#include "lpcnet.h"
#ifndef OPUS_BUILD
#define SURVIVORS 5
@ -461,6 +462,7 @@ void bits_pack(packer *bits, unsigned int data, int nb_bits) {
}
}
#endif
LPCNET_EXPORT int lpcnet_encoder_get_size() {
return sizeof(LPCNetEncState);
@ -586,11 +588,13 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int
float center_pitch;
int main_pitch;
int modulation;
int corr_id = 0;
#ifndef OPUS_BUILD
int c0_id=0;
int vq_end[3]={0};
int vq_mid=0;
int corr_id = 0;
int interp_id=0;
#endif
for(sub=0;sub<8;sub++) frame_weight_sum += st->frame_weight[2+sub];
for(sub=0;sub<8;sub++) st->frame_weight[2+sub] *= (8.f/frame_weight_sum);
for(sub=0;sub<8;sub++) {
@ -690,6 +694,7 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int
/*printf("%d %f %f %f\n", best_period, best_a, best_b, best_corr);*/
RNN_COPY(&st->xc[0][0], &st->xc[8][0], PITCH_MAX_PERIOD);
RNN_COPY(&st->xc[1][0], &st->xc[9][0], PITCH_MAX_PERIOD);
#ifndef OPUS_BUILD
if (quantize) {
/*printf("%f\n", st->features[3][0]);*/
c0_id = (int)floor(.5 + st->features[3][0]*4);
@ -701,6 +706,7 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int
interp_id = double_interp_search(st->features, st->vq_mem);
perform_double_interp(st->features, st->vq_mem, interp_id);
}
#endif
for (sub=0;sub<4;sub++) {
lpc_from_cepstrum(st->lpc, st->features[sub]);
for (i=0;i<LPC_ORDER;i++) st->features[sub][NB_BANDS+2+i] = st->lpc[i];
@ -708,6 +714,7 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int
/*printf("\n");*/
RNN_COPY(st->vq_mem, &st->features[3][0], NB_BANDS);
if (encode) {
#ifndef OPUS_BUILD
packer bits;
/*fprintf(stdout, "%d %d %d %d %d %d %d %d %d\n", c0_id+64, main_pitch, voiced ? modulation+4 : 0, corr_id, vq_end[0], vq_end[1], vq_end[2], vq_mid, interp_id);*/
bits_packer_init(&bits, buf, 8);
@ -721,6 +728,9 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int
bits_pack(&bits, vq_mid, 13);
bits_pack(&bits, interp_id, 3);
if (ffeat) fwrite(buf, 1, 8, ffeat);
#else
(void)buf;
#endif
} else if (ffeat) {
for (i=0;i<4;i++) {
fwrite(st->features[i], sizeof(float), NB_TOTAL_FEATURES, ffeat);