Skip to content

Commit

Permalink
freeimage: fix Big-endian build
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 committed Feb 6, 2024
1 parent 5dab32d commit b67891f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
5 changes: 5 additions & 0 deletions graphics/freeimage/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ use_zip yes
worksrcdir FreeImage

patchfiles patch-c99-fixes.diff
# https://github.com/AcademySoftwareFoundation/openexr/pull/126
patchfiles-append patch-fix-ImfFastHuf.diff
# https://sourceforge.net/p/freeimage/patches/153
patchfiles-append patch-fix-PluginBMP.diff \
patch-fix-PluginDDS.diff

post-patch {
set makefiles "${worksrcpath}/Makefile.fip ${worksrcpath}/Makefile.gnu"
Expand Down
47 changes: 47 additions & 0 deletions graphics/freeimage/files/patch-fix-ImfFastHuf.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--- Source/OpenEXR/IlmImf/ImfFastHuf.cpp.orig 2017-11-18 15:00:24.000000000 +0800
+++ Source/OpenEXR/IlmImf/ImfFastHuf.cpp 2024-01-30 02:54:44.000000000 +0800
@@ -107,7 +107,7 @@
for (int i = 0; i <= MAX_CODE_LEN; ++i)
{
codeCount[i] = 0;
- base[i] = 0xffffffffffffffffL;
+ base[i] = 0xffffffffffffffffULL;
offset[i] = 0;
}

@@ -352,7 +352,7 @@

for (int i = 0; i <= MAX_CODE_LEN; ++i)
{
- if (base[i] != 0xffffffffffffffffL)
+ if (base[i] != 0xffffffffffffffffULL)
{
_ljBase[i] = base[i] << (64 - i);
}
@@ -362,7 +362,7 @@
// Unused code length - insert dummy values
//

- _ljBase[i] = 0xffffffffffffffffL;
+ _ljBase[i] = 0xffffffffffffffffULL;
}
}

@@ -417,7 +417,7 @@

int minIdx = TABLE_LOOKUP_BITS;

- while (minIdx > 0 && _ljBase[minIdx] == 0xffffffffffffffffL)
+ while (minIdx > 0 && _ljBase[minIdx] == 0xffffffffffffffffULL)
minIdx--;

if (minIdx < 0)
@@ -427,7 +427,7 @@
// Set the min value such that the table is never tested.
//

- _tableMin = 0xffffffffffffffffL;
+ _tableMin = 0xffffffffffffffffULL;
}
else
{
29 changes: 29 additions & 0 deletions graphics/freeimage/files/patch-fix-PluginBMP.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- Source/FreeImage/PluginBMP.cpp.orig 2016-06-15 12:35:30.000000000 +0800
+++ Source/FreeImage/PluginBMP.cpp 2024-01-30 02:26:59.000000000 +0800
@@ -1419,7 +1419,7 @@

free(buffer);
#ifdef FREEIMAGE_BIGENDIAN
- } else if (bpp == 16) {
+ } else if (dst_bpp == 16) {
int padding = dst_pitch - dst_width * sizeof(WORD);
WORD pad = 0;
WORD pixel;
@@ -1440,7 +1440,7 @@
}
#endif
#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB
- } else if (bpp == 24) {
+ } else if (dst_bpp == 24) {
int padding = dst_pitch - dst_width * sizeof(FILE_BGR);
DWORD pad = 0;
FILE_BGR bgr;
@@ -1461,7 +1461,7 @@
}
}
}
- } else if (bpp == 32) {
+ } else if (dst_bpp == 32) {
FILE_BGRA bgra;
for(unsigned y = 0; y < dst_height; y++) {
BYTE *line = FreeImage_GetScanLine(dib, y);
25 changes: 25 additions & 0 deletions graphics/freeimage/files/patch-fix-PluginDDS.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- Source/FreeImage/PluginDDS.cpp.orig 2018-07-31 17:04:58.000000000 +0800
+++ Source/FreeImage/PluginDDS.cpp 2024-01-30 02:43:14.000000000 +0800
@@ -356,14 +356,14 @@
for(int i=0; i<11; i++) {
SwapLong(&header->surfaceDesc.dwReserved1[i]);
}
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwSize);
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwFlags);
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwFourCC);
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwRGBBitCount);
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwRBitMask);
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwGBitMask);
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwBBitMask);
- SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwRGBAlphaBitMask);
+ SwapLong(&header->surfaceDesc.ddspf.dwSize);
+ SwapLong(&header->surfaceDesc.ddspf.dwFlags);
+ SwapLong(&header->surfaceDesc.ddspf.dwFourCC);
+ SwapLong(&header->surfaceDesc.ddspf.dwRGBBitCount);
+ SwapLong(&header->surfaceDesc.ddspf.dwRBitMask);
+ SwapLong(&header->surfaceDesc.ddspf.dwGBitMask);
+ SwapLong(&header->surfaceDesc.ddspf.dwBBitMask);
+ SwapLong(&header->surfaceDesc.ddspf.dwRGBAlphaBitMask);
SwapLong(&header->surfaceDesc.ddsCaps.dwCaps1);
SwapLong(&header->surfaceDesc.ddsCaps.dwCaps2);
SwapLong(&header->surfaceDesc.ddsCaps.dwReserved[0]);

0 comments on commit b67891f

Please sign in to comment.