mirror of
https://github.com/xiph/opus.git
synced 2025-05-17 17:08:29 +00:00
Don't use the VQ codebooks when building Opus
This commit is contained in:
parent
d749351ae5
commit
47bcd4a7f5
4 changed files with 18 additions and 1 deletions
|
@ -280,6 +280,8 @@ LPCNET_EXPORT void lpcnet_synthesize(LPCNetState *lpcnet, const float *features,
|
||||||
lpcnet_synthesize_impl(lpcnet, features, output, N, 0);
|
lpcnet_synthesize_impl(lpcnet, features, output, N, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OPUS_BUILD
|
||||||
|
|
||||||
LPCNET_EXPORT int lpcnet_decoder_get_size()
|
LPCNET_EXPORT int lpcnet_decoder_get_size()
|
||||||
{
|
{
|
||||||
return sizeof(LPCNetDecState);
|
return sizeof(LPCNetDecState);
|
||||||
|
@ -316,3 +318,4 @@ LPCNET_EXPORT int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, sh
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -77,6 +77,7 @@ unsigned int bits_unpack(unpacker *bits, int nb_bits) {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OPUS_BUILD
|
||||||
void decode_packet(float features[4][NB_TOTAL_FEATURES], float *vq_mem, const unsigned char buf[8])
|
void decode_packet(float features[4][NB_TOTAL_FEATURES], float *vq_mem, const unsigned char buf[8])
|
||||||
{
|
{
|
||||||
int c0_id;
|
int c0_id;
|
||||||
|
@ -152,3 +153,4 @@ void decode_packet(float features[4][NB_TOTAL_FEATURES], float *vq_mem, const un
|
||||||
|
|
||||||
RNN_COPY(vq_mem, &features[3][0], NB_BANDS);
|
RNN_COPY(vq_mem, &features[3][0], NB_BANDS);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "lpcnet_private.h"
|
#include "lpcnet_private.h"
|
||||||
#include "lpcnet.h"
|
#include "lpcnet.h"
|
||||||
|
|
||||||
|
#ifndef OPUS_BUILD
|
||||||
|
|
||||||
#define SURVIVORS 5
|
#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() {
|
LPCNET_EXPORT int lpcnet_encoder_get_size() {
|
||||||
return sizeof(LPCNetEncState);
|
return sizeof(LPCNetEncState);
|
||||||
|
@ -586,11 +588,13 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int
|
||||||
float center_pitch;
|
float center_pitch;
|
||||||
int main_pitch;
|
int main_pitch;
|
||||||
int modulation;
|
int modulation;
|
||||||
|
int corr_id = 0;
|
||||||
|
#ifndef OPUS_BUILD
|
||||||
int c0_id=0;
|
int c0_id=0;
|
||||||
int vq_end[3]={0};
|
int vq_end[3]={0};
|
||||||
int vq_mid=0;
|
int vq_mid=0;
|
||||||
int corr_id = 0;
|
|
||||||
int interp_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++) 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++) st->frame_weight[2+sub] *= (8.f/frame_weight_sum);
|
||||||
for(sub=0;sub<8;sub++) {
|
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);*/
|
/*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[0][0], &st->xc[8][0], PITCH_MAX_PERIOD);
|
||||||
RNN_COPY(&st->xc[1][0], &st->xc[9][0], PITCH_MAX_PERIOD);
|
RNN_COPY(&st->xc[1][0], &st->xc[9][0], PITCH_MAX_PERIOD);
|
||||||
|
#ifndef OPUS_BUILD
|
||||||
if (quantize) {
|
if (quantize) {
|
||||||
/*printf("%f\n", st->features[3][0]);*/
|
/*printf("%f\n", st->features[3][0]);*/
|
||||||
c0_id = (int)floor(.5 + st->features[3][0]*4);
|
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);
|
interp_id = double_interp_search(st->features, st->vq_mem);
|
||||||
perform_double_interp(st->features, st->vq_mem, interp_id);
|
perform_double_interp(st->features, st->vq_mem, interp_id);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
for (sub=0;sub<4;sub++) {
|
for (sub=0;sub<4;sub++) {
|
||||||
lpc_from_cepstrum(st->lpc, st->features[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];
|
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");*/
|
/*printf("\n");*/
|
||||||
RNN_COPY(st->vq_mem, &st->features[3][0], NB_BANDS);
|
RNN_COPY(st->vq_mem, &st->features[3][0], NB_BANDS);
|
||||||
if (encode) {
|
if (encode) {
|
||||||
|
#ifndef OPUS_BUILD
|
||||||
packer bits;
|
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);*/
|
/*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);
|
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, vq_mid, 13);
|
||||||
bits_pack(&bits, interp_id, 3);
|
bits_pack(&bits, interp_id, 3);
|
||||||
if (ffeat) fwrite(buf, 1, 8, ffeat);
|
if (ffeat) fwrite(buf, 1, 8, ffeat);
|
||||||
|
#else
|
||||||
|
(void)buf;
|
||||||
|
#endif
|
||||||
} else if (ffeat) {
|
} else if (ffeat) {
|
||||||
for (i=0;i<4;i++) {
|
for (i=0;i<4;i++) {
|
||||||
fwrite(st->features[i], sizeof(float), NB_TOTAL_FEATURES, ffeat);
|
fwrite(st->features[i], sizeof(float), NB_TOTAL_FEATURES, ffeat);
|
||||||
|
|
|
@ -105,10 +105,12 @@ struct LPCNetPLCState {
|
||||||
short queued_samples[FRAME_SIZE];
|
short queued_samples[FRAME_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef OPUS_BUILD
|
||||||
extern float ceps_codebook1[];
|
extern float ceps_codebook1[];
|
||||||
extern float ceps_codebook2[];
|
extern float ceps_codebook2[];
|
||||||
extern float ceps_codebook3[];
|
extern float ceps_codebook3[];
|
||||||
extern float ceps_codebook_diff4[];
|
extern float ceps_codebook_diff4[];
|
||||||
|
#endif
|
||||||
|
|
||||||
void preemphasis(float *y, float *mem, const float *x, float coef, int N);
|
void preemphasis(float *y, float *mem, const float *x, float coef, int N);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue