//
// sub_6E47B8 from 0x6e47b8 to 0x6e49dc (548 bytes)
//
// 3 xrefs:
// > TIFFInitPixarLog @ 0x6e7a04
// > TIFFInitPixarLog @ 0x6e7a08
// > ??> @ 0x6e7b5c
//
// 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
//
int __fastcall sub_6E47B8(int a1)
{
__int16 v1; // r3
int v2; // r0
int v3; // r0
int v7; // [sp+Ch] [bp-10h]
int v8; // [sp+10h] [bp-Ch]
int v9; // [sp+14h] [bp-8h]
v7 = a1 + 40;
v8 = *(_DWORD *)(a1 + 576);
if ( !v8 )
_assert2();
if ( *(_WORD *)(v7 + 86) == 1 )
v1 = *(_WORD *)(v7 + 58);
else
v1 = 1;
*(_WORD *)(v8 + 124) = v1;
v2 = sub_6E3DCC(*(unsigned __int16 *)(v8 + 124), *(_DWORD *)(v7 + 16));
v3 = sub_6E3DCC(v2, *(_DWORD *)(v7 + 60));
v9 = sub_6E3DCC(v3, 2);
if ( !v9 )
return 0;
*(_DWORD *)(v8 + 120) = TIFFmalloc(v9);
if ( !*(_DWORD *)(v8 + 120) )
return 0;
if ( *(_DWORD *)(v8 + 132) == -1 )
*(_DWORD *)(v8 + 132) = sub_6E3C54(v7);
if ( *(_DWORD *)(v8 + 132) == -1 )
{
TIFFErrorExt(
*(_DWORD *)(a1 + 628),
(int)"PixarLogSetupEncode",
"PixarLog compression can't handle %d bit linear encodings",
*(unsigned __int16 *)(v7 + 44));
return 0;
}
else if ( j_deflateInit_(v8 + 64, *(_DWORD *)(v8 + 136), "1.2.3", 56) )
{
TIFFErrorExt(*(_DWORD *)(a1 + 628), (int)"PixarLogSetupEncode", "%s", *(const char **)(v8 + 88));
return 0;
}
else
{
*(_DWORD *)(v8 + 128) |= 1u;
return 1;
}
}