(caf7e6a2e) Replaced Concentus NuGet package with csproj (ensures correct System.Runtime references)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common.CPlusPlus;
|
||||
|
||||
/// <summary>
|
||||
/// Struct for CNG
|
||||
/// </summary>
|
||||
internal class CNGState
|
||||
{
|
||||
internal readonly int[] CNG_exc_buf_Q14 = new int[SilkConstants.MAX_FRAME_LENGTH];
|
||||
internal readonly short[] CNG_smth_NLSF_Q15 = new short[SilkConstants.MAX_LPC_ORDER];
|
||||
internal readonly int[] CNG_synth_state = new int[SilkConstants.MAX_LPC_ORDER];
|
||||
internal int CNG_smth_Gain_Q16 = 0;
|
||||
internal int rand_seed = 0;
|
||||
internal int fs_kHz = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetInt(CNG_exc_buf_Q14, 0, SilkConstants.MAX_FRAME_LENGTH);
|
||||
Arrays.MemSetShort(CNG_smth_NLSF_Q15, 0, SilkConstants.MAX_LPC_ORDER);
|
||||
Arrays.MemSetInt(CNG_synth_state, 0, SilkConstants.MAX_LPC_ORDER);
|
||||
CNG_smth_Gain_Q16 = 0;
|
||||
rand_seed = 0;
|
||||
fs_kHz = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Structure for controlling decoder operation and reading decoder status
|
||||
/// </summary>
|
||||
internal class DecControlState
|
||||
{
|
||||
/* I: Number of channels; 1/2 */
|
||||
internal int nChannelsAPI = 0;
|
||||
|
||||
/* I: Number of channels; 1/2 */
|
||||
internal int nChannelsInternal = 0;
|
||||
|
||||
/* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
|
||||
internal int API_sampleRate = 0;
|
||||
|
||||
/* I: Internal sampling rate used, in Hertz; 8000/12000/16000 */
|
||||
internal int internalSampleRate = 0;
|
||||
|
||||
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
|
||||
internal int payloadSize_ms = 0;
|
||||
|
||||
/* O: Pitch lag of previous frame (0 if unvoiced), measured in samples at 48 kHz */
|
||||
internal int prevPitchLag = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
nChannelsAPI = 0;
|
||||
nChannelsInternal = 0;
|
||||
API_sampleRate = 0;
|
||||
internalSampleRate = 0;
|
||||
payloadSize_ms = 0;
|
||||
prevPitchLag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Structure for controlling encoder operation
|
||||
/// </summary>
|
||||
internal class EncControlState
|
||||
{
|
||||
/* I: Number of channels; 1/2 */
|
||||
internal int nChannelsAPI = 0;
|
||||
|
||||
/* I: Number of channels; 1/2 */
|
||||
internal int nChannelsInternal = 0;
|
||||
|
||||
/* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
|
||||
internal int API_sampleRate = 0;
|
||||
|
||||
/* I: Maximum internal sampling rate in Hertz; 8000/12000/16000 */
|
||||
internal int maxInternalSampleRate = 0;
|
||||
|
||||
/* I: Minimum internal sampling rate in Hertz; 8000/12000/16000 */
|
||||
internal int minInternalSampleRate = 0;
|
||||
|
||||
/* I: Soft request for internal sampling rate in Hertz; 8000/12000/16000 */
|
||||
internal int desiredInternalSampleRate = 0;
|
||||
|
||||
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
|
||||
internal int payloadSize_ms = 0;
|
||||
|
||||
/* I: Bitrate during active speech in bits/second; internally limited */
|
||||
internal int bitRate = 0;
|
||||
|
||||
/* I: Uplink packet loss in percent (0-100) */
|
||||
internal int packetLossPercentage = 0;
|
||||
|
||||
/* I: Complexity mode; 0 is lowest, 10 is highest complexity */
|
||||
internal int complexity = 0;
|
||||
|
||||
/* I: Flag to enable in-band Forward Error Correction (FEC); 0/1 */
|
||||
internal int useInBandFEC = 0;
|
||||
|
||||
/* I: Flag to enable discontinuous transmission (DTX); 0/1 */
|
||||
internal int useDTX = 0;
|
||||
|
||||
/* I: Flag to use constant bitrate */
|
||||
internal int useCBR = 0;
|
||||
|
||||
/* I: Maximum number of bits allowed for the frame */
|
||||
internal int maxBits = 0;
|
||||
|
||||
/* I: Causes a smooth downmix to mono */
|
||||
internal int toMono = 0;
|
||||
|
||||
/* I: Opus encoder is allowing us to switch bandwidth */
|
||||
internal int opusCanSwitch = 0;
|
||||
|
||||
/* I: Make frames as independent as possible (but still use LPC) */
|
||||
internal int reducedDependency = 0;
|
||||
|
||||
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */
|
||||
internal int internalSampleRate = 0;
|
||||
|
||||
/* O: Flag that bandwidth switching is allowed (because low voice activity) */
|
||||
internal int allowBandwidthSwitch = 0;
|
||||
|
||||
/* O: Flag that SILK runs in WB mode without variable LP filter (use for switching between WB/SWB/FB) */
|
||||
internal int inWBmodeWithoutVariableLP = 0;
|
||||
|
||||
/* O: Stereo width */
|
||||
internal int stereoWidth_Q14 = 0;
|
||||
|
||||
/* O: Tells the Opus encoder we're ready to switch */
|
||||
internal int switchReady = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
nChannelsAPI = 0;
|
||||
nChannelsInternal = 0;
|
||||
API_sampleRate = 0;
|
||||
maxInternalSampleRate = 0;
|
||||
minInternalSampleRate = 0;
|
||||
desiredInternalSampleRate = 0;
|
||||
payloadSize_ms = 0;
|
||||
bitRate = 0;
|
||||
packetLossPercentage = 0;
|
||||
complexity = 0;
|
||||
useInBandFEC = 0;
|
||||
useDTX = 0;
|
||||
useCBR = 0;
|
||||
maxBits = 0;
|
||||
toMono = 0;
|
||||
opusCanSwitch = 0;
|
||||
reducedDependency = 0;
|
||||
internalSampleRate = 0;
|
||||
allowBandwidthSwitch = 0;
|
||||
inWBmodeWithoutVariableLP = 0;
|
||||
stereoWidth_Q14 = 0;
|
||||
switchReady = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks this encoder control struct and returns error code, if any
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal int check_control_input()
|
||||
{
|
||||
if (((API_sampleRate != 8000) &&
|
||||
(API_sampleRate != 12000) &&
|
||||
(API_sampleRate != 16000) &&
|
||||
(API_sampleRate != 24000) &&
|
||||
(API_sampleRate != 32000) &&
|
||||
(API_sampleRate != 44100) &&
|
||||
(API_sampleRate != 48000)) ||
|
||||
((desiredInternalSampleRate != 8000) &&
|
||||
(desiredInternalSampleRate != 12000) &&
|
||||
(desiredInternalSampleRate != 16000)) ||
|
||||
((maxInternalSampleRate != 8000) &&
|
||||
(maxInternalSampleRate != 12000) &&
|
||||
(maxInternalSampleRate != 16000)) ||
|
||||
((minInternalSampleRate != 8000) &&
|
||||
(minInternalSampleRate != 12000) &&
|
||||
(minInternalSampleRate != 16000)) ||
|
||||
(minInternalSampleRate > desiredInternalSampleRate) ||
|
||||
(maxInternalSampleRate < desiredInternalSampleRate) ||
|
||||
(minInternalSampleRate > maxInternalSampleRate))
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_FS_NOT_SUPPORTED;
|
||||
}
|
||||
if (payloadSize_ms != 10 &&
|
||||
payloadSize_ms != 20 &&
|
||||
payloadSize_ms != 40 &&
|
||||
payloadSize_ms != 60)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;
|
||||
}
|
||||
if (packetLossPercentage < 0 || packetLossPercentage > 100)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_LOSS_RATE;
|
||||
}
|
||||
if (useDTX < 0 || useDTX > 1)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_DTX_SETTING;
|
||||
}
|
||||
if (useCBR < 0 || useCBR > 1)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_CBR_SETTING;
|
||||
}
|
||||
if (useInBandFEC < 0 || useInBandFEC > 1)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_INBAND_FEC_SETTING;
|
||||
}
|
||||
if (nChannelsAPI < 1 || nChannelsAPI > SilkConstants.ENCODER_NUM_CHANNELS)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR;
|
||||
}
|
||||
if (nChannelsInternal < 1 || nChannelsInternal > SilkConstants.ENCODER_NUM_CHANNELS)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR;
|
||||
}
|
||||
if (nChannelsInternal > nChannelsAPI)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR;
|
||||
}
|
||||
if (complexity < 0 || complexity > 10)
|
||||
{
|
||||
Inlines.OpusAssert(false);
|
||||
return SilkError.SILK_ENC_INVALID_COMPLEXITY_SETTING;
|
||||
}
|
||||
|
||||
return SilkError.SILK_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Structure containing NLSF codebook
|
||||
/// </summary>
|
||||
internal class NLSFCodebook
|
||||
{
|
||||
internal short nVectors = 0;
|
||||
|
||||
internal short order = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Quantization step size
|
||||
/// </summary>
|
||||
internal short quantStepSize_Q16 = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Inverse quantization step size
|
||||
/// </summary>
|
||||
internal short invQuantStepSize_Q6 = 0;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER
|
||||
/// </summary>
|
||||
internal byte[] CB1_NLSF_Q8 = null;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER
|
||||
/// </summary>
|
||||
internal byte[] CB1_iCDF = null;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER to Backward predictor coefs [ order ]
|
||||
/// </summary>
|
||||
internal byte[] pred_Q8 = null;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER to Indices to entropy coding tables [ order ]
|
||||
/// </summary>
|
||||
internal byte[] ec_sel = null;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER
|
||||
/// </summary>
|
||||
internal byte[] ec_iCDF = null;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER
|
||||
/// </summary>
|
||||
internal byte[] ec_Rates_Q5 = null;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER
|
||||
/// </summary>
|
||||
internal short[] deltaMin_Q15 = null;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
nVectors = 0;
|
||||
order = 0;
|
||||
quantStepSize_Q16 = 0;
|
||||
invQuantStepSize_Q6 = 0;
|
||||
CB1_NLSF_Q8 = null;
|
||||
CB1_iCDF = null;
|
||||
pred_Q8 = null;
|
||||
ec_sel = null;
|
||||
ec_iCDF = null;
|
||||
ec_Rates_Q5 = null;
|
||||
deltaMin_Q15 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Struct for Packet Loss Concealment
|
||||
/// </summary>
|
||||
internal class PLCStruct
|
||||
{
|
||||
internal int pitchL_Q8 = 0; /* Pitch lag to use for voiced concealment */
|
||||
internal readonly short[] LTPCoef_Q14 = new short[SilkConstants.LTP_ORDER]; /* LTP coeficients to use for voiced concealment */
|
||||
internal readonly short[] prevLPC_Q12 = new short[SilkConstants.MAX_LPC_ORDER];
|
||||
internal int last_frame_lost = 0; /* Was previous frame lost */
|
||||
internal int rand_seed = 0; /* Seed for unvoiced signal generation */
|
||||
internal short randScale_Q14 = 0; /* Scaling of unvoiced random signal */
|
||||
internal int conc_energy = 0;
|
||||
internal int conc_energy_shift = 0;
|
||||
internal short prevLTP_scale_Q14 = 0;
|
||||
internal readonly int[] prevGain_Q16 = new int[2];
|
||||
internal int fs_kHz = 0;
|
||||
internal int nb_subfr = 0;
|
||||
internal int subfr_length = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
pitchL_Q8 = 0;
|
||||
Arrays.MemSetShort(LTPCoef_Q14, 0, SilkConstants.LTP_ORDER);
|
||||
Arrays.MemSetShort(prevLPC_Q12, 0, SilkConstants.MAX_LPC_ORDER);
|
||||
last_frame_lost = 0;
|
||||
rand_seed = 0;
|
||||
randScale_Q14 = 0;
|
||||
conc_energy = 0;
|
||||
conc_energy_shift = 0;
|
||||
prevLTP_scale_Q14 = 0;
|
||||
Arrays.MemSetInt(prevGain_Q16, 0, 2);
|
||||
fs_kHz = 0;
|
||||
nb_subfr = 0;
|
||||
subfr_length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
using System;
|
||||
|
||||
internal class SideInfoIndices
|
||||
{
|
||||
internal readonly sbyte[] GainsIndices = new sbyte[SilkConstants.MAX_NB_SUBFR];
|
||||
internal readonly sbyte[] LTPIndex = new sbyte[SilkConstants.MAX_NB_SUBFR];
|
||||
internal readonly sbyte[] NLSFIndices = new sbyte[SilkConstants.MAX_LPC_ORDER + 1];
|
||||
internal short lagIndex = 0;
|
||||
internal sbyte contourIndex = 0;
|
||||
internal sbyte signalType = 0;
|
||||
internal sbyte quantOffsetType = 0;
|
||||
internal sbyte NLSFInterpCoef_Q2 = 0;
|
||||
internal sbyte PERIndex = 0;
|
||||
internal sbyte LTP_scaleIndex = 0;
|
||||
internal sbyte Seed = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetSbyte(GainsIndices, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetSbyte(LTPIndex, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetSbyte(NLSFIndices, 0, SilkConstants.MAX_LPC_ORDER + 1);
|
||||
lagIndex = 0;
|
||||
contourIndex = 0;
|
||||
signalType = 0;
|
||||
quantOffsetType = 0;
|
||||
NLSFInterpCoef_Q2 = 0;
|
||||
PERIndex = 0;
|
||||
LTP_scaleIndex = 0;
|
||||
Seed = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overwrites this struct with values from another one. Equivalent to C struct assignment this = other
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
internal void Assign(SideInfoIndices other)
|
||||
{
|
||||
Array.Copy(other.GainsIndices, this.GainsIndices, SilkConstants.MAX_NB_SUBFR);
|
||||
Array.Copy(other.LTPIndex, this.LTPIndex, SilkConstants.MAX_NB_SUBFR);
|
||||
Array.Copy(other.NLSFIndices, this.NLSFIndices, SilkConstants.MAX_LPC_ORDER + 1);
|
||||
this.lagIndex = other.lagIndex;
|
||||
this.contourIndex = other.contourIndex;
|
||||
this.signalType = other.signalType;
|
||||
this.quantOffsetType = other.quantOffsetType;
|
||||
this.NLSFInterpCoef_Q2 = other.NLSFInterpCoef_Q2;
|
||||
this.PERIndex = other.PERIndex;
|
||||
this.LTP_scaleIndex = other.LTP_scaleIndex;
|
||||
this.Seed = other.Seed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
using System;
|
||||
/// <summary>
|
||||
/// Decoder state
|
||||
/// </summary>
|
||||
internal class SilkChannelDecoder
|
||||
{
|
||||
internal int prev_gain_Q16 = 0;
|
||||
internal readonly int[] exc_Q14 = new int[SilkConstants.MAX_FRAME_LENGTH];
|
||||
internal readonly int[] sLPC_Q14_buf = new int[SilkConstants.MAX_LPC_ORDER];
|
||||
internal readonly short[] outBuf = new short[SilkConstants.MAX_FRAME_LENGTH + 2 * SilkConstants.MAX_SUB_FRAME_LENGTH]; /* Buffer for output signal */
|
||||
internal int lagPrev = 0; /* Previous Lag */
|
||||
internal sbyte LastGainIndex = 0; /* Previous gain index */
|
||||
internal int fs_kHz = 0; /* Sampling frequency in kHz */
|
||||
internal int fs_API_hz = 0; /* API sample frequency (Hz) */
|
||||
internal int nb_subfr = 0; /* Number of 5 ms subframes in a frame */
|
||||
internal int frame_length = 0; /* Frame length (samples) */
|
||||
internal int subfr_length = 0; /* Subframe length (samples) */
|
||||
internal int ltp_mem_length = 0; /* Length of LTP memory */
|
||||
internal int LPC_order = 0; /* LPC order */
|
||||
internal readonly short[] prevNLSF_Q15 = new short[SilkConstants.MAX_LPC_ORDER]; /* Used to interpolate LSFs */
|
||||
internal int first_frame_after_reset = 0; /* Flag for deactivating NLSF interpolation */
|
||||
internal byte[] pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */
|
||||
internal byte[] pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */
|
||||
|
||||
/* For buffering payload in case of more frames per packet */
|
||||
internal int nFramesDecoded = 0;
|
||||
internal int nFramesPerPacket = 0;
|
||||
|
||||
/* Specifically for entropy coding */
|
||||
internal int ec_prevSignalType = 0;
|
||||
internal short ec_prevLagIndex = 0;
|
||||
|
||||
internal readonly int[] VAD_flags = new int[SilkConstants.MAX_FRAMES_PER_PACKET];
|
||||
internal int LBRR_flag = 0;
|
||||
internal readonly int[] LBRR_flags = new int[SilkConstants.MAX_FRAMES_PER_PACKET];
|
||||
|
||||
internal readonly SilkResamplerState resampler_state = new SilkResamplerState();
|
||||
|
||||
internal NLSFCodebook psNLSF_CB = null; /* Pointer to NLSF codebook */
|
||||
|
||||
/* Quantization indices */
|
||||
internal readonly SideInfoIndices indices = new SideInfoIndices();
|
||||
|
||||
/* CNG state */
|
||||
internal readonly CNGState sCNG = new CNGState();
|
||||
|
||||
/* Stuff used for PLC */
|
||||
internal int lossCnt = 0;
|
||||
internal int prevSignalType = 0;
|
||||
|
||||
internal readonly PLCStruct sPLC = new PLCStruct();
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
prev_gain_Q16 = 0;
|
||||
Arrays.MemSetInt(exc_Q14, 0, SilkConstants.MAX_FRAME_LENGTH);
|
||||
Arrays.MemSetInt(sLPC_Q14_buf, 0, SilkConstants.MAX_LPC_ORDER);
|
||||
Arrays.MemSetShort(outBuf, 0, SilkConstants.MAX_FRAME_LENGTH + 2 * SilkConstants.MAX_SUB_FRAME_LENGTH);
|
||||
lagPrev = 0;
|
||||
LastGainIndex = 0;
|
||||
fs_kHz = 0;
|
||||
fs_API_hz = 0;
|
||||
nb_subfr = 0;
|
||||
frame_length = 0;
|
||||
subfr_length = 0;
|
||||
ltp_mem_length = 0;
|
||||
LPC_order = 0;
|
||||
Arrays.MemSetShort(prevNLSF_Q15, 0, SilkConstants.MAX_LPC_ORDER);
|
||||
first_frame_after_reset = 0;
|
||||
pitch_lag_low_bits_iCDF = null;
|
||||
pitch_contour_iCDF = null;
|
||||
nFramesDecoded = 0;
|
||||
nFramesPerPacket = 0;
|
||||
ec_prevSignalType = 0;
|
||||
ec_prevLagIndex = 0;
|
||||
Arrays.MemSetInt(VAD_flags, 0, SilkConstants.MAX_FRAMES_PER_PACKET);
|
||||
LBRR_flag = 0;
|
||||
Arrays.MemSetInt(LBRR_flags, 0, SilkConstants.MAX_FRAMES_PER_PACKET);
|
||||
resampler_state.Reset();
|
||||
psNLSF_CB = null;
|
||||
indices.Reset();
|
||||
sCNG.Reset();
|
||||
lossCnt = 0;
|
||||
prevSignalType = 0;
|
||||
sPLC.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init Decoder State
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal int silk_init_decoder()
|
||||
{
|
||||
/* Clear the entire encoder state, except anything copied */
|
||||
this.Reset();
|
||||
|
||||
/* Used to deactivate LSF interpolation */
|
||||
this.first_frame_after_reset = 1;
|
||||
this.prev_gain_Q16 = 65536;
|
||||
|
||||
/* Reset CNG state */
|
||||
silk_CNG_Reset();
|
||||
|
||||
/* Reset PLC state */
|
||||
silk_PLC_Reset();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets CNG state
|
||||
/// </summary>
|
||||
private void silk_CNG_Reset()
|
||||
{
|
||||
int i, NLSF_step_Q15, NLSF_acc_Q15;
|
||||
|
||||
NLSF_step_Q15 = Inlines.silk_DIV32_16(short.MaxValue, this.LPC_order + 1);
|
||||
NLSF_acc_Q15 = 0;
|
||||
for (i = 0; i < this.LPC_order; i++)
|
||||
{
|
||||
NLSF_acc_Q15 += NLSF_step_Q15;
|
||||
this.sCNG.CNG_smth_NLSF_Q15[i] = (short)(NLSF_acc_Q15);
|
||||
}
|
||||
this.sCNG.CNG_smth_Gain_Q16 = 0;
|
||||
this.sCNG.rand_seed = 3176576;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets PLC state
|
||||
/// </summary>
|
||||
private void silk_PLC_Reset()
|
||||
{
|
||||
this.sPLC.pitchL_Q8 = Inlines.silk_LSHIFT(this.frame_length, 8 - 1);
|
||||
this.sPLC.prevGain_Q16[0] = ((int)((1) * ((long)1 << (16)) + 0.5))/*Inlines.SILK_CONST(1, 16)*/;
|
||||
this.sPLC.prevGain_Q16[1] = ((int)((1) * ((long)1 << (16)) + 0.5))/*Inlines.SILK_CONST(1, 16)*/;
|
||||
this.sPLC.subfr_length = 20;
|
||||
this.sPLC.nb_subfr = 2;
|
||||
}
|
||||
|
||||
/* Set decoder sampling rate */
|
||||
internal int silk_decoder_set_fs(
|
||||
int fs_kHz, /* I Sampling frequency (kHz) */
|
||||
int fs_API_Hz /* I API Sampling frequency (Hz) */
|
||||
)
|
||||
{
|
||||
int frame_length, ret = 0;
|
||||
|
||||
Inlines.OpusAssert(fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16);
|
||||
Inlines.OpusAssert(this.nb_subfr == SilkConstants.MAX_NB_SUBFR || this.nb_subfr == SilkConstants.MAX_NB_SUBFR / 2);
|
||||
|
||||
/* New (sub)frame length */
|
||||
this.subfr_length = Inlines.silk_SMULBB(SilkConstants.SUB_FRAME_LENGTH_MS, fs_kHz);
|
||||
frame_length = Inlines.silk_SMULBB(this.nb_subfr, this.subfr_length);
|
||||
|
||||
/* Initialize resampler when switching internal or external sampling frequency */
|
||||
if (this.fs_kHz != fs_kHz || this.fs_API_hz != fs_API_Hz)
|
||||
{
|
||||
/* Initialize the resampler for dec_API.c preparing resampling from fs_kHz to API_fs_Hz */
|
||||
ret += Resampler.silk_resampler_init(this.resampler_state, Inlines.silk_SMULBB(fs_kHz, 1000), fs_API_Hz, 0);
|
||||
|
||||
this.fs_API_hz = fs_API_Hz;
|
||||
}
|
||||
|
||||
if (this.fs_kHz != fs_kHz || frame_length != this.frame_length)
|
||||
{
|
||||
if (fs_kHz == 8)
|
||||
{
|
||||
if (this.nb_subfr == SilkConstants.MAX_NB_SUBFR)
|
||||
{
|
||||
this.pitch_contour_iCDF = Tables.silk_pitch_contour_NB_iCDF;
|
||||
}
|
||||
else {
|
||||
this.pitch_contour_iCDF = Tables.silk_pitch_contour_10_ms_NB_iCDF;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.nb_subfr == SilkConstants.MAX_NB_SUBFR)
|
||||
{
|
||||
this.pitch_contour_iCDF = Tables.silk_pitch_contour_iCDF;
|
||||
}
|
||||
else {
|
||||
this.pitch_contour_iCDF = Tables.silk_pitch_contour_10_ms_iCDF;
|
||||
}
|
||||
}
|
||||
if (this.fs_kHz != fs_kHz)
|
||||
{
|
||||
this.ltp_mem_length = Inlines.silk_SMULBB(SilkConstants.LTP_MEM_LENGTH_MS, fs_kHz);
|
||||
if (fs_kHz == 8 || fs_kHz == 12)
|
||||
{
|
||||
this.LPC_order = SilkConstants.MIN_LPC_ORDER;
|
||||
this.psNLSF_CB = Tables.silk_NLSF_CB_NB_MB;
|
||||
}
|
||||
else {
|
||||
this.LPC_order = SilkConstants.MAX_LPC_ORDER;
|
||||
this.psNLSF_CB = Tables.silk_NLSF_CB_WB;
|
||||
}
|
||||
if (fs_kHz == 16)
|
||||
{
|
||||
this.pitch_lag_low_bits_iCDF = Tables.silk_uniform8_iCDF;
|
||||
}
|
||||
else if (fs_kHz == 12)
|
||||
{
|
||||
this.pitch_lag_low_bits_iCDF = Tables.silk_uniform6_iCDF;
|
||||
}
|
||||
else if (fs_kHz == 8)
|
||||
{
|
||||
this.pitch_lag_low_bits_iCDF = Tables.silk_uniform4_iCDF;
|
||||
}
|
||||
else {
|
||||
/* unsupported sampling rate */
|
||||
Inlines.OpusAssert(false);
|
||||
}
|
||||
this.first_frame_after_reset = 1;
|
||||
this.lagPrev = 100;
|
||||
this.LastGainIndex = 10;
|
||||
this.prevSignalType = SilkConstants.TYPE_NO_VOICE_ACTIVITY;
|
||||
Arrays.MemSetShort(this.outBuf, 0, SilkConstants.MAX_FRAME_LENGTH + 2 * SilkConstants.MAX_SUB_FRAME_LENGTH);
|
||||
Arrays.MemSetInt(this.sLPC_Q14_buf, 0, SilkConstants.MAX_LPC_ORDER);
|
||||
}
|
||||
|
||||
this.fs_kHz = fs_kHz;
|
||||
this.frame_length = frame_length;
|
||||
}
|
||||
|
||||
/* Check that settings are valid */
|
||||
Inlines.OpusAssert(this.frame_length > 0 && this.frame_length <= SilkConstants.MAX_FRAME_LENGTH);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************/
|
||||
/* Decode frame */
|
||||
/****************/
|
||||
internal int silk_decode_frame(
|
||||
EntropyCoder psRangeDec, /* I/O Compressor data structure */
|
||||
short[] pOut, /* O Pointer to output speech frame */
|
||||
int pOut_ptr,
|
||||
BoxedValueInt pN, /* O Pointer to size of output frame */
|
||||
int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */
|
||||
int condCoding /* I The type of conditional coding to use */
|
||||
)
|
||||
{
|
||||
SilkDecoderControl thisCtrl = new SilkDecoderControl();
|
||||
int L, mv_len, ret = 0;
|
||||
|
||||
L = this.frame_length;
|
||||
thisCtrl.LTP_scale_Q14 = 0;
|
||||
|
||||
/* Safety checks */
|
||||
Inlines.OpusAssert(L > 0 && L <= SilkConstants.MAX_FRAME_LENGTH);
|
||||
|
||||
if (lostFlag == DecoderAPIFlag.FLAG_DECODE_NORMAL ||
|
||||
(lostFlag == DecoderAPIFlag.FLAG_DECODE_LBRR && this.LBRR_flags[this.nFramesDecoded] == 1))
|
||||
{
|
||||
short[] pulses = new short[(L + SilkConstants.SHELL_CODEC_FRAME_LENGTH - 1) & ~(SilkConstants.SHELL_CODEC_FRAME_LENGTH - 1)];
|
||||
/*********************************************/
|
||||
/* Decode quantization indices of side info */
|
||||
/*********************************************/
|
||||
DecodeIndices.silk_decode_indices(this, psRangeDec, this.nFramesDecoded, lostFlag, condCoding);
|
||||
|
||||
/*********************************************/
|
||||
/* Decode quantization indices of excitation */
|
||||
/*********************************************/
|
||||
DecodePulses.silk_decode_pulses(psRangeDec, pulses, this.indices.signalType,
|
||||
this.indices.quantOffsetType, this.frame_length);
|
||||
|
||||
/********************************************/
|
||||
/* Decode parameters and pulse signal */
|
||||
/********************************************/
|
||||
DecodeParameters.silk_decode_parameters(this, thisCtrl, condCoding);
|
||||
|
||||
/********************************************************/
|
||||
/* Run inverse NSQ */
|
||||
/********************************************************/
|
||||
DecodeCore.silk_decode_core(this, thisCtrl, pOut, pOut_ptr, pulses);
|
||||
|
||||
/********************************************************/
|
||||
/* Update PLC state */
|
||||
/********************************************************/
|
||||
PLC.silk_PLC(this, thisCtrl, pOut, pOut_ptr, 0);
|
||||
|
||||
this.lossCnt = 0;
|
||||
this.prevSignalType = this.indices.signalType;
|
||||
Inlines.OpusAssert(this.prevSignalType >= 0 && this.prevSignalType <= 2);
|
||||
|
||||
/* A frame has been decoded without errors */
|
||||
this.first_frame_after_reset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Handle packet loss by extrapolation */
|
||||
PLC.silk_PLC(this, thisCtrl, pOut, pOut_ptr, 1);
|
||||
}
|
||||
|
||||
/*************************/
|
||||
/* Update output buffer. */
|
||||
/*************************/
|
||||
Inlines.OpusAssert(this.ltp_mem_length >= this.frame_length);
|
||||
mv_len = this.ltp_mem_length - this.frame_length;
|
||||
Arrays.MemMoveShort(this.outBuf, this.frame_length, 0, mv_len);
|
||||
Array.Copy(pOut, pOut_ptr, this.outBuf, mv_len, this.frame_length);
|
||||
|
||||
/************************************************/
|
||||
/* Comfort noise generation / estimation */
|
||||
/************************************************/
|
||||
CNG.silk_CNG(this, thisCtrl, pOut, pOut_ptr, L);
|
||||
|
||||
/****************************************************************/
|
||||
/* Ensure smooth connection of extrapolated and good frames */
|
||||
/****************************************************************/
|
||||
PLC.silk_PLC_glue_frames(this, pOut, pOut_ptr, L);
|
||||
|
||||
/* Update some decoder state variables */
|
||||
this.lagPrev = thisCtrl.pitchL[this.nb_subfr - 1];
|
||||
|
||||
/* Set output frame length */
|
||||
pN.Val = L;
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Decoder super struct
|
||||
/// </summary>
|
||||
internal class SilkDecoder
|
||||
{
|
||||
internal readonly SilkChannelDecoder[] channel_state = new SilkChannelDecoder[SilkConstants.DECODER_NUM_CHANNELS];
|
||||
internal readonly StereoDecodeState sStereo = new StereoDecodeState();
|
||||
internal int nChannelsAPI = 0;
|
||||
internal int nChannelsInternal = 0;
|
||||
internal int prev_decode_only_middle = 0;
|
||||
|
||||
internal SilkDecoder()
|
||||
{
|
||||
for (int c = 0; c < SilkConstants.DECODER_NUM_CHANNELS; c++)
|
||||
{
|
||||
channel_state[c] = new SilkChannelDecoder();
|
||||
}
|
||||
}
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
for (int c = 0; c < SilkConstants.DECODER_NUM_CHANNELS; c++)
|
||||
{
|
||||
channel_state[c].Reset();
|
||||
}
|
||||
sStereo.Reset();
|
||||
nChannelsAPI = 0;
|
||||
nChannelsInternal = 0;
|
||||
prev_decode_only_middle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Decoder control
|
||||
/// </summary>
|
||||
internal class SilkDecoderControl
|
||||
{
|
||||
/* Prediction and coding parameters */
|
||||
internal readonly int[] pitchL = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
internal readonly int[] Gains_Q16 = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
|
||||
/* Holds interpolated and final coefficients */
|
||||
internal readonly short[][] PredCoef_Q12 = Arrays.InitTwoDimensionalArray<short>(2, SilkConstants.MAX_LPC_ORDER);
|
||||
internal readonly short[] LTPCoef_Q14 = new short[SilkConstants.LTP_ORDER * SilkConstants.MAX_NB_SUBFR];
|
||||
internal int LTP_scale_Q14 = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetInt(pitchL, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetInt(Gains_Q16, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetShort(PredCoef_Q12[0], 0, SilkConstants.MAX_LPC_ORDER);
|
||||
Arrays.MemSetShort(PredCoef_Q12[1], 0, SilkConstants.MAX_LPC_ORDER);
|
||||
Arrays.MemSetShort(LTPCoef_Q14, 0, SilkConstants.LTP_ORDER * SilkConstants.MAX_NB_SUBFR);
|
||||
LTP_scale_Q14 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Encoder Super Struct
|
||||
/// </summary>
|
||||
internal class SilkEncoder
|
||||
{
|
||||
internal readonly SilkChannelEncoder[] state_Fxx = new SilkChannelEncoder[SilkConstants.ENCODER_NUM_CHANNELS];
|
||||
internal readonly StereoEncodeState sStereo = new StereoEncodeState();
|
||||
internal int nBitsUsedLBRR = 0;
|
||||
internal int nBitsExceeded = 0;
|
||||
internal int nChannelsAPI = 0;
|
||||
internal int nChannelsInternal = 0;
|
||||
internal int nPrevChannelsInternal = 0;
|
||||
internal int timeSinceSwitchAllowed_ms = 0;
|
||||
internal int allowBandwidthSwitch = 0;
|
||||
internal int prev_decode_only_middle = 0;
|
||||
|
||||
internal SilkEncoder()
|
||||
{
|
||||
for (int c = 0; c < SilkConstants.ENCODER_NUM_CHANNELS; c++)
|
||||
{
|
||||
state_Fxx[c] = new SilkChannelEncoder();
|
||||
}
|
||||
}
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
for (int c = 0; c < SilkConstants.ENCODER_NUM_CHANNELS; c++)
|
||||
{
|
||||
state_Fxx[c].Reset();
|
||||
}
|
||||
|
||||
sStereo.Reset();
|
||||
nBitsUsedLBRR = 0;
|
||||
nBitsExceeded = 0;
|
||||
nChannelsAPI = 0;
|
||||
nChannelsInternal = 0;
|
||||
nPrevChannelsInternal = 0;
|
||||
timeSinceSwitchAllowed_ms = 0;
|
||||
allowBandwidthSwitch = 0;
|
||||
prev_decode_only_middle = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize Silk Encoder state
|
||||
/// </summary>
|
||||
/// <param name="psEnc">I/O Pointer to Silk FIX encoder state</param>
|
||||
/// <returns></returns>
|
||||
internal static int silk_init_encoder(SilkChannelEncoder psEnc)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
// Clear the entire encoder state
|
||||
psEnc.Reset();
|
||||
|
||||
psEnc.variable_HP_smth1_Q15 = Inlines.silk_LSHIFT(Inlines.silk_lin2log(((int)((TuningParameters.VARIABLE_HP_MIN_CUTOFF_HZ) * ((long)1 << (16)) + 0.5))/*Inlines.SILK_CONST(TuningParameters.VARIABLE_HP_MIN_CUTOFF_HZ, 16)*/) - (16 << 7), 8);
|
||||
psEnc.variable_HP_smth2_Q15 = psEnc.variable_HP_smth1_Q15;
|
||||
|
||||
// Used to deactivate LSF interpolation, pitch prediction
|
||||
psEnc.first_frame_after_reset = 1;
|
||||
|
||||
// Initialize Silk VAD
|
||||
ret += VoiceActivityDetection.silk_VAD_Init(psEnc.sVAD);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/************************/
|
||||
/* Encoder control FIX */
|
||||
/************************/
|
||||
internal class SilkEncoderControl
|
||||
{
|
||||
/* Prediction and coding parameters */
|
||||
internal readonly int[] Gains_Q16 = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
internal readonly short[][] PredCoef_Q12 = Arrays.InitTwoDimensionalArray<short>(2, SilkConstants.MAX_LPC_ORDER); /* holds interpolated and final coefficients */
|
||||
internal readonly short[] LTPCoef_Q14 = new short[SilkConstants.LTP_ORDER * SilkConstants.MAX_NB_SUBFR];
|
||||
internal int LTP_scale_Q14 = 0;
|
||||
internal readonly int[] pitchL = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
|
||||
/* Noise shaping parameters */
|
||||
internal readonly short[] AR1_Q13 = new short[SilkConstants.MAX_NB_SUBFR * SilkConstants.MAX_SHAPE_LPC_ORDER];
|
||||
internal readonly short[] AR2_Q13 = new short[SilkConstants.MAX_NB_SUBFR * SilkConstants.MAX_SHAPE_LPC_ORDER];
|
||||
internal readonly int[] LF_shp_Q14 = new int[SilkConstants.MAX_NB_SUBFR]; /* Packs two int16 coefficients per int32 value */
|
||||
internal readonly int[] GainsPre_Q14 = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
internal readonly int[] HarmBoost_Q14 = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
internal readonly int[] Tilt_Q14 = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
internal readonly int[] HarmShapeGain_Q14 = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
internal int Lambda_Q10 = 0;
|
||||
internal int input_quality_Q14 = 0;
|
||||
internal int coding_quality_Q14 = 0;
|
||||
|
||||
/* Measures */
|
||||
internal int sparseness_Q8 = 0;
|
||||
internal int predGain_Q16 = 0;
|
||||
internal int LTPredCodGain_Q7 = 0;
|
||||
|
||||
/* Residual energy per subframe */
|
||||
internal readonly int[] ResNrg = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
|
||||
/* Q domain for the residual energy > 0 */
|
||||
internal readonly int[] ResNrgQ = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
|
||||
/* Parameters for CBR mode */
|
||||
internal readonly int[] GainsUnq_Q16 = new int[SilkConstants.MAX_NB_SUBFR];
|
||||
internal sbyte lastGainIndexPrev = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetInt(Gains_Q16, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetShort(PredCoef_Q12[0], 0, SilkConstants.MAX_LPC_ORDER);
|
||||
Arrays.MemSetShort(PredCoef_Q12[1], 0, SilkConstants.MAX_LPC_ORDER);
|
||||
Arrays.MemSetShort(LTPCoef_Q14, 0, SilkConstants.LTP_ORDER * SilkConstants.MAX_NB_SUBFR);
|
||||
LTP_scale_Q14 = 0;
|
||||
Arrays.MemSetInt(pitchL, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetShort(AR1_Q13, 0, SilkConstants.MAX_NB_SUBFR * SilkConstants.MAX_SHAPE_LPC_ORDER);
|
||||
Arrays.MemSetShort(AR2_Q13, 0, SilkConstants.MAX_NB_SUBFR * SilkConstants.MAX_SHAPE_LPC_ORDER);
|
||||
Arrays.MemSetInt(LF_shp_Q14, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetInt(GainsPre_Q14, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetInt(HarmBoost_Q14, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetInt(Tilt_Q14, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetInt(HarmShapeGain_Q14, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Lambda_Q10 = 0;
|
||||
input_quality_Q14 = 0;
|
||||
coding_quality_Q14 = 0;
|
||||
sparseness_Q8 = 0;
|
||||
predGain_Q16 = 0;
|
||||
LTPredCodGain_Q7 = 0;
|
||||
Arrays.MemSetInt(ResNrg, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetInt(ResNrgQ, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
Arrays.MemSetInt(GainsUnq_Q16, 0, SilkConstants.MAX_NB_SUBFR);
|
||||
lastGainIndexPrev = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Variable cut-off low-pass filter state
|
||||
/// </summary>
|
||||
internal class SilkLPState
|
||||
{
|
||||
/// <summary>
|
||||
/// Low pass filter state
|
||||
/// </summary>
|
||||
internal readonly int[] In_LP_State = new int[2];
|
||||
|
||||
/// <summary>
|
||||
/// Counter which is mapped to a cut-off frequency
|
||||
/// </summary>
|
||||
internal int transition_frame_no = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Operating mode, <0: switch down, >0: switch up; 0: do nothing
|
||||
/// </summary>
|
||||
internal int mode = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
In_LP_State[0] = 0;
|
||||
In_LP_State[1] = 0;
|
||||
transition_frame_no = 0;
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
/* Low-pass filter with variable cutoff frequency based on */
|
||||
/* piece-wise linear interpolation between elliptic filters */
|
||||
/* Start by setting psEncC.mode <> 0; */
|
||||
/* Deactivate by setting psEncC.mode = 0; */
|
||||
internal void silk_LP_variable_cutoff(
|
||||
short[] frame, /* I/O Low-pass filtered output signal */
|
||||
int frame_ptr,
|
||||
int frame_length /* I Frame length */
|
||||
)
|
||||
{
|
||||
int[] B_Q28 = new int[SilkConstants.TRANSITION_NB];
|
||||
int[] A_Q28 = new int[SilkConstants.TRANSITION_NA];
|
||||
int fac_Q16 = 0;
|
||||
int ind = 0;
|
||||
|
||||
Inlines.OpusAssert(this.transition_frame_no >= 0 && this.transition_frame_no <= SilkConstants.TRANSITION_FRAMES);
|
||||
|
||||
/* Run filter if needed */
|
||||
if (this.mode != 0)
|
||||
{
|
||||
/* Calculate index and interpolation factor for interpolation */
|
||||
fac_Q16 = Inlines.silk_LSHIFT(SilkConstants.TRANSITION_FRAMES - this.transition_frame_no, 16 - 6);
|
||||
|
||||
ind = Inlines.silk_RSHIFT(fac_Q16, 16);
|
||||
fac_Q16 -= Inlines.silk_LSHIFT(ind, 16);
|
||||
|
||||
Inlines.OpusAssert(ind >= 0);
|
||||
Inlines.OpusAssert(ind < SilkConstants.TRANSITION_INT_NUM);
|
||||
|
||||
/* Interpolate filter coefficients */
|
||||
Filters.silk_LP_interpolate_filter_taps(B_Q28, A_Q28, ind, fac_Q16);
|
||||
|
||||
/* Update transition frame number for next frame */
|
||||
this.transition_frame_no = Inlines.silk_LIMIT(this.transition_frame_no + this.mode, 0, SilkConstants.TRANSITION_FRAMES);
|
||||
|
||||
/* ARMA low-pass filtering */
|
||||
Inlines.OpusAssert(SilkConstants.TRANSITION_NB == 3 && SilkConstants.TRANSITION_NA == 2);
|
||||
Filters.silk_biquad_alt(frame, frame_ptr, B_Q28, A_Q28, this.In_LP_State, frame, frame_ptr, frame_length, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Prefilter state
|
||||
/// </summary>
|
||||
internal class SilkPrefilterState
|
||||
{
|
||||
internal readonly short[] sLTP_shp = new short[SilkConstants.LTP_BUF_LENGTH];
|
||||
internal readonly int[] sAR_shp = new int[SilkConstants.MAX_SHAPE_LPC_ORDER + 1];
|
||||
internal int sLTP_shp_buf_idx = 0;
|
||||
internal int sLF_AR_shp_Q12 = 0;
|
||||
internal int sLF_MA_shp_Q12 = 0;
|
||||
internal int sHarmHP_Q2 = 0;
|
||||
internal int rand_seed = 0;
|
||||
internal int lagPrev = 0;
|
||||
|
||||
internal SilkPrefilterState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetShort(sLTP_shp, 0, SilkConstants.LTP_BUF_LENGTH);
|
||||
Arrays.MemSetInt(sAR_shp, 0, SilkConstants.MAX_SHAPE_LPC_ORDER + 1);
|
||||
sLTP_shp_buf_idx = 0;
|
||||
sLF_AR_shp_Q12 = 0;
|
||||
sLF_MA_shp_Q12 = 0;
|
||||
sHarmHP_Q2 = 0;
|
||||
rand_seed = 0;
|
||||
lagPrev = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
using System;
|
||||
internal class SilkResamplerState
|
||||
{
|
||||
internal readonly int[] sIIR = new int[SilkConstants.SILK_RESAMPLER_MAX_IIR_ORDER]; /* this must be the first element of this struct FIXME why? */
|
||||
internal readonly int[] sFIR_i32 = new int[SilkConstants.SILK_RESAMPLER_MAX_FIR_ORDER]; // porting note: these two fields were originally a union, so that means only 1 will ever be used at a time.
|
||||
internal readonly short[] sFIR_i16 = new short[SilkConstants.SILK_RESAMPLER_MAX_FIR_ORDER];
|
||||
|
||||
internal readonly short[] delayBuf = new short[48];
|
||||
internal int resampler_function = 0;
|
||||
internal int batchSize = 0;
|
||||
internal int invRatio_Q16 = 0;
|
||||
internal int FIR_Order = 0;
|
||||
internal int FIR_Fracs = 0;
|
||||
internal int Fs_in_kHz = 0;
|
||||
internal int Fs_out_kHz = 0;
|
||||
internal int inputDelay = 0;
|
||||
|
||||
/// <summary>
|
||||
/// POINTER
|
||||
/// </summary>
|
||||
internal short[] Coefs = null;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetInt(sIIR, 0, SilkConstants.SILK_RESAMPLER_MAX_IIR_ORDER);
|
||||
Arrays.MemSetInt(sFIR_i32, 0, SilkConstants.SILK_RESAMPLER_MAX_FIR_ORDER);
|
||||
Arrays.MemSetShort(sFIR_i16, 0, SilkConstants.SILK_RESAMPLER_MAX_FIR_ORDER);
|
||||
Arrays.MemSetShort(delayBuf, 0, 48);
|
||||
resampler_function = 0;
|
||||
batchSize = 0;
|
||||
invRatio_Q16 = 0;
|
||||
FIR_Order = 0;
|
||||
FIR_Fracs = 0;
|
||||
Fs_in_kHz = 0;
|
||||
Fs_out_kHz = 0;
|
||||
inputDelay = 0;
|
||||
Coefs = null;
|
||||
}
|
||||
|
||||
internal void Assign(SilkResamplerState other)
|
||||
{
|
||||
resampler_function = other.resampler_function;
|
||||
batchSize = other.batchSize;
|
||||
invRatio_Q16 = other.invRatio_Q16;
|
||||
FIR_Order = other.FIR_Order;
|
||||
FIR_Fracs = other.FIR_Fracs;
|
||||
Fs_in_kHz = other.Fs_in_kHz;
|
||||
Fs_out_kHz = other.Fs_out_kHz;
|
||||
inputDelay = other.inputDelay;
|
||||
Coefs = other.Coefs;
|
||||
Array.Copy(other.sIIR, this.sIIR, SilkConstants.SILK_RESAMPLER_MAX_IIR_ORDER);
|
||||
Array.Copy(other.sFIR_i32, this.sFIR_i32, SilkConstants.SILK_RESAMPLER_MAX_FIR_ORDER);
|
||||
Array.Copy(other.sFIR_i16, this.sFIR_i16, SilkConstants.SILK_RESAMPLER_MAX_FIR_ORDER);
|
||||
Array.Copy(other.delayBuf, this.delayBuf, 48);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Noise shaping analysis state
|
||||
/// </summary>
|
||||
internal class SilkShapeState
|
||||
{
|
||||
internal sbyte LastGainIndex = 0;
|
||||
internal int HarmBoost_smth_Q16 = 0;
|
||||
internal int HarmShapeGain_smth_Q16 = 0;
|
||||
internal int Tilt_smth_Q16 = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
LastGainIndex = 0;
|
||||
HarmBoost_smth_Q16 = 0;
|
||||
HarmShapeGain_smth_Q16 = 0;
|
||||
Tilt_smth_Q16 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// VAD state
|
||||
/// </summary>
|
||||
internal class SilkVADState
|
||||
{
|
||||
/// <summary>
|
||||
/// Analysis filterbank state: 0-8 kHz
|
||||
/// </summary>
|
||||
internal readonly int[] AnaState = new int[2];
|
||||
|
||||
/// <summary>
|
||||
/// Analysis filterbank state: 0-4 kHz
|
||||
/// </summary>
|
||||
internal readonly int[] AnaState1 = new int[2];
|
||||
|
||||
/// <summary>
|
||||
/// Analysis filterbank state: 0-2 kHz
|
||||
/// </summary>
|
||||
internal readonly int[] AnaState2 = new int[2];
|
||||
|
||||
/// <summary>
|
||||
/// Subframe energies
|
||||
/// </summary>
|
||||
internal readonly int[] XnrgSubfr = new int[SilkConstants.VAD_N_BANDS];
|
||||
|
||||
/// <summary>
|
||||
/// Smoothed energy level in each band
|
||||
/// </summary>
|
||||
internal readonly int[] NrgRatioSmth_Q8 = new int[SilkConstants.VAD_N_BANDS];
|
||||
|
||||
/// <summary>
|
||||
/// State of differentiator in the lowest band
|
||||
/// </summary>
|
||||
internal short HPstate = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Noise energy level in each band
|
||||
/// </summary>
|
||||
internal readonly int[] NL = new int[SilkConstants.VAD_N_BANDS];
|
||||
|
||||
/// <summary>
|
||||
/// Inverse noise energy level in each band
|
||||
/// </summary>
|
||||
internal readonly int[] inv_NL = new int[SilkConstants.VAD_N_BANDS];
|
||||
|
||||
/// <summary>
|
||||
/// Noise level estimator bias/offset
|
||||
/// </summary>
|
||||
internal readonly int[] NoiseLevelBias = new int[SilkConstants.VAD_N_BANDS];
|
||||
|
||||
/// <summary>
|
||||
/// Frame counter used in the initial phase
|
||||
/// </summary>
|
||||
internal int counter = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetInt(AnaState, 0, 2);
|
||||
Arrays.MemSetInt(AnaState1, 0, 2);
|
||||
Arrays.MemSetInt(AnaState2, 0, 2);
|
||||
Arrays.MemSetInt(XnrgSubfr, 0, SilkConstants.VAD_N_BANDS);
|
||||
Arrays.MemSetInt(NrgRatioSmth_Q8, 0, SilkConstants.VAD_N_BANDS);
|
||||
HPstate = 0;
|
||||
Arrays.MemSetInt(NL, 0, SilkConstants.VAD_N_BANDS);
|
||||
Arrays.MemSetInt(inv_NL, 0, SilkConstants.VAD_N_BANDS);
|
||||
Arrays.MemSetInt(NoiseLevelBias, 0, SilkConstants.VAD_N_BANDS);
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
internal class StereoDecodeState
|
||||
{
|
||||
internal readonly short[] pred_prev_Q13 = new short[2];
|
||||
internal readonly short[] sMid = new short[2];
|
||||
internal readonly short[] sSide = new short[2];
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetShort(pred_prev_Q13, 0, 2);
|
||||
Arrays.MemSetShort(sMid, 0, 2);
|
||||
Arrays.MemSetShort(sSide, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
internal class StereoEncodeState
|
||||
{
|
||||
internal readonly short[] pred_prev_Q13 = new short[2];
|
||||
internal readonly short[] sMid = new short[2];
|
||||
internal readonly short[] sSide = new short[2];
|
||||
internal readonly int[] mid_side_amp_Q0 = new int[4];
|
||||
internal short smth_width_Q14 = 0;
|
||||
internal short width_prev_Q14 = 0;
|
||||
internal short silent_side_len = 0;
|
||||
internal readonly sbyte[][][] predIx = Arrays.InitThreeDimensionalArray<sbyte>(SilkConstants.MAX_FRAMES_PER_PACKET, 2, 3);
|
||||
internal readonly sbyte[] mid_only_flags = new sbyte[SilkConstants.MAX_FRAMES_PER_PACKET];
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Arrays.MemSetShort(pred_prev_Q13, 0, 2);
|
||||
Arrays.MemSetShort(sMid, 0, 2);
|
||||
Arrays.MemSetShort(sSide, 0, 2);
|
||||
Arrays.MemSetInt(mid_side_amp_Q0, 0, 4);
|
||||
smth_width_Q14 = 0;
|
||||
width_prev_Q14 = 0;
|
||||
silent_side_len = 0;
|
||||
for (int x = 0; x < SilkConstants.MAX_FRAMES_PER_PACKET; x++)
|
||||
{
|
||||
for (int y= 0; y < 2; y++)
|
||||
{
|
||||
Arrays.MemSetSbyte(predIx[x][y], 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
Arrays.MemSetSbyte(mid_only_flags, 0, SilkConstants.MAX_FRAMES_PER_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/* Copyright (c) 2006-2011 Skype Limited. All Rights Reserved
|
||||
Ported to C# by Logan Stromberg
|
||||
|
||||
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.
|
||||
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace Concentus.Silk.Structs
|
||||
{
|
||||
using Concentus.Common;
|
||||
using Concentus.Common.CPlusPlus;
|
||||
using Concentus.Silk.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Struct for TOC (Table of Contents)
|
||||
/// </summary>
|
||||
internal class TOCStruct
|
||||
{
|
||||
/// <summary>
|
||||
/// Voice activity for packet
|
||||
/// </summary>
|
||||
internal int VADFlag = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Voice activity for each frame in packet
|
||||
/// </summary>
|
||||
internal readonly int[] VADFlags = new int[SilkConstants.SILK_MAX_FRAMES_PER_PACKET];
|
||||
|
||||
/// <summary>
|
||||
/// Flag indicating if packet contains in-band FEC
|
||||
/// </summary>
|
||||
internal int inbandFECFlag = 0;
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
VADFlag = 0;
|
||||
Arrays.MemSetInt(VADFlags, 0, SilkConstants.SILK_MAX_FRAMES_PER_PACKET);
|
||||
inbandFECFlag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user