aboutsummaryrefslogtreecommitdiff
path: root/community/kodi
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2017-05-03 20:21:40 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2017-05-03 20:21:40 +0000
commitd1ca8bf0a308b7b090c9c0acaa7376234379e9c1 (patch)
tree0ac8df8e9e820901d076eaebbff3c9ac2a7fa8e7 /community/kodi
parent2075d342094d6e7db71f37f32eb6f94e3418f87e (diff)
downloadalpine_aports-d1ca8bf0a308b7b090c9c0acaa7376234379e9c1.tar.bz2
alpine_aports-d1ca8bf0a308b7b090c9c0acaa7376234379e9c1.tar.xz
alpine_aports-d1ca8bf0a308b7b090c9c0acaa7376234379e9c1.zip
community/kodi: upgrade to 17.1
Diffstat (limited to 'community/kodi')
-rw-r--r--community/kodi/APKBUILD38
-rw-r--r--community/kodi/fix-fileemu.patch256
-rw-r--r--community/kodi/fix-musl.patch48
-rw-r--r--community/kodi/gcc6-fix.patch1434
-rw-r--r--community/kodi/remove-filewrap.patch18
5 files changed, 175 insertions, 1619 deletions
diff --git a/community/kodi/APKBUILD b/community/kodi/APKBUILD
index aec2d6e5e2..7f1361be21 100644
--- a/community/kodi/APKBUILD
+++ b/community/kodi/APKBUILD
@@ -1,9 +1,9 @@
1# Contributor: Carlo Landmeter <clandmeter@gmail.com> 1# Contributor: Carlo Landmeter <clandmeter@gmail.com>
2# Maintainer: Natanael Copa <ncopa@alpinelinux.org> 2# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
3pkgname=kodi 3pkgname=kodi
4pkgver=16.1 4pkgver=17.1
5_realname=Jarvis 5_realname=Krypton
6pkgrel=3 6pkgrel=0
7pkgdesc="A software media player and entertainment hub for digital media" 7pkgdesc="A software media player and entertainment hub for digital media"
8url="http://kodi.tv" 8url="http://kodi.tv"
9arch="x86 x86_64" 9arch="x86 x86_64"
@@ -19,8 +19,9 @@ depends_dev="gettext-dev boost-dev mesa-dev glew-dev glu-dev mariadb-dev
19 libxt-dev libxmu-dev samba-dev gawk libssh-dev libva-dev libnfs-dev 19 libxt-dev libxmu-dev samba-dev gawk libssh-dev libva-dev libnfs-dev
20 yasm-dev libmpeg2-dev libmad-dev libsamplerate-dev rtmpdump-dev 20 yasm-dev libmpeg2-dev libmad-dev libsamplerate-dev rtmpdump-dev
21 libjpeg-turbo-dev eudev-dev libcap-dev udisks2-dev faac-dev gnutls-dev 21 libjpeg-turbo-dev eudev-dev libcap-dev udisks2-dev faac-dev gnutls-dev
22 libxslt-dev libplist-dev libshairport-dev ffmpeg2.8-dev afpfs-ng-dev 22 libxslt-dev libplist-dev libshairport-dev ffmpeg-dev afpfs-ng-dev
23 libcec-dev x264-dev bsd-compat-headers curl-dev python2-dev dcadec-dev" 23 libcec-dev x264-dev bsd-compat-headers curl-dev python2-dev dcadec-dev
24 libdvdcss-dev"
24makedepends="$depends_dev automake autoconf m4 libtool swig findutils 25makedepends="$depends_dev automake autoconf m4 libtool swig findutils
25 openjdk8-jre-base boost-thread zip gperf cmake coreutils nasm tar 26 openjdk8-jre-base boost-thread zip gperf cmake coreutils nasm tar
26 git" 27 git"
@@ -29,7 +30,6 @@ install=""
29replaces="xbmc" 30replaces="xbmc"
30options="ldpath-recursive" 31options="ldpath-recursive"
31source="https://github.com/xbmc/xbmc/archive/$pkgver-$_realname.tar.gz 32source="https://github.com/xbmc/xbmc/archive/$pkgver-$_realname.tar.gz
32 gcc6-fix.patch
33 fix-musl.patch 33 fix-musl.patch
34 fix-fileemu.patch 34 fix-fileemu.patch
35 fortify-source-fix.patch 35 fortify-source-fix.patch
@@ -70,6 +70,7 @@ build() {
70 --with-ffmpeg=shared \ 70 --with-ffmpeg=shared \
71 --enable-static=no \ 71 --enable-static=no \
72 --enable-libbluray \ 72 --enable-libbluray \
73 --enable-external-libraries \
73 || return 1 74 || return 1
74 make || return 1 75 make || return 1
75} 76}
@@ -79,27 +80,10 @@ package() {
79 make DESTDIR="$pkgdir" install || return 1 80 make DESTDIR="$pkgdir" install || return 1
80} 81}
81 82
82md5sums="79358ad5f77f42c5498a9412d5a78dd5 16.1-Jarvis.tar.gz 83sha512sums="5093fe7dcdf22e2604ea93696c909028c00a8b0c858e7b25f55dade6c3423b4a68f5a49a8a0dd5238b10f4a7dd5e815a82251949ce7adb8a8f8cf5d58fc7bd41 17.1-Krypton.tar.gz
83f723a234a2a341ad3d20777c24a0d28a gcc6-fix.patch 84f225073ca75647581463094c0a9d1dd1fa3e1a58353292e1c99da30eb6f97026f4647853da2bbdc7777c6c1b13a16b368b09c93f5d4c1be13f8a11b4bbfbabbf fix-musl.patch
8495651684aaabac248e30203980b6acf2 fix-musl.patch 857dea044f77d9a38a4bccc9d542ba62d0146f2bf60f92999ddada1a4fc020b88e054c7f047ba9b8b21639889b31c3f117308f38aa50fab759f941cc014cb0e69d fix-fileemu.patch
8569049c53ffc4a403ccff3bba77e47793 fix-fileemu.patch
86a769a0018f58cb4f5ea865dcabbe2bed fortify-source-fix.patch
87cb116c5b55438222db308d4b6b7bc6ff remove-filewrap.patch
88ed12b2515c259c87ea622e04df78dfe5 add-missing-includes.patch
89deff09ba18d3bc4674d1c195a40ea399 set-default-stacksize.patch"
90sha256sums="7d82c8aff2715c83deecdf10c566e26105bec0473af530a1356d4c747ebdfd10 16.1-Jarvis.tar.gz
910d4946220a64ab33efb1ec5c097976d0cb32844f90ba373eb9cfe933886b33d9 gcc6-fix.patch
92c2da00fd415eb4b3d1146c3534aa4f36f68a21bd0efae41b2a36e717efec8ae8 fix-musl.patch
93cd566ae87c0ecc3e7cbeee9d80b042ae937d4f243413293616bd31f24efffec7 fix-fileemu.patch
94b5b6636e77dc11bd3a78d811e60cd98b6929e018b8f32ae2ee100a00e5535bea fortify-source-fix.patch
9511f537c6d5a2089053c80600b4dc1d6530faaee2141eba1a7eb0b941385ba9f1 remove-filewrap.patch
960ea70141b3b80ac586e941c97806f819b562f1d5166d0fe045e28dff0b62d739 add-missing-includes.patch
97212cb3d9861b2b57d9929c2046917c5789d4bacf7849ec3f7c5a4740693349b2 set-default-stacksize.patch"
98sha512sums="fe7012ea899906d418faa19af5066e5976d092745e91030106ea4f75399ad67a4bb4e4f384605ab7b2d9e24174aab2e243531f31d79ff5ae33564361b25eb073 16.1-Jarvis.tar.gz
992b76f26088bf87ea1a904aa685e08e1ed271e7f272e3994be852c6d2ce23348ce5dfa9023d09f3f2b20e3719f426f7b4b26a824d9026352a7d1f57e5bf9f249d gcc6-fix.patch
1003f3c5183f1b3181e60867d3749633e5e2bb435daf6dfd89c365ed40eea9d8f6d0af8e0d0599553a23a235b889eb3d8882872b38159edcfdfa40aa93d9f6b3fd6 fix-musl.patch
101d2c284a7156a842e23a1089053cb28af1a825fddbeb5b5e8d4a8f2d8b37a7861a7082529e603cfe56eb2c7fd35c4ce1aa7e9f224690ab42689c9886d60dafbc7 fix-fileemu.patch
1025e972e6f6ad13f5dc8ac5e9d593171988e0cc93879178aa7621af44d41b89b5b86429af4d0c2e6516b626d042f247bcf0b1f957f647138a03ce73c5c7b3311b9 fortify-source-fix.patch 865e972e6f6ad13f5dc8ac5e9d593171988e0cc93879178aa7621af44d41b89b5b86429af4d0c2e6516b626d042f247bcf0b1f957f647138a03ce73c5c7b3311b9 fortify-source-fix.patch
103cdac558134441633a83a346c2d5f5d69a1dea10276d5a46d18433d5c94937528610a662749db0909685e6bf42277e1318726409b572390f3b8ebea61209ee5c9 remove-filewrap.patch 87118a4e10ac5abdd9b6cfc87ad1b91cf03b3641023337571250beb5125c2c830e678eced1e42703253d66af61ec9fe3ce6c44cf7c0012d457f9bebc0ddfe992d2 remove-filewrap.patch
104378a0e8fd9676dd76cfb30d62085b953625dd0185e2673de2331fc7ae0802dae4f56d0b74e878e4d313942fda8831e9669bff284dbe974db5ad16fe07af884d6 add-missing-includes.patch 88378a0e8fd9676dd76cfb30d62085b953625dd0185e2673de2331fc7ae0802dae4f56d0b74e878e4d313942fda8831e9669bff284dbe974db5ad16fe07af884d6 add-missing-includes.patch
1053fd97e9fa22e59b3cd30fdad19474e177a9d062598765fa8ba4955f1da4e10581ff1463dd0794d3ee3cefebf753007a4d445b2bc47a257574d3927c1408b8876 set-default-stacksize.patch" 893fd97e9fa22e59b3cd30fdad19474e177a9d062598765fa8ba4955f1da4e10581ff1463dd0794d3ee3cefebf753007a4d445b2bc47a257574d3927c1408b8876 set-default-stacksize.patch"
diff --git a/community/kodi/fix-fileemu.patch b/community/kodi/fix-fileemu.patch
index 59d0045ac1..79ecdca772 100644
--- a/community/kodi/fix-fileemu.patch
+++ b/community/kodi/fix-fileemu.patch
@@ -1,16 +1,16 @@
1diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp 1diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
2index ae7ccb5..d8fd7fc 100644 2index ab14942..cf9d73d 100644
3--- a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp 3--- a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
4+++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp 4+++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
5@@ -49,6 +49,7 @@ 5@@ -51,6 +51,7 @@
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <time.h> 7 #include <time.h>
8 #include <signal.h> 8 #include <signal.h>
9+#include <paths.h> 9+#include <paths.h>
10 #ifdef TARGET_POSIX 10 #ifdef TARGET_POSIX
11 #include "PlatformDefs.h" // for __stat64 11 #include "PlatformDefs.h" // for __stat64
12 #endif 12 #include "XFileUtils.h"
13@@ -466,13 +467,10 @@ extern "C" 13@@ -476,13 +477,10 @@ extern "C"
14 EmuFileObject* o = g_emuFileWrapper.GetFileObjectByDescriptor(fd); 14 EmuFileObject* o = g_emuFileWrapper.GetFileObjectByDescriptor(fd);
15 if (o) 15 if (o)
16 { 16 {
@@ -25,7 +25,7 @@ index ae7ccb5..d8fd7fc 100644
25 } 25 }
26 else if (!IS_STD_DESCRIPTOR(fd)) 26 else if (!IS_STD_DESCRIPTOR(fd))
27 { 27 {
28@@ -535,7 +533,7 @@ extern "C" 28@@ -545,7 +543,7 @@ extern "C"
29 return -1; 29 return -1;
30 } 30 }
31 object->mode = iMode; 31 object->mode = iMode;
@@ -34,7 +34,7 @@ index ae7ccb5..d8fd7fc 100644
34 } 34 }
35 delete pFile; 35 delete pFile;
36 return -1; 36 return -1;
37@@ -1181,8 +1179,8 @@ extern "C" 37@@ -1214,8 +1212,8 @@ extern "C"
38 { 38 {
39 FILE* file = NULL; 39 FILE* file = NULL;
40 #if defined(TARGET_LINUX) && !defined(TARGET_ANDROID) 40 #if defined(TARGET_LINUX) && !defined(TARGET_ANDROID)
@@ -45,7 +45,7 @@ index ae7ccb5..d8fd7fc 100644
45 { 45 {
46 CLog::Log(LOGINFO, "%s - something opened the mount file, let's hope it knows what it's doing", __FUNCTION__); 46 CLog::Log(LOGINFO, "%s - something opened the mount file, let's hope it knows what it's doing", __FUNCTION__);
47 return fopen(filename, mode); 47 return fopen(filename, mode);
48@@ -1572,7 +1570,7 @@ extern "C" 48@@ -1622,7 +1620,7 @@ extern "C"
49 int ret; 49 int ret;
50 50
51 ret = dll_fgetpos64(stream, &tmpPos); 51 ret = dll_fgetpos64(stream, &tmpPos);
@@ -54,7 +54,7 @@ index ae7ccb5..d8fd7fc 100644
54 *pos = (fpos_t)tmpPos; 54 *pos = (fpos_t)tmpPos;
55 #else 55 #else
56 pos->__pos = (off_t)tmpPos.__pos; 56 pos->__pos = (off_t)tmpPos.__pos;
57@@ -1585,8 +1583,9 @@ extern "C" 57@@ -1635,8 +1633,9 @@ extern "C"
58 CFile* pFile = g_emuFileWrapper.GetFileXbmcByStream(stream); 58 CFile* pFile = g_emuFileWrapper.GetFileXbmcByStream(stream);
59 if (pFile != NULL) 59 if (pFile != NULL)
60 { 60 {
@@ -66,7 +66,7 @@ index ae7ccb5..d8fd7fc 100644
66 #else 66 #else
67 pos->__pos = pFile->GetPosition(); 67 pos->__pos = pFile->GetPosition();
68 #endif 68 #endif
69@@ -1607,8 +1606,9 @@ extern "C" 69@@ -1657,8 +1656,9 @@ extern "C"
70 int fd = g_emuFileWrapper.GetDescriptorByStream(stream); 70 int fd = g_emuFileWrapper.GetDescriptorByStream(stream);
71 if (fd >= 0) 71 if (fd >= 0)
72 { 72 {
@@ -78,7 +78,7 @@ index ae7ccb5..d8fd7fc 100644
78 #else 78 #else
79 if (dll_lseeki64(fd, (__off64_t)pos->__pos, SEEK_SET) >= 0) 79 if (dll_lseeki64(fd, (__off64_t)pos->__pos, SEEK_SET) >= 0)
80 #endif 80 #endif
81@@ -1624,7 +1624,7 @@ extern "C" 81@@ -1674,7 +1674,7 @@ extern "C"
82 { 82 {
83 // it might be something else than a file, or the file is not emulated 83 // it might be something else than a file, or the file is not emulated
84 // let the operating system handle it 84 // let the operating system handle it
@@ -87,7 +87,7 @@ index ae7ccb5..d8fd7fc 100644
87 return fsetpos(stream, pos); 87 return fsetpos(stream, pos);
88 #else 88 #else
89 return fsetpos64(stream, pos); 89 return fsetpos64(stream, pos);
90@@ -1640,7 +1640,7 @@ extern "C" 90@@ -1690,7 +1690,7 @@ extern "C"
91 if (fd >= 0) 91 if (fd >= 0)
92 { 92 {
93 fpos64_t tmpPos; 93 fpos64_t tmpPos;
@@ -97,10 +97,10 @@ index ae7ccb5..d8fd7fc 100644
97 #else 97 #else
98 tmpPos.__pos = (off64_t)(pos->__pos); 98 tmpPos.__pos = (off64_t)(pos->__pos);
99diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.h b/xbmc/cores/DllLoader/exports/emu_msvcrt.h 99diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.h b/xbmc/cores/DllLoader/exports/emu_msvcrt.h
100index ae9b1c4..3b19122 100644 100index 3294d9a..3ce8b24 100644
101--- a/xbmc/cores/DllLoader/exports/emu_msvcrt.h 101--- a/xbmc/cores/DllLoader/exports/emu_msvcrt.h
102+++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.h 102+++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.h
103@@ -26,7 +26,7 @@ 103@@ -24,7 +24,7 @@
104 #define _onexit_t void* 104 #define _onexit_t void*
105 #endif 105 #endif
106 106
@@ -110,10 +110,10 @@ index ae9b1c4..3b19122 100644
110 typedef int64_t off64_t; 110 typedef int64_t off64_t;
111 typedef off64_t __off64_t; 111 typedef off64_t __off64_t;
112diff --git a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp 112diff --git a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp
113index cf8a060..9110312 100644 113index 8927d41..0e78707 100644
114--- a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp 114--- a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp
115+++ b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp 115+++ b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp
116@@ -27,12 +27,7 @@ CEmuFileWrapper g_emuFileWrapper; 116@@ -53,15 +53,7 @@ constexpr bool isValidFilePtr(FILE* f)
117 CEmuFileWrapper::CEmuFileWrapper() 117 CEmuFileWrapper::CEmuFileWrapper()
118 { 118 {
119 // since we always use dlls we might just initialize it directly 119 // since we always use dlls we might just initialize it directly
@@ -121,13 +121,16 @@ index cf8a060..9110312 100644
121- { 121- {
122- memset(&m_files[i], 0, sizeof(EmuFileObject)); 122- memset(&m_files[i], 0, sizeof(EmuFileObject));
123- m_files[i].used = false; 123- m_files[i].used = false;
124- m_files[i].file_emu._file = -1; 124-#if defined(TARGET_WINDOWS) && (_MSC_VER >= 1900)
125- m_files[i].file_emu._Placeholder = new kodi_iobuf();
126-#endif
127- FileDescriptor(m_files[i].file_emu)->_file = -1;
125- } 128- }
126+ memset(m_files, 0, sizeof(m_files)); 129+ memset(m_files, 0, sizeof(m_files));
127 } 130 }
128 131
129 CEmuFileWrapper::~CEmuFileWrapper() 132 CEmuFileWrapper::~CEmuFileWrapper()
130@@ -43,22 +38,7 @@ void CEmuFileWrapper::CleanUp() 133@@ -73,29 +65,7 @@ void CEmuFileWrapper::CleanUp()
131 { 134 {
132 CSingleLock lock(m_criticalSection); 135 CSingleLock lock(m_criticalSection);
133 for (int i = 0; i < MAX_EMULATED_FILES; i++) 136 for (int i = 0; i < MAX_EMULATED_FILES; i++)
@@ -140,18 +143,25 @@ index cf8a060..9110312 100644
140- if (m_files[i].file_lock) 143- if (m_files[i].file_lock)
141- { 144- {
142- delete m_files[i].file_lock; 145- delete m_files[i].file_lock;
143- m_files[i].file_lock = NULL; 146- m_files[i].file_lock = nullptr;
144- } 147- }
148-#if !defined(TARGET_WINDOWS)
149- //Don't memset on Windows as it overwrites our pointer
145- memset(&m_files[i], 0, sizeof(EmuFileObject)); 150- memset(&m_files[i], 0, sizeof(EmuFileObject));
151-#endif
146- m_files[i].used = false; 152- m_files[i].used = false;
147- m_files[i].file_emu._file = -1; 153- FileDescriptor(m_files[i].file_emu)->_file = -1;
148- } 154- }
155-#if defined(TARGET_WINDOWS) && (_MSC_VER >= 1900)
156- delete static_cast<kodi_iobuf*>(m_files[i].file_emu._Placeholder);
157- m_files[i].file_emu._Placeholder = nullptr;
158-#endif
149- } 159- }
150+ UnRegisterFileObject(&m_files[i], true); 160+ UnRegisterFileObject(&m_files[i], true);
151 } 161 }
152 162
153 EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile) 163 EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile)
154@@ -69,13 +49,11 @@ EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile) 164@@ -106,13 +76,11 @@ EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile)
155 165
156 for (int i = 0; i < MAX_EMULATED_FILES; i++) 166 for (int i = 0; i < MAX_EMULATED_FILES; i++)
157 { 167 {
@@ -162,11 +172,11 @@ index cf8a060..9110312 100644
162 object = &m_files[i]; 172 object = &m_files[i];
163- object->used = true; 173- object->used = true;
164 object->file_xbmc = pFile; 174 object->file_xbmc = pFile;
165- object->file_emu._file = (i + FILE_WRAPPER_OFFSET); 175- FileDescriptor(object->file_emu)->_file = (i + FILE_WRAPPER_OFFSET);
166 object->file_lock = new CCriticalSection(); 176 object->file_lock = new CCriticalSection();
167 break; 177 break;
168 } 178 }
169@@ -84,82 +62,71 @@ EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile) 179@@ -121,82 +89,70 @@ EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile)
170 return object; 180 return object;
171 } 181 }
172 182
@@ -174,49 +184,49 @@ index cf8a060..9110312 100644
174+void CEmuFileWrapper::UnRegisterFileObject(EmuFileObject *object, bool free_file) 184+void CEmuFileWrapper::UnRegisterFileObject(EmuFileObject *object, bool free_file)
175 { 185 {
176- int i = fd - FILE_WRAPPER_OFFSET; 186- int i = fd - FILE_WRAPPER_OFFSET;
177- if (i >= 0 && i < MAX_EMULATED_FILES) 187- if (! (i >= 0 && i < MAX_EMULATED_FILES))
178+ if (object && object->file_xbmc) 188+ if (! (object && object->file_xbmc))
179 { 189 return;
180- if (m_files[i].used) 190
181+ if (object->file_xbmc && free_file) 191- if (!m_files[i].used)
182 { 192- return;
183- CSingleLock lock(m_criticalSection);
184- 193-
185- // we assume the emulated function alreay deleted the CFile object 194- CSingleLock lock(m_criticalSection);
186- if (m_files[i].used) 195-
187- { 196- // we assume the emulated function alreay deleted the CFile object
188- if (m_files[i].file_lock) 197- if (m_files[i].file_lock)
189- { 198+ if (object->file_xbmc && free_file)
190- delete m_files[i].file_lock; 199 {
191- m_files[i].file_lock = NULL; 200- delete m_files[i].file_lock;
192- } 201- m_files[i].file_lock = nullptr;
193- memset(&m_files[i], 0, sizeof(EmuFileObject)); 202+ CSingleLock lock(m_criticalSection);
194- m_files[i].used = false;
195- m_files[i].file_emu._file = -1;
196- }
197+ object->file_xbmc->Close();
198+ delete object->file_xbmc;
199 }
200+ if (object->file_lock)
201+ {
202+ delete object->file_lock;
203+ }
204+ 203+
205+ memset(object, 0, sizeof(*object)); 204+ object->file_xbmc->Close();
205+ delete object->file_xbmc;
206 } 206 }
207 } 207-#if !defined(TARGET_WINDOWS)
208 208- //Don't memset on Windows as it overwrites our pointer
209- memset(&m_files[i], 0, sizeof(EmuFileObject));
210-#endif
211- m_files[i].used = false;
212- FileDescriptor(m_files[i].file_emu)->_file = -1;
213+ if (object->file_lock)
214+ delete object->file_lock;
215+
216+ memset(object, 0, sizeof(*object));
217+}
218+
209+void CEmuFileWrapper::UnRegisterFileObjectByDescriptor(int fd) 219+void CEmuFileWrapper::UnRegisterFileObjectByDescriptor(int fd)
210+{ 220+{
211+ CSingleLock lock(m_criticalSection); 221+ CSingleLock lock(m_criticalSection);
212+ UnRegisterFileObject(GetFileObjectByDescriptor(fd), false); 222+ UnRegisterFileObject(GetFileObjectByDescriptor(fd), false);
213+} 223 }
214+ 224
215 void CEmuFileWrapper::UnRegisterFileObjectByStream(FILE* stream) 225 void CEmuFileWrapper::UnRegisterFileObjectByStream(FILE* stream)
216 { 226 {
217- if (stream != NULL) 227- if (isValidFilePtr(stream))
218- { 228- {
219- return UnRegisterFileObjectByDescriptor(stream->_file); 229- return UnRegisterFileObjectByDescriptor(FileDescriptor(*stream)->_file);
220- } 230- }
221+ CSingleLock lock(m_criticalSection); 231+ CSingleLock lock(m_criticalSection);
222+ UnRegisterFileObject(GetFileObjectByStream(stream), false); 232+ UnRegisterFileObject(GetFileObjectByStream(stream), false);
@@ -238,37 +248,32 @@ index cf8a060..9110312 100644
238 } 248 }
239 249
240 bool CEmuFileWrapper::TryLockFileObjectByDescriptor(int fd) 250 bool CEmuFileWrapper::TryLockFileObjectByDescriptor(int fd)
241-{ 251 {
242- int i = fd - FILE_WRAPPER_OFFSET; 252- int i = fd - FILE_WRAPPER_OFFSET;
243- if (i >= 0 && i < MAX_EMULATED_FILES) 253- if (i >= 0 && i < MAX_EMULATED_FILES)
244- { 254+ EmuFileObject* object = GetFileObjectByDescriptor(fd);
255+ if (object && object->file_xbmc)
256 {
245- if (m_files[i].used) 257- if (m_files[i].used)
246- { 258- {
247- return m_files[i].file_lock->try_lock(); 259- return m_files[i].file_lock->try_lock();
248- } 260- }
249+{
250+ EmuFileObject* object = GetFileObjectByDescriptor(fd);
251+ if (object && object->file_xbmc)
252+ {
253+ return object->file_lock->try_lock(); 261+ return object->file_lock->try_lock();
254 } 262 }
255+
256 return false; 263 return false;
257 } 264 }
258 265
259 void CEmuFileWrapper::UnlockFileObjectByDescriptor(int fd) 266 void CEmuFileWrapper::UnlockFileObjectByDescriptor(int fd)
260-{ 267 {
261- int i = fd - FILE_WRAPPER_OFFSET; 268- int i = fd - FILE_WRAPPER_OFFSET;
262- if (i >= 0 && i < MAX_EMULATED_FILES) 269- if (i >= 0 && i < MAX_EMULATED_FILES)
263- { 270+ EmuFileObject* object = GetFileObjectByDescriptor(fd);
271+ if (object && object->file_xbmc)
272 {
264- if (m_files[i].used) 273- if (m_files[i].used)
265- { 274- {
266- m_files[i].file_lock->unlock(); 275- m_files[i].file_lock->unlock();
267- } 276- }
268+{
269+ EmuFileObject* object = GetFileObjectByDescriptor(fd);
270+ if (object && object->file_xbmc)
271+ {
272+ object->file_lock->unlock(); 277+ object->file_lock->unlock();
273 } 278 }
274 } 279 }
@@ -284,18 +289,18 @@ index cf8a060..9110312 100644
284 { 289 {
285 return &m_files[i]; 290 return &m_files[i];
286 } 291 }
287@@ -167,20 +134,38 @@ EmuFileObject* CEmuFileWrapper::GetFileObjectByDescriptor(int fd) 292@@ -204,20 +160,38 @@ EmuFileObject* CEmuFileWrapper::GetFileObjectByDescriptor(int fd)
288 return NULL; 293 return nullptr;
289 } 294 }
290 295
291-EmuFileObject* CEmuFileWrapper::GetFileObjectByStream(FILE* stream) 296-EmuFileObject* CEmuFileWrapper::GetFileObjectByStream(FILE* stream)
292+int CEmuFileWrapper::GetDescriptorByFileObject(EmuFileObject *object) 297+int CEmuFileWrapper::GetDescriptorByFileObject(EmuFileObject *object)
293 { 298 {
294- if (stream != NULL) 299- if (isValidFilePtr(stream))
295+ int i = object - m_files; 300+ int i = object - m_files;
296+ if (i >= 0 && i < MAX_EMULATED_FILES) 301+ if (i >= 0 && i < MAX_EMULATED_FILES)
297 { 302 {
298- return GetFileObjectByDescriptor(stream->_file); 303- return GetFileObjectByDescriptor(FileDescriptor(*stream)->_file);
299+ return 0x7000000 + i; 304+ return 0x7000000 + i;
300 } 305 }
301+ return -1; 306+ return -1;
@@ -311,7 +316,7 @@ index cf8a060..9110312 100644
311+ return object; 316+ return object;
312+ } 317+ }
313+ } 318+ }
314 return NULL; 319 return nullptr;
315 } 320 }
316 321
317+FILE* CEmuFileWrapper::GetStreamByFileObject(EmuFileObject *object) 322+FILE* CEmuFileWrapper::GetStreamByFileObject(EmuFileObject *object)
@@ -321,33 +326,33 @@ index cf8a060..9110312 100644
321+ 326+
322 XFILE::CFile* CEmuFileWrapper::GetFileXbmcByDescriptor(int fd) 327 XFILE::CFile* CEmuFileWrapper::GetFileXbmcByDescriptor(int fd)
323 { 328 {
324 EmuFileObject* object = GetFileObjectByDescriptor(fd); 329 auto object = GetFileObjectByDescriptor(fd);
325- if (object != NULL && object->used) 330- if (object != nullptr && object->used)
326+ if (object != NULL) 331+ if (object != nullptr)
327 { 332 {
328 return object->file_xbmc; 333 return object->file_xbmc;
329 } 334 }
330@@ -191,8 +176,8 @@ XFILE::CFile* CEmuFileWrapper::GetFileXbmcByStream(FILE* stream) 335@@ -228,8 +202,8 @@ XFILE::CFile* CEmuFileWrapper::GetFileXbmcByStream(FILE* stream)
331 { 336 {
332 if (stream != NULL) 337 if (isValidFilePtr(stream))
333 { 338 {
334- EmuFileObject* object = GetFileObjectByDescriptor(stream->_file); 339- auto object = GetFileObjectByDescriptor(FileDescriptor(*stream)->_file);
335- if (object != NULL && object->used) 340- if (object != nullptr && object->used)
336+ EmuFileObject* object = GetFileObjectByStream(stream); 341+ auto object = GetFileObjectByStream(stream);
337+ if (object != NULL) 342+ if (object != nullptr)
338 { 343 {
339 return object->file_xbmc; 344 return object->file_xbmc;
340 } 345 }
341@@ -202,42 +187,20 @@ XFILE::CFile* CEmuFileWrapper::GetFileXbmcByStream(FILE* stream) 346@@ -239,32 +213,25 @@ XFILE::CFile* CEmuFileWrapper::GetFileXbmcByStream(FILE* stream)
342 347
343 int CEmuFileWrapper::GetDescriptorByStream(FILE* stream) 348 int CEmuFileWrapper::GetDescriptorByStream(FILE* stream)
344 { 349 {
345- if (stream != NULL) 350- if (isValidFilePtr(stream))
346- { 351- {
347- int i = stream->_file - FILE_WRAPPER_OFFSET; 352- int i = FileDescriptor(*stream)->_file - FILE_WRAPPER_OFFSET;
348- if (i >= 0 && i < MAX_EMULATED_FILES) 353- if (i >= 0 && i < MAX_EMULATED_FILES)
349- { 354- {
350- return stream->_file; 355- return i + FILE_WRAPPER_OFFSET;
351- } 356- }
352- } 357- }
353- return -1; 358- return -1;
@@ -356,40 +361,35 @@ index cf8a060..9110312 100644
356 361
357 FILE* CEmuFileWrapper::GetStreamByDescriptor(int fd) 362 FILE* CEmuFileWrapper::GetStreamByDescriptor(int fd)
358 { 363 {
359- EmuFileObject* object = GetFileObjectByDescriptor(fd); 364- auto object = GetFileObjectByDescriptor(fd);
360- if (object != NULL && object->used) 365- if (object != nullptr && object->used)
361- { 366- {
362- return &object->file_emu; 367- return &object->file_emu;
363- } 368- }
364- return NULL; 369- return nullptr;
365+ return GetStreamByFileObject(GetFileObjectByDescriptor(fd)); 370+ return GetStreamByFileObject(GetFileObjectByDescriptor(fd));
366 } 371 }
367 372
368 bool CEmuFileWrapper::DescriptorIsEmulatedFile(int fd)
369 {
370- int i = fd - FILE_WRAPPER_OFFSET;
371- if (i >= 0 && i < MAX_EMULATED_FILES)
372- {
373- return true;
374- }
375- return false;
376+ return GetFileObjectByDescriptor(fd) != NULL;
377 }
378
379 bool CEmuFileWrapper::StreamIsEmulatedFile(FILE* stream) 373 bool CEmuFileWrapper::StreamIsEmulatedFile(FILE* stream)
380 { 374 {
381- if (stream != NULL) 375 if (isValidFilePtr(stream))
382- { 376 {
383- return DescriptorIsEmulatedFile(stream->_file); 377- return DescriptorIsEmulatedFile(FileDescriptor(*stream)->_file);
384- } 378+ return DescriptorIsEmulatedFile(GetDescriptorByStream(stream));
385- return false; 379 }
386+ return GetFileObjectByStream(stream) != NULL; 380 return false;
387 } 381 }
382+
383+bool CEmuFileWrapper::DescriptorIsEmulatedFile(int fd)
384+{
385+ return GetFileObjectByDescriptor(fd) != NULL;
386+}
387+
388diff --git a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h 388diff --git a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h
389index 3d79c7a..1b3e62f 100644 389index 786fa85..311a5cf 100644
390--- a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h 390--- a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h
391+++ b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h 391+++ b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h
392@@ -27,14 +27,14 @@ 392@@ -25,14 +25,14 @@
393 #include "system.h" 393 #include "system.h"
394 #include "threads/CriticalSection.h" 394 #include "threads/CriticalSection.h"
395 395
@@ -405,28 +405,27 @@ index 3d79c7a..1b3e62f 100644
405+//#endif 405+//#endif
406 406
407 #define MAX_EMULATED_FILES 50 407 #define MAX_EMULATED_FILES 50
408-#define FILE_WRAPPER_OFFSET 0x00000100 408-#define FILE_WRAPPER_OFFSET 0x00000200
409+//#define FILE_WRAPPER_OFFSET 0x00000100 409+//#define FILE_WRAPPER_OFFSET 0x00000200
410 410
411 namespace XFILE 411 namespace XFILE
412 { 412 {
413@@ -43,11 +43,9 @@ namespace XFILE 413@@ -47,12 +47,9 @@ struct kodi_iobuf {
414 414
415 typedef struct stEmuFileObject 415 typedef struct stEmuFileObject
416 { 416 {
417- bool used;
418- FILE file_emu; 417- FILE file_emu;
419- XFILE::CFile* file_xbmc; 418 XFILE::CFile* file_xbmc;
420+ XFILE::CFile* file_xbmc;
421 CCriticalSection *file_lock; 419 CCriticalSection *file_lock;
422- int mode; 420 int mode;
423+ int mode; 421- //Stick this last to avoid 3-7 bytes of padding
422- bool used;
424 } EmuFileObject; 423 } EmuFileObject;
425 424
426 class CEmuFileWrapper 425 class CEmuFileWrapper
427@@ -62,19 +60,22 @@ public: 426@@ -67,22 +64,22 @@ public:
428 void CleanUp(); 427 void CleanUp();
429 428
430 EmuFileObject* RegisterFileObject(XFILE::CFile* pFile); 429 EmuFileObject* RegisterFileObject(XFILE::CFile* pFile);
431+ void UnRegisterFileObject(EmuFileObject*, bool free_file); 430+ void UnRegisterFileObject(EmuFileObject*, bool free_file);
432 void UnRegisterFileObjectByDescriptor(int fd); 431 void UnRegisterFileObjectByDescriptor(int fd);
@@ -434,18 +433,19 @@ index 3d79c7a..1b3e62f 100644
434 void LockFileObjectByDescriptor(int fd); 433 void LockFileObjectByDescriptor(int fd);
435 bool TryLockFileObjectByDescriptor(int fd); 434 bool TryLockFileObjectByDescriptor(int fd);
436 void UnlockFileObjectByDescriptor(int fd); 435 void UnlockFileObjectByDescriptor(int fd);
437- EmuFileObject* GetFileObjectByDescriptor(int fd); 436 EmuFileObject* GetFileObjectByDescriptor(int fd);
438- EmuFileObject* GetFileObjectByStream(FILE* stream);
439+ EmuFileObject* GetFileObjectByDescriptor(int fd);
440+ int GetDescriptorByFileObject(EmuFileObject*); 437+ int GetDescriptorByFileObject(EmuFileObject*);
441+ EmuFileObject* GetFileObjectByStream(FILE* stream); 438 EmuFileObject* GetFileObjectByStream(FILE* stream);
442+ FILE* GetStreamByFileObject(EmuFileObject*); 439+ FILE* GetStreamByFileObject(EmuFileObject*);
443 XFILE::CFile* GetFileXbmcByDescriptor(int fd); 440 XFILE::CFile* GetFileXbmcByDescriptor(int fd);
444 XFILE::CFile* GetFileXbmcByStream(FILE* stream); 441 XFILE::CFile* GetFileXbmcByStream(FILE* stream);
445- static int GetDescriptorByStream(FILE* stream); 442- static int GetDescriptorByStream(FILE* stream);
446+ int GetDescriptorByStream(FILE* stream); 443+ int GetDescriptorByStream(FILE* stream);
447 FILE* GetStreamByDescriptor(int fd); 444 FILE* GetStreamByDescriptor(int fd);
448- static bool DescriptorIsEmulatedFile(int fd); 445- static constexpr bool DescriptorIsEmulatedFile(int fd)
446- {
447- return fd >= FILE_WRAPPER_OFFSET && fd < FILE_WRAPPER_OFFSET + MAX_EMULATED_FILES;
448- }
449- static bool StreamIsEmulatedFile(FILE* stream); 449- static bool StreamIsEmulatedFile(FILE* stream);
450+ bool DescriptorIsEmulatedFile(int fd); 450+ bool DescriptorIsEmulatedFile(int fd);
451+ bool StreamIsEmulatedFile(FILE* stream); 451+ bool StreamIsEmulatedFile(FILE* stream);
@@ -453,7 +453,7 @@ index 3d79c7a..1b3e62f 100644
453 EmuFileObject m_files[MAX_EMULATED_FILES]; 453 EmuFileObject m_files[MAX_EMULATED_FILES];
454 CCriticalSection m_criticalSection; 454 CCriticalSection m_criticalSection;
455diff --git a/xbmc/cores/DllLoader/exports/wrapper.c b/xbmc/cores/DllLoader/exports/wrapper.c 455diff --git a/xbmc/cores/DllLoader/exports/wrapper.c b/xbmc/cores/DllLoader/exports/wrapper.c
456index a9225e5..355da1c 100644 456index e363662..4498c27 100644
457--- a/xbmc/cores/DllLoader/exports/wrapper.c 457--- a/xbmc/cores/DllLoader/exports/wrapper.c
458+++ b/xbmc/cores/DllLoader/exports/wrapper.c 458+++ b/xbmc/cores/DllLoader/exports/wrapper.c
459@@ -39,7 +39,7 @@ 459@@ -39,7 +39,7 @@
diff --git a/community/kodi/fix-musl.patch b/community/kodi/fix-musl.patch
index 75a7b07f32..a5a9d92141 100644
--- a/community/kodi/fix-musl.patch
+++ b/community/kodi/fix-musl.patch
@@ -1,38 +1,27 @@
1--- ./xbmc/cores/DllLoader/ldt_keeper.c.orig
2+++ ./xbmc/cores/DllLoader/ldt_keeper.c
3@@ -48,7 +48,7 @@
4 #if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0))
5 _syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
6 #else
7-#if defined(TARGET_ANDROID) && defined(__i386__) && !defined(modify_ldt)
8+#if defined(__linux__) && !defined(__GLIBC__) && !defined(modify_ldt)
9 #define modify_ldt(a,b,c) syscall( __NR_modify_ldt, a, b, c);
10 #else
11 int modify_ldt(int func, void *ptr, unsigned long bytecount);
12diff --git a/configure.ac b/configure.ac 1diff --git a/configure.ac b/configure.ac
13index 5d47a4a..3860e32 100644 2index 9bd8d6e..205acfc 100644
14--- a/configure.ac 3--- a/configure.ac
15+++ b/configure.ac 4+++ b/configure.ac
16@@ -564,7 +564,7 @@ case $host in 5@@ -526,7 +526,7 @@ case $host in
17 use_x11=no 6 use_x11=no
18 build_shared_lib=yes 7 build_shared_lib=yes
19 ;; 8 ;;
20- i*86*-linux-gnu*|i*86*-*-linux-uclibc*) 9- i*86*-linux-gnu*|i*86*-*-linux-uclibc*)
21+ i*86*-linux-*) 10+ i*86*-linux-*)
22 target_platform=target_linux 11 target_platform=target_linux
12 CORE_SYSTEM_NAME=linux
23 ARCH="i486-linux" 13 ARCH="i486-linux"
24 if test "$use_cpu" = "no" -a "$cross_compiling" = "yes"; then 14@@ -549,7 +549,7 @@ case $host in
25@@ -586,7 +586,7 @@ case $host in
26 fi 15 fi
27 fi 16 fi
28 ;; 17 ;;
29- x86_64-*-linux-gnu*|x86_64-*-linux-uclibc*) 18- x86_64-*-linux-gnu*|x86_64-*-linux-uclibc*)
30+ x86_64-*-linux-*) 19+ x86_64-*-linux-*)
31 target_platform=target_linux 20 target_platform=target_linux
21 CORE_SYSTEM_NAME=linux
32 ARCH="x86_64-linux" 22 ARCH="x86_64-linux"
33 if test "$use_cpu" = "no" -a "$cross_compiling" = "yes"; then
34diff --git a/m4/xbmc_arch.m4 b/m4/xbmc_arch.m4 23diff --git a/m4/xbmc_arch.m4 b/m4/xbmc_arch.m4
35index 0b66a82..5198263 100644 24index d28f263..6fb6210 100644
36--- a/m4/xbmc_arch.m4 25--- a/m4/xbmc_arch.m4
37+++ b/m4/xbmc_arch.m4 26+++ b/m4/xbmc_arch.m4
38@@ -2,10 +2,10 @@ AC_DEFUN([XBMC_SETUP_ARCH_DEFINES],[ 27@@ -2,10 +2,10 @@ AC_DEFUN([XBMC_SETUP_ARCH_DEFINES],[
@@ -86,11 +75,11 @@ index 0b66a82..5198263 100644
86+ powerpc-*-linux-*) 75+ powerpc-*-linux-*)
87 AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC") 76 AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC")
88 ;; 77 ;;
89- powerpc64-*-linux-gnu*|powerpc64-*-linux-uclibc*) 78- powerpc64*-*-linux-gnu*|powerpc64*-*-linux-uclibc*)
90+ powerpc64-*-linux-*) 79+ powerpc64*-*-linux-*)
91 AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC64") 80 AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC64")
92 ;; 81 ;;
93- arm*-*-linux-gnu*|arm*-*-linux-uclibc*) 82- arm*-*-linux-gnu*|arm*-*-linux-uclibc*|aarch64*-*-linux-gnu*|aarch64*-*-linux-uclibc*)
94+ arm*-*-linux-*) 83+ arm*-*-linux-*)
95 AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX") 84 AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
96 ;; 85 ;;
@@ -100,10 +89,10 @@ index 0b66a82..5198263 100644
100 ;; 89 ;;
101 *-*linux-android*) 90 *-*linux-android*)
102diff --git a/tools/depends/configure.ac b/tools/depends/configure.ac 91diff --git a/tools/depends/configure.ac b/tools/depends/configure.ac
103index 12935e3..fdd5bf3 100644 92index 3626ea5..f178f7a 100644
104--- a/tools/depends/configure.ac 93--- a/tools/depends/configure.ac
105+++ b/tools/depends/configure.ac 94+++ b/tools/depends/configure.ac
106@@ -97,13 +97,13 @@ platform_cc=gcc 95@@ -120,13 +120,13 @@ platform_cc=gcc
107 platform_cxx=g++ 96 platform_cxx=g++
108 97
109 case $build in 98 case $build in
@@ -120,3 +109,16 @@ index 12935e3..fdd5bf3 100644
120 build_os="linux" 109 build_os="linux"
121 ;; 110 ;;
122 *darwin*) 111 *darwin*)
112diff --git a/xbmc/cores/DllLoader/ldt_keeper.c b/xbmc/cores/DllLoader/ldt_keeper.c
113index 3fe6854..ca78612 100644
114--- a/xbmc/cores/DllLoader/ldt_keeper.c
115+++ b/xbmc/cores/DllLoader/ldt_keeper.c
116@@ -48,7 +48,7 @@ extern "C" {
117 #if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0))
118 _syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
119 #else
120-#if defined(TARGET_ANDROID) && defined(__i386__) && !defined(modify_ldt)
121+#if defined(__linux__) && !defined(__GLIBC__) && !defined(modify_ldt)
122 #define modify_ldt(a,b,c) syscall( __NR_modify_ldt, a, b, c);
123 #else
124 int modify_ldt(int func, void *ptr, unsigned long bytecount);
diff --git a/community/kodi/gcc6-fix.patch b/community/kodi/gcc6-fix.patch
deleted file mode 100644
index 0be60e9f3c..0000000000
--- a/community/kodi/gcc6-fix.patch
+++ /dev/null
@@ -1,1434 +0,0 @@
1https://github.com/xbmc/xbmc/commit/8f82e51563f0e1bc9b7a8adf669ad2b66e7ce3e5.patch
2
3From 8f82e51563f0e1bc9b7a8adf669ad2b66e7ce3e5 Mon Sep 17 00:00:00 2001
4From: Bernd Kuhls <bernd.kuhls@t-online.de>
5Date: Thu, 28 Apr 2016 17:17:40 +0200
6Subject: [PATCH] lib/cximage-6.0: fix compilation with gcc6
7
8For a quick fix I renamed min() to cxmin() and max() to cxmax() to
9prevent the conflict with the gcc definition.
10
11Forum thread for reference:
12http://forum.kodi.tv/showthread.php?tid=263884
13---
14 lib/cximage-6.0/CxImage/ximabmp.cpp | 6 +-
15 lib/cximage-6.0/CxImage/ximadef.h | 8 +-
16 lib/cximage-6.0/CxImage/ximadsp.cpp | 182 +++++++++++++++++------------------
17 lib/cximage-6.0/CxImage/ximage.cpp | 4 +-
18 lib/cximage-6.0/CxImage/ximagif.cpp | 6 +-
19 lib/cximage-6.0/CxImage/ximahist.cpp | 12 +--
20 lib/cximage-6.0/CxImage/ximaint.cpp | 8 +-
21 lib/cximage-6.0/CxImage/ximaiter.h | 4 +-
22 lib/cximage-6.0/CxImage/ximajbg.cpp | 2 +-
23 lib/cximage-6.0/CxImage/ximapal.cpp | 14 +--
24 lib/cximage-6.0/CxImage/ximapng.cpp | 12 +--
25 lib/cximage-6.0/CxImage/ximaraw.cpp | 4 +-
26 lib/cximage-6.0/CxImage/ximasel.cpp | 50 +++++-----
27 lib/cximage-6.0/CxImage/ximath.cpp | 8 +-
28 lib/cximage-6.0/CxImage/ximatif.cpp | 6 +-
29 lib/cximage-6.0/CxImage/ximatran.cpp | 138 +++++++++++++-------------
30 lib/cximage-6.0/CxImage/ximawnd.cpp | 16 +--
31 17 files changed, 236 insertions(+), 244 deletions(-)
32
33diff --git a/lib/cximage-6.0/CxImage/ximabmp.cpp b/lib/cximage-6.0/CxImage/ximabmp.cpp
34index 726ff91..55842b1 100644
35--- a/lib/cximage-6.0/CxImage/ximabmp.cpp
36+++ b/lib/cximage-6.0/CxImage/ximabmp.cpp
37@@ -46,7 +46,7 @@ bool CxImageBMP::Encode(CxFile * hFile)
38 bihtoh(&infohdr);
39
40 // Write the file header
41- hFile->Write(&hdr,min(14,sizeof(BITMAPFILEHEADER)),1);
42+ hFile->Write(&hdr,cxmin(14,sizeof(BITMAPFILEHEADER)),1);
43 hFile->Write(&infohdr,sizeof(BITMAPINFOHEADER),1);
44 //and DIB+ALPHA interlaced
45 BYTE *srcalpha = AlphaGetPointer();
46@@ -64,7 +64,7 @@ bool CxImageBMP::Encode(CxFile * hFile)
47 #endif //CXIMAGE_SUPPORT_ALPHA
48 {
49 // Write the file header
50- hFile->Write(&hdr,min(14,sizeof(BITMAPFILEHEADER)),1);
51+ hFile->Write(&hdr,cxmin(14,sizeof(BITMAPFILEHEADER)),1);
52 //copy attributes
53 memcpy(pDib,&head,sizeof(BITMAPINFOHEADER));
54 bihtoh((BITMAPINFOHEADER*)pDib);
55@@ -86,7 +86,7 @@ bool CxImageBMP::Decode(CxFile * hFile)
56 BITMAPFILEHEADER bf;
57 DWORD off = hFile->Tell(); //<CSC>
58 cx_try {
59- if (hFile->Read(&bf,min(14,sizeof(bf)),1)==0) cx_throw("Not a BMP");
60+ if (hFile->Read(&bf,cxmin(14,sizeof(bf)),1)==0) cx_throw("Not a BMP");
61
62 bf.bfSize = my_ntohl(bf.bfSize);
63 bf.bfOffBits = my_ntohl(bf.bfOffBits);
64diff --git a/lib/cximage-6.0/CxImage/ximadef.h b/lib/cximage-6.0/CxImage/ximadef.h
65index fe383bf..53ea452 100644
66--- a/lib/cximage-6.0/CxImage/ximadef.h
67+++ b/lib/cximage-6.0/CxImage/ximadef.h
68@@ -53,12 +53,8 @@
69 #define CXIMAGE_SUPPORT_WINDOWS 0
70 #endif
71
72-#ifndef min
73-#define min(a,b) (((a)<(b))?(a):(b))
74-#endif
75-#ifndef max
76-#define max(a,b) (((a)>(b))?(a):(b))
77-#endif
78+#define cxmin(a,b) (((a)<(b))?(a):(b))
79+#define cxmax(a,b) (((a)>(b))?(a):(b))
80
81 #ifndef PI
82 #define PI 3.141592653589793f
83diff --git a/lib/cximage-6.0/CxImage/ximadsp.cpp b/lib/cximage-6.0/CxImage/ximadsp.cpp
84index 8425bb2..813253b 100644
85--- a/lib/cximage-6.0/CxImage/ximadsp.cpp
86+++ b/lib/cximage-6.0/CxImage/ximadsp.cpp
87@@ -389,8 +389,8 @@ RGBQUAD CxImage::RGBtoHSL(RGBQUAD lRGBColor)
88 G = lRGBColor.rgbGreen;
89 B = lRGBColor.rgbBlue;
90
91- cMax = max( max(R,G), B); /* calculate lightness */
92- cMin = min( min(R,G), B);
93+ cMax = cxmax( cxmax(R,G), B); /* calculate lightness */
94+ cMin = cxmin( cxmin(R,G), B);
95 L = (BYTE)((((cMax+cMin)*HSLMAX)+RGBMAX)/(2*RGBMAX));
96
97 if (cMax==cMin){ /* r=g=b --> achromatic case */
98@@ -489,9 +489,9 @@ RGBQUAD CxImage::YUVtoRGB(RGBQUAD lYUVColor)
99 G = (int)( Y - 0.344f * U - 0.714f * V);
100 B = (int)( Y + 1.770f * U);
101
102- R= min(255,max(0,R));
103- G= min(255,max(0,G));
104- B= min(255,max(0,B));
105+ R= cxmin(255,cxmax(0,R));
106+ G= cxmin(255,cxmax(0,G));
107+ B= cxmin(255,cxmax(0,B));
108 RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
109 return rgb;
110 }
111@@ -510,9 +510,9 @@ RGBQUAD CxImage::RGBtoYUV(RGBQUAD lRGBColor)
112 U = (int)((B-Y) * 0.565f + 128);
113 V = (int)((R-Y) * 0.713f + 128);
114
115- Y= min(255,max(0,Y));
116- U= min(255,max(0,U));
117- V= min(255,max(0,V));
118+ Y= cxmin(255,cxmax(0,Y));
119+ U= cxmin(255,cxmax(0,U));
120+ V= cxmin(255,cxmax(0,V));
121 RGBQUAD yuv={(BYTE)V,(BYTE)U,(BYTE)Y,0};
122 return yuv;
123 }
124@@ -528,9 +528,9 @@ RGBQUAD CxImage::YIQtoRGB(RGBQUAD lYIQColor)
125 G = (int)( Y - 0.273f * I - 0.647f * Q);
126 B = (int)( Y - 1.104f * I + 1.701f * Q);
127
128- R= min(255,max(0,R));
129- G= min(255,max(0,G));
130- B= min(255,max(0,B));
131+ R= cxmin(255,cxmax(0,R));
132+ G= cxmin(255,cxmax(0,G));
133+ B= cxmin(255,cxmax(0,B));
134 RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
135 return rgb;
136 }
137@@ -546,9 +546,9 @@ RGBQUAD CxImage::RGBtoYIQ(RGBQUAD lRGBColor)
138 I = (int)( 0.5960f * R - 0.2742f * G - 0.3219f * B + 128);
139 Q = (int)( 0.2109f * R - 0.5229f * G + 0.3120f * B + 128);
140
141- Y= min(255,max(0,Y));
142- I= min(255,max(0,I));
143- Q= min(255,max(0,Q));
144+ Y= cxmin(255,cxmax(0,Y));
145+ I= cxmin(255,cxmax(0,I));
146+ Q= cxmin(255,cxmax(0,Q));
147 RGBQUAD yiq={(BYTE)Q,(BYTE)I,(BYTE)Y,0};
148 return yiq;
149 }
150@@ -565,9 +565,9 @@ RGBQUAD CxImage::XYZtoRGB(RGBQUAD lXYZColor)
151 G = (int)( -0.969256f * X + 1.875992f * Y + 0.041556f * Z * k);
152 B = (int)( 0.055648f * X - 0.204043f * Y + 1.057311f * Z * k);
153
154- R= min(255,max(0,R));
155- G= min(255,max(0,G));
156- B= min(255,max(0,B));
157+ R= cxmin(255,cxmax(0,R));
158+ G= cxmin(255,cxmax(0,G));
159+ B= cxmin(255,cxmax(0,B));
160 RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
161 return rgb;
162 }
163@@ -583,9 +583,9 @@ RGBQUAD CxImage::RGBtoXYZ(RGBQUAD lRGBColor)
164 Y = (int)( 0.212671f * R + 0.715160f * G + 0.072169f * B);
165 Z = (int)((0.019334f * R + 0.119193f * G + 0.950227f * B)*0.918483657f);
166
167- //X= min(255,max(0,X));
168- //Y= min(255,max(0,Y));
169- //Z= min(255,max(0,Z));
170+ //X= cxmin(255,cxmax(0,X));
171+ //Y= cxmin(255,cxmax(0,Y));
172+ //Z= cxmin(255,cxmax(0,Z));
173 RGBQUAD xyz={(BYTE)Z,(BYTE)Y,(BYTE)X,0};
174 return xyz;
175 }
176@@ -707,7 +707,7 @@ bool CxImage::Light(long brightness, long contrast)
177
178 BYTE cTable[256]; //<nipper>
179 for (int i=0;i<256;i++) {
180- cTable[i] = (BYTE)max(0,min(255,(int)((i-128)*c + brightness + 0.5f)));
181+ cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)((i-128)*c + brightness + 0.5f)));
182 }
183
184 return Lut(cTable);
185@@ -830,11 +830,11 @@ bool CxImage::Filter(long* kernel, long Ksize, long Kfactor, long Koffset)
186 }
187 }
188 if (Kfactor==0 || ksumcur==0){
189- cPtr2[iY1] = (BYTE)min(255, max(0,(int)(b + Koffset)));
190+ cPtr2[iY1] = (BYTE)cxmin(255, cxmax(0,(int)(b + Koffset)));
191 } else if (ksumtot == ksumcur) {
192- cPtr2[iY1] = (BYTE)min(255, max(0,(int)(b/Kfactor + Koffset)));
193+ cPtr2[iY1] = (BYTE)cxmin(255, cxmax(0,(int)(b/Kfactor + Koffset)));
194 } else {
195- cPtr2[iY1] = (BYTE)min(255, max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
196+ cPtr2[iY1] = (BYTE)cxmin(255, cxmax(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
197 }
198 }
199 }
200@@ -863,17 +863,17 @@ bool CxImage::Filter(long* kernel, long Ksize, long Kfactor, long Koffset)
201 }
202 }
203 if (Kfactor==0 || ksumcur==0){
204- c.rgbRed = (BYTE)min(255, max(0,(int)(r + Koffset)));
205- c.rgbGreen = (BYTE)min(255, max(0,(int)(g + Koffset)));
206- c.rgbBlue = (BYTE)min(255, max(0,(int)(b + Koffset)));
207+ c.rgbRed = (BYTE)cxmin(255, cxmax(0,(int)(r + Koffset)));
208+ c.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(g + Koffset)));
209+ c.rgbBlue = (BYTE)cxmin(255, cxmax(0,(int)(b + Koffset)));
210 } else if (ksumtot == ksumcur) {
211- c.rgbRed = (BYTE)min(255, max(0,(int)(r/Kfactor + Koffset)));
212- c.rgbGreen = (BYTE)min(255, max(0,(int)(g/Kfactor + Koffset)));
213- c.rgbBlue = (BYTE)min(255, max(0,(int)(b/Kfactor + Koffset)));
214+ c.rgbRed = (BYTE)cxmin(255, cxmax(0,(int)(r/Kfactor + Koffset)));
215+ c.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(g/Kfactor + Koffset)));
216+ c.rgbBlue = (BYTE)cxmin(255, cxmax(0,(int)(b/Kfactor + Koffset)));
217 } else {
218- c.rgbRed = (BYTE)min(255, max(0,(int)((r*ksumtot)/(ksumcur*Kfactor) + Koffset)));
219- c.rgbGreen = (BYTE)min(255, max(0,(int)((g*ksumtot)/(ksumcur*Kfactor) + Koffset)));
220- c.rgbBlue = (BYTE)min(255, max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
221+ c.rgbRed = (BYTE)cxmin(255, cxmax(0,(int)((r*ksumtot)/(ksumcur*Kfactor) + Koffset)));
222+ c.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)((g*ksumtot)/(ksumcur*Kfactor) + Koffset)));
223+ c.rgbBlue = (BYTE)cxmin(255, cxmax(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
224 }
225 tmp.BlindSetPixelColor(x,y,c);
226 }
227@@ -1078,8 +1078,8 @@ bool CxImage::Edge(long Ksize)
228 //
229 void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffset, bool bMixAlpha)
230 {
231- long lWide = min(GetWidth(),imgsrc2.GetWidth()-lXOffset);
232- long lHeight = min(GetHeight(),imgsrc2.GetHeight()-lYOffset);
233+ long lWide = cxmin(GetWidth(),imgsrc2.GetWidth()-lXOffset);
234+ long lHeight = cxmin(GetHeight(),imgsrc2.GetHeight()-lYOffset);
235
236 bool bEditAlpha = imgsrc2.AlphaIsValid() & bMixAlpha;
237
238@@ -1112,16 +1112,16 @@ void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffse
239 if (bEditAlpha) rgbDest.rgbReserved = (BYTE)((rgb1.rgbReserved+rgb2.rgbReserved)/2);
240 break;
241 case OpAdd:
242- rgbDest.rgbBlue = (BYTE)max(0,min(255,rgb1.rgbBlue+rgb2.rgbBlue));
243- rgbDest.rgbGreen = (BYTE)max(0,min(255,rgb1.rgbGreen+rgb2.rgbGreen));
244- rgbDest.rgbRed = (BYTE)max(0,min(255,rgb1.rgbRed+rgb2.rgbRed));
245- if (bEditAlpha) rgbDest.rgbReserved = (BYTE)max(0,min(255,rgb1.rgbReserved+rgb2.rgbReserved));
246+ rgbDest.rgbBlue = (BYTE)cxmax(0,cxmin(255,rgb1.rgbBlue+rgb2.rgbBlue));
247+ rgbDest.rgbGreen = (BYTE)cxmax(0,cxmin(255,rgb1.rgbGreen+rgb2.rgbGreen));
248+ rgbDest.rgbRed = (BYTE)cxmax(0,cxmin(255,rgb1.rgbRed+rgb2.rgbRed));
249+ if (bEditAlpha) rgbDest.rgbReserved = (BYTE)cxmax(0,cxmin(255,rgb1.rgbReserved+rgb2.rgbReserved));
250 break;
251 case OpSub:
252- rgbDest.rgbBlue = (BYTE)max(0,min(255,rgb1.rgbBlue-rgb2.rgbBlue));
253- rgbDest.rgbGreen = (BYTE)max(0,min(255,rgb1.rgbGreen-rgb2.rgbGreen));
254- rgbDest.rgbRed = (BYTE)max(0,min(255,rgb1.rgbRed-rgb2.rgbRed));
255- if (bEditAlpha) rgbDest.rgbReserved = (BYTE)max(0,min(255,rgb1.rgbReserved-rgb2.rgbReserved));
256+ rgbDest.rgbBlue = (BYTE)cxmax(0,cxmin(255,rgb1.rgbBlue-rgb2.rgbBlue));
257+ rgbDest.rgbGreen = (BYTE)cxmax(0,cxmin(255,rgb1.rgbGreen-rgb2.rgbGreen));
258+ rgbDest.rgbRed = (BYTE)cxmax(0,cxmin(255,rgb1.rgbRed-rgb2.rgbRed));
259+ if (bEditAlpha) rgbDest.rgbReserved = (BYTE)cxmax(0,cxmin(255,rgb1.rgbReserved-rgb2.rgbReserved));
260 break;
261 case OpAnd:
262 rgbDest.rgbBlue = (BYTE)(rgb1.rgbBlue&rgb2.rgbBlue);
263@@ -1202,11 +1202,11 @@ void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffse
264 double dSmallAmt = dSmall*((double)rgb2.rgbBlue);
265
266 if( lAverage < lThresh+1){
267- rgbDest.rgbBlue = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbBlue) +
268+ rgbDest.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(dLarge*((double)rgb1.rgbBlue) +
269 dSmallAmt)));
270- rgbDest.rgbGreen = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbGreen) +
271+ rgbDest.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(dLarge*((double)rgb1.rgbGreen) +
272 dSmallAmt)));
273- rgbDest.rgbRed = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbRed) +
274+ rgbDest.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(dLarge*((double)rgb1.rgbRed) +
275 dSmallAmt)));
276 }
277 else
278@@ -1274,9 +1274,9 @@ bool CxImage::ShiftRGB(long r, long g, long b)
279 #endif //CXIMAGE_SUPPORT_SELECTION
280 {
281 color = BlindGetPixelColor(x,y);
282- color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + r)));
283- color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + g)));
284- color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + b)));
285+ color.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbRed + r)));
286+ color.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbGreen + g)));
287+ color.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbBlue + b)));
288 BlindSetPixelColor(x,y,color);
289 }
290 }
291@@ -1284,9 +1284,9 @@ bool CxImage::ShiftRGB(long r, long g, long b)
292 } else {
293 for(DWORD j=0; j<head.biClrUsed; j++){
294 color = GetPaletteColor((BYTE)j);
295- color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + r)));
296- color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + g)));
297- color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + b)));
298+ color.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbRed + r)));
299+ color.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbGreen + g)));
300+ color.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbBlue + b)));
301 SetPaletteColor((BYTE)j,color);
302 }
303 }
304@@ -1310,7 +1310,7 @@ bool CxImage::Gamma(float gamma)
305
306 BYTE cTable[256]; //<nipper>
307 for (int i=0;i<256;i++) {
308- cTable[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
309+ cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
310 }
311
312 return Lut(cTable);
313@@ -1337,21 +1337,21 @@ bool CxImage::GammaRGB(float gammaR, float gammaG, float gammaB)
314 dMax = pow(255.0, dinvgamma) / 255.0;
315 BYTE cTableR[256];
316 for (i=0;i<256;i++) {
317- cTableR[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
318+ cTableR[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
319 }
320
321 dinvgamma = 1/gammaG;
322 dMax = pow(255.0, dinvgamma) / 255.0;
323 BYTE cTableG[256];
324 for (i=0;i<256;i++) {
325- cTableG[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
326+ cTableG[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
327 }
328
329 dinvgamma = 1/gammaB;
330 dMax = pow(255.0, dinvgamma) / 255.0;
331 BYTE cTableB[256];
332 for (i=0;i<256;i++) {
333- cTableB[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
334+ cTableB[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
335 }
336
337 return Lut(cTableR, cTableG, cTableB);
338@@ -1442,11 +1442,11 @@ bool CxImage::Noise(long level)
339 {
340 color = BlindGetPixelColor(x,y);
341 n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
342- color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + n)));
343+ color.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbRed + n)));
344 n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
345- color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + n)));
346+ color.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbGreen + n)));
347 n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
348- color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + n)));
349+ color.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbBlue + n)));
350 BlindSetPixelColor(x,y,color);
351 }
352 }
353@@ -1561,8 +1561,8 @@ bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage
354
355 //DFT buffers
356 double *real2,*imag2;
357- real2 = (double*)malloc(max(w,h) * sizeof(double));
358- imag2 = (double*)malloc(max(w,h) * sizeof(double));
359+ real2 = (double*)malloc(cxmax(w,h) * sizeof(double));
360+ imag2 = (double*)malloc(cxmax(w,h) * sizeof(double));
361
362 /* Transform the rows */
363 real = (double *)malloc(w * sizeof(double));
364@@ -1617,7 +1617,7 @@ bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage
365
366 /* converting from double to byte, there is a HUGE loss in the dynamics
367 "nn" tries to keep an acceptable SNR, but 8bit=48dB: don't ask more */
368- double nn=pow((double)2,(double)log((double)max(w,h))/(double)log((double)2)-4);
369+ double nn=pow((double)2,(double)log((double)cxmax(w,h))/(double)log((double)2)-4);
370 //reversed gain for reversed transform
371 if (direction==-1) nn=1/nn;
372 //bMagnitude : just to see it on the screen
373@@ -1626,15 +1626,15 @@ bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage
374 for (j=0;j<h;j++) {
375 for (k=0;k<w;k++) {
376 if (bMagnitude){
377- tmpReal->SetPixelIndex(k,j,(BYTE)max(0,min(255,(nn*(3+log(_cabs(grid[k][j])))))));
378+ tmpReal->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(nn*(3+log(_cabs(grid[k][j])))))));
379 if (grid[k][j].x==0){
380- tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128+(atan(grid[k][j].y/0.0000000001)*nn)))));
381+ tmpImag->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128+(atan(grid[k][j].y/0.0000000001)*nn)))));
382 } else {
383- tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128+(atan(grid[k][j].y/grid[k][j].x)*nn)))));
384+ tmpImag->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128+(atan(grid[k][j].y/grid[k][j].x)*nn)))));
385 }
386 } else {
387- tmpReal->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128 + grid[k][j].x*nn))));
388- tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128 + grid[k][j].y*nn))));
389+ tmpReal->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128 + grid[k][j].x*nn))));
390+ tmpImag->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128 + grid[k][j].y*nn))));
391 }
392 }
393 }
394@@ -1922,7 +1922,7 @@ bool CxImage::RepairChannel(CxImage *ch, float radius)
395
396 correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
397
398- tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
399+ tmp.BlindSetPixelIndex(x,y,(BYTE)cxmin(255,cxmax(0,(xy0 + radius * correction + 0.5))));
400 }
401 }
402
403@@ -1943,7 +1943,7 @@ bool CxImage::RepairChannel(CxImage *ch, float radius)
404
405 correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
406
407- tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
408+ tmp.BlindSetPixelIndex(x,y,(BYTE)cxmin(255,cxmax(0,(xy0 + radius * correction + 0.5))));
409 }
410 }
411 for (x=0;x<=w;x+=w){
412@@ -1963,7 +1963,7 @@ bool CxImage::RepairChannel(CxImage *ch, float radius)
413
414 correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
415
416- tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
417+ tmp.BlindSetPixelIndex(x,y,(BYTE)cxmin(255,cxmax(0,(xy0 + radius * correction + 0.5))));
418 }
419 }
420
421@@ -2621,8 +2621,8 @@ bool CxImage::SelectiveBlur(float radius, BYTE threshold, CxImage* iDst)
422 }
423
424 //build the difference mask
425- BYTE thresh_dw = (BYTE)max( 0 ,(int)(128 - threshold));
426- BYTE thresh_up = (BYTE)min(255,(int)(128 + threshold));
427+ BYTE thresh_dw = (BYTE)cxmax( 0 ,(int)(128 - threshold));
428+ BYTE thresh_up = (BYTE)cxmin(255,(int)(128 + threshold));
429 long kernel[]={-100,-100,-100,-100,801,-100,-100,-100,-100};
430 if (!Tmp.Filter(kernel,3,800,128)){
431 delete [] pPalette;
432@@ -2755,7 +2755,7 @@ bool CxImage::UnsharpMask(float radius /*= 5.0*/, float amount /*= 0.5*/, int th
433 if (abs(diff) < threshold){
434 dest_row[z] = cur_row[z];
435 } else {
436- dest_row[z] = (BYTE)min(255, max(0,(int)(cur_row[z] + amount * diff)));
437+ dest_row[z] = (BYTE)cxmin(255, cxmax(0,(int)(cur_row[z] + amount * diff)));
438 }
439 }
440 }
441@@ -2952,7 +2952,7 @@ bool CxImage::RedEyeRemove(float strength)
442 float a = 1.0f-5.0f*((float)((x-0.5f*(xmax+xmin))*(x-0.5f*(xmax+xmin))+(y-0.5f*(ymax+ymin))*(y-0.5f*(ymax+ymin))))/((float)((xmax-xmin)*(ymax-ymin)));
443 if (a<0) a=0;
444 color = BlindGetPixelColor(x,y);
445- color.rgbRed = (BYTE)(a*min(color.rgbGreen,color.rgbBlue)+(1.0f-a)*color.rgbRed);
446+ color.rgbRed = (BYTE)(a*cxmin(color.rgbGreen,color.rgbBlue)+(1.0f-a)*color.rgbRed);
447 BlindSetPixelColor(x,y,color);
448 }
449 }
450@@ -2990,7 +2990,7 @@ bool CxImage::Saturate(const long saturation, const long colorspace)
451 case 1:
452 {
453 for (int i=0;i<256;i++) {
454- cTable[i] = (BYTE)max(0,min(255,(int)(i + saturation)));
455+ cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)(i + saturation)));
456 }
457 for(long y=ymin; y<ymax; y++){
458 info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
459@@ -3012,7 +3012,7 @@ bool CxImage::Saturate(const long saturation, const long colorspace)
460 case 2:
461 {
462 for (int i=0;i<256;i++) {
463- cTable[i] = (BYTE)max(0,min(255,(int)((i-128)*(100 + saturation)/100.0f + 128.5f)));
464+ cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)((i-128)*(100 + saturation)/100.0f + 128.5f)));
465 }
466 for(long y=ymin; y<ymax; y++){
467 info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
468@@ -3242,10 +3242,10 @@ int CxImage::OptimalThreshold(long method, RECT * pBox, CxImage* pContrastMask)
469
470 long xmin,xmax,ymin,ymax;
471 if (pBox){
472- xmin = max(pBox->left,0);
473- xmax = min(pBox->right,head.biWidth);
474- ymin = max(pBox->bottom,0);
475- ymax = min(pBox->top,head.biHeight);
476+ xmin = cxmax(pBox->left,0);
477+ xmax = cxmin(pBox->right,head.biWidth);
478+ ymin = cxmax(pBox->bottom,0);
479+ ymax = cxmin(pBox->top,head.biHeight);
480 } else {
481 xmin = ymin = 0;
482 xmax = head.biWidth; ymax=head.biHeight;
483@@ -3463,7 +3463,7 @@ bool CxImage::AdaptiveThreshold(long method, long nBoxSize, CxImage* pContrastMa
484 r.top = r.bottom + nBoxSize;
485 int threshold = OptimalThreshold(method, &r, pContrastMask);
486 if (threshold <0) return false;
487- mask.SetPixelIndex(x,y,(BYTE)max(0,min(255,nBias+((1.0f-fGlobalLocalBalance)*threshold + fGlobalLocalBalance*globalthreshold))));
488+ mask.SetPixelIndex(x,y,(BYTE)cxmax(0,cxmin(255,nBias+((1.0f-fGlobalLocalBalance)*threshold + fGlobalLocalBalance*globalthreshold))));
489 }
490 }
491
492@@ -3490,10 +3490,6 @@ bool CxImage::AdaptiveThreshold(long method, long nBoxSize, CxImage* pContrastMa
493 * Note: nOpacity=0 && bSelectFilledArea=true act as a "magic wand"
494 * \return true if everything is ok
495 */
496-#if defined(XBMC) && !defined(_WIN32)
497-int max(int a, int b) { return a > b ? a : b; }
498-int min(int a, int b) { return a < b ? a : b; }
499-#endif
500
501 bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFillColor, const BYTE nTolerance,
502 BYTE nOpacity, const bool bSelectFilledArea, const BYTE nSelectionLevel)
503@@ -3538,8 +3534,8 @@ bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFil
504 if (IsIndexed()){ //--- Generic indexed image, no tolerance OR Grayscale image with tolerance
505 BYTE idxRef = GetPixelIndex(xStart,yStart);
506 BYTE idxFill = GetNearestIndex(cFillColor);
507- BYTE idxMin = (BYTE)min(255, max(0,(int)(idxRef - nTolerance)));
508- BYTE idxMax = (BYTE)min(255, max(0,(int)(idxRef + nTolerance)));
509+ BYTE idxMin = (BYTE)cxmin(255, cxmax(0,(int)(idxRef - nTolerance)));
510+ BYTE idxMax = (BYTE)cxmin(255, cxmax(0,(int)(idxRef + nTolerance)));
511
512 while(!q.empty())
513 {
514@@ -3575,12 +3571,12 @@ bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFil
515 } else { //--- RGB image
516 RGBQUAD cRef = GetPixelColor(xStart,yStart);
517 RGBQUAD cRefMin, cRefMax;
518- cRefMin.rgbRed = (BYTE)min(255, max(0,(int)(cRef.rgbRed - nTolerance)));
519- cRefMin.rgbGreen = (BYTE)min(255, max(0,(int)(cRef.rgbGreen - nTolerance)));
520- cRefMin.rgbBlue = (BYTE)min(255, max(0,(int)(cRef.rgbBlue - nTolerance)));
521- cRefMax.rgbRed = (BYTE)min(255, max(0,(int)(cRef.rgbRed + nTolerance)));
522- cRefMax.rgbGreen = (BYTE)min(255, max(0,(int)(cRef.rgbGreen + nTolerance)));
523- cRefMax.rgbBlue = (BYTE)min(255, max(0,(int)(cRef.rgbBlue + nTolerance)));
524+ cRefMin.rgbRed = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbRed - nTolerance)));
525+ cRefMin.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbGreen - nTolerance)));
526+ cRefMin.rgbBlue = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbBlue - nTolerance)));
527+ cRefMax.rgbRed = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbRed + nTolerance)));
528+ cRefMax.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbGreen + nTolerance)));
529+ cRefMax.rgbBlue = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbBlue + nTolerance)));
530
531 while(!q.empty())
532 {
533diff --git a/lib/cximage-6.0/CxImage/ximage.cpp b/lib/cximage-6.0/CxImage/ximage.cpp
534index e81d3c6..26c6993 100644
535--- a/lib/cximage-6.0/CxImage/ximage.cpp
536+++ b/lib/cximage-6.0/CxImage/ximage.cpp
537@@ -460,7 +460,7 @@ bool CxImage::CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dw
538 src+=4;
539 }
540 } else {
541- memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
542+ memcpy(dst,src,cxmin(info.dwEffWidth,dwBytesperline));
543 }
544 }
545 return true;
546@@ -500,7 +500,7 @@ bool CxImage::CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWOR
547 src+=4;
548 }
549 } else {
550- memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
551+ memcpy(dst,src,cxmin(info.dwEffWidth,dwBytesperline));
552 }
553 }
554 }
555diff --git a/lib/cximage-6.0/CxImage/ximagif.cpp b/lib/cximage-6.0/CxImage/ximagif.cpp
556index b89e061..64b1ccc 100644
557--- a/lib/cximage-6.0/CxImage/ximagif.cpp
558+++ b/lib/cximage-6.0/CxImage/ximagif.cpp
559@@ -478,7 +478,7 @@ bool CxImageGIF::Encode(CxFile * fp, CxImage ** pImages, int pagecount, bool bLo
560 ghost.EncodeHeader(fp);
561
562 if (m_loops!=1){
563- ghost.SetLoops(max(0,m_loops-1));
564+ ghost.SetLoops(cxmax(0,m_loops-1));
565 ghost.EncodeLoopExtension(fp);
566 }
567
568@@ -1340,10 +1340,10 @@ void CxImageGIF::GetComment(char* sz_comment_out)
569 ////////////////////////////////////////////////////////////////////////////////
570 void CxImageGIF::GifMix(CxImage & imgsrc2, struct_image & imgdesc)
571 {
572- long ymin = max(0,(long)(GetHeight()-imgdesc.t - imgdesc.h));
573+ long ymin = cxmax(0,(long)(GetHeight()-imgdesc.t - imgdesc.h));
574 long ymax = GetHeight()-imgdesc.t;
575 long xmin = imgdesc.l;
576- long xmax = min(GetWidth(), (DWORD)(imgdesc.l + imgdesc.w));
577+ long xmax = cxmin(GetWidth(), (DWORD)(imgdesc.l + imgdesc.w));
578
579 long ibg2= imgsrc2.GetTransIndex();
580 BYTE i2;
581diff --git a/lib/cximage-6.0/CxImage/ximahist.cpp b/lib/cximage-6.0/CxImage/ximahist.cpp
582index a2aed03..5391107 100644
583--- a/lib/cximage-6.0/CxImage/ximahist.cpp
584+++ b/lib/cximage-6.0/CxImage/ximahist.cpp
585@@ -110,7 +110,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
586 // calculate LUT
587 BYTE lut[256];
588 for (x = 0; x <256; x++){
589- lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
590+ lut[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minc) / (maxc - minc))));
591 }
592
593 for (y=0; y<head.biHeight; y++) {
594@@ -152,7 +152,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
595 // calculate LUT
596 BYTE lut[256];
597 for (x = 0; x <256; x++){
598- lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
599+ lut[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minc) / (maxc - minc))));
600 }
601
602 // normalize image
603@@ -225,7 +225,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
604 BYTE range = maxR - minR;
605 if (range != 0) {
606 for (x = 0; x <256; x++){
607- lutR[x] = (BYTE)max(0,min(255,(255 * (x - minR) / range)));
608+ lutR[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minR) / range)));
609 }
610 } else lutR[minR] = minR;
611
612@@ -233,7 +233,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
613 range = maxG - minG;
614 if (range != 0) {
615 for (x = 0; x <256; x++){
616- lutG[x] = (BYTE)max(0,min(255,(255 * (x - minG) / range)));
617+ lutG[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minG) / range)));
618 }
619 } else lutG[minG] = minG;
620
621@@ -241,7 +241,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
622 range = maxB - minB;
623 if (range != 0) {
624 for (x = 0; x <256; x++){
625- lutB[x] = (BYTE)max(0,min(255,(255 * (x - minB) / range)));
626+ lutB[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minB) / range)));
627 }
628 } else lutB[minB] = minB;
629
630@@ -292,7 +292,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
631 // calculate LUT
632 BYTE lut[256];
633 for (x = 0; x <256; x++){
634- lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
635+ lut[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minc) / (maxc - minc))));
636 }
637
638 for(y=0; y<head.biHeight; y++){
639diff --git a/lib/cximage-6.0/CxImage/ximaint.cpp b/lib/cximage-6.0/CxImage/ximaint.cpp
640index 989d76c..5d49213 100644
641--- a/lib/cximage-6.0/CxImage/ximaint.cpp
642+++ b/lib/cximage-6.0/CxImage/ximaint.cpp
643@@ -26,8 +26,8 @@ void CxImage::OverflowCoordinates(long &x, long &y, OverflowMethod const ofMetho
644 switch (ofMethod) {
645 case OM_REPEAT:
646 //clip coordinates
647- x=max(x,0); x=min(x, head.biWidth-1);
648- y=max(y,0); y=min(y, head.biHeight-1);
649+ x=cxmax(x,0); x=cxmin(x, head.biWidth-1);
650+ y=cxmax(y,0); y=cxmin(y, head.biHeight-1);
651 break;
652 case OM_WRAP:
653 //wrap coordinates
654@@ -59,8 +59,8 @@ void CxImage::OverflowCoordinates(float &x, float &y, OverflowMethod const ofMet
655 switch (ofMethod) {
656 case OM_REPEAT:
657 //clip coordinates
658- x=max(x,0); x=min(x, head.biWidth-1);
659- y=max(y,0); y=min(y, head.biHeight-1);
660+ x=cxmax(x,0); x=cxmin(x, head.biWidth-1);
661+ y=cxmax(y,0); y=cxmin(y, head.biHeight-1);
662 break;
663 case OM_WRAP:
664 //wrap coordinates
665diff --git a/lib/cximage-6.0/CxImage/ximaiter.h b/lib/cximage-6.0/CxImage/ximaiter.h
666index 9788919..01a720b 100644
667--- a/lib/cximage-6.0/CxImage/ximaiter.h
668+++ b/lib/cximage-6.0/CxImage/ximaiter.h
669@@ -140,7 +140,7 @@ inline void CImageIterator::SetY(int y)
670 inline void CImageIterator::SetRow(BYTE *buf, int n)
671 {
672 if (n<0) n = (int)ima->GetEffWidth();
673- else n = min(n,(int)ima->GetEffWidth());
674+ else n = cxmin(n,(int)ima->GetEffWidth());
675
676 if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n);
677 }
678@@ -148,7 +148,7 @@ inline void CImageIterator::SetRow(BYTE *buf, int n)
679 inline void CImageIterator::GetRow(BYTE *buf, int n)
680 {
681 if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0))
682- memcpy(buf,IterImage,min(n,(int)ima->GetEffWidth()));
683+ memcpy(buf,IterImage,cxmin(n,(int)ima->GetEffWidth()));
684 }
685 /////////////////////////////////////////////////////////////////////
686 inline BYTE* CImageIterator::GetRow()
687diff --git a/lib/cximage-6.0/CxImage/ximajbg.cpp b/lib/cximage-6.0/CxImage/ximajbg.cpp
688index 06fb9bf..8a01e28 100644
689--- a/lib/cximage-6.0/CxImage/ximajbg.cpp
690+++ b/lib/cximage-6.0/CxImage/ximajbg.cpp
691@@ -145,7 +145,7 @@ bool CxImageJBG::Encode(CxFile * hFile)
692 jbg_enc_init(&jbig_state, w, h, planes, &buffer, jbig_data_out, hFile);
693
694 //jbg_enc_layers(&jbig_state, 2);
695- //jbg_enc_lrlmax(&jbig_state, 800, 600);
696+ //jbg_enc_lrlcxmax(&jbig_state, 800, 600);
697
698 // Specify a few other options (each is ignored if negative)
699 int dl = -1, dh = -1, d = -1, l0 = -1, mx = -1;
700diff --git a/lib/cximage-6.0/CxImage/ximapal.cpp b/lib/cximage-6.0/CxImage/ximapal.cpp
701index b3bd3da..3788c98 100644
702--- a/lib/cximage-6.0/CxImage/ximapal.cpp
703+++ b/lib/cximage-6.0/CxImage/ximapal.cpp
704@@ -398,8 +398,8 @@ void CxImage::RGBtoBGR(BYTE *buffer, int length)
705 {
706 if (buffer && (head.biClrUsed==0)){
707 BYTE temp;
708- length = min(length,(int)info.dwEffWidth);
709- length = min(length,(int)(3*head.biWidth));
710+ length = cxmin(length,(int)info.dwEffWidth);
711+ length = cxmin(length,(int)(3*head.biWidth));
712 for (int i=0;i<length;i+=3){
713 temp = buffer[i]; buffer[i] = buffer[i+2]; buffer[i+2] = temp;
714 }
715@@ -444,7 +444,7 @@ void CxImage::SetPalette(DWORD n, BYTE *r, BYTE *g, BYTE *b)
716 if (!g) g = r;
717 if (!b) b = g;
718 RGBQUAD* ppal=GetPalette();
719- DWORD m=min(n,head.biClrUsed);
720+ DWORD m=cxmin(n,head.biClrUsed);
721 for (DWORD i=0; i<m;i++){
722 ppal[i].rgbRed=r[i];
723 ppal[i].rgbGreen=g[i];
724@@ -457,7 +457,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
725 {
726 if ((!rgb)||(pDib==NULL)||(head.biClrUsed==0)) return;
727 RGBQUAD* ppal=GetPalette();
728- DWORD m=min(nColors,head.biClrUsed);
729+ DWORD m=cxmin(nColors,head.biClrUsed);
730 for (DWORD i=0; i<m;i++){
731 ppal[i].rgbRed=rgb[i].r;
732 ppal[i].rgbGreen=rgb[i].g;
733@@ -469,7 +469,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
734 void CxImage::SetPalette(RGBQUAD* pPal,DWORD nColors)
735 {
736 if ((pPal==NULL)||(pDib==NULL)||(head.biClrUsed==0)) return;
737- memcpy(GetPalette(),pPal,min(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
738+ memcpy(GetPalette(),pPal,cxmin(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
739 info.last_c_isvalid = false;
740 }
741 ////////////////////////////////////////////////////////////////////////////////
742@@ -654,10 +654,10 @@ void CxImage::SetClrImportant(DWORD ncolors)
743
744 switch(head.biBitCount){
745 case 1:
746- head.biClrImportant = min(ncolors,2);
747+ head.biClrImportant = cxmin(ncolors,2);
748 break;
749 case 4:
750- head.biClrImportant = min(ncolors,16);
751+ head.biClrImportant = cxmin(ncolors,16);
752 break;
753 case 8:
754 head.biClrImportant = ncolors;
755diff --git a/lib/cximage-6.0/CxImage/ximapng.cpp b/lib/cximage-6.0/CxImage/ximapng.cpp
756index a58441c..4b5cc50 100644
757--- a/lib/cximage-6.0/CxImage/ximapng.cpp
758+++ b/lib/cximage-6.0/CxImage/ximapng.cpp
759@@ -206,9 +206,9 @@ bool CxImagePNG::Decode(CxFile *hFile)
760 } else SetGrayPalette(); //<DP> needed for grayscale PNGs
761
762 #ifdef USE_NEW_LIBPNG_API
763- int nshift = max(0,(_bit_depth>>3)-1)<<3;
764+ int nshift = cxmax(0,(_bit_depth>>3)-1)<<3;
765 #else
766- int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3;
767+ int nshift = cxmax(0,(info_ptr->bit_depth>>3)-1)<<3;
768 #endif
769
770 #ifdef USE_NEW_LIBPNG_API
771@@ -255,10 +255,10 @@ bool CxImagePNG::Decode(CxFile *hFile)
772 if (pal){
773 DWORD ip;
774 #ifdef USE_NEW_LIBPNG_API
775- for (ip=0;ip<min(head.biClrUsed,(unsigned long)_num_trans);ip++)
776+ for (ip=0;ip<cxmin(head.biClrUsed,(unsigned long)_num_trans);ip++)
777 pal[ip].rgbReserved=_trans_alpha[ip];
778 #else
779- for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
780+ for (ip=0;ip<cxmin(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
781 #if PNG_LIBPNG_VER > 10399
782 pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
783 #else
784@@ -737,9 +737,9 @@ bool CxImagePNG::Encode(CxFile *hFile)
785 #endif // CXIMAGE_SUPPORT_ALPHA // <vho>
786
787 #ifdef USE_NEW_LIBPNG_API
788- int row_size = max(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
789+ int row_size = cxmax(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
790 #else
791- int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
792+ int row_size = cxmax(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
793 info_ptr->rowbytes = row_size;
794 #endif
795 BYTE *row_pointers = new BYTE[row_size];
796diff --git a/lib/cximage-6.0/CxImage/ximaraw.cpp b/lib/cximage-6.0/CxImage/ximaraw.cpp
797index fd86f96..52d964d 100644
798--- a/lib/cximage-6.0/CxImage/ximaraw.cpp
799+++ b/lib/cximage-6.0/CxImage/ximaraw.cpp
800@@ -216,7 +216,7 @@ bool CxImageRAW::Decode(CxFile *hFile)
801
802 DWORD size = dcr.width * (dcr.colors*dcr.opt.output_bps/8);
803 RGBtoBGR(ppm,size);
804- memcpy(GetBits(dcr.height - 1 - row), ppm, min(size,GetEffWidth()));
805+ memcpy(GetBits(dcr.height - 1 - row), ppm, cxmin(size,GetEffWidth()));
806 }
807 free (ppm);
808
809@@ -298,7 +298,7 @@ bool CxImageRAW::GetExifThumbnail(const char *filename, const char *outname, int
810 // Resizing.
811 if (image.GetWidth() > 256 || image.GetHeight() > 256)
812 {
813- float amount = 256.0f / max(image.GetWidth(), image.GetHeight());
814+ float amount = 256.0f / cxmax(image.GetWidth(), image.GetHeight());
815 image.Resample((long)(image.GetWidth() * amount), (long)(image.GetHeight() * amount), 0);
816 }
817
818diff --git a/lib/cximage-6.0/CxImage/ximasel.cpp b/lib/cximage-6.0/CxImage/ximasel.cpp
819index 3a7c9a1..37cd10f 100644
820--- a/lib/cximage-6.0/CxImage/ximasel.cpp
821+++ b/lib/cximage-6.0/CxImage/ximasel.cpp
822@@ -113,15 +113,15 @@ bool CxImage::SelectionAddRect(RECT r, BYTE level)
823 if (r.left<r.right) {r2.left=r.left; r2.right=r.right; } else {r2.left=r.right ; r2.right=r.left; }
824 if (r.bottom<r.top) {r2.bottom=r.bottom; r2.top=r.top; } else {r2.bottom=r.top ; r2.top=r.bottom; }
825
826- if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = max(0L,min(head.biHeight,r2.top+1));
827- if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = max(0L,min(head.biWidth,r2.left));
828- if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = max(0L,min(head.biWidth,r2.right+1));
829- if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = max(0L,min(head.biHeight,r2.bottom));
830+ if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = cxmax(0L,cxmin(head.biHeight,r2.top+1));
831+ if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = cxmax(0L,cxmin(head.biWidth,r2.left));
832+ if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = cxmax(0L,cxmin(head.biWidth,r2.right+1));
833+ if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = cxmax(0L,cxmin(head.biHeight,r2.bottom));
834
835- long ymin = max(0L,min(head.biHeight,r2.bottom));
836- long ymax = max(0L,min(head.biHeight,r2.top+1));
837- long xmin = max(0L,min(head.biWidth,r2.left));
838- long xmax = max(0L,min(head.biWidth,r2.right+1));
839+ long ymin = cxmax(0L,cxmin(head.biHeight,r2.bottom));
840+ long ymax = cxmax(0L,cxmin(head.biHeight,r2.top+1));
841+ long xmin = cxmax(0L,cxmin(head.biWidth,r2.left));
842+ long xmax = cxmax(0L,cxmin(head.biWidth,r2.right+1));
843
844 for (long y=ymin; y<ymax; y++)
845 memset(pSelection + xmin + y * head.biWidth, level, xmax-xmin);
846@@ -144,18 +144,18 @@ bool CxImage::SelectionAddEllipse(RECT r, BYTE level)
847 long xcenter = (r.right + r.left)/2;
848 long ycenter = (r.top + r.bottom)/2;
849
850- if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = max(0L,min(head.biWidth,(xcenter - xradius)));
851- if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = max(0L,min(head.biWidth,(xcenter + xradius + 1)));
852- if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = max(0L,min(head.biHeight,(ycenter - yradius)));
853- if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = max(0L,min(head.biHeight,(ycenter + yradius + 1)));
854+ if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = cxmax(0L,cxmin(head.biWidth,(xcenter - xradius)));
855+ if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = cxmax(0L,cxmin(head.biWidth,(xcenter + xradius + 1)));
856+ if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = cxmax(0L,cxmin(head.biHeight,(ycenter - yradius)));
857+ if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = cxmax(0L,cxmin(head.biHeight,(ycenter + yradius + 1)));
858
859- long xmin = max(0L,min(head.biWidth,xcenter - xradius));
860- long xmax = max(0L,min(head.biWidth,xcenter + xradius + 1));
861- long ymin = max(0L,min(head.biHeight,ycenter - yradius));
862- long ymax = max(0L,min(head.biHeight,ycenter + yradius + 1));
863+ long xmin = cxmax(0L,cxmin(head.biWidth,xcenter - xradius));
864+ long xmax = cxmax(0L,cxmin(head.biWidth,xcenter + xradius + 1));
865+ long ymin = cxmax(0L,cxmin(head.biHeight,ycenter - yradius));
866+ long ymax = cxmax(0L,cxmin(head.biHeight,ycenter + yradius + 1));
867
868 long y,yo;
869- for (y=ymin; y<min(ycenter,ymax); y++){
870+ for (y=ymin; y<cxmin(ycenter,ymax); y++){
871 for (long x=xmin; x<xmax; x++){
872 yo = (long)(ycenter - yradius * sqrt(1-pow((float)(x - xcenter)/(float)xradius,2)));
873 if (yo<y) pSelection[x + y * head.biWidth] = level;
874@@ -268,10 +268,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
875 RECT r2;
876 if (current->x < next->x) {r2.left=current->x; r2.right=next->x; } else {r2.left=next->x ; r2.right=current->x; }
877 if (current->y < next->y) {r2.bottom=current->y; r2.top=next->y; } else {r2.bottom=next->y ; r2.top=current->y; }
878- if (localbox.top < r2.top) localbox.top = max(0L,min(head.biHeight-1,r2.top+1));
879- if (localbox.left > r2.left) localbox.left = max(0L,min(head.biWidth-1,r2.left-1));
880- if (localbox.right < r2.right) localbox.right = max(0L,min(head.biWidth-1,r2.right+1));
881- if (localbox.bottom > r2.bottom) localbox.bottom = max(0L,min(head.biHeight-1,r2.bottom-1));
882+ if (localbox.top < r2.top) localbox.top = cxmax(0L,cxmin(head.biHeight-1,r2.top+1));
883+ if (localbox.left > r2.left) localbox.left = cxmax(0L,cxmin(head.biWidth-1,r2.left-1));
884+ if (localbox.right < r2.right) localbox.right = cxmax(0L,cxmin(head.biWidth-1,r2.right+1));
885+ if (localbox.bottom > r2.bottom) localbox.bottom = cxmax(0L,cxmin(head.biHeight-1,r2.bottom-1));
886
887 i++;
888 }
889@@ -385,10 +385,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
890 for (x=localbox.left; x<=localbox.right; x++)
891 if (plocal[x + yoffset]!=1) pSelection[x + yoffset]=level;
892 }
893- if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = min(head.biHeight,localbox.top + 1);
894- if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = min(head.biWidth,localbox.left);
895- if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = min(head.biWidth,localbox.right + 1);
896- if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = min(head.biHeight,localbox.bottom);
897+ if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = cxmin(head.biHeight,localbox.top + 1);
898+ if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = cxmin(head.biWidth,localbox.left);
899+ if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = cxmin(head.biWidth,localbox.right + 1);
900+ if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = cxmin(head.biHeight,localbox.bottom);
901
902 free(plocal);
903 free(pix);
904diff --git a/lib/cximage-6.0/CxImage/ximath.cpp b/lib/cximage-6.0/CxImage/ximath.cpp
905index 37533e2..f84eb72 100644
906--- a/lib/cximage-6.0/CxImage/ximath.cpp
907+++ b/lib/cximage-6.0/CxImage/ximath.cpp
908@@ -64,10 +64,10 @@ CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const
909 */
910 {
911 CxRect2 cs;
912- cs.botLeft.x=max(botLeft.x, r2.botLeft.x);
913- cs.botLeft.y=max(botLeft.y, r2.botLeft.y);
914- cs.topRight.x=min(topRight.x, r2.topRight.x);
915- cs.topRight.y=min(topRight.y, r2.topRight.y);
916+ cs.botLeft.x=cxmax(botLeft.x, r2.botLeft.x);
917+ cs.botLeft.y=cxmax(botLeft.y, r2.botLeft.y);
918+ cs.topRight.x=cxmin(topRight.x, r2.topRight.x);
919+ cs.topRight.y=cxmin(topRight.y, r2.topRight.y);
920 if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) {
921 return cs;
922 } else {
923diff --git a/lib/cximage-6.0/CxImage/ximatif.cpp b/lib/cximage-6.0/CxImage/ximatif.cpp
924index 658392a..002766c 100644
925--- a/lib/cximage-6.0/CxImage/ximatif.cpp
926+++ b/lib/cximage-6.0/CxImage/ximatif.cpp
927@@ -470,9 +470,9 @@ bool CxImageTIF::Decode(CxFile * hFile)
928 if ( cb > 0.00304 ) cb = 1.055 * pow(cb,0.41667) - 0.055;
929 else cb = 12.92 * cb;
930
931- c.rgbRed =(BYTE)max(0,min(255,(int)(cr*255)));
932- c.rgbGreen=(BYTE)max(0,min(255,(int)(cg*255)));
933- c.rgbBlue =(BYTE)max(0,min(255,(int)(cb*255)));
934+ c.rgbRed =(BYTE)cxmax(0,cxmin(255,(int)(cr*255)));
935+ c.rgbGreen=(BYTE)cxmax(0,cxmin(255,(int)(cg*255)));
936+ c.rgbBlue =(BYTE)cxmax(0,cxmin(255,(int)(cb*255)));
937
938 SetPixelColor(xi,yi,c);
939 #if CXIMAGE_SUPPORT_ALPHA
940diff --git a/lib/cximage-6.0/CxImage/ximatran.cpp b/lib/cximage-6.0/CxImage/ximatran.cpp
941index 64a71e7..84d5e03 100644
942--- a/lib/cximage-6.0/CxImage/ximatran.cpp
943+++ b/lib/cximage-6.0/CxImage/ximatran.cpp
944@@ -302,12 +302,12 @@ bool CxImage::RotateLeft(CxImage* iDst)
945 for (ys = 0; ys < newHeight; ys+=RBLOCK) {
946 if (head.biBitCount==24) {
947 //RGB24 optimized pixel access:
948- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){ //do rotation
949+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){ //do rotation
950 info.nProgress = (long)(100*x/newWidth);
951 x2=newWidth-x-1;
952 dstPtr = (BYTE*) imgDest.BlindGetPixelPointer(x,ys);
953 srcPtr = (BYTE*) BlindGetPixelPointer(ys, x2);
954- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
955+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
956 //imgDest.SetPixelColor(x, y, GetPixelColor(y, x2));
957 *(dstPtr) = *(srcPtr);
958 *(dstPtr+1) = *(srcPtr+1);
959@@ -318,19 +318,19 @@ bool CxImage::RotateLeft(CxImage* iDst)
960 }//for x
961 } else {
962 //anything else than 24bpp (and 1bpp): palette
963- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
964+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
965 info.nProgress = (long)(100*x/newWidth); //<Anatoly Ivasyuk>
966 x2=newWidth-x-1;
967- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
968+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
969 imgDest.SetPixelIndex(x, y, BlindGetPixelIndex(y, x2));
970 }//for y
971 }//for x
972 }//if (version selection)
973 #if CXIMAGE_SUPPORT_ALPHA
974 if (AlphaIsValid()) {
975- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
976+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
977 x2=newWidth-x-1;
978- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
979+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
980 imgDest.AlphaSet(x,y,BlindAlphaGet(y, x2));
981 }//for y
982 }//for x
983@@ -343,9 +343,9 @@ bool CxImage::RotateLeft(CxImage* iDst)
984 imgDest.info.rSelectionBox.right = newWidth-info.rSelectionBox.bottom;
985 imgDest.info.rSelectionBox.bottom = info.rSelectionBox.left;
986 imgDest.info.rSelectionBox.top = info.rSelectionBox.right;
987- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
988+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
989 x2=newWidth-x-1;
990- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
991+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
992 imgDest.SelectionSet(x,y,BlindSelectionGet(y, x2));
993 }//for y
994 }//for x
995@@ -447,12 +447,12 @@ bool CxImage::RotateRight(CxImage* iDst)
996 for (ys = 0; ys < newHeight; ys+=RBLOCK) {
997 if (head.biBitCount==24) {
998 //RGB24 optimized pixel access:
999- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
1000+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
1001 info.nProgress = (long)(100*y/newHeight); //<Anatoly Ivasyuk>
1002 y2=newHeight-y-1;
1003 dstPtr = (BYTE*) imgDest.BlindGetPixelPointer(xs,y);
1004 srcPtr = (BYTE*) BlindGetPixelPointer(y2, xs);
1005- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
1006+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
1007 //imgDest.SetPixelColor(x, y, GetPixelColor(y2, x));
1008 *(dstPtr) = *(srcPtr);
1009 *(dstPtr+1) = *(srcPtr+1);
1010@@ -463,19 +463,19 @@ bool CxImage::RotateRight(CxImage* iDst)
1011 }//for y
1012 } else {
1013 //anything else than BW & RGB24: palette
1014- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
1015+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
1016 info.nProgress = (long)(100*y/newHeight); //<Anatoly Ivasyuk>
1017 y2=newHeight-y-1;
1018- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
1019+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
1020 imgDest.SetPixelIndex(x, y, BlindGetPixelIndex(y2, x));
1021 }//for x
1022 }//for y
1023 }//if
1024 #if CXIMAGE_SUPPORT_ALPHA
1025 if (AlphaIsValid()){
1026- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
1027+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
1028 y2=newHeight-y-1;
1029- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
1030+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
1031 imgDest.AlphaSet(x,y,BlindAlphaGet(y2, x));
1032 }//for x
1033 }//for y
1034@@ -488,9 +488,9 @@ bool CxImage::RotateRight(CxImage* iDst)
1035 imgDest.info.rSelectionBox.right = info.rSelectionBox.top;
1036 imgDest.info.rSelectionBox.bottom = newHeight-info.rSelectionBox.right;
1037 imgDest.info.rSelectionBox.top = newHeight-info.rSelectionBox.left;
1038- for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
1039+ for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
1040 y2=newHeight-y-1;
1041- for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
1042+ for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
1043 imgDest.SelectionSet(x,y,BlindSelectionGet(y2, x));
1044 }//for x
1045 }//for y
1046@@ -608,10 +608,10 @@ bool CxImage::Rotate(float angle, CxImage* iDst)
1047 newP4.x = (float)(p4.x*cos_angle - p4.y*sin_angle);
1048 newP4.y = (float)(p4.x*sin_angle + p4.y*cos_angle);
1049
1050- leftTop.x = min(min(newP1.x,newP2.x),min(newP3.x,newP4.x));
1051- leftTop.y = min(min(newP1.y,newP2.y),min(newP3.y,newP4.y));
1052- rightBottom.x = max(max(newP1.x,newP2.x),max(newP3.x,newP4.x));
1053- rightBottom.y = max(max(newP1.y,newP2.y),max(newP3.y,newP4.y));
1054+ leftTop.x = cxmin(cxmin(newP1.x,newP2.x),cxmin(newP3.x,newP4.x));
1055+ leftTop.y = cxmin(cxmin(newP1.y,newP2.y),cxmin(newP3.y,newP4.y));
1056+ rightBottom.x = cxmax(cxmax(newP1.x,newP2.x),cxmax(newP3.x,newP4.x));
1057+ rightBottom.y = cxmax(cxmax(newP1.y,newP2.y),cxmax(newP3.y,newP4.y));
1058 leftBottom.x = leftTop.x;
1059 leftBottom.y = rightBottom.y;
1060 rightTop.x = rightBottom.x;
1061@@ -740,10 +740,10 @@ bool CxImage::Rotate2(float angle,
1062 }//if
1063
1064 //(read new dimensions from location of corners)
1065- float minx = (float) min(min(newp[0].x,newp[1].x),min(newp[2].x,newp[3].x));
1066- float miny = (float) min(min(newp[0].y,newp[1].y),min(newp[2].y,newp[3].y));
1067- float maxx = (float) max(max(newp[0].x,newp[1].x),max(newp[2].x,newp[3].x));
1068- float maxy = (float) max(max(newp[0].y,newp[1].y),max(newp[2].y,newp[3].y));
1069+ float minx = (float) cxmin(cxmin(newp[0].x,newp[1].x),cxmin(newp[2].x,newp[3].x));
1070+ float miny = (float) cxmin(cxmin(newp[0].y,newp[1].y),cxmin(newp[2].y,newp[3].y));
1071+ float maxx = (float) cxmax(cxmax(newp[0].x,newp[1].x),cxmax(newp[2].x,newp[3].x));
1072+ float maxy = (float) cxmax(cxmax(newp[0].y,newp[1].y),cxmax(newp[2].y,newp[3].y));
1073 int newWidth = (int) floor(maxx-minx+0.5f);
1074 int newHeight= (int) floor(maxy-miny+0.5f);
1075 float ssx=((maxx+minx)- ((float) newWidth-1))/2.0f; //start for x
1076@@ -1003,12 +1003,12 @@ bool CxImage::Resample(long newx, long newy, int mode, CxImage* iDst)
1077 if (info.nEscape) break;
1078 fY = y * yScale;
1079 ifY = (int)fY;
1080- ifY1 = min(ymax, ifY+1);
1081+ ifY1 = cxmin(ymax, ifY+1);
1082 dy = fY - ifY;
1083 for(long x=0; x<newx; x++){
1084 fX = x * xScale;
1085 ifX = (int)fX;
1086- ifX1 = min(xmax, ifX+1);
1087+ ifX1 = cxmin(xmax, ifX+1);
1088 dx = fX - ifX;
1089 // Interpolate using the four nearest pixels in the source
1090 if (head.biClrUsed){
1091@@ -1328,9 +1328,9 @@ bool CxImage::DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal, DWORD
1092 eb=(long)c.rgbBlue - (long)ce.rgbBlue;
1093
1094 c = GetPixelColor(x+1,y);
1095- c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er*7)/16)));
1096- c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg*7)/16)));
1097- c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb*7)/16)));
1098+ c.rgbRed = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbRed + ((er*7)/16)));
1099+ c.rgbGreen = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbGreen + ((eg*7)/16)));
1100+ c.rgbBlue = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbBlue + ((eb*7)/16)));
1101 SetPixelColor(x+1,y,c);
1102 int coeff=1;
1103 for(int i=-1; i<2; i++){
1104@@ -1343,9 +1343,9 @@ bool CxImage::DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal, DWORD
1105 coeff=1; break;
1106 }
1107 c = GetPixelColor(x+i,y+1);
1108- c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er * coeff)/16)));
1109- c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg * coeff)/16)));
1110- c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb * coeff)/16)));
1111+ c.rgbRed = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbRed + ((er * coeff)/16)));
1112+ c.rgbGreen = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbGreen + ((eg * coeff)/16)));
1113+ c.rgbBlue = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbBlue + ((eb * coeff)/16)));
1114 SetPixelColor(x+i,y+1,c);
1115 }
1116 }
1117@@ -1566,10 +1566,10 @@ bool CxImage::Dither(long method)
1118 }
1119
1120 nlevel = GetPixelIndex(x + 1, y) + (error * 8) / TotalCoeffSum;
1121- level = (BYTE)min(255, max(0, (int)nlevel));
1122+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1123 SetPixelIndex(x + 1, y, level);
1124 nlevel = GetPixelIndex(x + 2, y) + (error * 4) / TotalCoeffSum;
1125- level = (BYTE)min(255, max(0, (int)nlevel));
1126+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1127 SetPixelIndex(x + 2, y, level);
1128 int i;
1129 for (i = -2; i < 3; i++) {
1130@@ -1591,7 +1591,7 @@ bool CxImage::Dither(long method)
1131 break;
1132 }
1133 nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
1134- level = (BYTE)min(255, max(0, (int)nlevel));
1135+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1136 SetPixelIndex(x + i, y + 1, level);
1137 }
1138 }
1139@@ -1620,10 +1620,10 @@ bool CxImage::Dither(long method)
1140 }
1141
1142 nlevel = GetPixelIndex(x + 1, y) + (error * 8) / TotalCoeffSum;
1143- level = (BYTE)min(255, max(0, (int)nlevel));
1144+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1145 SetPixelIndex(x + 1, y, level);
1146 nlevel = GetPixelIndex(x + 2, y) + (error * 4) / TotalCoeffSum;
1147- level = (BYTE)min(255, max(0, (int)nlevel));
1148+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1149 SetPixelIndex(x + 2, y, level);
1150 int i;
1151 for (i = -2; i < 3; i++) {
1152@@ -1645,7 +1645,7 @@ bool CxImage::Dither(long method)
1153 break;
1154 }
1155 nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
1156- level = (BYTE)min(255, max(0, (int)nlevel));
1157+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1158 SetPixelIndex(x + i, y + 1, level);
1159 }
1160 for (i = -2; i < 3; i++) {
1161@@ -1667,7 +1667,7 @@ bool CxImage::Dither(long method)
1162 break;
1163 }
1164 nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
1165- level = (BYTE)min(255, max(0, (int)nlevel));
1166+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1167 SetPixelIndex(x + i, y + 2, level);
1168 }
1169 }
1170@@ -1696,10 +1696,10 @@ bool CxImage::Dither(long method)
1171 }
1172
1173 nlevel = GetPixelIndex(x + 1, y) + (error * 7) / TotalCoeffSum;
1174- level = (BYTE)min(255, max(0, (int)nlevel));
1175+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1176 SetPixelIndex(x + 1, y, level);
1177 nlevel = GetPixelIndex(x + 2, y) + (error * 5) / TotalCoeffSum;
1178- level = (BYTE)min(255, max(0, (int)nlevel));
1179+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1180 SetPixelIndex(x + 2, y, level);
1181 int i;
1182 for (i = -2; i < 3; i++) {
1183@@ -1721,7 +1721,7 @@ bool CxImage::Dither(long method)
1184 break;
1185 }
1186 nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
1187- level = (BYTE)min(255, max(0, (int)nlevel));
1188+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1189 SetPixelIndex(x + i, y + 1, level);
1190 }
1191 for (i = -2; i < 3; i++) {
1192@@ -1743,7 +1743,7 @@ bool CxImage::Dither(long method)
1193 break;
1194 }
1195 nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
1196- level = (BYTE)min(255, max(0, (int)nlevel));
1197+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1198 SetPixelIndex(x + i, y + 2, level);
1199 }
1200 }
1201@@ -1772,10 +1772,10 @@ bool CxImage::Dither(long method)
1202 }
1203
1204 nlevel = GetPixelIndex(x + 1, y) + (error * 5) / TotalCoeffSum;
1205- level = (BYTE)min(255, max(0, (int)nlevel));
1206+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1207 SetPixelIndex(x + 1, y, level);
1208 nlevel = GetPixelIndex(x + 2, y) + (error * 3) / TotalCoeffSum;
1209- level = (BYTE)min(255, max(0, (int)nlevel));
1210+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1211 SetPixelIndex(x + 2, y, level);
1212 int i;
1213 for (i = -2; i < 3; i++) {
1214@@ -1797,7 +1797,7 @@ bool CxImage::Dither(long method)
1215 break;
1216 }
1217 nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
1218- level = (BYTE)min(255, max(0, (int)nlevel));
1219+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1220 SetPixelIndex(x + i, y + 1, level);
1221 }
1222 for (i = -1; i < 2; i++) {
1223@@ -1813,7 +1813,7 @@ bool CxImage::Dither(long method)
1224 break;
1225 }
1226 nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
1227- level = (BYTE)min(255, max(0, (int)nlevel));
1228+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1229 SetPixelIndex(x + i, y + 2, level);
1230 }
1231 }
1232@@ -1845,76 +1845,76 @@ bool CxImage::Dither(long method)
1233 int tmp_index_y = y;
1234 int tmp_coeff = 32;
1235 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1236- level = (BYTE)min(255, max(0, (int)nlevel));
1237+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1238 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1239
1240 tmp_index_x = x - 3;
1241 tmp_index_y = y + 1;
1242 tmp_coeff = 12;
1243 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1244- level = (BYTE)min(255, max(0, (int)nlevel));
1245+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1246 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1247
1248 tmp_index_x = x - 1;
1249 tmp_coeff = 26;
1250 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1251- level = (BYTE)min(255, max(0, (int)nlevel));
1252+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1253 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1254
1255 tmp_index_x = x + 1;
1256 tmp_coeff = 30;
1257 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1258- level = (BYTE)min(255, max(0, (int)nlevel));
1259+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1260 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1261
1262 tmp_index_x = x + 3;
1263 tmp_coeff = 16;
1264 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1265- level = (BYTE)min(255, max(0, (int)nlevel));
1266+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1267 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1268
1269 tmp_index_x = x - 2;
1270 tmp_index_y = y + 2;
1271 tmp_coeff = 12;
1272 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1273- level = (BYTE)min(255, max(0, (int)nlevel));
1274+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1275 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1276
1277 tmp_index_x = x;
1278 tmp_coeff = 26;
1279 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1280- level = (BYTE)min(255, max(0, (int)nlevel));
1281+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1282 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1283
1284 tmp_index_x = x + 2;
1285 tmp_coeff = 12;
1286 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1287- level = (BYTE)min(255, max(0, (int)nlevel));
1288+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1289 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1290
1291 tmp_index_x = x - 3;
1292 tmp_index_y = y + 3;
1293 tmp_coeff = 5;
1294 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1295- level = (BYTE)min(255, max(0, (int)nlevel));
1296+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1297 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1298
1299 tmp_index_x = x - 1;
1300 tmp_coeff = 12;
1301 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1302- level = (BYTE)min(255, max(0, (int)nlevel));
1303+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1304 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1305
1306 tmp_index_x = x + 1;
1307 tmp_coeff = 12;
1308 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1309- level = (BYTE)min(255, max(0, (int)nlevel));
1310+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1311 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1312
1313 tmp_index_x = x + 3;
1314 tmp_coeff = 5;
1315 nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
1316- level = (BYTE)min(255, max(0, (int)nlevel));
1317+ level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
1318 SetPixelIndex(tmp_index_x, tmp_index_y, level);
1319 }
1320 }
1321@@ -1941,7 +1941,7 @@ bool CxImage::Dither(long method)
1322 Bmatrix[i] = (BYTE)(dither);
1323 }
1324
1325- int scale = max(0,(8-2*order));
1326+ int scale = cxmax(0,(8-2*order));
1327 int level;
1328 for (long y=0;y<head.biHeight;y++){
1329 info.nProgress = (long)(100*y/head.biHeight);
1330@@ -1981,7 +1981,7 @@ bool CxImage::Dither(long method)
1331 }
1332
1333 nlevel = GetPixelIndex(x+1,y) + (error * 7)/16;
1334- level = (BYTE)min(255,max(0,(int)nlevel));
1335+ level = (BYTE)cxmin(255,cxmax(0,(int)nlevel));
1336 SetPixelIndex(x+1,y,level);
1337 for(int i=-1; i<2; i++){
1338 switch(i){
1339@@ -1993,7 +1993,7 @@ bool CxImage::Dither(long method)
1340 coeff=1; break;
1341 }
1342 nlevel = GetPixelIndex(x+i,y+1) + (error * coeff)/16;
1343- level = (BYTE)min(255,max(0,(int)nlevel));
1344+ level = (BYTE)cxmin(255,cxmax(0,(int)nlevel));
1345 SetPixelIndex(x+i,y+1,level);
1346 }
1347 }
1348@@ -2031,7 +2031,7 @@ bool CxImage::CropRotatedRectangle( long topx, long topy, long width, long heigh
1349 if ( fabs(angle)<0.0002 )
1350 return Crop( topx, topy, topx+width, topy+height, iDst);
1351
1352- startx = min(topx, topx - (long)(sin_angle*(double)height));
1353+ startx = cxmin(topx, topx - (long)(sin_angle*(double)height));
1354 endx = topx + (long)(cos_angle*(double)width);
1355 endy = topy + (long)(cos_angle*(double)height + sin_angle*(double)width);
1356 // check: corners of the rectangle must be inside
1357@@ -2079,10 +2079,10 @@ bool CxImage::Crop(long left, long top, long right, long bottom, CxImage* iDst)
1358 {
1359 if (!pDib) return false;
1360
1361- long startx = max(0L,min(left,head.biWidth));
1362- long endx = max(0L,min(right,head.biWidth));
1363- long starty = head.biHeight - max(0L,min(top,head.biHeight));
1364- long endy = head.biHeight - max(0L,min(bottom,head.biHeight));
1365+ long startx = cxmax(0L,cxmin(left,head.biWidth));
1366+ long endx = cxmax(0L,cxmin(right,head.biWidth));
1367+ long starty = head.biHeight - cxmax(0L,cxmin(top,head.biHeight));
1368+ long endy = head.biHeight - cxmax(0L,cxmin(bottom,head.biHeight));
1369
1370 if (startx==endx || starty==endy) return false;
1371
1372@@ -2443,8 +2443,8 @@ bool CxImage::CircleTransform(int type,long rmax,float Koeff)
1373 nx=x+(x%32)-16;
1374 ny=y;
1375 }
1376-// nx=max(xmin,min(nx,xmax));
1377-// ny=max(ymin,min(ny,ymax));
1378+// nx=cxmax(xmin,cxmin(nx,xmax));
1379+// ny=cxmax(ymin,cxmin(ny,ymax));
1380 }
1381 else { nx=-1;ny=-1;}
1382 if (head.biClrUsed==0){
1383diff --git a/lib/cximage-6.0/CxImage/ximawnd.cpp b/lib/cximage-6.0/CxImage/ximawnd.cpp
1384index 2ae2f93..7029cc7 100644
1385--- a/lib/cximage-6.0/CxImage/ximawnd.cpp
1386+++ b/lib/cximage-6.0/CxImage/ximawnd.cpp
1387@@ -682,10 +682,10 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
1388 RECT clipbox,paintbox;
1389 GetClipBox(hdc,&clipbox);
1390
1391- paintbox.top = min(clipbox.bottom,max(clipbox.top,y));
1392- paintbox.left = min(clipbox.right,max(clipbox.left,x));
1393- paintbox.right = max(clipbox.left,min(clipbox.right,x+cx));
1394- paintbox.bottom = max(clipbox.top,min(clipbox.bottom,y+cy));
1395+ paintbox.top = cxmin(clipbox.bottom,cxmax(clipbox.top,y));
1396+ paintbox.left = cxmin(clipbox.right,cxmax(clipbox.left,x));
1397+ paintbox.right = cxmax(clipbox.left,cxmin(clipbox.right,x+cx));
1398+ paintbox.bottom = cxmax(clipbox.top,cxmin(clipbox.bottom,y+cy));
1399
1400 long destw = paintbox.right - paintbox.left;
1401 long desth = paintbox.bottom - paintbox.top;
1402@@ -730,12 +730,12 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
1403
1404 for(yy=0;yy<desth;yy++){
1405 dy = head.biHeight-(ymax-yy-y)*fy;
1406- sy = max(0L,(long)floor(dy));
1407+ sy = cxmax(0L,(long)floor(dy));
1408 psrc = info.pImage+sy*info.dwEffWidth;
1409 pdst = pbase+yy*ew;
1410 for(xx=0;xx<destw;xx++){
1411 dx = (xx+xmin-x)*fx;
1412- sx = max(0L,(long)floor(dx));
1413+ sx = cxmax(0L,(long)floor(dx));
1414 #if CXIMAGE_SUPPORT_INTERPOLATION
1415 if (bSmooth){
1416 if (fx > 1 && fy > 1) {
1417@@ -813,7 +813,7 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
1418
1419 for(yy=0;yy<desth;yy++){
1420 dy = head.biHeight-(ymax-yy-y)*fy;
1421- sy = max(0L,(long)floor(dy));
1422+ sy = cxmax(0L,(long)floor(dy));
1423
1424 alphaoffset = sy*head.biWidth;
1425 pdst = pbase + yy*ew;
1426@@ -821,7 +821,7 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
1427
1428 for(xx=0;xx<destw;xx++){
1429 dx = (xx+xmin-x)*fx;
1430- sx = max(0L,(long)floor(dx));
1431+ sx = cxmax(0L,(long)floor(dx));
1432
1433 if (bAlpha) a=pAlpha[alphaoffset+sx]; else a=255;
1434 a =(BYTE)((a*(1+info.nAlphaMax))>>8);
diff --git a/community/kodi/remove-filewrap.patch b/community/kodi/remove-filewrap.patch
index 70145b0ba8..9f20397e8b 100644
--- a/community/kodi/remove-filewrap.patch
+++ b/community/kodi/remove-filewrap.patch
@@ -1,7 +1,9 @@
1--- a/xbmc/utils/posix/PosixInterfaceForCLog.cpp.orig 1diff --git a/xbmc/utils/posix/PosixInterfaceForCLog.cpp b/xbmc/utils/posix/PosixInterfaceForCLog.cpp
2index a3d4983..8443024 100644
3--- a/xbmc/utils/posix/PosixInterfaceForCLog.cpp
2+++ b/xbmc/utils/posix/PosixInterfaceForCLog.cpp 4+++ b/xbmc/utils/posix/PosixInterfaceForCLog.cpp
3@@ -28,10 +28,6 @@ 5@@ -29,10 +29,6 @@
4 #include "android/activity/XBMCApp.h" 6 #include "platform/android/activity/XBMCApp.h"
5 #endif // TARGET_ANDROID 7 #endif // TARGET_ANDROID
6 8
7-struct FILEWRAP : public FILE 9-struct FILEWRAP : public FILE
@@ -11,7 +13,7 @@
11 CPosixInterfaceForCLog::CPosixInterfaceForCLog() : 13 CPosixInterfaceForCLog::CPosixInterfaceForCLog() :
12 m_file(NULL) 14 m_file(NULL)
13 { } 15 { }
14@@ -50,7 +46,7 @@ 16@@ -52,7 +48,7 @@ bool CPosixInterfaceForCLog::OpenLogFile(const std::string &logFilename, const s
15 (void)remove(backupOldLogToFilename.c_str()); // if it's failed, try to continue 17 (void)remove(backupOldLogToFilename.c_str()); // if it's failed, try to continue
16 (void)rename(logFilename.c_str(), backupOldLogToFilename.c_str()); // if it's failed, try to continue 18 (void)rename(logFilename.c_str(), backupOldLogToFilename.c_str()); // if it's failed, try to continue
17 19
@@ -20,7 +22,9 @@
20 if (!m_file) 22 if (!m_file)
21 return false; // error, can't open log file 23 return false; // error, can't open log file
22 24
23--- a/xbmc/utils/posix/PosixInterfaceForCLog.h.orig 25diff --git a/xbmc/utils/posix/PosixInterfaceForCLog.h b/xbmc/utils/posix/PosixInterfaceForCLog.h
26index c1e8ffe..9999ead 100644
27--- a/xbmc/utils/posix/PosixInterfaceForCLog.h
24+++ b/xbmc/utils/posix/PosixInterfaceForCLog.h 28+++ b/xbmc/utils/posix/PosixInterfaceForCLog.h
25@@ -21,8 +21,6 @@ 29@@ -21,8 +21,6 @@
26 30
@@ -31,9 +35,9 @@
31 class CPosixInterfaceForCLog 35 class CPosixInterfaceForCLog
32 { 36 {
33 public: 37 public:
34@@ -34,5 +32,5 @@ 38@@ -34,5 +32,5 @@ public:
35 void PrintDebugString(const std::string& debugString); 39 void PrintDebugString(const std::string& debugString);
36 static void GetCurrentLocalTime(int& hour, int& minute, int& second); 40 static void GetCurrentLocalTime(int& hour, int& minute, int& second, double& millisecond);
37 private: 41 private:
38- FILEWRAP* m_file; 42- FILEWRAP* m_file;
39+ FILE * m_file; 43+ FILE * m_file;