Skip to content
Snippets Groups Projects
Unverified Commit db78df8c authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Delaying new DRED data when just out of silence

We don't need redundancy for the first active frame
since we already have the main Opus payload.
parent c5117c5c
No related branches found
No related tags found
No related merge requests found
Pipeline #5135 passed
......@@ -257,7 +257,7 @@ static int dred_voice_active(const unsigned char *activity_mem, int offset) {
return 0;
}
int dred_encode_silk_frame(const DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes, int q0, int dQ, unsigned char *activity_mem, int arch) {
int dred_encode_silk_frame(DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes, int q0, int dQ, unsigned char *activity_mem, int arch) {
ec_enc ec_encoder;
int q_level;
......@@ -270,13 +270,22 @@ int dred_encode_silk_frame(const DREDEnc *enc, unsigned char *buf, int max_chunk
int latent_offset;
int extra_dred_offset=0;
int dred_encoded=0;
int delayed_dred=0;
int total_offset;
latent_offset = enc->latent_offset;
/* Delaying new DRED data when just out of silence because we already have the
main Opus payload for that frame. */
if (activity_mem[0] && enc->last_extra_dred_offset>0) {
latent_offset = enc->last_extra_dred_offset;
delayed_dred = 1;
enc->last_extra_dred_offset = 0;
}
while (latent_offset < enc->latents_buffer_fill && !dred_voice_active(activity_mem, latent_offset)) {
latent_offset++;
extra_dred_offset++;
}
if (!delayed_dred) enc->last_extra_dred_offset = extra_dred_offset;
/* entropy coding of state and latents */
ec_enc_init(&ec_encoder, buf, max_bytes);
......
......@@ -51,6 +51,7 @@ typedef struct {
int input_buffer_fill;
int dred_offset;
int latent_offset;
int last_extra_dred_offset;
float latents_buffer[DRED_MAX_FRAMES * DRED_LATENT_DIM];
int latents_buffer_fill;
float state_buffer[DRED_MAX_FRAMES * DRED_STATE_DIM];
......@@ -65,6 +66,6 @@ void dred_deinit_encoder(DREDEnc *enc);
void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int extra_delay, int arch);
int dred_encode_silk_frame(const DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes, int q0, int dQ, unsigned char *activity_mem, int arch);
int dred_encode_silk_frame(DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes, int q0, int dQ, unsigned char *activity_mem, int arch);
#endif
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