Skip to content
Snippets Groups Projects
Verified Commit 8b42b006 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Fix DRED for 10-ms frames

parent 28503d92
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@
#include "celt/laplace.h"
#include "os_support.h"
#include "dred_config.h"
#include "dred_coding.h"
#define LATENT_DIM 80
#define PVQ_DIM 24
......@@ -74,9 +75,12 @@ static void encode_pvq(const int *iy, int N, int K, ec_enc *enc) {
}
}
void dred_encode_state(ec_enc *enc, float *x) {
void dred_encode_state(ec_enc *enc, const float *x) {
int iy[PVQ_DIM];
op_pvq_search_c(x, iy, PVQ_K, PVQ_DIM, 0);
float x0[PVQ_DIM];
/* Copy state because the PVQ search will trash it. */
OPUS_COPY(x0, x, PVQ_DIM);
op_pvq_search_c(x0, iy, PVQ_K, PVQ_DIM, 0);
encode_pvq(iy, PVQ_DIM, PVQ_K, enc);
}
......
......@@ -33,7 +33,7 @@
int compute_quantizer(int q0, int dQ, int i);
void dred_encode_state(ec_enc *enc, float *x);
void dred_encode_state(ec_enc *enc, const float *x);
void dred_encode_latents(ec_enc *enc, const float *x, const opus_uint16 *scale, const opus_uint16 *dzone, const opus_uint16 *r, const opus_uint16 *p0);
......
......@@ -107,7 +107,7 @@ void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size)
}
}
int dred_encode_silk_frame(DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes) {
int dred_encode_silk_frame(const DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes) {
const opus_uint16 *dead_zone = DRED_rdovae_get_dead_zone_pointer();
const opus_uint16 *p0 = DRED_rdovae_get_p0_pointer();
const opus_uint16 *quant_scales = DRED_rdovae_get_quant_scales_pointer();
......
......@@ -59,6 +59,6 @@ void dred_deinit_encoder(DREDEnc *enc);
void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size);
int dred_encode_silk_frame(DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes);
int dred_encode_silk_frame(const DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes);
#endif
......@@ -670,7 +670,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
if (st->lpcnet.blend == 0) needed_feature_frames+=2;
for (i=0;i<needed_feature_frames;i++) {
int feature_offset = (needed_feature_frames-i-1 + (dred_offset/(st->Fs/100)-2));
if (feature_offset <= 4*dred->nb_latents-1) {
if (feature_offset <= 4*dred->nb_latents-1 && feature_offset >= 0) {
lpcnet_plc_fec_add(&st->lpcnet, dred->fec_features+feature_offset*DRED_NUM_FEATURES);
} else {
lpcnet_plc_fec_add(&st->lpcnet, NULL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment