summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2022-12-19 17:24:47 -0500
committerJean-Marc Valin <jmvalin@amazon.com>2022-12-19 17:24:47 -0500
commit6e4154b4d8f80dabf813bae5befbfed370b5a489 (patch)
tree3cf15702504c40b63ececadaabcf51f2867cbc54
parente213529ccb40f35c903594109d14b5557985ca85 (diff)
downloadopus-6e4154b4d8f80dabf813bae5befbfed370b5a489.tar.gz
Should handle mixes of PLC and DRED
-rwxr-xr-xautogen.sh2
m---------lpcnet0
-rw-r--r--silk/PLC.c2
-rw-r--r--silk/structs.h2
-rw-r--r--src/opus_decoder.c13
-rw-r--r--src/opus_demo.c2
6 files changed, 11 insertions, 10 deletions
diff --git a/autogen.sh b/autogen.sh
index aa322168..fa97ec56 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -9,7 +9,7 @@ set -e
srcdir=`dirname $0`
test -n "$srcdir" && cd "$srcdir"
-(cd lpcnet; ./download_model.sh plc_challenge)
+(cd lpcnet; ./download_model.sh 5e88ebe)
echo "Updating build configuration files, please wait...."
diff --git a/lpcnet b/lpcnet
-Subproject ffc51ce3381bf9c874ed45dd3ba03e85c423f8b
+Subproject dc30fbef3fe48fa9e5d87860c6b21efb02db5f4
diff --git a/silk/PLC.c b/silk/PLC.c
index ecb34b9e..12907b92 100644
--- a/silk/PLC.c
+++ b/silk/PLC.c
@@ -103,6 +103,7 @@ void silk_PLC(
#ifdef NEURAL_PLC
if ( psDec->sPLC.fs_kHz == 16 ) {
int k;
+ psDec->sPLC.pre_filled = 0;
for( k = 0; k < psDec->nb_subfr; k += 2 ) {
lpcnet_plc_update( psDec->sPLC.lpcnet, frame + k * psDec->subfr_length );
}
@@ -393,6 +394,7 @@ static OPUS_INLINE void silk_PLC_conceal(
}
#ifdef NEURAL_PLC
if ( psDec->sPLC.fs_kHz == 16 ) {
+ psDec->sPLC.pre_filled = 1;
for( k = 0; k < psDec->nb_subfr; k += 2 ) {
lpcnet_plc_conceal(psDec->sPLC.lpcnet, frame + k * psDec->subfr_length );
}
diff --git a/silk/structs.h b/silk/structs.h
index 48f47f55..22f56ee0 100644
--- a/silk/structs.h
+++ b/silk/structs.h
@@ -261,11 +261,11 @@ typedef struct {
#ifdef NEURAL_PLC
/* FIXME: We should include the state struct directly to preserve the state shadow copy property. */
LPCNetPLCState *lpcnet;
+ int pre_filled;
#ifdef ENABLE_NEURAL_FEC
DREDDec dred_decoder;
float fec_features[2*DRED_NUM_REDUNDANCY_FRAMES*DRED_NUM_FEATURES];
int nb_fec_frames;
- int pre_filled;
#endif
#endif
} silk_PLC_struct;
diff --git a/src/opus_decoder.c b/src/opus_decoder.c
index 70364e22..947d6fed 100644
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -659,15 +659,15 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
features_per_frame = frame_size/(st->Fs/100);
needed_feature_frames = features_per_frame;
if (!silk_dec->sPLC.pre_filled) needed_feature_frames+=2;
- silk_dec->sPLC.pre_filled = 1;
for (i=0;i<needed_feature_frames;i++) {
int feature_offset = (needed_feature_frames-i-1 + (decode_fec-1)*features_per_frame);
- /* FIXME: Find something better than that (involving actual PLC) */
- feature_offset = IMIN(feature_offset, silk_dec->sPLC.nb_fec_frames-1);
- lpcnet_plc_fec_add(silk_dec->sPLC.lpcnet, silk_dec->sPLC.fec_features+feature_offset*DRED_NUM_FEATURES);
+ if (feature_offset <= silk_dec->sPLC.nb_fec_frames-1) {
+ lpcnet_plc_fec_add(silk_dec->sPLC.lpcnet, silk_dec->sPLC.fec_features+feature_offset*DRED_NUM_FEATURES);
+ } else {
+ lpcnet_plc_fec_add(silk_dec->sPLC.lpcnet, NULL);
+ }
+
}
- } else {
- silk_dec->sPLC.pre_filled = 0;
}
if (len==0 || data==NULL)
{
@@ -1114,7 +1114,6 @@ int opus_decoder_dred_input(OpusDecoder *st, const unsigned char *data,
/*printf("Found: %p of size %d\n", payload, payload_len);*/
min_feature_frames = IMIN(2 + offset, 2*DRED_NUM_REDUNDANCY_FRAMES);
silk_dec->sPLC.nb_fec_frames = dred_decode_redundancy_package(&silk_dec->sPLC.dred_decoder, silk_dec->sPLC.fec_features, payload, payload_len, min_feature_frames);
- /*printf("%d\n", silk_dec->sPLC.nb_fec_frames);*/
return 1;
}
return 0;
diff --git a/src/opus_demo.c b/src/opus_demo.c
index 50a66db3..c40819a1 100644
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -787,7 +787,7 @@ int main(int argc, char *argv[])
if (run_decoder)
run_decoder += lost_count;
if (!lost && lost_count > 0) {
- opus_decoder_dred_input(dec, data, len, 100);
+ opus_decoder_dred_input(dec, data, len, 2);
}
/* FIXME: Figure out how to trigger the decoder when the last packet of the file is lost. */
for (fr=0;fr<run_decoder;fr++) {