mirror of
https://github.com/Q3Rally-Team/q3rally.git
synced 2024-12-15 14:50:58 +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
159 lines
4.4 KiB
C
159 lines
4.4 KiB
C
/********************************************************************
|
|
* *
|
|
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
|
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
|
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
|
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
|
* *
|
|
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
|
|
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
|
* *
|
|
********************************************************************
|
|
|
|
function: LPC low level routines
|
|
|
|
********************************************************************/
|
|
|
|
/* Some of these routines (autocorrelator, LPC coefficient estimator)
|
|
are derived from code written by Jutta Degener and Carsten Bormann;
|
|
thus we include their copyright below. The entirety of this file
|
|
is freely redistributable on the condition that both of these
|
|
copyright notices are preserved without modification. */
|
|
|
|
/* Preserved Copyright: *********************************************/
|
|
|
|
/* Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
|
|
Technische Universita"t Berlin
|
|
|
|
Any use of this software is permitted provided that this notice is not
|
|
removed and that neither the authors nor the Technische Universita"t
|
|
Berlin are deemed to have made any representations as to the
|
|
suitability of this software for any purpose nor are held responsible
|
|
for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR
|
|
THIS SOFTWARE.
|
|
|
|
As a matter of courtesy, the authors request to be informed about uses
|
|
this software has found, about bugs in this software, and about any
|
|
improvements that may be of general interest.
|
|
|
|
Berlin, 28.11.1994
|
|
Jutta Degener
|
|
Carsten Bormann
|
|
|
|
*********************************************************************/
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include "os.h"
|
|
#include "smallft.h"
|
|
#include "lpc.h"
|
|
#include "scales.h"
|
|
#include "misc.h"
|
|
|
|
/* Autocorrelation LPC coeff generation algorithm invented by
|
|
N. Levinson in 1947, modified by J. Durbin in 1959. */
|
|
|
|
/* Input : n elements of time doamin data
|
|
Output: m lpc coefficients, excitation energy */
|
|
|
|
float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
|
|
double *aut=alloca(sizeof(*aut)*(m+1));
|
|
double *lpc=alloca(sizeof(*lpc)*(m));
|
|
double error;
|
|
double epsilon;
|
|
int i,j;
|
|
|
|
/* autocorrelation, p+1 lag coefficients */
|
|
j=m+1;
|
|
while(j--){
|
|
double d=0; /* double needed for accumulator depth */
|
|
for(i=j;i<n;i++)d+=(double)data[i]*data[i-j];
|
|
aut[j]=d;
|
|
}
|
|
|
|
/* Generate lpc coefficients from autocorr values */
|
|
|
|
/* set our noise floor to about -100dB */
|
|
error=aut[0] * (1. + 1e-10);
|
|
epsilon=1e-9*aut[0]+1e-10;
|
|
|
|
for(i=0;i<m;i++){
|
|
double r= -aut[i+1];
|
|
|
|
if(error<epsilon){
|
|
memset(lpc+i,0,(m-i)*sizeof(*lpc));
|
|
goto done;
|
|
}
|
|
|
|
/* Sum up this iteration's reflection coefficient; note that in
|
|
Vorbis we don't save it. If anyone wants to recycle this code
|
|
and needs reflection coefficients, save the results of 'r' from
|
|
each iteration. */
|
|
|
|
for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
|
|
r/=error;
|
|
|
|
/* Update LPC coefficients and total error */
|
|
|
|
lpc[i]=r;
|
|
for(j=0;j<i/2;j++){
|
|
double tmp=lpc[j];
|
|
|
|
lpc[j]+=r*lpc[i-1-j];
|
|
lpc[i-1-j]+=r*tmp;
|
|
}
|
|
if(i&1)lpc[j]+=lpc[j]*r;
|
|
|
|
error*=1.-r*r;
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
/* slightly damp the filter */
|
|
{
|
|
double g = .99;
|
|
double damp = g;
|
|
for(j=0;j<m;j++){
|
|
lpc[j]*=damp;
|
|
damp*=g;
|
|
}
|
|
}
|
|
|
|
for(j=0;j<m;j++)lpci[j]=(float)lpc[j];
|
|
|
|
/* we need the error value to know how big an impulse to hit the
|
|
filter with later */
|
|
|
|
return error;
|
|
}
|
|
|
|
void vorbis_lpc_predict(float *coeff,float *prime,int m,
|
|
float *data,long n){
|
|
|
|
/* in: coeff[0...m-1] LPC coefficients
|
|
prime[0...m-1] initial values (allocated size of n+m-1)
|
|
out: data[0...n-1] data samples */
|
|
|
|
long i,j,o,p;
|
|
float y;
|
|
float *work=alloca(sizeof(*work)*(m+n));
|
|
|
|
if(!prime)
|
|
for(i=0;i<m;i++)
|
|
work[i]=0.f;
|
|
else
|
|
for(i=0;i<m;i++)
|
|
work[i]=prime[i];
|
|
|
|
for(i=0;i<n;i++){
|
|
y=0;
|
|
o=i;
|
|
p=m;
|
|
for(j=0;j<m;j++)
|
|
y-=work[o++]*coeff[--p];
|
|
|
|
data[i]=work[o]=y;
|
|
}
|
|
}
|