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.
This commit is contained in:
parent
c5117c5ccd
commit
db78df8c01
2 changed files with 12 additions and 2 deletions
|
@ -257,7 +257,7 @@ static int dred_voice_active(const unsigned char *activity_mem, int offset) {
|
||||||
return 0;
|
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;
|
ec_enc ec_encoder;
|
||||||
|
|
||||||
int q_level;
|
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 latent_offset;
|
||||||
int extra_dred_offset=0;
|
int extra_dred_offset=0;
|
||||||
int dred_encoded=0;
|
int dred_encoded=0;
|
||||||
|
int delayed_dred=0;
|
||||||
int total_offset;
|
int total_offset;
|
||||||
|
|
||||||
latent_offset = enc->latent_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)) {
|
while (latent_offset < enc->latents_buffer_fill && !dred_voice_active(activity_mem, latent_offset)) {
|
||||||
latent_offset++;
|
latent_offset++;
|
||||||
extra_dred_offset++;
|
extra_dred_offset++;
|
||||||
}
|
}
|
||||||
|
if (!delayed_dred) enc->last_extra_dred_offset = extra_dred_offset;
|
||||||
|
|
||||||
/* entropy coding of state and latents */
|
/* entropy coding of state and latents */
|
||||||
ec_enc_init(&ec_encoder, buf, max_bytes);
|
ec_enc_init(&ec_encoder, buf, max_bytes);
|
||||||
|
|
|
@ -51,6 +51,7 @@ typedef struct {
|
||||||
int input_buffer_fill;
|
int input_buffer_fill;
|
||||||
int dred_offset;
|
int dred_offset;
|
||||||
int latent_offset;
|
int latent_offset;
|
||||||
|
int last_extra_dred_offset;
|
||||||
float latents_buffer[DRED_MAX_FRAMES * DRED_LATENT_DIM];
|
float latents_buffer[DRED_MAX_FRAMES * DRED_LATENT_DIM];
|
||||||
int latents_buffer_fill;
|
int latents_buffer_fill;
|
||||||
float state_buffer[DRED_MAX_FRAMES * DRED_STATE_DIM];
|
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);
|
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
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue