diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-05-13 02:05:31 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2023-06-16 20:01:32 +0300 |
commit | 906ee4b2369d7f0d5526274ee97d39da9ba616ad (patch) | |
tree | 2e9ceabb0ac836580202b888b40a3491cdf99b45 /silk | |
parent | 34a4ba0d4f813ffcbcc5a4952c7bb9265e774775 (diff) |
DRED refactoring/renaming
Diffstat (limited to 'silk')
-rw-r--r-- | silk/dred_decoder.c | 36 | ||||
-rw-r--r-- | silk/dred_decoder.h | 13 |
2 files changed, 39 insertions, 10 deletions
diff --git a/silk/dred_decoder.c b/silk/dred_decoder.c index 54a47926..5240a67a 100644 --- a/silk/dred_decoder.c +++ b/silk/dred_decoder.c @@ -31,23 +31,53 @@ #include "config.h" #endif +#include "os_support.h" #include "dred_decoder.h" #include "dred_coding.h" #include "celt/entdec.h" -void init_dred_decoder(DREDDec *dec) +int opus_dred_init(OpusDRED *dec) { memset(dec, 0, sizeof(*dec)); dec->rdovae_dec = DRED_rdovae_create_decoder(); + return OPUS_OK; } -void dred_deinit_decoder(DREDDec *dec) +int opus_dred_get_size(void) +{ + return sizeof(OpusDRED); +} + +OpusDRED *opus_dred_create(int *error) +{ + int ret; + OpusDRED *dec; + dec = (OpusDRED *)opus_alloc(opus_dred_get_size()); + if (dec == NULL) + { + if (error) + *error = OPUS_ALLOC_FAIL; + return NULL; + } + ret = opus_dred_init(dec); + if (error) + *error = ret; + if (ret != OPUS_OK) + { + opus_free(dec); + dec = NULL; + } + return dec; + +} + +void opus_dred_destroy(OpusDRED *dec) { DRED_rdovae_destroy_decoder(dec->rdovae_dec); } -int dred_decode_redundancy_package(DREDDec *dec, float *features, const opus_uint8 *bytes, int num_bytes, int min_feature_frames) +int dred_decode_redundancy_package(OpusDRED *dec, float *features, const opus_uint8 *bytes, int num_bytes, int min_feature_frames) { const opus_uint16 *p0 = DRED_rdovae_get_p0_pointer(); const opus_uint16 *quant_scales = DRED_rdovae_get_quant_scales_pointer(); diff --git a/silk/dred_decoder.h b/silk/dred_decoder.h index 633e4c83..2c739d4a 100644 --- a/silk/dred_decoder.h +++ b/silk/dred_decoder.h @@ -25,17 +25,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "opus.h" #include "dred_config.h" #include "dred_rdovae.h" #include "entcode.h" -typedef struct { +struct OpusDRED { RDOVAEDec *rdovae_dec; -} DREDDec; + float fec_features[2*DRED_NUM_REDUNDANCY_FRAMES*DRED_NUM_FEATURES]; + int nb_fec_frames; +}; -void init_dred_decoder(DREDDec *dec); - -void dred_deinit_decoder(DREDDec *dec); - -int dred_decode_redundancy_package(DREDDec *dec, float *features, const opus_uint8 *bytes, int num_bytes, int min_feature_frames); +int dred_decode_redundancy_package(OpusDRED *dec, float *features, const opus_uint8 *bytes, int num_bytes, int min_feature_frames); |