diff options
author | Jan Buethe <jbuethe@amazon.de> | 2022-10-26 10:15:31 +0000 |
---|---|---|
committer | Jan Buethe <jbuethe@amazon.de> | 2022-10-26 10:15:31 +0000 |
commit | 7c423e61aacc582e846b593974544e508306bf21 (patch) | |
tree | 789fe747ba34d00e342d8acf2dd06e7e2396eb8d | |
parent | 56f14668aab5a6fe65e1dc8b6fc189f26350620f (diff) | |
download | opus-7c423e61aacc582e846b593974544e508306bf21.tar.gz |
changed data types for r, dead_zone, quant_scale and p0 to opus_uint16
m--------- | lpcnet | 0 | ||||
-rw-r--r-- | silk/dred_coding.c | 4 | ||||
-rw-r--r-- | silk/dred_config.h | 40 | ||||
-rw-r--r-- | silk/dred_decoder.c | 36 | ||||
-rw-r--r-- | silk/dred_decoder.h | 40 | ||||
-rw-r--r-- | silk/dred_encoder.c | 35 | ||||
-rw-r--r-- | silk/dred_encoder.h | 15 |
7 files changed, 151 insertions, 19 deletions
diff --git a/lpcnet b/lpcnet -Subproject 03ea9aad02f94baebb0dc6a43d8d303277fdb1e +Subproject b7dc36526a90df74e7b4f11ed3e0a6543b79e5a diff --git a/silk/dred_coding.c b/silk/dred_coding.c index 9e1bfcea..d2e71c74 100644 --- a/silk/dred_coding.c +++ b/silk/dred_coding.c @@ -66,7 +66,7 @@ void dred_encode_state(ec_enc *enc, float *x) { encode_pvq(iy, PVQ_DIM, PVQ_K, enc); } -void dred_encode_latents(ec_enc *enc, const float *x, const opus_int16 *scale, const opus_int16 *dzone, const opus_int16 *r, const opus_int16 *p0) { +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) { int i; float eps = .1f; for (i=0;i<LATENT_DIM;i++) { @@ -118,7 +118,7 @@ void dred_decode_state(ec_enc *dec, float *x) { } -void dred_decode_latents(ec_dec *dec, float *x, const opus_int16 *scale, const opus_int16 *r, const opus_int16 *p0) { +void dred_decode_latents(ec_dec *dec, float *x, const opus_uint16 *scale, const opus_uint16 *r, const opus_uint16 *p0) { int i; for (i=0;i<LATENT_DIM;i++) { int q; diff --git a/silk/dred_config.h b/silk/dred_config.h new file mode 100644 index 00000000..6a059abb --- /dev/null +++ b/silk/dred_config.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2022 Amazon + Written by Jan Buethe */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* 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 24 +#define DRED_NUM_QUANTIZATION_LEVELS 40 +#define DRED_MAX_FRAMES 100 +#define DRED_SILK_ENCODER_DELAY 79 +#define DRED_FRAME_SIZE 160 +#define DRED_DFRAME_SIZE (2 * (DRED_FRAME_SIZE)) +#define DRED_MAX_DATA_SIZE 1000 +#define DRED_ENC_Q0 9 +#define DRED_ENC_Q1 15 +#define DRED_NUM_REDUNDANCY_FRAMES 50
\ No newline at end of file diff --git a/silk/dred_decoder.c b/silk/dred_decoder.c index e69de29b..1a431f84 100644 --- a/silk/dred_decoder.c +++ b/silk/dred_decoder.c @@ -0,0 +1,36 @@ +/* Copyright (c) 2022 Amazon + Written by Jan Buethe */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dred_decoder.h" + +void init_dred_decoder(DREDDec *dec); + +void dred_decode_redundancy_package(DREDDec *dec, float *features, opus_uint8 *bytes, int num_bytes);
\ No newline at end of file diff --git a/silk/dred_decoder.h b/silk/dred_decoder.h new file mode 100644 index 00000000..98da6e78 --- /dev/null +++ b/silk/dred_decoder.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2022 Amazon + Written by Jan Buethe */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "dred_config.h" +#include "dred_rdovae.h" +#include "entcode.h" + +typedef struct { + ec_enc ec_encoder; + RDOVAEDec *rdovae_dec; +} DREDDec; + + +void init_dred_decoder(DREDDec *dec); + +void dred_decode_redundancy_package(DREDDec *dec, float *features, opus_uint8 *bytes, int num_bytes); diff --git a/silk/dred_encoder.c b/silk/dred_encoder.c index 51a895be..8628863d 100644 --- a/silk/dred_encoder.c +++ b/silk/dred_encoder.c @@ -1,3 +1,30 @@ +/* Copyright (c) 2022 Amazon + Written by Jan Buethe */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + #include <string.h> #include <stdio.h> @@ -20,10 +47,10 @@ void init_dred_encoder(DREDEnc* enc) void dred_encode_silk_frame(DREDEnc *enc, const opus_int16 *silk_frame) { - const opus_int16 *dead_zone = DRED_rdovae_get_dead_zone_pointer(); - const opus_int16 *p0 = DRED_rdovae_get_p0_pointer(); - const opus_int16 *quant_scales = DRED_rdovae_get_quant_scales_pointer(); - const opus_int16 *r = DRED_rdovae_get_r_pointer(); + 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(); + const opus_uint16 *r = DRED_rdovae_get_r_pointer(); float input_buffer[2*DRED_NUM_FEATURES] = {0}; diff --git a/silk/dred_encoder.h b/silk/dred_encoder.h index a462e56d..90c7c7cd 100644 --- a/silk/dred_encoder.h +++ b/silk/dred_encoder.h @@ -29,22 +29,11 @@ #define _DRED_ENCODER_H #include "lpcnet.h" +#include "dred_config.h" #include "dred_rdovae.h" #include "entcode.h" -/* 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 24 -#define DRED_NUM_QUANTIZATION_LEVELS 40 -#define DRED_MAX_FRAMES 100 -#define DRED_SILK_ENCODER_DELAY 79 -#define DRED_FRAME_SIZE 160 -#define DRED_DFRAME_SIZE (2 * (DRED_FRAME_SIZE)) -#define DRED_MAX_DATA_SIZE 1000 -#define DRED_ENC_Q0 9 -#define DRED_ENC_Q1 15 -#define DRED_NUM_REDUNDANCY_FRAMES 50 + typedef struct { opus_int16 input_buffer[DRED_DFRAME_SIZE + DRED_SILK_ENCODER_DELAY]; |