//
// png_set_filter_heuristics from 0x662948 to 0x662b9a (594 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall png_set_filter_heuristics(int a1, unsigned int a2, signed int a3, double *a4, double *a5)
{
void *v6; // r1
void *v10; // r1
void *v11; // r1
int v12; // r2
double *v13; // r3
int v14; // r0
double v15; // d7
int v16; // r1
double v17; // d7
double v18; // d7
double v19; // d7
double v20; // d7
if ( a1 )
{
v6 = *(void **)(a1 + 724);
*(_WORD *)(a1 + 720) = 1;
if ( v6 )
{
*(_DWORD *)(a1 + 724) = 0;
png_free(a1, v6);
}
v10 = *(void **)(a1 + 728);
if ( v10 )
{
*(_DWORD *)(a1 + 728) = 0;
png_free(a1, v10);
}
v11 = *(void **)(a1 + 732);
if ( v11 )
{
*(_DWORD *)(a1 + 732) = 0;
png_free(a1, v11);
}
if ( a2 == 2 )
{
if ( sub_661270(a1, a3) )
{
if ( a3 > 0 )
{
v12 = 2 * a3;
v13 = a4;
v14 = 0;
do
{
while ( 1 )
{
v15 = *v13++;
if ( v15 <= 0.0 )
break;
*(_WORD *)(*(_DWORD *)(a1 + 732) + v14) = (unsigned int)(v15 * 256.0 + 0.5);
*(_WORD *)(*(_DWORD *)(a1 + 728) + v14) = (unsigned int)(256.0 / *(v13 - 1) + 0.5);
v14 += 2;
if ( v14 == v12 )
goto LABEL_18;
}
v16 = *(_DWORD *)(a1 + 732);
*(_WORD *)(*(_DWORD *)(a1 + 728) + v14) = 256;
*(_WORD *)(v16 + v14) = 256;
v14 += 2;
}
while ( v14 != v12 );
}
LABEL_18:
if ( *a5 >= 1.0 )
{
**(_WORD **)(a1 + 740) = (unsigned int)(8.0 / *a5 + 0.5);
**(_WORD **)(a1 + 736) = (unsigned int)(*a5 * 8.0 + 0.5);
}
v17 = a5[1];
if ( v17 >= 1.0 )
{
*(_WORD *)(*(_DWORD *)(a1 + 740) + 2) = (unsigned int)(8.0 / v17 + 0.5);
*(_WORD *)(*(_DWORD *)(a1 + 736) + 2) = (unsigned int)(a5[1] * 8.0 + 0.5);
}
v18 = a5[2];
if ( v18 >= 1.0 )
{
*(_WORD *)(*(_DWORD *)(a1 + 740) + 4) = (unsigned int)(8.0 / v18 + 0.5);
*(_WORD *)(*(_DWORD *)(a1 + 736) + 4) = (unsigned int)(a5[2] * 8.0 + 0.5);
}
v19 = a5[3];
if ( v19 >= 1.0 )
{
*(_WORD *)(*(_DWORD *)(a1 + 740) + 6) = (unsigned int)(8.0 / v19 + 0.5);
*(_WORD *)(*(_DWORD *)(a1 + 736) + 6) = (unsigned int)(a5[3] * 8.0 + 0.5);
}
v20 = a5[4];
if ( v20 >= 1.0 )
{
*(_WORD *)(*(_DWORD *)(a1 + 740) + 8) = (unsigned int)(8.0 / v20 + 0.5);
*(_WORD *)(*(_DWORD *)(a1 + 736) + 8) = (unsigned int)(a5[4] * 8.0 + 0.5);
}
}
}
else if ( a2 > 1 )
{
png_warning(a1, "Unknown filter heuristic method");
}
}
}