//
// sub_E78FF4 from 0xe78ff4 to 0xe79118 (292 bytes)
//
// 2 xrefs:
// > jinit_downsampler @ 0xe79728
// > jinit_downsampler @ 0xe7974c
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:10:41 +0000
//
unsigned __int64 __fastcall sub_E78FF4(__int64 a1, __int64 a2, unsigned __int8 **a3, __int64 *a4)
{
unsigned int v6; // w2
unsigned int v7; // w20
unsigned __int64 result; // x0
int v10; // w24
__int64 v11; // x26
__int64 v12; // x23
size_t v13; // x25
unsigned __int8 *v14; // x0
__int64 *v15; // x10
unsigned __int8 **v16; // x9
int i; // w11
__int64 v18; // x8
unsigned __int8 *v19; // x3
unsigned __int8 *v20; // x2
__int64 v21; // x4
int v22; // w6
int v23; // w7
int v24; // w0
int v25; // w0
v6 = *(_DWORD *)(a1 + 48);
v7 = *(_DWORD *)(a2 + 36) * *(_DWORD *)(a2 + 28);
result = 2 * v7 - v6;
v10 = *(_DWORD *)(a1 + 356);
if ( (int)(2 * v7 - v6) > 0 )
{
if ( v10 <= 0 )
return result;
v11 = v6;
v12 = 0;
v13 = (int)result - 1 + 1LL;
do
{
v14 = a3[v12++];
result = (unsigned __int64)memset(&v14[v11], v14[v11 - 1], v13);
}
while ( v10 > (int)v12 );
v10 = *(_DWORD *)(a1 + 356);
}
if ( v10 > 0 )
{
v15 = a4;
v16 = a3;
for ( i = 0; i < v10; i += 2 )
{
v18 = *v15;
v19 = *v16;
v20 = v16[1];
if ( v7 )
{
v21 = 0;
v22 = 1;
do
{
v20 += 2;
v23 = *v19;
v24 = v19[1];
v19 += 2;
v25 = v23 + v24 + *(v20 - 2) + *(v20 - 1) + v22;
v22 ^= 3u;
result = (unsigned int)(v25 >> 2);
*(_BYTE *)(v18 + v21++) = result;
}
while ( v7 > (unsigned int)v21 );
v10 = *(_DWORD *)(a1 + 356);
}
++v15;
v16 += 2;
}
}
return result;
}