ref: 47bcd4a7f51511f6836fd51dfb5a1b26acb304e9
parent: d749351ae573de0c87751af31866d9eb726e2180
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Tue Jun 6 19:01:00 EDT 2023
Don't use the VQ codebooks when building Opus
--- a/dnn/lpcnet.c
+++ b/dnn/lpcnet.c
@@ -280,6 +280,8 @@
lpcnet_synthesize_impl(lpcnet, features, output, N, 0);
}
+#ifndef OPUS_BUILD
+
LPCNET_EXPORT int lpcnet_decoder_get_size()
{
return sizeof(LPCNetDecState);
@@ -316,3 +318,4 @@
return 0;
}
+#endif
--- a/dnn/lpcnet_dec.c
+++ b/dnn/lpcnet_dec.c
@@ -77,6 +77,7 @@
return d;
}
+#ifndef OPUS_BUILD
void decode_packet(float features[4][NB_TOTAL_FEATURES], float *vq_mem, const unsigned char buf[8])
{
int c0_id;
@@ -152,3 +153,4 @@
RNN_COPY(vq_mem, &features[3][0], NB_BANDS);
}
+#endif
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -45,6 +45,7 @@
#include "lpcnet_private.h"
#include "lpcnet.h"
+#ifndef OPUS_BUILD
#define SURVIVORS 5
@@ -461,6 +462,7 @@
}
}
+#endif
LPCNET_EXPORT int lpcnet_encoder_get_size() {
return sizeof(LPCNetEncState);
@@ -586,11 +588,13 @@
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 @@
/*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 @@
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 @@
/*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 @@
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);
--- a/dnn/lpcnet_private.h
+++ b/dnn/lpcnet_private.h
@@ -105,10 +105,12 @@
short queued_samples[FRAME_SIZE];
};
+#ifndef OPUS_BUILD
extern float ceps_codebook1[];
extern float ceps_codebook2[];
extern float ceps_codebook3[];
extern float ceps_codebook_diff4[];
+#endif
void preemphasis(float *y, float *mem, const float *x, float coef, int N);
--
⑨