diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-11-07 01:49:18 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2023-11-07 08:07:14 +0300 |
commit | 0ab0640d4ad41d765ab2b9916f7146c67fe56a3c (patch) | |
tree | 2543d40c2536a6c9207f6df15968d543ae1529cb /silk | |
parent | 2386a60ec644fadc437155cd6e5f6d4c561940d4 (diff) |
Split stats in two and remove useless dimensions
Diffstat (limited to 'silk')
-rw-r--r-- | silk/dred_config.h | 3 | ||||
-rw-r--r-- | silk/dred_decoder.c | 21 | ||||
-rw-r--r-- | silk/dred_decoder.h | 1 | ||||
-rw-r--r-- | silk/dred_encoder.c | 25 |
4 files changed, 22 insertions, 28 deletions
diff --git a/silk/dred_config.h b/silk/dred_config.h index 5e3e74a3..207908fc 100644 --- a/silk/dred_config.h +++ b/silk/dred_config.h @@ -39,9 +39,6 @@ #define DRED_MIN_BYTES 16 /* these are inpart duplicates to the values defined in dred_rdovae_constants.h */ -#define DRED_NUM_FEATURES 20 -#define DRED_LATENT_DIM 80 -#define DRED_STATE_DIM 80 #define DRED_SILK_ENCODER_DELAY (79+12-80) #define DRED_FRAME_SIZE 160 #define DRED_DFRAME_SIZE (2 * (DRED_FRAME_SIZE)) diff --git a/silk/dred_decoder.c b/silk/dred_decoder.c index 68ba8559..c1489f3c 100644 --- a/silk/dred_decoder.c +++ b/silk/dred_decoder.c @@ -36,6 +36,8 @@ #include "dred_coding.h" #include "celt/entdec.h" #include "celt/laplace.h" +#include "dred_rdovae_stats_data.h" +#include "dred_rdovae_constants.h" /* From http://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend */ static int sign_extend(int x, int b) { @@ -55,9 +57,6 @@ static void dred_decode_latents(ec_dec *dec, float *x, const opus_uint16 *scale, int dred_ec_decode(OpusDRED *dec, const opus_uint8 *bytes, int num_bytes, int min_feature_frames) { - const opus_uint8 *p0 = DRED_rdovae_get_p0_pointer(); - const opus_uint16 *quant_scales = DRED_rdovae_get_quant_scales_pointer(); - const opus_uint8 *r = DRED_rdovae_get_r_pointer(); ec_dec ec; int q_level; int i; @@ -78,13 +77,13 @@ int dred_ec_decode(OpusDRED *dec, const opus_uint8 *bytes, int num_bytes, int mi /*printf("%d %d %d\n", dred_offset, q0, dQ);*/ //dred_decode_state(&ec, dec->state); - state_qoffset = q0*(DRED_LATENT_DIM+DRED_STATE_DIM) + DRED_LATENT_DIM; + state_qoffset = q0*DRED_STATE_DIM; dred_decode_latents( &ec, dec->state, - quant_scales + state_qoffset, - r + state_qoffset, - p0 + state_qoffset, + dred_state_quant_scales_q8 + state_qoffset, + dred_state_r_q8 + state_qoffset, + dred_state_p0_q8 + state_qoffset, DRED_STATE_DIM); /* decode newest to oldest and store oldest to newest */ @@ -94,13 +93,13 @@ int dred_ec_decode(OpusDRED *dec, const opus_uint8 *bytes, int num_bytes, int mi if (8*num_bytes - ec_tell(&ec) <= 7) break; q_level = compute_quantizer(q0, dQ, i/2); - offset = q_level * (DRED_LATENT_DIM+DRED_STATE_DIM); + offset = q_level*DRED_LATENT_DIM; dred_decode_latents( &ec, &dec->latents[(i/2)*DRED_LATENT_DIM], - quant_scales + offset, - r + offset, - p0 + offset, + dred_latent_quant_scales_q8 + offset, + dred_latent_r_q8 + offset, + dred_latent_p0_q8 + offset, DRED_LATENT_DIM ); diff --git a/silk/dred_decoder.h b/silk/dred_decoder.h index c7355ed1..f8d050ff 100644 --- a/silk/dred_decoder.h +++ b/silk/dred_decoder.h @@ -32,6 +32,7 @@ #include "dred_config.h" #include "dred_rdovae.h" #include "entcode.h" +#include "dred_rdovae_constants.h" struct OpusDRED { float fec_features[2*DRED_NUM_REDUNDANCY_FRAMES*DRED_NUM_FEATURES]; diff --git a/silk/dred_encoder.c b/silk/dred_encoder.c index 3f842af0..e4959b30 100644 --- a/silk/dred_encoder.c +++ b/silk/dred_encoder.c @@ -44,6 +44,7 @@ #include "float_cast.h" #include "os_support.h" #include "celt/laplace.h" +#include "dred_rdovae_stats_data.h" int dred_encoder_load_model(DREDEnc* enc, const unsigned char *data, int len) @@ -244,10 +245,6 @@ static void dred_encode_latents(ec_enc *enc, const float *x, const opus_uint16 * } 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_uint8 *p0 = DRED_rdovae_get_p0_pointer(); - const opus_uint16 *quant_scales = DRED_rdovae_get_quant_scales_pointer(); - const opus_uint8 *r = DRED_rdovae_get_r_pointer(); ec_enc ec_encoder; int q_level; @@ -265,14 +262,14 @@ int dred_encode_silk_frame(const DREDEnc *enc, unsigned char *buf, int max_chunk ec_enc_uint(&ec_encoder, enc->dred_offset, 32); ec_enc_uint(&ec_encoder, q0, 16); ec_enc_uint(&ec_encoder, dQ, 8); - state_qoffset = q0*(DRED_LATENT_DIM+DRED_STATE_DIM) + DRED_LATENT_DIM; + state_qoffset = q0*DRED_STATE_DIM; dred_encode_latents( &ec_encoder, enc->initial_state, - quant_scales + state_qoffset, - dead_zone + state_qoffset, - r + state_qoffset, - p0 + state_qoffset, + dred_state_quant_scales_q8 + state_qoffset, + dred_state_dead_zone_q10 + state_qoffset, + dred_state_r_q8 + state_qoffset, + dred_state_p0_q8 + state_qoffset, DRED_STATE_DIM); if (ec_tell(&ec_encoder) > 8*max_bytes) { return 0; @@ -283,15 +280,15 @@ int dred_encode_silk_frame(const DREDEnc *enc, unsigned char *buf, int max_chunk ec_bak = ec_encoder; q_level = compute_quantizer(q0, dQ, i/2); - offset = q_level * (DRED_LATENT_DIM+DRED_STATE_DIM); + offset = q_level * DRED_LATENT_DIM; dred_encode_latents( &ec_encoder, enc->latents_buffer + (i+enc->latent_offset) * DRED_LATENT_DIM, - quant_scales + offset, - dead_zone + offset, - r + offset, - p0 + offset, + dred_latent_quant_scales_q8 + offset, + dred_latent_dead_zone_q10 + offset, + dred_latent_r_q8 + offset, + dred_latent_p0_q8 + offset, DRED_LATENT_DIM ); if (ec_tell(&ec_encoder) > 8*max_bytes) { |