Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • xiph/opus
  • tterribe/opus
  • markh/opus
  • cisquiers/opus
  • xnorpx/opus
  • tpm/opus
  • 0dvictor/opus
  • traud/opus
  • thesamesam/opus
  • TD-Linux/opus
  • mklingb/opus
  • jmvalin/opus
  • janbuethe/opus
  • tmatth/opus
  • MarekPikula/opus
15 results
Show changes
Commits on Source (6)
[submodule "lpcnet"]
path = lpcnet
url = https://github.com/xiph/LPCNet
......@@ -10,9 +10,11 @@ lib_LTLIBRARIES = libopus.la
DIST_SUBDIRS = doc
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/celt -I$(top_srcdir)/silk \
-I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed $(NE10_CFLAGS)
-I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed $(NE10_CFLAGS) \
-I$(top_srcdir)/lpcnet/include
include celt_sources.mk
include lpcnet_sources.mk
include silk_sources.mk
include opus_sources.mk
......@@ -75,7 +77,7 @@ include celt_headers.mk
include silk_headers.mk
include opus_headers.mk
libopus_la_SOURCES = $(CELT_SOURCES) $(SILK_SOURCES) $(OPUS_SOURCES)
libopus_la_SOURCES = $(CELT_SOURCES) $(SILK_SOURCES) $(LPCNET_SOURCES) $(OPUS_SOURCES)
libopus_la_LDFLAGS = -no-undefined -version-info @OPUS_LT_CURRENT@:@OPUS_LT_REVISION@:@OPUS_LT_AGE@
libopus_la_LIBADD = $(NE10_LIBS) $(LIBM)
if OPUS_ARM_EXTERNAL_ASM
......@@ -149,16 +151,17 @@ tests_test_opus_padding_LDADD = libopus.la $(NE10_LIBS) $(LIBM)
CELT_OBJ = $(CELT_SOURCES:.c=.lo)
SILK_OBJ = $(SILK_SOURCES:.c=.lo)
LPCNET_OBJ = $(LPCNET_SOURCES:.c=.lo)
OPUS_OBJ = $(OPUS_SOURCES:.c=.lo)
tests_test_opus_projection_SOURCES = tests/test_opus_projection.c tests/test_opus_common.h
tests_test_opus_projection_LDADD = $(OPUS_OBJ) $(SILK_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM)
tests_test_opus_projection_LDADD = $(OPUS_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM)
if OPUS_ARM_EXTERNAL_ASM
tests_test_opus_projection_LDADD += libarmasm.la
endif
silk_tests_test_unit_LPC_inv_pred_gain_SOURCES = silk/tests/test_unit_LPC_inv_pred_gain.c
silk_tests_test_unit_LPC_inv_pred_gain_LDADD = $(SILK_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM)
silk_tests_test_unit_LPC_inv_pred_gain_LDADD = $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM)
if OPUS_ARM_EXTERNAL_ASM
silk_tests_test_unit_LPC_inv_pred_gain_LDADD += libarmasm.la
endif
......
......@@ -73,10 +73,13 @@ On Apple macOS, install Xcode and brew.sh, then in the Terminal enter:
2) Compiling the source
% git submodule update --init
% ./autogen.sh
% ./configure
% make
On x86, it's a good idea to use a -march= option that allows the use of AVX2.
3) Install the codec libraries (optional)
% sudo make install
......
......@@ -9,6 +9,8 @@ set -e
srcdir=`dirname $0`
test -n "$srcdir" && cd "$srcdir"
(cd lpcnet; ./download_model.sh plc_challenge_weights)
echo "Updating build configuration files, please wait...."
autoreconf -isf
......@@ -153,7 +153,7 @@ AS_IF([test "$enable_float_api" = "no"],[
AC_ARG_ENABLE([custom-modes],
[AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],,
[enable_custom_modes=no])
[enable_custom_modes=yes])
AS_IF([test "$enable_custom_modes" = "yes"],[
AC_DEFINE([CUSTOM_MODES], [1], [Custom modes])
......@@ -162,6 +162,14 @@ AS_IF([test "$enable_custom_modes" = "yes"],[
AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"])
AC_ARG_ENABLE([neural-plc],
[AS_HELP_STRING([--enable-neural-plc], [Use neural PLC for SILK])],,
[enable_neural_plc=yes])
AS_IF([test "$enable_neural_plc" = "yes"],[
AC_DEFINE([NEURAL_PLC], [1], [Neural PLC])
])
has_float_approx=no
#case "$host_cpu" in
#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
......
Subproject commit e0acf521b56094df4a3b88cc10f2c79c2db27cd0
LPCNET_SOURCES = \
lpcnet/src/burg.c \
lpcnet/src/ceps_codebooks.c \
lpcnet/src/common.c \
lpcnet/src/freq.c \
lpcnet/src/kiss99.c \
lpcnet/src/lpcnet.c \
lpcnet/src/lpcnet_dec.c \
lpcnet/src/lpcnet_enc.c \
lpcnet/src/lpcnet_plc.c \
lpcnet/src/nnet.c \
lpcnet/src/nnet_data.c \
lpcnet/src/plc_data.c
......@@ -33,6 +33,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "stack_alloc.h"
#include "PLC.h"
#ifdef NEURAL_PLC
#include "lpcnet.h"
#endif
#define NB_ATT 2
static const opus_int16 HARM_ATT_Q15[NB_ATT] = { 32440, 31130 }; /* 0.99, 0.95 */
static const opus_int16 PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = { 31130, 26214 }; /* 0.95, 0.8 */
......@@ -60,6 +64,14 @@ void silk_PLC_Reset(
psDec->sPLC.prevGain_Q16[ 1 ] = SILK_FIX_CONST( 1, 16 );
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);
}
#endif
}
void silk_PLC(
......@@ -88,6 +100,14 @@ void silk_PLC(
/* Update state */
/****************************/
silk_PLC_update( psDec, psDecCtrl );
#ifdef NEURAL_PLC
if ( psDec->sPLC.fs_kHz == 16 ) {
int k;
for( k = 0; k < psDec->nb_subfr; k += 2 ) {
lpcnet_plc_update( psDec->sPLC.lpcnet, frame + k * psDec->subfr_length );
}
}
#endif
}
}
......@@ -371,6 +391,17 @@ static OPUS_INLINE void silk_PLC_conceal(
/* Scale with Gain */
frame[ i ] = (opus_int16)silk_SAT16( silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], prevGain_Q10[ 1 ] ), 8 ) ) );
}
#ifdef NEURAL_PLC
if ( psDec->sPLC.fs_kHz == 16 ) {
for( k = 0; k < psDec->nb_subfr; k += 2 ) {
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. */
for( i = 0; i < psDec->frame_length; i++ ) {
sLPC_Q14_ptr[ MAX_LPC_ORDER + i ] = (int)floor(.5 + frame[ i ] * (float)(1 << 24) / prevGain_Q10[ 1 ] );
}
#endif
/* Save LPC state */
silk_memcpy( psDec->sLPC_Q14_buf, &sLPC_Q14_ptr[ psDec->frame_length ], MAX_LPC_ORDER * sizeof( opus_int32 ) );
......@@ -431,12 +462,16 @@ void silk_PLC_glue_frames(
slope_Q16 = silk_DIV32_16( ( (opus_int32)1 << 16 ) - gain_Q16, length );
/* Make slope 4x steeper to avoid missing onsets after DTX */
slope_Q16 = silk_LSHIFT( slope_Q16, 2 );
for( i = 0; i < length; i++ ) {
frame[ i ] = silk_SMULWB( gain_Q16, frame[ i ] );
gain_Q16 += slope_Q16;
if( gain_Q16 > (opus_int32)1 << 16 ) {
break;
#ifdef NEURAL_PLC
if ( psDec->sPLC.fs_kHz != 16 )
#endif
{
for( i = 0; i < length; i++ ) {
frame[ i ] = silk_SMULWB( gain_Q16, frame[ i ] );
gain_Q16 += slope_Q16;
if( gain_Q16 > (opus_int32)1 << 16 ) {
break;
}
}
}
}
......
......@@ -34,6 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "entenc.h"
#include "entdec.h"
#ifdef NEURAL_PLC
#include "lpcnet.h"
#endif
#ifdef __cplusplus
extern "C"
{
......@@ -243,6 +247,10 @@ typedef struct {
opus_int fs_kHz;
opus_int nb_subfr;
opus_int subfr_length;
#ifdef NEURAL_PLC
/* FIXME: We should include the state struct directly to preserve the state shadow copy property. */
LPCNetPLCState *lpcnet;
#endif
} silk_PLC_struct;
/* Struct for CNG */
......