diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-05-15 22:08:08 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2023-06-16 20:01:35 +0300 |
commit | 71d5edcffbf520792a4e11959945735a0f9822e7 (patch) | |
tree | 994522d6e15fcef8d505be41078b52be63c3726e /silk | |
parent | 112b160a28787285a193bcc61161367449c859db (diff) |
Directly include LPCNet state in SILK structs
Makes shallow copy of decoder possible again
Diffstat (limited to 'silk')
-rw-r--r-- | silk/PLC.c | 11 | ||||
-rw-r--r-- | silk/structs.h | 3 |
2 files changed, 5 insertions, 9 deletions
@@ -65,12 +65,7 @@ void silk_PLC_Reset( psDec->sPLC.subfr_length = 20; psDec->sPLC.nb_subfr = 2; #ifdef NEURAL_PLC - if( psDec->sPLC.lpcnet != NULL ) { - lpcnet_plc_init( psDec->sPLC.lpcnet, LPCNET_PLC_CODEC ); - } else { - /* FIXME: This is leaking memory. The right fix is for the LPCNet state to be part of the PLC struct itself. */ - psDec->sPLC.lpcnet = lpcnet_plc_create(LPCNET_PLC_CODEC); - } + lpcnet_plc_init( &psDec->sPLC.lpcnet, LPCNET_PLC_CODEC ); #endif } @@ -105,7 +100,7 @@ void silk_PLC( 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 ); + lpcnet_plc_update( &psDec->sPLC.lpcnet, frame + k * psDec->subfr_length ); } } #endif @@ -396,7 +391,7 @@ static OPUS_INLINE void silk_PLC_conceal( 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 ); + lpcnet_plc_conceal( &psDec->sPLC.lpcnet, frame + k * psDec->subfr_length ); } } /* We *should* be able to copy only from psDec->frame_length-MAX_LPC_ORDER, i.e. the last MAX_LPC_ORDER samples. */ diff --git a/silk/structs.h b/silk/structs.h index d2d44c54..17efd8e9 100644 --- a/silk/structs.h +++ b/silk/structs.h @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef NEURAL_PLC #include "lpcnet.h" +#include "lpcnet/src/lpcnet_private.h" #endif #ifdef ENABLE_NEURAL_FEC @@ -260,7 +261,7 @@ typedef struct { opus_int subfr_length; #ifdef NEURAL_PLC /* FIXME: We should include the state struct directly to preserve the state shadow copy property. */ - LPCNetPLCState *lpcnet; + LPCNetPLCState lpcnet; int pre_filled; #endif } silk_PLC_struct; |