Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
485d64df
Commit
485d64df
authored
Feb 14, 2011
by
Koen Vos
Committed by
Jean-Marc Valin
Feb 14, 2011
Browse files
SILK update with LBRR and some bugfixes
parent
fc06bda8
Changes
195
Expand all
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
485d64df
...
...
@@ -40,13 +40,13 @@ src_common/SKP_Silk_encode_indices.c \
src_common/SKP_Silk_encode_pulses.c
\
src_common/SKP_Silk_gain_quant.c
\
src_common/SKP_Silk_interpolate.c
\
src_common/SKP_Silk_LBRR_embed.c
\
src_common/SKP_Silk_LP_variable_cutoff.c
\
src_common/SKP_Silk_NLSF2A_stable.c
\
src_common/SKP_Silk_NLSF_MSVQ_decode.c
\
src_common/SKP_Silk_NSQ.c
\
src_common/SKP_Silk_NSQ_del_dec.c
\
src_common/SKP_Silk_PLC.c
\
src_common/SKP_Silk_pulses_to_bytes.c
\
src_common/SKP_Silk_shell_coder.c
\
src_common/SKP_Silk_tables_gain.c
\
src_common/SKP_Silk_tables_LTP.c
\
...
...
@@ -78,7 +78,6 @@ src_FLP/SKP_Silk_NLSF_MSVQ_decode_FLP.c \
src_FLP/SKP_Silk_NLSF_MSVQ_encode_FLP.c
\
src_FLP/SKP_Silk_NLSF_VQ_rate_distortion_FLP.c
\
src_FLP/SKP_Silk_NLSF_VQ_sum_error_FLP.c
\
src_FLP/SKP_Silk_NLSF_VQ_weights_laroia_FLP.c
\
src_FLP/SKP_Silk_noise_shape_analysis_FLP.c
\
src_FLP/SKP_Silk_prefilter_FLP.c
\
src_FLP/SKP_Silk_process_gains_FLP.c
\
...
...
@@ -98,6 +97,7 @@ src_SigProc_FIX/SKP_Silk_biquad_alt.c \
src_SigProc_FIX/SKP_Silk_burg_modified.c
\
src_SigProc_FIX/SKP_Silk_bwexpander_32.c
\
src_SigProc_FIX/SKP_Silk_bwexpander.c
\
src_SigProc_FIX/SKP_Silk_debug.c
\
src_SigProc_FIX/SKP_Silk_decode_pitch.c
\
src_SigProc_FIX/SKP_Silk_inner_prod_aligned.c
\
src_SigProc_FIX/SKP_Silk_k2a.c
\
...
...
@@ -106,12 +106,12 @@ src_SigProc_FIX/SKP_Silk_lin2log.c \
src_SigProc_FIX/SKP_Silk_log2lin.c
\
src_SigProc_FIX/SKP_Silk_lowpass_int.c
\
src_SigProc_FIX/SKP_Silk_lowpass_short.c
\
src_SigProc_FIX/SKP_Silk_LPC_analysis_filter.c
\
src_SigProc_FIX/SKP_Silk_LPC_inv_pred_gain.c
\
src_SigProc_FIX/SKP_Silk_LPC_stabilize.c
\
src_SigProc_FIX/SKP_Silk_LPC_synthesis_filter.c
\
src_SigProc_FIX/SKP_Silk_LPC_synthesis_order16.c
\
src_SigProc_FIX/SKP_Silk_LSF_cos_table.c
\
src_SigProc_FIX/SKP_Silk_MA.c
\
src_SigProc_FIX/SKP_Silk_NLSF2A.c
\
src_SigProc_FIX/SKP_Silk_NLSF_stabilize.c
\
src_SigProc_FIX/SKP_Silk_NLSF_VQ_weights_laroia.c
\
...
...
@@ -138,17 +138,15 @@ src_SigProc_FIX/SKP_Silk_schur.c \
src_SigProc_FIX/SKP_Silk_sigm_Q15.c
\
src_SigProc_FIX/SKP_Silk_sort.c
\
src_SigProc_FIX/SKP_Silk_sum_sqr_shift.c
\
src_SigProc_FLP/SKP_Silk_allpass_int_FLP.c
\
src_SigProc_FLP/SKP_Silk_autocorrelation_FLP.c
\
src_SigProc_FLP/SKP_Silk_burg_modified_FLP.c
\
src_SigProc_FLP/SKP_Silk_bwexpander_FLP.c
\
src_SigProc_FLP/SKP_Silk_decimate2_coarse_FLP.c
\
src_SigProc_FLP/SKP_Silk_decimate2_coarsest_FLP.c
\
src_SigProc_FLP/SKP_Silk_energy_FLP.c
\
src_SigProc_FLP/SKP_Silk_inner_product_FLP.c
\
src_SigProc_FLP/SKP_Silk_k2a_FLP.c
\
src_SigProc_FLP/SKP_Silk_levinsondurbin_FLP.c
\
src_SigProc_FLP/SKP_Silk_LPC_inv_pred_gain_FLP.c
\
src_SigProc_FLP/SKP_Silk_NLSF_VQ_weights_laroia_FLP.c
\
src_SigProc_FLP/SKP_Silk_pitch_analysis_core_FLP.c
\
src_SigProc_FLP/SKP_Silk_scale_copy_vector_FLP.c
\
src_SigProc_FLP/SKP_Silk_scale_vector_FLP.c
\
...
...
@@ -172,13 +170,12 @@ src_common/SKP_Silk_structs.h \
src_common/SKP_Silk_tables.h
\
src_common/SKP_Silk_tables_NLSF_CB.h
\
src_common/SKP_Silk_tuning_parameters.h
\
src_common/SKP_Silk_setup
_complexity
.h
\
src_common/SKP_Silk_setup.h
\
src_FIX/SKP_Silk_main_FIX.h
\
src_FIX/SKP_Silk_structs_FIX.h
\
src_FLP/SKP_Silk_assembler_FLP.h
\
src_FLP/SKP_Silk_main_FLP.h
\
src_FLP/SKP_Silk_structs_FLP.h
\
src_SigProc_FIX/SKP_Silk_common_pitch_est_defines.h
\
src_SigProc_FIX/SKP_Silk_Inlines.h
\
src_SigProc_FIX/SKP_Silk_MacroCount.h
\
src_SigProc_FIX/SKP_Silk_MacroDebug.h
\
...
...
interface/SKP_Silk_SDK_API.h
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -43,11 +43,9 @@ extern "C"
/* Struct for TOC (Table of Contents) */
typedef
struct
{
SKP_int
framesInPacket
;
/* Number of 20 ms frames in packet */
SKP_int
fs_kHz
;
/* Sampling frequency in packet */
SKP_int
inbandLBRR
;
/* Does packet contain LBRR information */
SKP_int
corrupt
;
/* Packet is corrupt */
SKP_int
signalTypeFlags
[
SILK_MAX_FRAMES_PER_PACKET
];
/* Signal type for each frame in packet */
SKP_int
VADFlag
;
/* Voice activity for packet */
SKP_int
VADFlags
[
SILK_MAX_FRAMES_PER_PACKET
];
/* Voice activity for each frame in packet */
SKP_int
inbandFECFlag
;
/* Flag indicating if packet contains in-band FEC */
}
SKP_Silk_TOC_struct
;
/****************************************/
...
...
@@ -113,7 +111,8 @@ SKP_int SKP_Silk_SDK_InitDecoder( /* O: Returns error co
SKP_int
SKP_Silk_SDK_Decode
(
/* O: Returns error code */
void
*
decState
,
/* I/O: State */
SKP_SILK_SDK_DecControlStruct
*
decControl
,
/* I/O: Control Structure */
SKP_int
lostFlag
,
/* I: 0: no loss, 1 loss */
SKP_int
lostFlag
,
/* I: 0: no loss, 1 loss, 2 decode fec */
SKP_int
newPacketFlag
,
/* I: Indicates first decoder call for this packet */
ec_dec
*
psRangeDec
,
/* I/O Compressor data structure */
const
SKP_int
nBytesIn
,
/* I: Number of input bytes */
SKP_int16
*
samplesOut
,
/* O: Decoded output speech vector */
...
...
@@ -134,10 +133,11 @@ void SKP_Silk_SDK_search_for_LBRR(
/**************************************/
/* Get table of contents for a packet */
/**************************************/
void
SKP_Silk_SDK_get_TOC
(
ec_dec
*
psRangeDec
,
/* I/O Compressor data structure */
const
SKP_int16
nBytesIn
,
/* I: Number of input bytes */
SKP_Silk_TOC_struct
*
Silk_TOC
/* O: Table of contents */
SKP_int
SKP_Silk_SDK_get_TOC
(
const
SKP_uint8
*
payload
,
/* I Payload data */
const
SKP_int
nBytesIn
,
/* I: Number of input bytes */
const
SKP_int
nFramesPerPayload
,
/* I: Number of SILK frames per payload */
SKP_Silk_TOC_struct
*
Silk_TOC
/* O: Type of content */
);
#ifdef __cplusplus
...
...
interface/SKP_Silk_control.h
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -42,10 +42,10 @@ typedef struct {
/* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
SKP_int32
API_sampleRate
;
/* I: Maximum internal sampling rate in Hertz; 8000/12000/16000
/24000
*/
/* I: Maximum internal sampling rate in Hertz; 8000/12000/16000
*/
SKP_int32
maxInternalSampleRate
;
/* I: Minimum internal sampling rate in Hertz; 8000/12000/16000
/24000
*/
/* I: Minimum internal sampling rate in Hertz; 8000/12000/16000
*/
SKP_int32
minInternalSampleRate
;
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
...
...
@@ -69,7 +69,7 @@ typedef struct {
/* I: Flag to use constant bitrate */
SKP_int
useCBR
;
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000
/24000
*/
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000
*/
SKP_int32
internalSampleRate
;
}
SKP_SILK_SDK_EncControlStruct
;
...
...
@@ -83,7 +83,7 @@ typedef struct {
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
SKP_int
payloadSize_ms
;
/* I: Internal sampling rate used, in Hertz; 8000/12000/16000
/24000
*/
/* I: Internal sampling rate used, in Hertz; 8000/12000/16000
*/
SKP_int32
internalSampleRate
;
/* O: Number of samples per frame */
...
...
@@ -91,12 +91,6 @@ typedef struct {
/* O: Frames per payload 1, 2, 3 */
SKP_int
framesPerPayload
;
/* O: Flag to indicate that the decoder has remaining payloads internally */
SKP_int
moreInternalDecoderFrames
;
/* O: Distance between main payload and redundant payload in packets */
SKP_int
inBandFECOffset
;
}
SKP_SILK_SDK_DecControlStruct
;
#ifdef __cplusplus
...
...
interface/SKP_Silk_errors.h
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -45,10 +45,10 @@ extern "C"
/* Input length is not a multiple of 10 ms, or length is longer than the packet length */
#define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -101
/* Sampling frequency not 8000, 12000
, 16000
or
24
000 Hertz */
/* Sampling frequency not 8000, 12000 or
16
000 Hertz */
#define SKP_SILK_ENC_FS_NOT_SUPPORTED -102
/* Packet size not 20, 40,
60, 80
or
10
0 ms */
/* Packet size not
10,
20, 40, or
6
0 ms */
#define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -103
/* Allocated payload buffer too short */
...
...
interface/SKP_Silk_typedef.h
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
interface/SKP_debug.h
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
src_FIX/SKP_Silk_HP_variable_cutoff_FIX.c
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
src_FIX/SKP_Silk_LTP_analysis_filter_FIX.c
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
src_FIX/SKP_Silk_LTP_scale_ctrl_FIX.c
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -41,7 +41,7 @@ void SKP_Silk_LTP_scale_ctrl_FIX(
SKP_Silk_encoder_control_FIX
*
psEncCtrl
/* I/O encoder control FIX */
)
{
SKP_int
round_loss
,
frames_per_packet
;
SKP_int
round_loss
;
SKP_int
g_out_Q5
,
g_limit_Q15
,
thrld1_Q15
,
thrld2_Q15
;
/* 1st order high-pass filter */
...
...
@@ -55,27 +55,25 @@ void SKP_Silk_LTP_scale_ctrl_FIX(
g_limit_Q15
=
SKP_Silk_sigm_Q15
(
g_out_Q5
-
(
3
<<
5
)
);
/* Default is minimum scaling */
psEnc
Ctrl
->
sCmn
.
LTP_scaleIndex
=
0
;
psEnc
->
sCmn
.
indices
.
LTP_scaleIndex
=
0
;
/* Round the loss measure to whole pct */
round_loss
=
(
SKP_int
)
psEnc
->
sCmn
.
PacketLoss_perc
;
/* Only scale if first frame in packet
0%
*/
if
(
psEnc
->
sCmn
.
nFrames
InPayloadBuf
==
0
)
{
/* Only scale if first frame in packet */
if
(
psEnc
->
sCmn
.
nFrames
Analyzed
==
0
)
{
frames_per_packet
=
SKP_DIV32_16
(
psEnc
->
sCmn
.
PacketSize_ms
,
SKP_SMULBB
(
SUB_FRAME_LENGTH_MS
,
psEnc
->
sCmn
.
nb_subfr
)
);
round_loss
+=
frames_per_packet
-
1
;
round_loss
+=
psEnc
->
sCmn
.
nFramesPerPacket
-
1
;
thrld1_Q15
=
LTPScaleThresholds_Q15
[
SKP_min_int
(
round_loss
,
NB_THRESHOLDS
-
1
)
];
thrld2_Q15
=
LTPScaleThresholds_Q15
[
SKP_min_int
(
round_loss
+
1
,
NB_THRESHOLDS
-
1
)
];
if
(
g_limit_Q15
>
thrld1_Q15
)
{
/* Maximum scaling */
psEnc
Ctrl
->
sCmn
.
LTP_scaleIndex
=
2
;
psEnc
->
sCmn
.
indices
.
LTP_scaleIndex
=
2
;
}
else
if
(
g_limit_Q15
>
thrld2_Q15
)
{
/* Medium scaling */
psEnc
Ctrl
->
sCmn
.
LTP_scaleIndex
=
1
;
psEnc
->
sCmn
.
indices
.
LTP_scaleIndex
=
1
;
}
}
psEncCtrl
->
LTP_scale_Q14
=
SKP_Silk_LTPScales_table_Q14
[
psEnc
Ctrl
->
sCmn
.
LTP_scaleIndex
];
psEncCtrl
->
LTP_scale_Q14
=
SKP_Silk_LTPScales_table_Q14
[
psEnc
->
sCmn
.
indices
.
LTP_scaleIndex
];
}
src_FIX/SKP_Silk_NLSF_MSVQ_encode_FIX.c
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* NLSF vector encoder */
/***********************/
void
SKP_Silk_NLSF_MSVQ_encode_FIX
(
SKP_int
*
NLSFIndices
,
/* O Codebook path vector [ CB_STAGES ] */
SKP_int
8
*
NLSFIndices
,
/* O Codebook path vector [ CB_STAGES ] */
SKP_int
*
pNLSF_Q15
,
/* I/O Quantized NLSF vector [ LPC_ORDER ] */
const
SKP_Silk_NLSF_CB_struct
*
psNLSF_CB
,
/* I Codebook object */
const
SKP_int
*
pNLSF_q_Q15_prev
,
/* I Prev. quantized NLSF vector [LPC_ORDER] */
...
...
@@ -53,13 +53,15 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
SKP_int32
pRate_Q5
[
MAX_NLSF_MSVQ_SURVIVORS
];
SKP_int32
pRate_new_Q5
[
MAX_NLSF_MSVQ_SURVIVORS
];
SKP_int
pTempIndices
[
MAX_NLSF_MSVQ_SURVIVORS
];
SKP_int
pPath
[
MAX_NLSF_MSVQ_SURVIVORS
*
NLSF_MSVQ_MAX_CB_STAGES
];
SKP_int
pPath_new
[
MAX_NLSF_MSVQ_SURVIVORS
*
NLSF_MSVQ_MAX_CB_STAGES
];
SKP_int
pRes_Q15
[
MAX_NLSF_MSVQ_SURVIVORS
*
MAX_LPC_ORDER
];
SKP_int
pRes_new_Q15
[
MAX_NLSF_MSVQ_SURVIVORS
*
MAX_LPC_ORDER
];
const
SKP_int
*
pConstInt
;
SKP_int
*
pInt
;
SKP_int8
pPath
[
MAX_NLSF_MSVQ_SURVIVORS
*
NLSF_MSVQ_MAX_CB_STAGES
];
SKP_int8
pPath_new
[
MAX_NLSF_MSVQ_SURVIVORS
*
NLSF_MSVQ_MAX_CB_STAGES
];
SKP_int16
pRes_Q15
[
MAX_NLSF_MSVQ_SURVIVORS
*
MAX_LPC_ORDER
];
SKP_int16
pRes_new_Q15
[
MAX_NLSF_MSVQ_SURVIVORS
*
MAX_LPC_ORDER
];
const
SKP_int16
*
pConstInt16
;
SKP_int16
*
pInt16
;
const
SKP_int8
*
pConstInt8
;
SKP_int8
*
pInt8
;
const
SKP_int8
*
pCB_element
;
const
SKP_Silk_NLSF_CBS
*
pCurrentCBStage
;
...
...
@@ -140,35 +142,35 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
}
/* Subtract new contribution from the previous residual vector for each of 'cur_survivors' */
pConstInt
=
&
pRes_Q15
[
SKP_SMULBB
(
input_index
,
LPC_order
)
];
pConstInt
16
=
&
pRes_Q15
[
SKP_SMULBB
(
input_index
,
LPC_order
)
];
pCB_element
=
&
pCurrentCBStage
->
CB_NLSF_Q8
[
SKP_SMULBB
(
cb_index
,
LPC_order
)
];
pInt
=
&
pRes_new_Q15
[
SKP_SMULBB
(
k
,
LPC_order
)
];
pInt
16
=
&
pRes_new_Q15
[
SKP_SMULBB
(
k
,
LPC_order
)
];
for
(
i
=
0
;
i
<
LPC_order
;
i
++
)
{
pInt
[
i
]
=
pConstInt
[
i
]
-
SKP_LSHIFT16
(
(
SKP_int
)
pCB_element
[
i
],
7
);
pInt
16
[
i
]
=
pConstInt
16
[
i
]
-
SKP_LSHIFT16
(
(
SKP_int
16
)
pCB_element
[
i
],
7
);
}
/* Update accumulated rate for stage 1 to the current */
pRate_new_Q5
[
k
]
=
pRate_Q5
[
input_index
]
+
SKP_LSHIFT32
(
(
SKP_int32
)
pCurrentCBStage
->
Rates_Q4
[
cb_index
],
1
);
/* Copy paths from previous matrix, starting with the best path */
pConstInt
=
&
pPath
[
SKP_SMULBB
(
input_index
,
psNLSF_CB
->
nStages
)
];
pInt
=
&
pPath_new
[
SKP_SMULBB
(
k
,
psNLSF_CB
->
nStages
)
];
pConstInt
8
=
&
pPath
[
SKP_SMULBB
(
input_index
,
psNLSF_CB
->
nStages
)
];
pInt
8
=
&
pPath_new
[
SKP_SMULBB
(
k
,
psNLSF_CB
->
nStages
)
];
for
(
i
=
0
;
i
<
s
;
i
++
)
{
pInt
[
i
]
=
pConstInt
[
i
];
pInt
8
[
i
]
=
pConstInt
8
[
i
];
}
/* Write the current stage indices for the 'cur_survivors' to the best path matrix */
pInt
[
s
]
=
cb_index
;
pInt
8
[
s
]
=
(
SKP_int8
)
cb_index
;
}
if
(
s
<
psNLSF_CB
->
nStages
-
1
)
{
/* Copy NLSF residual matrix for next stage */
SKP_memcpy
(
pRes_Q15
,
pRes_new_Q15
,
SKP_SMULBB
(
cur_survivors
,
LPC_order
)
*
sizeof
(
SKP_int
)
);
SKP_memcpy
(
pRes_Q15
,
pRes_new_Q15
,
SKP_SMULBB
(
cur_survivors
,
LPC_order
)
*
sizeof
(
SKP_int
16
)
);
/* Copy rate vector for next stage */
SKP_memcpy
(
pRate_Q5
,
pRate_new_Q5
,
cur_survivors
*
sizeof
(
SKP_int32
)
);
/* Copy best path matrix for next stage */
SKP_memcpy
(
pPath
,
pPath_new
,
SKP_SMULBB
(
cur_survivors
,
psNLSF_CB
->
nStages
)
*
sizeof
(
SKP_int
)
);
SKP_memcpy
(
pPath
,
pPath_new
,
SKP_SMULBB
(
cur_survivors
,
psNLSF_CB
->
nStages
)
*
sizeof
(
SKP_int
8
)
);
}
prev_survivors
=
cur_survivors
;
...
...
@@ -215,7 +217,7 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
#endif
/* Copy best path to output argument */
SKP_memcpy
(
NLSFIndices
,
&
pPath_new
[
SKP_SMULBB
(
bestIndex
,
psNLSF_CB
->
nStages
)
],
psNLSF_CB
->
nStages
*
sizeof
(
SKP_int
)
);
SKP_memcpy
(
NLSFIndices
,
&
pPath_new
[
SKP_SMULBB
(
bestIndex
,
psNLSF_CB
->
nStages
)
],
psNLSF_CB
->
nStages
*
sizeof
(
SKP_int
8
)
);
/* Decode and stabilize the best survivor */
SKP_Silk_NLSF_MSVQ_decode
(
pNLSF_Q15
,
psNLSF_CB
,
NLSFIndices
,
LPC_order
);
...
...
src_FIX/SKP_Silk_NLSF_VQ_rate_distortion_FIX.c
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
void
SKP_Silk_NLSF_VQ_rate_distortion_FIX
(
SKP_int32
*
pRD_Q20
,
/* O Rate-distortion values [psNLSF_CBS->nVectors*N] */
const
SKP_Silk_NLSF_CBS
*
psNLSF_CBS
,
/* I NLSF codebook stage struct */
const
SKP_int
*
in_Q15
,
/* I Input vectors to be quantized */
const
SKP_int
16
*
in_Q15
,
/* I Input vectors to be quantized */
const
SKP_int
*
w_Q6
,
/* I Weight vector */
const
SKP_int32
*
rate_acc_Q5
,
/* I Accumulated rates from previous stage */
const
SKP_int
mu_Q15
,
/* I Weight between weighted error and rate */
...
...
src_FIX/SKP_Silk_NLSF_VQ_sum_error_FIX.c
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -30,8 +30,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */
void
SKP_Silk_NLSF_VQ_sum_error_FIX
(
SKP_int32
*
err_Q20
,
/* O Weighted quantization errors [N*K] */
const
SKP_int
*
in_Q15
,
/* I Input vectors to be quantized [N*LPC_order] */
const
SKP_int
*
w_Q6
,
/* I Weighting vectors [
N*
LPC_order] */
const
SKP_int
16
*
in_Q15
,
/* I Input vectors to be quantized [N*LPC_order] */
const
SKP_int
*
w_Q6
,
/* I Weighting vectors [LPC_order]
*/
const
SKP_int8
*
pCB_Q8
,
/* I Codebook vectors [K*LPC_order] */
const
SKP_int
N
,
/* I Number of input vectors */
const
SKP_int
K
,
/* I Number of codebook vectors */
...
...
@@ -62,11 +62,11 @@ void SKP_Silk_NLSF_VQ_sum_error_FIX(
Wtmp_Q6
=
Wcpy_Q6
[
SKP_RSHIFT
(
m
,
1
)
];
/* Compute weighted squared quantization error for index m */
diff_Q15
=
in_Q15
[
m
]
-
SKP_LSHIFT16
(
(
SKP_int
)(
*
cb_vec_Q8
++
),
7
);
// range: [ -32767 : 32767 ]
diff_Q15
=
in_Q15
[
m
]
-
SKP_LSHIFT16
(
(
SKP_int
16
)(
*
cb_vec_Q8
++
),
7
);
// range: [ -32767 : 32767 ]
sum_error
=
SKP_SMLAWB
(
sum_error
,
SKP_SMULBB
(
diff_Q15
,
diff_Q15
),
Wtmp_Q6
);
/* Compute weighted squared quantization error for index m + 1 */
diff_Q15
=
in_Q15
[
m
+
1
]
-
SKP_LSHIFT16
(
(
SKP_int
)(
*
cb_vec_Q8
++
),
7
);
// range: [ -32767 : 32767 ]
diff_Q15
=
in_Q15
[
m
+
1
]
-
SKP_LSHIFT16
(
(
SKP_int
16
)(
*
cb_vec_Q8
++
),
7
);
// range: [ -32767 : 32767 ]
sum_error
=
SKP_SMLAWT
(
sum_error
,
SKP_SMULBB
(
diff_Q15
,
diff_Q15
),
Wtmp_Q6
);
}
SKP_assert
(
sum_error
>=
0
);
...
...
src_FIX/SKP_Silk_control_codec_FIX.c
View file @
485d64df
/***********************************************************************
Copyright (c) 2006-201
0
, Skype Limited. All rights reserved.
Copyright (c) 2006-201
1
, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
...
...
@@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include
"SKP_Silk_main_FIX.h"
#include
"SKP_Silk_setup
_complexity
.h"
#include
"SKP_Silk_setup.h"
/* ToDo: Move the functions belowto common to be able to use them in FLP control codec also */
SKP_INLINE
SKP_int
SKP_Silk_setup_resamplers
(
...
...
@@ -42,11 +42,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
SKP_INLINE
SKP_int
SKP_Silk_setup_rate
(
SKP_Silk_encoder_state_FIX
*
psEnc
,
/* I/O */
SKP_int
TargetRate_bps
/* I */
);
SKP_INLINE
SKP_int
SKP_Silk_setup_LBRR
(
SKP_Silk_encoder_state_FIX
*
psEnc
/* I/O */
SKP_int32
TargetRate_bps
/* I */
);
/* Control encoder SNR */
...
...
@@ -106,7 +102,7 @@ SKP_int SKP_Silk_control_encoder_FIX(
/********************************************/
/* Set LBRR usage */
/********************************************/
ret
+=
SKP_Silk_setup_LBRR
(
psEnc
);
ret
+=
SKP_Silk_setup_LBRR
(
&
psEnc
->
sCmn
);
psEnc
->
sCmn
.
controlled_since_last_payload
=
1
;
...
...
@@ -182,7 +178,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
ret
=
SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED
;
}
if
(
PacketSize_ms
==
10
)
{
/* Only allowed when the payload buffer is empty */
psEnc
->
sCmn
.
nFramesPerPacket
=
1
;
psEnc
->
sCmn
.
nb_subfr
=
MAX_NB_SUBFR
>>
1
;
psEnc
->
sPred
.
pitch_LPC_win_length
=
SKP_SMULBB
(
FIND_PITCH_LPC_WIN_MS_2_SF
,
fs_kHz
);
if
(
psEnc
->
sCmn
.
fs_kHz
==
8
)
{
...
...
@@ -191,6 +187,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
psEnc
->
sCmn
.
pitch_contour_iCDF
=
SKP_Silk_pitch_contour_10_ms_iCDF
;
}
}
else
{
psEnc
->
sCmn
.
nFramesPerPacket
=
SKP_DIV32_16
(
PacketSize_ms
,
MAX_FRAME_LENGTH_MS
);
psEnc
->
sCmn
.
nb_subfr
=
MAX_NB_SUBFR
;
psEnc
->
sPred
.
pitch_LPC_win_length
=
SKP_SMULBB
(
FIND_PITCH_LPC_WIN_MS
,
fs_kHz
);
if
(
psEnc
->
sCmn
.
fs_kHz
==
8
)
{
...
...
@@ -200,21 +197,18 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
}
}
psEnc
->
sCmn
.
PacketSize_ms
=
PacketSize_ms
;
psEnc
->
sCmn
.
LBRR_nBytes
=
0
;
}
/* Set internal sampling frequency */
if
(
psEnc
->
sCmn
.
fs_kHz
!=
fs_kHz
)
{
/* reset part of the state */
SKP_memset
(
&
psEnc
->
sShape
,
0
,
sizeof
(
SKP_Silk_shape_state_FIX
)
);
SKP_memset
(
&
psEnc
->
sPrefilt
,
0
,
sizeof
(
SKP_Silk_prefilter_state_FIX
)
);
SKP_memset
(
&
psEnc
->
sNSQ
,
0
,
sizeof
(
SKP_Silk_nsq_state
)
);
SKP_memset
(
&
psEnc
->
sPred
,
0
,
sizeof
(
SKP_Silk_predict_state_FIX
)
);
SKP_memset
(
psEnc
->
sNSQ
.
xq
,
0
,
2
*
MAX_FRAME_LENGTH
*
sizeof
(
SKP_int16
)
);
SKP_memset
(
psEnc
->
sNSQ_LBRR
.
xq
,
0
,
2
*
MAX_FRAME_LENGTH
*
sizeof
(
SKP_int16
)
);
SKP_memset
(
psEnc
->
sPred
.
prev_NLSFq_Q15
,
0
,
MAX_LPC_ORDER
*
sizeof
(
SKP_int
)
);
SKP_memset
(
&
psEnc
->
sShape
,
0
,
sizeof
(
SKP_Silk_shape_state_FIX
)
);
SKP_memset
(
&
psEnc
->
sPrefilt
,
0
,
sizeof
(
SKP_Silk_prefilter_state_FIX
)
);
SKP_memset
(
&
psEnc
->
sCmn
.
sNSQ
,
0
,
sizeof
(
SKP_Silk_nsq_state
)
);
SKP_memset
(
&
psEnc
->
sPred
,
0
,
sizeof
(
SKP_Silk_predict_state_FIX
)
);
SKP_memset
(
psEnc
->
sPred
.
prev_NLSFq_Q15
,
0
,
sizeof
(
psEnc
->
sPred
.
prev_NLSFq_Q15
)
);
#if SWITCH_TRANSITION_FILTERING
SKP_memset
(
psEnc
->
sCmn
.
sLP
.
In_LP_State
,
0
,
2
*
sizeof
(
SKP_int32
)
);
SKP_memset
(
psEnc
->
sCmn
.
sLP
.
In_LP_State
,
0
,
sizeof
(
psEnc
->
sCmn
.
sLP
.
In_LP_State
)
);
if
(
psEnc
->
sCmn
.
sLP
.
mode
==
1
)
{
/* Begin transition phase */
psEnc
->
sCmn
.
sLP
.
transition_frame_no
=
1
;
...
...
@@ -223,20 +217,17 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
psEnc
->
sCmn
.
sLP
.
transition_frame_no
=
0
;
}
#endif
psEnc
->
sCmn
.
LBRR_nBytes
=
0
;
psEnc
->
sCmn
.
inputBufIx
=
0
;
psEnc
->
sCmn
.
nFramesInPayloadBuf
=
0
;
psEnc
->
sCmn
.
nBytesInPayloadBuf
=
0
;
psEnc
->
sCmn
.
nFramesAnalyzed
=
0
;
psEnc
->
sCmn
.
TargetRate_bps
=
0
;
/* Ensures that psEnc->SNR_dB is recomputed */
/* Initialize non-zero parameters */
psEnc
->
sCmn
.
prevLag
=
100
;
psEnc
->
sCmn
.
first_frame_after_reset
=
1
;
psEnc
->
sPrefilt
.
lagPrev
=
100
;
psEnc
->
sShape
.
LastGainIndex
=
1
;
psEnc
->
sNSQ
.
lagPrev
=
100
;
psEnc
->
sNSQ
.
prev_inv_gain_Q16
=
65536
;
psEnc
->
sNSQ_LBRR
.
prev_inv_gain_Q16
=
65536
;
psEnc
->
sCmn
.
prevLag
=
100
;
psEnc
->
sCmn
.
first_frame_after_reset
=
1
;
psEnc
->
sPrefilt
.
lagPrev
=
100
;
psEnc
->
sShape
.
LastGainIndex
=
10
;
psEnc
->
sCmn
.
sNSQ
.
lagPrev
=
100
;
psEnc
->
sCmn
.
sNSQ
.
prev_inv_gain_Q16
=
65536
;
psEnc
->
sCmn
.
fs_kHz
=
fs_kHz
;
if
(
psEnc
->
sCmn
.
fs_kHz
==
8
)
{
...
...
@@ -297,7 +288,6 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
/* unsupported sampling rate */
SKP_assert
(
0
);
}
psEnc
->
sCmn
.
fs_kHz_changed
=
1
;
}
/* Check that settings are valid */
...
...
@@ -308,12 +298,12 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
SKP_INLINE
SKP_int
SKP_Silk_setup_rate
(
SKP_Silk_encoder_state_FIX
*
psEnc
,
/* I/O */
SKP_int
TargetRate_bps
/* I */
SKP_int
32
TargetRate_bps
/* I */
)
{
SKP_int
k
,
ret
=
SKP_SILK_NO_ERROR
;
SKP_int32
frac_Q6
;
const
SKP_
u
int
16
*
rateTable
;
const
SKP_int
32
*
rateTable
;
/* Set bitrate/coding quality */
if
(
TargetRate_bps
!=
psEnc
->
sCmn
.
TargetRate_bps
)
{
...
...
@@ -335,7 +325,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_rate(
}
for
(
k
=
1
;
k
<
TARGET_RATE_TAB_SZ
;
k
++
)
{
/* Find bitrate interval in table and interpolate */
if
(
TargetRate_bps
<
rateTable
[
k
]
)
{
if
(
TargetRate_bps
<
=
rateTable
[
k
]
)
{
frac_Q6
=
SKP_DIV32
(
SKP_LSHIFT
(
TargetRate_bps
-
rateTable
[
k
-
1
],
6
),
rateTable
[
k
]
-
rateTable
[
k
-
1
]
);
psEnc
->
SNR_dB_Q7
=
SKP_LSHIFT
(
SNR_table_Q1
[
k
-
1
],
6
)
+
SKP_MUL
(
frac_Q6
,
SNR_table_Q1
[
k
]
-
SNR_table_Q1
[
k
-
1
]
);
...
...
@@ -345,55 +335,3 @@ SKP_INLINE SKP_int SKP_Silk_setup_rate(
}
return
(
ret
);
}
SKP_INLINE
SKP_int
SKP_Silk_setup_LBRR
(
SKP_Silk_encoder_state_FIX
*
psEnc
/* I/O */
)
{
SKP_int
ret
=
SKP_SILK_NO_ERROR
;
#if USE_LBRR
SKP_int32
LBRRRate_thres_bps
;
if
(
psEnc
->
sCmn
.
useInBandFEC
<
0
||
psEnc
->
sCmn
.
useInBandFEC
>
1
)
{
ret
=
SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING
;
}
psEnc
->
sCmn
.
LBRR_enabled
=
psEnc
->
sCmn
.
useInBandFEC
;
if
(
psEnc
->
sCmn
.
fs_kHz
==
8
)
{
LBRRRate_thres_bps
=
INBAND_FEC_MIN_RATE_BPS
-
9000
;
}
else
if
(
psEnc
->
sCmn
.
fs_kHz
==
12
)
{
LBRRRate_thres_bps
=
INBAND_FEC_MIN_RATE_BPS
-
6000
;;
}
else
if
(
psEnc
->
sCmn
.
fs_kHz
==
16
)
{
LBRRRate_thres_bps
=
INBAND_FEC_MIN_RATE_BPS
-
3000
;
}
else
{
LBRRRate_thres_bps
=
INBAND_FEC_MIN_RATE_BPS
;
}
if
(
psEnc
->
sCmn
.
TargetRate_bps
>=
LBRRRate_thres_bps
)
{
/* Set gain increase / rate reduction for LBRR usage */
/* Coarsely tuned with PESQ for now. */
/* Linear regression coefs G = 8 - 0.5 * loss */
/* Meaning that at 16% loss main rate and redundant rate is the same, -> G = 0 */
psEnc
->
sCmn
.
LBRR_GainIncreases
=
SKP_max_int
(
8
-
SKP_RSHIFT
(
psEnc
->
sCmn
.
PacketLoss_perc
,
1
),
0
);
/* Set main stream rate compensation */
if
(
psEnc
->
sCmn
.
LBRR_enabled
&&
psEnc
->
sCmn
.
PacketLoss_perc
>
LBRR_LOSS_THRES
)
{
/* Tuned to give approx same mean / weighted bitrate as no inband FEC */
psEnc
->
inBandFEC_SNR_comp_Q8
=
SKP_FIX_CONST
(
6
.
0
f
,
8
)
-
SKP_LSHIFT
(
psEnc
->
sCmn
.
LBRR_GainIncreases
,
7
);
}
else
{
psEnc
->
inBandFEC_SNR_comp_Q8
=
0
;
psEnc
->
sCmn
.
LBRR_enabled
=
0
;
}
}
else
{
psEnc
->
inBandFEC_SNR_comp_Q8
=
0
;
psEnc
->
sCmn
.
LBRR_enabled
=
0
;
}
#else
if
(
psEnc
->
sCmn
.
LBRR_enabled
!=
0
)
{
ret
=
SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING
;
psEnc
->
sCmn
.
LBRR_enabled
=
0
;
}
#endif
return
ret
;
}
src_FIX/SKP_Silk_corrMatrix_FIX.c
View file @
485d64df