Fixed SoftwareLimiter crash on 64 bit devices

More cleanup is due, but will suffice for now.
This commit is contained in:
Iscle 2023-03-10 22:54:33 +01:00
parent 8eed46db09
commit 952d24ba7a
2 changed files with 21 additions and 33 deletions

View File

@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 3.16.3)
set(CMAKE_CXX_COMPILER_VERSION 20) set(CMAKE_CXX_COMPILER_VERSION 20)
# NDK Settings # NDK Settings
#set(ANDROID_ABI arm64-v8a) #add_compile_definitions(ANDROID_ABI=arm64-v8a)
set(ANDROID_ABI armeabi-v7a) #add_compile_definitions(ANDROID_ABI=armeabi-v7a)
set(ANDROID_ARM_NEON true) #add_compile_definitions(ANDROID_ARM_NEON=true)
set(ANDROID_PLATFORM android-24) #add_compile_definitions(ANDROID_PLATFORM=android-24)
project("ViPER4Android") project("ViPER4Android")
add_compile_definitions(VERSION_CODE=20221231) add_compile_definitions(VERSION_CODE=20230311)
add_compile_definitions(VERSION_NAME="0.1.0") add_compile_definitions(VERSION_NAME="0.3.0")
# FFTS # FFTS
add_subdirectory(src/viper/ffts) add_subdirectory(src/viper/ffts)

View File

@ -15,59 +15,47 @@ SoftwareLimiter::SoftwareLimiter() {
float SoftwareLimiter::Process(float sample) { float SoftwareLimiter::Process(float sample) {
bool bVar1; bool bVar1;
float *pfVar2;
uint uVar3; uint uVar3;
uint uVar4; uint uVar4;
int iVar5; int iVar5;
uint uVar6; uint uVar6;
uint *puVar7;
uint uVar8; uint uVar8;
float fVar9; float fVar9;
float fVar10; float fVar10;
float gate;
float abs_sample; float abs_sample;
gate = this->gate;
abs_sample = std::abs(sample); abs_sample = std::abs(sample);
if (abs_sample < gate) { if (abs_sample < this->gate) {
if (this->ready) goto LAB_0006d86c; if (this->ready) goto LAB_0006d86c;
uVar8 = this->unknown4; uVar8 = this->unknown4;
} }
else { else {
if (!this->ready) { if (!this->ready) {
iVar5 = 0x200; memset(this->arr512, 0, sizeof(this->arr512));
pfVar2 = this->arr512;
do {
iVar5 = iVar5 + -1;
*pfVar2 = 0.0;
pfVar2 = pfVar2 + 1;
} while (iVar5 != 0);
}
this->ready = true; this->ready = true;
}
LAB_0006d86c: LAB_0006d86c:
uVar3 = 8; uVar3 = 8;
puVar7 = &this->unknown4; uVar8 = this->unknown4;
uVar8 = *puVar7;
uVar4 = uVar8; uVar4 = uVar8;
do { do {
iVar5 = 2 << (uVar3 & 0xff); iVar5 = 2 << (uVar3 & 0xff);
uVar6 = uVar4 ^ 1; uVar6 = uVar4 ^ 1;
puVar7[uVar4 - iVar5] = (uint)abs_sample; this->arr512[512 + uVar4 - iVar5] = abs_sample;
uVar4 = (int)uVar4 >> 1; uVar4 = uVar4 / 2;
if (abs_sample < (float)puVar7[uVar6 - iVar5]) { if (abs_sample < this->arr512[512 + uVar6 - iVar5]) {
abs_sample = (float)puVar7[uVar6 - iVar5]; abs_sample = this->arr512[512 + uVar6 - iVar5];
} }
uVar3 = uVar3 - 1; uVar3 = uVar3 - 1;
} while (uVar3 != 0); } while (uVar3 != 0);
gate = this->gate; if (this->gate < abs_sample) {
if (gate < abs_sample) {
bVar1 = this->ready; bVar1 = this->ready;
fVar10 = this->unknown1; fVar10 = this->unknown1;
uVar4 = uVar8 + 1 & 0xff; uVar4 = (uVar8 + 1) % 256;
this->arr256[uVar8] = sample; this->arr256[uVar8] = sample;
this->unknown4 = uVar4; this->unknown4 = uVar4;
if (bVar1) { if (bVar1) {
fVar10 = gate / abs_sample; fVar10 = this->gate / abs_sample;
} }
abs_sample = this->arr256[uVar4]; abs_sample = this->arr256[uVar4];
goto LAB_0006d8fc; goto LAB_0006d8fc;
@ -76,7 +64,7 @@ LAB_0006d86c:
} }
fVar10 = this->unknown1; fVar10 = this->unknown1;
this->arr256[uVar8] = sample; this->arr256[uVar8] = sample;
uVar8 = uVar8 + 1 & 0xff; uVar8 = (uVar8 + 1) % 256;
this->unknown4 = uVar8; this->unknown4 = uVar8;
abs_sample = this->arr256[uVar8]; abs_sample = this->arr256[uVar8];
LAB_0006d8fc: LAB_0006d8fc:
@ -95,10 +83,10 @@ LAB_0006d8fc:
} }
fVar9 = abs_sample * fVar9; fVar9 = abs_sample * fVar9;
fVar10 = std::abs(fVar9); fVar10 = std::abs(fVar9);
if (gate <= fVar10) { if (this->gate <= fVar10) {
fVar9 = gate / std::abs(abs_sample); fVar9 = this->gate / std::abs(abs_sample);
} }
if (gate <= fVar10) { if (this->gate <= fVar10) {
this->unknown2 = fVar9; this->unknown2 = fVar9;
fVar9 = abs_sample * fVar9; fVar9 = abs_sample * fVar9;
} }