mirror of
https://github.com/Q3Rally-Team/q3rally.git
synced 2024-12-03 00:42:30 +00:00
0d5fb492cd
Fix GCC 6 misleading-indentation warning add SECURITY.md OpenGL2: Restore adding fixed ambient light when HDR is enabled Few LCC memory fixes. fix a few potential buffer overwrite in Game VM Enable compiler optimization on all macOS architectures Don't allow qagame module to create "botlib.log" at ANY filesystem location Make FS_BuildOSPath for botlib.log consistent with typical usage tiny readme thing Remove extra plus sign from Huff_Compress() Fix VMs being able to change CVAR_PROTECTED cvars Don't register fs_game cvar everywhere just to get the value Don't let VMs change engine latch cvars immediately Fix fs_game '..' reading outside of home and base path Fix VMs forcing engine latch cvar to update to latched value Revert my recent cvar latch changes Revert "Don't let VMs change engine latch cvars immediately" Partially revert "Fix fs_game '..' reading outside of home and base path" Revert "Fix VMs forcing engine latch cvar to update to latched value" Fix exploit to bypass filename restrictions on Windows Changes to systemd q3a.service Fix Q_vsnprintf for mingw-w64 Fix timelimit causing an infinite map ending loop Fix invalid access to cluster 0 in AAS_AreaRouteToGoalArea() Fix negative frag/capturelimit causing an infinite map end loop OpenGL2: Fix dark lightmap on shader in mpteam6 Make FS_InvalidGameDir() consider subdirectories invalid [qcommon] Remove dead serialization code [qcommon] Make several zone variables and functions static. Fix MAC_OS_X_VERSION_MIN_REQUIRED for macOS 10.10 and later Increase q3_ui .arena filename list buffer size to 4096 bytes OpenGL2: Fix crash when BSP has deluxe maps and vertex lit surfaces Support Unicode characters greater than 0xFF in cl_consoleKeys Fix macOS app bundle with space in name OpenGL1: Use glGenTextures instead of hardcoded values Remove CON_FlushIn function and where STDIN needs flushing, use tcflush POSIX function Update libogg from 1.3.2 to 1.3.3 Rename (already updated) libogg-1.3.2 to libogg-1.3.3 Update libvorbis from 1.3.5 to 1.3.6 * Fix CVE-2018-5146 - out-of-bounds write on codebook decoding. * Fix CVE-2017-14632 - free() on unitialized data * Fix CVE-2017-14633 - out-of-bounds read Rename (already updated) libvorbis-1.3.5 to libvorbis-1.3.6 Update opus from 1.1.4 to 1.2.1 Rename (already updated) opus-1.1.4 to opus-1.2.1 Update opusfile from 0.8 to 0.9 Rename (already updated) opusfile-0.8 to opusfile-0.9 First swing at a CONTRIBUTING.md Allow loading system OpenAL library on macOS again Remove duplicate setting of FREETYPE_CFLAGS in Makefile Fix exploit to reset player by sending wrong serverId Fix "Going to CS_ZOMBIE for [clientname]" developer message Fix MSG_Read*String*() functions not being able to read last byte from message
207 lines
10 KiB
C
207 lines
10 KiB
C
/***********************************************************************
|
|
Copyright (c) 2006-2011, Skype Limited. All rights reserved.
|
|
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.
|
|
***********************************************************************/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "main_FLP.h"
|
|
|
|
/* Wrappers. Calls flp / fix code */
|
|
|
|
/* Convert AR filter coefficients to NLSF parameters */
|
|
void silk_A2NLSF_FLP(
|
|
opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
|
|
const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */
|
|
const opus_int LPC_order /* I LPC order */
|
|
)
|
|
{
|
|
opus_int i;
|
|
opus_int32 a_fix_Q16[ MAX_LPC_ORDER ];
|
|
|
|
for( i = 0; i < LPC_order; i++ ) {
|
|
a_fix_Q16[ i ] = silk_float2int( pAR[ i ] * 65536.0f );
|
|
}
|
|
|
|
silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order );
|
|
}
|
|
|
|
/* Convert LSF parameters to AR prediction filter coefficients */
|
|
void silk_NLSF2A_FLP(
|
|
silk_float *pAR, /* O LPC coefficients [ LPC_order ] */
|
|
const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
|
|
const opus_int LPC_order, /* I LPC order */
|
|
int arch /* I Run-time architecture */
|
|
)
|
|
{
|
|
opus_int i;
|
|
opus_int16 a_fix_Q12[ MAX_LPC_ORDER ];
|
|
|
|
silk_NLSF2A( a_fix_Q12, NLSF_Q15, LPC_order, arch );
|
|
|
|
for( i = 0; i < LPC_order; i++ ) {
|
|
pAR[ i ] = ( silk_float )a_fix_Q12[ i ] * ( 1.0f / 4096.0f );
|
|
}
|
|
}
|
|
|
|
/******************************************/
|
|
/* Floating-point NLSF processing wrapper */
|
|
/******************************************/
|
|
void silk_process_NLSFs_FLP(
|
|
silk_encoder_state *psEncC, /* I/O Encoder state */
|
|
silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
|
|
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
|
|
const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
|
|
)
|
|
{
|
|
opus_int i, j;
|
|
opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
|
|
|
silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15);
|
|
|
|
for( j = 0; j < 2; j++ ) {
|
|
for( i = 0; i < psEncC->predictLPCOrder; i++ ) {
|
|
PredCoef[ j ][ i ] = ( silk_float )PredCoef_Q12[ j ][ i ] * ( 1.0f / 4096.0f );
|
|
}
|
|
}
|
|
}
|
|
|
|
/****************************************/
|
|
/* Floating-point Silk NSQ wrapper */
|
|
/****************************************/
|
|
void silk_NSQ_wrapper_FLP(
|
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
|
SideInfoIndices *psIndices, /* I/O Quantization indices */
|
|
silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
|
|
opus_int8 pulses[], /* O Quantized pulse signal */
|
|
const silk_float x[] /* I Prefiltered input signal */
|
|
)
|
|
{
|
|
opus_int i, j;
|
|
opus_int16 x16[ MAX_FRAME_LENGTH ];
|
|
opus_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
|
silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
|
opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
|
|
opus_int LTP_scale_Q14;
|
|
|
|
/* Noise shaping parameters */
|
|
opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
|
opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */
|
|
opus_int Lambda_Q10;
|
|
opus_int Tilt_Q14[ MAX_NB_SUBFR ];
|
|
opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ];
|
|
|
|
/* Convert control struct to fix control struct */
|
|
/* Noise shape parameters */
|
|
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
|
for( j = 0; j < psEnc->sCmn.shapingLPCOrder; j++ ) {
|
|
AR_Q13[ i * MAX_SHAPE_LPC_ORDER + j ] = silk_float2int( psEncCtrl->AR[ i * MAX_SHAPE_LPC_ORDER + j ] * 8192.0f );
|
|
}
|
|
}
|
|
|
|
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
|
LF_shp_Q14[ i ] = silk_LSHIFT32( silk_float2int( psEncCtrl->LF_AR_shp[ i ] * 16384.0f ), 16 ) |
|
|
(opus_uint16)silk_float2int( psEncCtrl->LF_MA_shp[ i ] * 16384.0f );
|
|
Tilt_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->Tilt[ i ] * 16384.0f );
|
|
HarmShapeGain_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->HarmShapeGain[ i ] * 16384.0f );
|
|
}
|
|
Lambda_Q10 = ( opus_int )silk_float2int( psEncCtrl->Lambda * 1024.0f );
|
|
|
|
/* prediction and coding parameters */
|
|
for( i = 0; i < psEnc->sCmn.nb_subfr * LTP_ORDER; i++ ) {
|
|
LTPCoef_Q14[ i ] = (opus_int16)silk_float2int( psEncCtrl->LTPCoef[ i ] * 16384.0f );
|
|
}
|
|
|
|
for( j = 0; j < 2; j++ ) {
|
|
for( i = 0; i < psEnc->sCmn.predictLPCOrder; i++ ) {
|
|
PredCoef_Q12[ j ][ i ] = (opus_int16)silk_float2int( psEncCtrl->PredCoef[ j ][ i ] * 4096.0f );
|
|
}
|
|
}
|
|
|
|
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
|
Gains_Q16[ i ] = silk_float2int( psEncCtrl->Gains[ i ] * 65536.0f );
|
|
silk_assert( Gains_Q16[ i ] > 0 );
|
|
}
|
|
|
|
if( psIndices->signalType == TYPE_VOICED ) {
|
|
LTP_scale_Q14 = silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ];
|
|
} else {
|
|
LTP_scale_Q14 = 0;
|
|
}
|
|
|
|
/* Convert input to fix */
|
|
for( i = 0; i < psEnc->sCmn.frame_length; i++ ) {
|
|
x16[ i ] = silk_float2int( x[ i ] );
|
|
}
|
|
|
|
/* Call NSQ */
|
|
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
|
|
silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14,
|
|
AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch );
|
|
} else {
|
|
silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14,
|
|
AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch );
|
|
}
|
|
}
|
|
|
|
/***********************************************/
|
|
/* Floating-point Silk LTP quantiation wrapper */
|
|
/***********************************************/
|
|
void silk_quant_LTP_gains_FLP(
|
|
silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */
|
|
opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
|
|
opus_int8 *periodicity_index, /* O Periodicity index */
|
|
opus_int32 *sum_log_gain_Q7, /* I/O Cumulative max prediction gain */
|
|
silk_float *pred_gain_dB, /* O LTP prediction gain */
|
|
const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */
|
|
const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */
|
|
const opus_int subfr_len, /* I Number of samples per subframe */
|
|
const opus_int nb_subfr, /* I Number of subframes */
|
|
int arch /* I Run-time architecture */
|
|
)
|
|
{
|
|
opus_int i, pred_gain_dB_Q7;
|
|
opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ];
|
|
opus_int32 XX_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ];
|
|
opus_int32 xX_Q17[ MAX_NB_SUBFR * LTP_ORDER ];
|
|
|
|
for( i = 0; i < nb_subfr * LTP_ORDER * LTP_ORDER; i++ ) {
|
|
XX_Q17[ i ] = (opus_int32)silk_float2int( XX[ i ] * 131072.0f );
|
|
}
|
|
for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) {
|
|
xX_Q17[ i ] = (opus_int32)silk_float2int( xX[ i ] * 131072.0f );
|
|
}
|
|
|
|
silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, sum_log_gain_Q7, &pred_gain_dB_Q7, XX_Q17, xX_Q17, subfr_len, nb_subfr, arch );
|
|
|
|
for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) {
|
|
B[ i ] = (silk_float)B_Q14[ i ] * ( 1.0f / 16384.0f );
|
|
}
|
|
|
|
*pred_gain_dB = (silk_float)pred_gain_dB_Q7 * ( 1.0f / 128.0f );
|
|
}
|