mirror of
https://github.com/Q3Rally-Team/q3rally.git
synced 2024-11-29 23:22:55 +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
242 lines
7.6 KiB
C
242 lines
7.6 KiB
C
/* Copyright (c) 2007-2008 CSIRO
|
|
Copyright (c) 2007-2009 Xiph.Org Foundation
|
|
Copyright (c) 2008 Gregory Maxwell
|
|
Written by Jean-Marc Valin and Gregory Maxwell */
|
|
/**
|
|
@file celt.h
|
|
@brief Contains all the functions for encoding and decoding audio
|
|
*/
|
|
|
|
/*
|
|
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.
|
|
|
|
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.
|
|
*/
|
|
|
|
#ifndef CELT_H
|
|
#define CELT_H
|
|
|
|
#include "opus_types.h"
|
|
#include "opus_defines.h"
|
|
#include "opus_custom.h"
|
|
#include "entenc.h"
|
|
#include "entdec.h"
|
|
#include "arch.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define CELTEncoder OpusCustomEncoder
|
|
#define CELTDecoder OpusCustomDecoder
|
|
#define CELTMode OpusCustomMode
|
|
|
|
#define LEAK_BANDS 19
|
|
|
|
typedef struct {
|
|
int valid;
|
|
float tonality;
|
|
float tonality_slope;
|
|
float noisiness;
|
|
float activity;
|
|
float music_prob;
|
|
float vad_prob;
|
|
int bandwidth;
|
|
float activity_probability;
|
|
/* Store as Q6 char to save space. */
|
|
unsigned char leak_boost[LEAK_BANDS];
|
|
} AnalysisInfo;
|
|
|
|
typedef struct {
|
|
int signalType;
|
|
int offset;
|
|
} SILKInfo;
|
|
|
|
#define __celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)))
|
|
|
|
#define __celt_check_analysis_ptr(ptr) ((ptr) + ((ptr) - (const AnalysisInfo*)(ptr)))
|
|
|
|
#define __celt_check_silkinfo_ptr(ptr) ((ptr) + ((ptr) - (const SILKInfo*)(ptr)))
|
|
|
|
/* Encoder/decoder Requests */
|
|
|
|
|
|
#define CELT_SET_PREDICTION_REQUEST 10002
|
|
/** Controls the use of interframe prediction.
|
|
0=Independent frames
|
|
1=Short term interframe prediction allowed
|
|
2=Long term prediction allowed
|
|
*/
|
|
#define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, __opus_check_int(x)
|
|
|
|
#define CELT_SET_INPUT_CLIPPING_REQUEST 10004
|
|
#define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_check_int(x)
|
|
|
|
#define CELT_GET_AND_CLEAR_ERROR_REQUEST 10007
|
|
#define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, __opus_check_int_ptr(x)
|
|
|
|
#define CELT_SET_CHANNELS_REQUEST 10008
|
|
#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, __opus_check_int(x)
|
|
|
|
|
|
/* Internal */
|
|
#define CELT_SET_START_BAND_REQUEST 10010
|
|
#define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, __opus_check_int(x)
|
|
|
|
#define CELT_SET_END_BAND_REQUEST 10012
|
|
#define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, __opus_check_int(x)
|
|
|
|
#define CELT_GET_MODE_REQUEST 10015
|
|
/** Get the CELTMode used by an encoder or decoder */
|
|
#define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, __celt_check_mode_ptr_ptr(x)
|
|
|
|
#define CELT_SET_SIGNALLING_REQUEST 10016
|
|
#define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, __opus_check_int(x)
|
|
|
|
#define CELT_SET_TONALITY_REQUEST 10018
|
|
#define CELT_SET_TONALITY(x) CELT_SET_TONALITY_REQUEST, __opus_check_int(x)
|
|
#define CELT_SET_TONALITY_SLOPE_REQUEST 10020
|
|
#define CELT_SET_TONALITY_SLOPE(x) CELT_SET_TONALITY_SLOPE_REQUEST, __opus_check_int(x)
|
|
|
|
#define CELT_SET_ANALYSIS_REQUEST 10022
|
|
#define CELT_SET_ANALYSIS(x) CELT_SET_ANALYSIS_REQUEST, __celt_check_analysis_ptr(x)
|
|
|
|
#define OPUS_SET_LFE_REQUEST 10024
|
|
#define OPUS_SET_LFE(x) OPUS_SET_LFE_REQUEST, __opus_check_int(x)
|
|
|
|
#define OPUS_SET_ENERGY_MASK_REQUEST 10026
|
|
#define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16_ptr(x)
|
|
|
|
#define CELT_SET_SILK_INFO_REQUEST 10028
|
|
#define CELT_SET_SILK_INFO(x) CELT_SET_SILK_INFO_REQUEST, __celt_check_silkinfo_ptr(x)
|
|
|
|
/* Encoder stuff */
|
|
|
|
int celt_encoder_get_size(int channels);
|
|
|
|
int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);
|
|
|
|
int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels,
|
|
int arch);
|
|
|
|
|
|
|
|
/* Decoder stuff */
|
|
|
|
int celt_decoder_get_size(int channels);
|
|
|
|
|
|
int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels);
|
|
|
|
int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data,
|
|
int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum);
|
|
|
|
#define celt_encoder_ctl opus_custom_encoder_ctl
|
|
#define celt_decoder_ctl opus_custom_decoder_ctl
|
|
|
|
|
|
#ifdef CUSTOM_MODES
|
|
#define OPUS_CUSTOM_NOSTATIC
|
|
#else
|
|
#define OPUS_CUSTOM_NOSTATIC static OPUS_INLINE
|
|
#endif
|
|
|
|
static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0};
|
|
/* Probs: NONE: 21.875%, LIGHT: 6.25%, NORMAL: 65.625%, AGGRESSIVE: 6.25% */
|
|
static const unsigned char spread_icdf[4] = {25, 23, 2, 0};
|
|
|
|
static const unsigned char tapset_icdf[3]={2,1,0};
|
|
|
|
#ifdef CUSTOM_MODES
|
|
static const unsigned char toOpusTable[20] = {
|
|
0xE0, 0xE8, 0xF0, 0xF8,
|
|
0xC0, 0xC8, 0xD0, 0xD8,
|
|
0xA0, 0xA8, 0xB0, 0xB8,
|
|
0x00, 0x00, 0x00, 0x00,
|
|
0x80, 0x88, 0x90, 0x98,
|
|
};
|
|
|
|
static const unsigned char fromOpusTable[16] = {
|
|
0x80, 0x88, 0x90, 0x98,
|
|
0x40, 0x48, 0x50, 0x58,
|
|
0x20, 0x28, 0x30, 0x38,
|
|
0x00, 0x08, 0x10, 0x18
|
|
};
|
|
|
|
static OPUS_INLINE int toOpus(unsigned char c)
|
|
{
|
|
int ret=0;
|
|
if (c<0xA0)
|
|
ret = toOpusTable[c>>3];
|
|
if (ret == 0)
|
|
return -1;
|
|
else
|
|
return ret|(c&0x7);
|
|
}
|
|
|
|
static OPUS_INLINE int fromOpus(unsigned char c)
|
|
{
|
|
if (c<0x80)
|
|
return -1;
|
|
else
|
|
return fromOpusTable[(c>>3)-16] | (c&0x7);
|
|
}
|
|
#endif /* CUSTOM_MODES */
|
|
|
|
#define COMBFILTER_MAXPERIOD 1024
|
|
#define COMBFILTER_MINPERIOD 15
|
|
|
|
extern const signed char tf_select_table[4][8];
|
|
|
|
int resampling_factor(opus_int32 rate);
|
|
|
|
void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp,
|
|
int N, int CC, int upsample, const opus_val16 *coef, celt_sig *mem, int clip);
|
|
|
|
void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
|
|
opus_val16 g0, opus_val16 g1, int tapset0, int tapset1,
|
|
const opus_val16 *window, int overlap, int arch);
|
|
|
|
#ifdef NON_STATIC_COMB_FILTER_CONST_C
|
|
void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N,
|
|
opus_val16 g10, opus_val16 g11, opus_val16 g12);
|
|
#endif
|
|
|
|
#ifndef OVERRIDE_COMB_FILTER_CONST
|
|
# define comb_filter_const(y, x, T, N, g10, g11, g12, arch) \
|
|
((void)(arch),comb_filter_const_c(y, x, T, N, g10, g11, g12))
|
|
#endif
|
|
|
|
void init_caps(const CELTMode *m,int *cap,int LM,int C);
|
|
|
|
#ifdef RESYNTH
|
|
void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem);
|
|
void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[],
|
|
opus_val16 *oldBandE, int start, int effEnd, int C, int CC, int isTransient,
|
|
int LM, int downsample, int silence);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* CELT_H */
|