//
// sub_ECBFEC from 0xecbfec to 0xecc314 (808 bytes)
//
// 1 xrefs:
// > TIFFInitSGILog @ 0xecd824
//
// 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:11:38 +0000
//
__int64 __fastcall sub_ECBFEC(__int64 a1)
{
__int64 v1; // x20
int v2; // w3
__int64 v4; // x21
int v5; // w1
const char *v6; // x3
int v8; // w0
__int64 v9; // x1
__int64 v10; // x3
__int64 v11; // x0
__int64 v12; // x1
void *v13; // x0
int v14; // w1
int v15; // w1
v1 = a1 + 56;
v2 = *(unsigned __int16 *)(a1 + 122);
v4 = *(_QWORD *)(a1 + 848);
if ( v2 == 32844 )
{
v8 = *(_DWORD *)v4;
if ( *(_DWORD *)v4 != -1 )
goto LABEL_14;
v15 = (8 * *(unsigned __int16 *)(a1 + 130))
| (*(unsigned __int16 *)(a1 + 116) << 6)
| *(unsigned __int16 *)(a1 + 118);
if ( v15 > 1034 )
{
if ( v15 != 1036 )
{
if ( v15 == 2059 )
v8 = 0;
else
v8 = -1;
*(_DWORD *)v4 = v8;
goto LABEL_14;
}
}
else if ( v15 < 1033 )
{
if ( v15 == 521 || v15 == 524 )
v8 = 3;
*(_DWORD *)v4 = v8;
LABEL_14:
if ( v8 == 1 )
{
*(_DWORD *)(v4 + 8) = 2;
}
else if ( v8 == 3 )
{
*(_DWORD *)(v4 + 8) = 1;
}
else
{
if ( v8 )
{
TIFFErrorExt(
*(_QWORD *)(a1 + 952),
(__int64)"LogL16InitState",
"No support for converting user data format to LogL");
return 1;
}
*(_DWORD *)(v4 + 8) = 4;
}
if ( (*(_DWORD *)(a1 + 16) & 0x400) != 0 )
{
v9 = *(unsigned int *)(v1 + 44);
v10 = *(unsigned int *)(v1 + 48);
v11 = v9 * v10;
if ( !*(_DWORD *)(v1 + 44) )
goto LABEL_31;
}
else
{
v9 = *(unsigned int *)(v1 + 32);
v10 = *(unsigned int *)(v1 + 76);
v11 = v9 * v10;
if ( !*(_DWORD *)(v1 + 32) )
goto LABEL_31;
}
if ( v10 != v11 / v9 )
{
v11 = 0;
*(_QWORD *)(v4 + 24) = 0;
v12 = 0;
LABEL_32:
if ( v12 )
{
v13 = TIFFmalloc(2 * v11);
*(_QWORD *)(v4 + 16) = v13;
if ( v13 )
{
v14 = *(_DWORD *)v4;
*(_QWORD *)(a1 + 768) = sub_ECAC80;
if ( v14 )
{
if ( v14 != 1 )
goto LABEL_8;
}
else
{
*(_QWORD *)(v4 + 32) = sub_ECC910;
}
return 1;
}
}
LABEL_25:
TIFFErrorExt(*(_QWORD *)(a1 + 952), (__int64)"LogL16InitState", "No space for SGILog translation buffer");
return 1;
}
LABEL_31:
*(_QWORD *)(v4 + 24) = v11;
v12 = 2 * v11;
if ( v11 && v12 / v11 != 2 )
goto LABEL_25;
goto LABEL_32;
}
v8 = 1;
*(_DWORD *)v4 = 1;
goto LABEL_14;
}
if ( v2 != 32845 )
{
TIFFErrorExt(
*(_QWORD *)(a1 + 952),
(__int64)"LogLuvSetupEncode",
"Inappropriate photometric interpretation %d for SGILog compression; %s",
v2,
"must be either LogLUV or LogL");
return 1;
}
if ( !(unsigned int)sub_ECBDC4(a1) )
return 1;
v5 = *(_DWORD *)v4;
if ( *(unsigned __int16 *)(v1 + 64) == 34677 )
{
*(_QWORD *)(a1 + 768) = sub_ECBCC8;
if ( v5 == 1 )
{
*(_QWORD *)(v4 + 32) = sub_ECCDB8;
return 1;
}
if ( v5 == 2 )
return 1;
if ( v5 )
goto LABEL_8;
*(_QWORD *)(v4 + 32) = sub_ECD3A0;
return 1;
}
*(_QWORD *)(a1 + 768) = sub_ECB4FC;
switch ( v5 )
{
case 1:
*(_QWORD *)(v4 + 32) = sub_EC9D20;
return 1;
case 2:
return 1;
case 0:
*(_QWORD *)(v4 + 32) = sub_ECD720;
return 1;
}
LABEL_8:
if ( *(unsigned __int16 *)(v1 + 66) == 32844 )
v6 = "Y, L";
else
v6 = "XYZ, Luv";
TIFFErrorExt(
*(_QWORD *)(a1 + 952),
(__int64)"LogLuvSetupEncode",
"SGILog compression supported only for %s, or raw data",
v6);
return 0;
}