[arch-commits] Commit in kodi/trunk (11 files)

Ike Devolder idevolder at gemini.archlinux.org
Thu Feb 17 18:33:47 UTC 2022


    Date: Thursday, February 17, 2022 @ 18:33:46
  Author: idevolder
Revision: 1133791

upgpkg: kodi 19.3-3

rebuilt for libnfs 5.x

Added:
  kodi/trunk/cheat-sse-build.patch
Modified:
  kodi/trunk/PKGBUILD
Deleted:
  kodi/trunk/0001-allow-separate-windowing-binaries-being-launched-fro.patch
  kodi/trunk/10160.patch
  kodi/trunk/10775.patch
  kodi/trunk/17804.patch
  kodi/trunk/18131.patch
  kodi/trunk/9703.patch
  kodi/trunk/cheat-sse-build.patch
  kodi/trunk/fix-ftpparse.patch
  kodi/trunk/fix-python-lib-path.patch

-----------------------------------------------------------------+
 0001-allow-separate-windowing-binaries-being-launched-fro.patch |   67 
 10160.patch                                                     |   22 
 10775.patch                                                     |  839 -----
 17804.patch                                                     |   25 
 18131.patch                                                     | 1256 --------
 9703.patch                                                      | 1432 ----------
 PKGBUILD                                                        |    5 
 cheat-sse-build.patch                                           |   22 
 fix-ftpparse.patch                                              |   71 
 fix-python-lib-path.patch                                       |   29 
 10 files changed, 14 insertions(+), 3754 deletions(-)

Deleted: 0001-allow-separate-windowing-binaries-being-launched-fro.patch
===================================================================
--- 0001-allow-separate-windowing-binaries-being-launched-fro.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ 0001-allow-separate-windowing-binaries-being-launched-fro.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,67 +0,0 @@
-From 5b75228b51c3422644468050debbc495f5195585 Mon Sep 17 00:00:00 2001
-From: BlackEagle <ike.devolder at gmail.com>
-Date: Thu, 25 Feb 2021 15:24:21 +0100
-Subject: [PATCH] allow separate windowing binaries being launched from kodi
- wrapper
-
-Signed-off-by: BlackEagle <ike.devolder at gmail.com>
----
- tools/Linux/kodi.sh.in | 29 ++++++++++++++++++++++++++++-
- 1 file changed, 28 insertions(+), 1 deletion(-)
-
-diff --git a/tools/Linux/kodi.sh.in b/tools/Linux/kodi.sh.in
-index 108c0b0..38a49e0 100644
---- a/tools/Linux/kodi.sh.in
-+++ b/tools/Linux/kodi.sh.in
-@@ -28,6 +28,7 @@ LIBDIR="@libdir@"
- APP_BINARY=$LIBDIR/${bin_name}/@APP_BINARY@
- CRASHLOG_DIR=${CRASHLOG_DIR:-$HOME}
- KODI_DATA=${KODI_DATA:-"${HOME}/.${bin_name}"} # mapped to special://home/
-+WINDOWING=${WINDOWING:-"auto"}
- 
- # Workaround for high CPU load with nvidia GFX
- export __GL_YIELD=USLEEP
-@@ -43,13 +44,39 @@ do
-             LIBDIR="$2"
-             shift; shift
-             ;;
-+        --windowing)
-+            WINDOWING="$2"
-+            echo "$SAVED_ARGS" | sed "s/--windowing[ ]*$2//g"
-+            shift; shift
-+            ;;
-         *)
-             shift
-             ;;
-     esac
- done
- 
--KODI_BINARY=${APP_BINARY}
-+# Note: by default only one of those binaries exists
-+# To be able to select a different one, if has to be compiled specifically
-+# Your distribution might provide extra packages for those
-+if [ "$WINDOWING" = "auto" ]; then
-+    # Wayland
-+    if [ -n "$WAYLAND_DISPLAY" ] && [ -x $LIBDIR/${bin_name}/${bin_name}-wayland ]; then
-+        KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-wayland
-+    # X11
-+    elif echo $DISPLAY | grep -qE ":[0-9]+" && [ -x $LIBDIR/${bin_name}/${bin_name}-x11 ]; then
-+        KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-x11
-+    # GBM/DRM
-+    elif [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ -x $LIBDIR/${bin_name}/${bin_name}-gbm ]; then
-+        KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-gbm
-+    # Default kodi.bin
-+    else
-+        KODI_BINARY=${APP_BINARY}
-+    fi
-+elif [ -n "$WINDOWING" ]; then
-+    KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-${WINDOWING}
-+else
-+    KODI_BINARY=${APP_BINARY}
-+fi
- 
- if [ ! -x ${KODI_BINARY} ]; then
-     echo "Error: ${KODI_BINARY} not found"
--- 
-2.30.1
-

Deleted: 10160.patch
===================================================================
--- 10160.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ 10160.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,22 +0,0 @@
-diff --git a/xbmc/filesystem/DllLibCurl.h b/xbmc/filesystem/DllLibCurl.h
-index 1bdaae1..9e78a91 100644
---- a/xbmc/filesystem/DllLibCurl.h
-+++ b/xbmc/filesystem/DllLibCurl.h
-@@ -52,7 +52,7 @@ namespace XCURL
-     virtual CURLMcode multi_fdset(CURLM *multi_handle, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *exc_fd_set, int *max_fd)=0;
-     virtual CURLMcode multi_timeout(CURLM *multi_handle, long *timeout)=0;
-     virtual CURLMsg*  multi_info_read(CURLM *multi_handle, int *msgs_in_queue)=0;
--    virtual void multi_cleanup(CURL_HANDLE * handle )=0;
-+    virtual CURLMcode multi_cleanup(CURLM * handle )=0;
-     virtual struct curl_slist* slist_append(struct curl_slist *, const char *)=0;
-     virtual void  slist_free_all(struct curl_slist *)=0;
-   };
-@@ -77,7 +77,7 @@ namespace XCURL
-     DEFINE_METHOD5(CURLMcode, multi_fdset, (CURLM *p1, fd_set *p2, fd_set *p3, fd_set *p4, int *p5))
-     DEFINE_METHOD2(CURLMcode, multi_timeout, (CURLM *p1, long *p2))
-     DEFINE_METHOD2(CURLMsg*,  multi_info_read, (CURLM *p1, int *p2))
--    DEFINE_METHOD1(void, multi_cleanup, (CURLM *p1))
-+    DEFINE_METHOD1(CURLMcode, multi_cleanup, (CURLM *p1))
-     DEFINE_METHOD2(struct curl_slist*, slist_append, (struct curl_slist * p1, const char * p2))
-     DEFINE_METHOD1(void, slist_free_all, (struct curl_slist * p1))
-     DEFINE_METHOD1(const char *, easy_strerror, (CURLcode p1))

Deleted: 10775.patch
===================================================================
--- 10775.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ 10775.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,839 +0,0 @@
-From cc3ae0339faf2b669bee20cb360c526410910f42 Mon Sep 17 00:00:00 2001
-From: Lars Op den Kamp <lars at opdenkamp.eu>
-Date: Fri, 11 Nov 2016 10:09:36 +0100
-Subject: [PATCH 1/4] [cec] bump to libCEC 4.0.0
-
----
- .../resource.language.en_gb/resources/strings.po   |   5 -
- configure.ac                                       |   4 +-
- project/BuildDependencies/scripts/0_package.list   |   2 +-
- project/cmake/modules/FindCEC.cmake                |   2 +-
- system/peripherals.xml                             |   1 -
- tools/depends/target/Makefile                      |   5 +-
- tools/depends/target/libcec/Makefile               |   4 +-
- tools/depends/target/p8-platform/Makefile          |  34 ++++
- xbmc/peripherals/devices/PeripheralCecAdapter.cpp  | 192 +++++++++------------
- xbmc/peripherals/devices/PeripheralCecAdapter.h    |  17 +-
- 10 files changed, 138 insertions(+), 128 deletions(-)
- create mode 100644 tools/depends/target/p8-platform/Makefile
-
-diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
-index e3f8a37..e482196 100644
---- a/addons/resource.language.en_gb/resources/strings.po
-+++ b/addons/resource.language.en_gb/resources/strings.po
-@@ -16376,11 +16376,6 @@ msgctxt "#36021"
- msgid "Physical address (overrules HDMI port)"
- msgstr ""
-
--#: system/peripherals.xml
--msgctxt "#36022"
--msgid "COM port (leave empty unless needed)"
--msgstr ""
--
- #: xbmc/peripherals/devices/peripheralcecadapter.cpp
- msgctxt "#36023"
- msgid "Configuration updated"
-diff --git a/configure.ac b/configure.ac
-index e61d4ae..34fe643 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1453,9 +1453,9 @@ if test "x$use_libcec" != "xno"; then
-   # libcec is dyloaded, so we need to check for its headers and link any depends.
-   if test "x$use_libcec" != "xno"; then
-     if test "x$use_libcec" != "xauto"; then
--      PKG_CHECK_MODULES([CEC],[libcec >= 3.0.0],,[use_libcec="no";AC_MSG_ERROR($libcec_disabled)])
-+      PKG_CHECK_MODULES([CEC],[libcec >= 4.0.0],,[use_libcec="no";AC_MSG_ERROR($libcec_disabled)])
-     else
--      PKG_CHECK_MODULES([CEC],[libcec >= 3.0.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
-+      PKG_CHECK_MODULES([CEC],[libcec >= 4.0.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
-     fi
-
-     if test "x$use_libcec" != "xno"; then
-diff --git a/project/BuildDependencies/scripts/0_package.list b/project/BuildDependencies/scripts/0_package.list
-index 9a5bccb..7b6ec1a 100644
---- a/project/BuildDependencies/scripts/0_package.list
-+++ b/project/BuildDependencies/scripts/0_package.list
-@@ -19,7 +19,7 @@ jsonschemabuilder-1.0.0-win32-3.7z
- libass-0.12.1-win32.7z
- libbluray-0.8.1-win32-vc120.7z
- libcdio-0.83-win32-2.7z
--libcec-3.0.0-win32-2.7z
-+libcec-4.0.0-win32-vc140.7z
- libexpat_2.0.1-win32.7z
- libflac-1.2.1-win32.7z
- libfribidi-0.19.2-win32.7z
-diff --git a/system/peripherals.xml b/system/peripherals.xml
-index f939c0b..58a9d24 100644
---- a/system/peripherals.xml
-+++ b/system/peripherals.xml
-@@ -24,7 +24,6 @@
-     <setting key="connected_device" type="enum" label="36019" value="36037" lvalues="36037|36038" order="12" />
-     <setting key="cec_hdmi_port" type="int" value="1" min="1" max="15" label="36015" order="13" />
-     <setting key="physical_address" type="string" label="36021" value="0" order="14" />
--    <setting key="port" type="string" value="" label="36022" order="15" />
-
-     <setting key="tv_vendor" type="int" value="0" configurable="0" />
-     <setting key="device_name" type="string" value="Kodi" configurable="0" />
-diff --git a/tools/depends/target/Makefile b/tools/depends/target/Makefile
-index 9bca188..82b378d 100644
---- a/tools/depends/target/Makefile
-+++ b/tools/depends/target/Makefile
-@@ -15,7 +15,7 @@
- 	python26 libshairplay \
- 	libplist libcec libbluray boost tinyxml dummy-libxbmc \
- 	libamplayer libssh taglib libusb libnfs \
--	pythonmodule-pil libxslt ffmpeg platform crossguid libdcadec giflib
-+	pythonmodule-pil libxslt ffmpeg platform crossguid libdcadec giflib p8-platform
-
- FFMPEG_DEPENDS = gnutls libdcadec
-
-@@ -101,7 +101,8 @@ pythonmodule-setuptools: python27
- libsdl2: $(LINUX_SYSTEM_LIBS)
- libxslt: libgcrypt
- ffmpeg: $(ICONV) $(ZLIB) bzip2 libvorbis $(FFMPEG_DEPENDS)
--libcec: platform
-+platform: p8-platform
-+libcec: p8-platform
- crossguid: $(CROSSGUID_DEPS)
-
- .installed-$(PLATFORM): $(DEPENDS)
-diff --git a/tools/depends/target/libcec/Makefile b/tools/depends/target/libcec/Makefile
-index f54af9e..c75b300 100644
---- a/tools/depends/target/libcec/Makefile
-+++ b/tools/depends/target/libcec/Makefile
-@@ -3,12 +3,12 @@ DEPS= ../../Makefile.include Makefile
-
- # lib name, version
- LIBNAME=libcec
--VERSION_MAJOR=3
-+VERSION_MAJOR=4
- VERSION_MINOR=0
- VERSION_PATCH=0
-
- VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
--SOURCE=$(LIBNAME)-$(VERSION)-6
-+SOURCE=$(LIBNAME)-$(VERSION)
- ARCHIVE=$(SOURCE).tar.gz
-
- LIBDYLIB=$(PLATFORM)/build/src/$(LIBNAME).la
-diff --git a/tools/depends/target/p8-platform/Makefile b/tools/depends/target/p8-platform/Makefile
-new file mode 100644
-index 0000000..d5918d7
---- /dev/null
-+++ b/tools/depends/target/p8-platform/Makefile
-@@ -0,0 +1,34 @@
-+include ../../Makefile.include
-+DEPS= ../../Makefile.include Makefile
-+
-+# lib name, version
-+LIBNAME=p8-platform
-+VERSION=2.1.0.1
-+SOURCE=$(LIBNAME)-$(VERSION)
-+ARCHIVE=$(SOURCE).tar.gz
-+
-+LIBDYLIB=$(PLATFORM)/build/src/$(LIBNAME).a
-+
-+all: .installed-$(PLATFORM)
-+
-+$(TARBALLS_LOCATION)/$(ARCHIVE):
-+	cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
-+
-+$(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS)
-+	rm -rf $(PLATFORM); mkdir -p $(PLATFORM)/build
-+	cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
-+	cd $(PLATFORM)/build; $(CMAKE) -DBUILD_SHARED_LIBS=0 -DCMAKE_INSTALL_LIBDIR=$(PREFIX)/lib ..
-+
-+$(LIBDYLIB): $(PLATFORM)
-+	$(MAKE) -C $(PLATFORM)/build
-+
-+.installed-$(PLATFORM): $(LIBDYLIB)
-+	$(MAKE) -C $(PLATFORM)/build install
-+	touch $@
-+
-+clean:
-+	rm -rf $(PLATFORM) .installed-$(PLATFORM)
-+
-+distclean::
-+	rm -rf $(PLATFORM) .installed-$(PLATFORM)
-+
-diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-index e6bcbce..a71dc4b 100644
---- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-@@ -43,7 +43,7 @@ using namespace PERIPHERALS;
- using namespace ANNOUNCEMENT;
- using namespace CEC;
-
--#define CEC_LIB_SUPPORTED_VERSION LIBCEC_VERSION_TO_UINT(3, 0, 0)
-+#define CEC_LIB_SUPPORTED_VERSION LIBCEC_VERSION_TO_UINT(4, 0, 0)
-
- /* time in seconds to ignore standby commands from devices after the screensaver has been activated */
- #define SCREENSAVER_TIMEOUT       20
-@@ -119,25 +119,30 @@ void CPeripheralCecAdapter::ResetMembers(void)
-     m_dll->CECDestroy(m_cecAdapter);
-   m_cecAdapter               = NULL;
-   delete m_dll;
--  m_dll                      = NULL;
--  m_bStarted                 = false;
--  m_bHasButton               = false;
--  m_bIsReady                 = false;
--  m_bHasConnectedAudioSystem = false;
--  m_strMenuLanguage          = "???";
--  m_lastKeypress             = 0;
--  m_lastChange               = VOLUME_CHANGE_NONE;
--  m_iExitCode                = EXITCODE_QUIT;
--  m_bIsMuted                 = false; // TODO fetch the correct initial value when system audiostatus is implemented in libCEC
--  m_bGoingToStandby          = false;
--  m_bIsRunning               = false;
--  m_bDeviceRemoved           = false;
--  m_bActiveSourcePending     = false;
--  m_bStandbyPending          = false;
-+  m_dll                        = NULL;
-+  m_bStarted                   = false;
-+  m_bHasButton                 = false;
-+  m_bIsReady                   = false;
-+  m_bHasConnectedAudioSystem   = false;
-+  m_strMenuLanguage            = "???";
-+  m_lastKeypress               = 0;
-+  m_lastChange                 = VOLUME_CHANGE_NONE;
-+  m_iExitCode                  = EXITCODE_QUIT;
-+  m_bIsMuted                   = false; //! @todo fetch the correct initial value when system audiostatus is implemented in libCEC
-+  m_bGoingToStandby            = false;
-+  m_bIsRunning                 = false;
-+  m_bDeviceRemoved             = false;
-+  m_bActiveSourcePending       = false;
-+  m_bStandbyPending            = false;
-   m_bActiveSourceBeforeStandby = false;
--  m_bOnPlayReceived          = false;
--  m_bPlaybackPaused          = false;
--  m_queryThread              = NULL;
-+  m_bOnPlayReceived            = false;
-+  m_bPlaybackPaused            = false;
-+  m_queryThread                = NULL;
-+  m_bPowerOnScreensaver        = false;
-+  m_bUseTVMenuLanguage         = false;
-+  m_bSendInactiveSource        = false;
-+  m_bPowerOffScreensaver       = false;
-+  m_bShutdownOnStandby         = false;
-
-   m_currentButton.iButton    = 0;
-   m_currentButton.iDuration  = 0;
-@@ -166,8 +171,8 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
-       if (bIgnoreDeactivate)
-         CLog::Log(LOGDEBUG, "%s - ignoring OnScreensaverDeactivated for power action", __FUNCTION__);
-     }
--    if (m_configuration.bPowerOnScreensaver == 1 && !bIgnoreDeactivate &&
--        m_configuration.bActivateSource == 1)
-+    if (m_bPowerOnScreensaver && !bIgnoreDeactivate &&
-+        m_configuration.bActivateSource)
-     {
-       ActivateSource();
-     }
-@@ -175,7 +180,7 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
-   else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverActivated") && m_bIsReady)
-   {
-     // Don't put devices to standby if application is currently playing
--    if ((!g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) && m_configuration.bPowerOffScreensaver == 1)
-+    if (!g_application.m_pPlayer->IsPlaying() && m_bPowerOffScreensaver)
-     {
-       // only power off when we're the active source
-       if (m_cecAdapter->IsLibCECActiveSource())
-@@ -241,14 +246,14 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
-
-     SetConfigurationFromSettings();
-     m_callbacks.Clear();
--    m_callbacks.CBCecLogMessage           = &CecLogMessage;
--    m_callbacks.CBCecKeyPress             = &CecKeyPress;
--    m_callbacks.CBCecCommand              = &CecCommand;
--    m_callbacks.CBCecConfigurationChanged = &CecConfiguration;
--    m_callbacks.CBCecAlert                = &CecAlert;
--    m_callbacks.CBCecSourceActivated      = &CecSourceActivated;
--    m_configuration.callbackParam         = this;
--    m_configuration.callbacks             = &m_callbacks;
-+    m_callbacks.logMessage           = &CecLogMessage;
-+    m_callbacks.keyPress             = &CecKeyPress;
-+    m_callbacks.commandReceived      = &CecCommand;
-+    m_callbacks.configurationChanged = &CecConfiguration;
-+    m_callbacks.alert                = &CecAlert;
-+    m_callbacks.sourceActivated      = &CecSourceActivated;
-+    m_configuration.callbackParam    = this;
-+    m_configuration.callbacks        = &m_callbacks;
-
-     m_dll = new DllLibCEC;
-     if (m_dll->Load() && m_dll->IsLoaded())
-@@ -414,7 +419,7 @@ void CPeripheralCecAdapter::Process(void)
-         m_standbySent = CDateTime::GetCurrentDateTime();
-         m_cecAdapter->StandbyDevices();
-       }
--      else if (m_configuration.bSendInactiveSource == 1)
-+      else if (m_bSendInactiveSource)
-       {
-         CLog::Log(LOGDEBUG, "%s - sending inactive source commands", __FUNCTION__);
-         m_cecAdapter->SetInactiveView();
-@@ -614,43 +619,43 @@ void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage)
-     CLog::Log(LOGWARNING, "%s - TV menu language set to unknown value '%s'", __FUNCTION__, strLanguage);
- }
-
--int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command command)
-+void CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command* command)
- {
--  CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+  CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
-   if (!adapter)
--    return 0;
-+    return;
-
-   if (adapter->m_bIsReady)
-   {
--    switch (command.opcode)
-+    switch (command->opcode)
-     {
-     case CEC_OPCODE_STANDBY:
-       /* a device was put in standby mode */
--      if (command.initiator == CECDEVICE_TV &&
--          (adapter->m_configuration.bPowerOffOnStandby == 1 || adapter->m_configuration.bShutdownOnStandby == 1) &&
-+      if (command->initiator == CECDEVICE_TV &&
-+          (adapter->m_configuration.bPowerOffOnStandby == 1 || adapter->m_bShutdownOnStandby) &&
-           (!adapter->m_standbySent.IsValid() || CDateTime::GetCurrentDateTime() - adapter->m_standbySent > CDateTimeSpan(0, 0, 0, SCREENSAVER_TIMEOUT)))
-       {
-         adapter->m_bStarted = false;
-         if (adapter->m_configuration.bPowerOffOnStandby == 1)
-           g_application.ExecuteXBMCAction("Suspend");
--        else if (adapter->m_configuration.bShutdownOnStandby == 1)
-+        else if (adapter->m_bShutdownOnStandby)
-           g_application.ExecuteXBMCAction("Shutdown");
-       }
-       break;
-     case CEC_OPCODE_SET_MENU_LANGUAGE:
--      if (adapter->m_configuration.bUseTVMenuLanguage == 1 && command.initiator == CECDEVICE_TV && command.parameters.size == 3)
-+      if (adapter->m_bUseTVMenuLanguage == 1 && command->initiator == CECDEVICE_TV && command->parameters.size == 3)
-       {
-         char strNewLanguage[4];
-         for (int iPtr = 0; iPtr < 3; iPtr++)
--          strNewLanguage[iPtr] = command.parameters[iPtr];
-+          strNewLanguage[iPtr] = command->parameters[iPtr];
-         strNewLanguage[3] = 0;
-         adapter->SetMenuLanguage(strNewLanguage);
-       }
-       break;
-     case CEC_OPCODE_DECK_CONTROL:
--      if (command.initiator == CECDEVICE_TV &&
--          command.parameters.size == 1 &&
--          command.parameters[0] == CEC_DECK_CONTROL_MODE_STOP)
-+      if (command->initiator == CECDEVICE_TV &&
-+          command->parameters.size == 1 &&
-+          command->parameters[0] == CEC_DECK_CONTROL_MODE_STOP)
-       {
-         cec_keypress key;
-         key.duration = 500;
-@@ -659,17 +664,17 @@ int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command command)
-       }
-       break;
-     case CEC_OPCODE_PLAY:
--      if (command.initiator == CECDEVICE_TV &&
--          command.parameters.size == 1)
-+      if (command->initiator == CECDEVICE_TV &&
-+          command->parameters.size == 1)
-       {
--        if (command.parameters[0] == CEC_PLAY_MODE_PLAY_FORWARD)
-+        if (command->parameters[0] == CEC_PLAY_MODE_PLAY_FORWARD)
-         {
-           cec_keypress key;
-           key.duration = 500;
-           key.keycode = CEC_USER_CONTROL_CODE_PLAY;
-           adapter->PushCecKeypress(key);
-         }
--        else if (command.parameters[0] == CEC_PLAY_MODE_PLAY_STILL)
-+        else if (command->parameters[0] == CEC_PLAY_MODE_PLAY_STILL)
-         {
-           cec_keypress key;
-           key.duration = 500;
-@@ -682,25 +687,23 @@ int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command command)
-       break;
-     }
-   }
--  return 1;
- }
-
--int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configuration config)
-+void CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configuration* config)
- {
--  CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+  CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
-   if (!adapter)
--    return 0;
-+    return;
-
-   CSingleLock lock(adapter->m_critSection);
--  adapter->SetConfigurationFromLibCEC(config);
--  return 1;
-+  adapter->SetConfigurationFromLibCEC(*config);
- }
-
--int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter data)
-+void CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter data)
- {
--  CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+  CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
-   if (!adapter)
--    return 0;
-+    return;
-
-   bool bReopenConnection(false);
-   int iAlertString(0);
-@@ -743,18 +746,13 @@ int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, con
-
-   if (bReopenConnection)
-     adapter->ReopenConnection();
--
--  return 1;
- }
-
--int CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress key)
-+void CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress* key)
- {
--  CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
--  if (!adapter)
--    return 0;
--
--  adapter->PushCecKeypress(key);
--  return 1;
-+  CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
-+  if (!!adapter)
-+    adapter->PushCecKeypress(*key);
- }
-
- void CPeripheralCecAdapter::GetNextKey(void)
-@@ -1154,7 +1152,7 @@ void CPeripheralCecAdapter::OnSettingChanged(const std::string &strChangedSettin
-
- void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_logical_address address, const uint8_t activated)
- {
--  CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+  CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
-   if (!adapter)
-     return;
-
-@@ -1196,14 +1194,14 @@ void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_log
-   }
- }
-
--int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message message)
-+void CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message* message)
- {
--  CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+  CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
-   if (!adapter)
--    return 0;
-+    return;
-
-   int iLevel = -1;
--  switch (message.level)
-+  switch (message->level)
-   {
-   case CEC_LOG_ERROR:
-     iLevel = LOGERROR;
-@@ -1223,9 +1221,7 @@ int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message me
-   }
-
-   if (iLevel >= CEC_LOG_NOTICE || (iLevel >= 0 && CLog::IsLogLevelLogged(LOGDEBUG) && g_advancedSettings.CanLogComponent(LOGCEC)))
--    CLog::Log(iLevel, "%s - %s", __FUNCTION__, message.message);
--
--  return 1;
-+    CLog::Log(iLevel, "%s - %s", __FUNCTION__, message->message);
- }
-
- void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configuration &config)
-@@ -1270,35 +1266,18 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
-   bChanged |= WriteLogicalAddresses(config.powerOffDevices, "standby_devices", "standby_devices_advanced");
-
-   // set the boolean settings
--  m_configuration.bUseTVMenuLanguage = config.bUseTVMenuLanguage;
--  bChanged |= SetSetting("use_tv_menu_language", m_configuration.bUseTVMenuLanguage == 1);
--
-   m_configuration.bActivateSource = config.bActivateSource;
-   bChanged |= SetSetting("activate_source", m_configuration.bActivateSource == 1);
-
--  m_configuration.bPowerOffScreensaver = config.bPowerOffScreensaver;
--  bChanged |= SetSetting("cec_standby_screensaver", m_configuration.bPowerOffScreensaver == 1);
--
--  m_configuration.bPowerOnScreensaver = config.bPowerOnScreensaver;
--  bChanged |= SetSetting("cec_wake_screensaver", m_configuration.bPowerOnScreensaver == 1);
--
-   m_configuration.bPowerOffOnStandby = config.bPowerOffOnStandby;
-
--  m_configuration.bSendInactiveSource = config.bSendInactiveSource;
--  bChanged |= SetSetting("send_inactive_source", m_configuration.bSendInactiveSource == 1);
--
-   m_configuration.iFirmwareVersion = config.iFirmwareVersion;
--  m_configuration.bShutdownOnStandby = config.bShutdownOnStandby;
-
-   memcpy(m_configuration.strDeviceLanguage, config.strDeviceLanguage, 3);
-   m_configuration.iFirmwareBuildDate = config.iFirmwareBuildDate;
-
-   SetVersionInfo(m_configuration);
-
--  bChanged |= SetSetting("standby_pc_on_tv_standby",
--             m_configuration.bPowerOffOnStandby == 1 ? 13011 :
--             m_configuration.bShutdownOnStandby == 1 ? 13005 : 36028);
--
-   if (bChanged)
-     CLog::Log(LOGDEBUG, "SetConfigurationFromLibCEC - settings updated by libCEC");
- }
-@@ -1306,7 +1285,7 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
- void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
- {
-   // client version matches the version of libCEC that we originally used the API from
--  m_configuration.clientVersion = LIBCEC_VERSION_TO_UINT(3, 0, 0);
-+  m_configuration.clientVersion = LIBCEC_VERSION_TO_UINT(4, 0, 0);
-
-   // device name 'XBMC'
-   snprintf(m_configuration.strDeviceName, 13, "%s", GetSettingString("device_name").c_str());
-@@ -1373,16 +1352,16 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
-     ReadLogicalAddresses(GetSettingInt("standby_devices"), m_configuration.powerOffDevices);
-
-   // read the boolean settings
--  m_configuration.bUseTVMenuLanguage   = GetSettingBool("use_tv_menu_language") ? 1 : 0;
-+  m_bUseTVMenuLanguage                 = GetSettingBool("use_tv_menu_language") ? 1 : 0;
-   m_configuration.bActivateSource      = GetSettingBool("activate_source") ? 1 : 0;
--  m_configuration.bPowerOffScreensaver = GetSettingBool("cec_standby_screensaver") ? 1 : 0;
--  m_configuration.bPowerOnScreensaver  = GetSettingBool("cec_wake_screensaver") ? 1 : 0;
--  m_configuration.bSendInactiveSource  = GetSettingBool("send_inactive_source") ? 1 : 0;
-+  m_bPowerOffScreensaver               = GetSettingBool("cec_standby_screensaver") ? 1 : 0;
-+  m_bPowerOnScreensaver                = GetSettingBool("cec_wake_screensaver") ? 1 : 0;
-+  m_bSendInactiveSource                = GetSettingBool("send_inactive_source") ? 1 : 0;
-
-   // read the mutually exclusive boolean settings
-   int iStandbyAction(GetSettingInt("standby_pc_on_tv_standby"));
-   m_configuration.bPowerOffOnStandby = iStandbyAction == 13011 ? 1 : 0;
--  m_configuration.bShutdownOnStandby = iStandbyAction == 13005 ? 1 : 0;
-+  m_bShutdownOnStandby = iStandbyAction == 13005;
-
- #if defined(CEC_DOUBLE_TAP_TIMEOUT_MS_OLD)
-   // double tap prevention timeout in ms. libCEC uses 50ms units for this in 2.2.0, so divide by 50
-@@ -1529,14 +1508,11 @@ bool CPeripheralCecAdapterUpdateThread::WaitReady(void)
- void CPeripheralCecAdapterUpdateThread::UpdateMenuLanguage(void)
- {
-   // request the menu language of the TV
--  if (m_configuration.bUseTVMenuLanguage == 1)
-+  if (m_adapter->m_bUseTVMenuLanguage == 1)
-   {
-     CLog::Log(LOGDEBUG, "%s - requesting the menu language of the TV", __FUNCTION__);
--    cec_menu_language language;
--    if (m_adapter->m_cecAdapter->GetDeviceMenuLanguage(CECDEVICE_TV, &language))
--      m_adapter->SetMenuLanguage(language.language);
--    else
--      CLog::Log(LOGDEBUG, "%s - unknown menu language", __FUNCTION__);
-+    std::string language(m_adapter->m_cecAdapter->GetDeviceMenuLanguage(CECDEVICE_TV));
-+    m_adapter->SetMenuLanguage(language.c_str());
-   }
-   else
-   {
-@@ -1553,9 +1529,9 @@ std::string CPeripheralCecAdapterUpdateThread::UpdateAudioSystemStatus(void)
-   if (m_adapter->m_cecAdapter->IsActiveDeviceType(CEC_DEVICE_TYPE_AUDIO_SYSTEM))
-   {
-     // request the OSD name of the amp
--    cec_osd_name ampName = m_adapter->m_cecAdapter->GetDeviceOSDName(CECDEVICE_AUDIOSYSTEM);
--    CLog::Log(LOGDEBUG, "%s - CEC capable amplifier found (%s). volume will be controlled on the amp", __FUNCTION__, ampName.name);
--    strAmpName += StringUtils::Format("%s", ampName.name);
-+    std::string ampName(m_adapter->m_cecAdapter->GetDeviceOSDName(CECDEVICE_AUDIOSYSTEM));
-+    CLog::Log(LOGDEBUG, "%s - CEC capable amplifier found (%s). volume will be controlled on the amp", __FUNCTION__, ampName.c_str());
-+    strAmpName += StringUtils::Format("%s", ampName.c_str());
-
-     // set amp present
-     m_adapter->SetAudioSystemConnected(true);
-@@ -1592,8 +1568,8 @@ bool CPeripheralCecAdapterUpdateThread::SetInitialConfiguration(void)
-
-   // request the OSD name of the TV
-   std::string strNotification;
--  cec_osd_name tvName = m_adapter->m_cecAdapter->GetDeviceOSDName(CECDEVICE_TV);
--  strNotification = StringUtils::Format("%s: %s", g_localizeStrings.Get(36016).c_str(), tvName.name);
-+  std::string tvName(m_adapter->m_cecAdapter->GetDeviceOSDName(CECDEVICE_TV));
-+  strNotification = StringUtils::Format("%s: %s", g_localizeStrings.Get(36016).c_str(), tvName.c_str());
-
-   std::string strAmpName = UpdateAudioSystemStatus();
-   if (!strAmpName.empty())
-@@ -1766,7 +1742,7 @@ void CPeripheralCecAdapter::ProcessStandbyDevices(void)
-       m_standbySent = CDateTime::GetCurrentDateTime();
-       m_cecAdapter->StandbyDevices(CECDEVICE_BROADCAST);
-     }
--    else if (m_configuration.bSendInactiveSource == 1)
-+    else if (m_bSendInactiveSource == 1)
-     {
-       CLog::Log(LOGDEBUG, "%s - sending inactive source commands", __FUNCTION__);
-       m_cecAdapter->SetInactiveView();
-diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.h b/xbmc/peripherals/devices/PeripheralCecAdapter.h
-index e7f769f..30b22c9 100644
---- a/xbmc/peripherals/devices/PeripheralCecAdapter.h
-+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.h
-@@ -146,12 +146,12 @@ namespace PERIPHERALS
-     void SetMenuLanguage(const char *strLanguage);
-
-     // callbacks from libCEC
--    static int CecLogMessage(void *cbParam, const CEC::cec_log_message message);
--    static int CecCommand(void *cbParam, const CEC::cec_command command);
--    static int CecConfiguration(void *cbParam, const CEC::libcec_configuration config);
--    static int CecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter data);
-+    static void CecLogMessage(void *cbParam, const CEC::cec_log_message* message);
-+    static void CecCommand(void *cbParam, const CEC::cec_command* command);
-+    static void CecConfiguration(void *cbParam, const CEC::libcec_configuration* config);
-+    static void CecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter data);
-     static void CecSourceActivated(void *param, const CEC::cec_logical_address address, const uint8_t activated);
--    static int CecKeyPress(void *cbParam, const CEC::cec_keypress key);
-+    static void CecKeyPress(void *cbParam, const CEC::cec_keypress* key);
-
-     DllLibCEC*                        m_dll;
-     CEC::ICECAdapter*                 m_cecAdapter;
-@@ -181,7 +181,12 @@ namespace PERIPHERALS
-     bool                              m_bActiveSourceBeforeStandby;
-     bool                              m_bOnPlayReceived;
-     bool                              m_bPlaybackPaused;
--    std::string                        m_strComPort;
-+    std::string                       m_strComPort;
-+    bool                              m_bPowerOnScreensaver;
-+    bool                              m_bUseTVMenuLanguage;
-+    bool                              m_bSendInactiveSource;
-+    bool                              m_bPowerOffScreensaver;
-+    bool                              m_bShutdownOnStandby;
-   };
-
-   class CPeripheralCecAdapterUpdateThread : public CThread
-
-From 82fe52deb8c11df31fbdf8c298b28a5e1a1491aa Mon Sep 17 00:00:00 2001
-From: Lars Op den Kamp <lars at opdenkamp.eu>
-Date: Fri, 11 Nov 2016 10:09:48 +0100
-Subject: [PATCH 2/4] [cec] Added advanced settings for action when TV goes
- standby
-
-Added advances settings for action when TV goes standby : Pause
-playback, Stop playback, Exit Kodi
----
- system/peripherals.xml                            |  2 +-
- xbmc/peripherals/devices/PeripheralCecAdapter.cpp | 47 ++++++++++++++++++-----
- xbmc/peripherals/devices/PeripheralCecAdapter.h   |  1 +
- 3 files changed, 39 insertions(+), 11 deletions(-)
-
-diff --git a/system/peripherals.xml b/system/peripherals.xml
-index 58a9d24..1fa31e1 100644
---- a/system/peripherals.xml
-+++ b/system/peripherals.xml
-@@ -16,7 +16,7 @@
-     <setting key="send_inactive_source" type="bool" value="1" label="36025" order="5" />
-     <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="6" />
-     <setting key="cec_wake_screensaver" type="bool" value="1" label="36010" order="7" />
--    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="8" lvalues="36028|13005|13011" />
-+    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="8" lvalues="36028|13005|13011|13009|36043|36045" />
-     <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="9" />
-     <setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="10" />
-     <setting key="pause_playback_on_deactivate" type="bool" value="1" label="36033" configurable="0" />
-diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-index a71dc4b..1b7c38e 100644
---- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-@@ -55,6 +55,10 @@ using namespace CEC;
- #define LOCALISED_ID_TV_AVR       36039
- #define LOCALISED_ID_STOP         36044
- #define LOCALISED_ID_PAUSE        36045
-+#define LOCALISED_ID_POWEROFF     13005
-+#define LOCALISED_ID_SUSPEND      13011
-+#define LOCALISED_ID_QUIT         13009
-+#define LOCALISED_ID_IGNORE       36028
-
- #define LOCALISED_ID_NONE         231
-
-@@ -619,6 +623,35 @@ void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage)
-     CLog::Log(LOGWARNING, "%s - TV menu language set to unknown value '%s'", __FUNCTION__, strLanguage);
- }
-
-+void CPeripheralCecAdapter::OnTvStandby(void)
-+{
-+  int iActionOnTvStandby = GetSettingInt("standby_pc_on_tv_standby");
-+  switch (iActionOnTvStandby)
-+  {
-+  case LOCALISED_ID_POWEROFF:
-+    m_bStarted = false;
-+    g_application.ExecuteXBMCAction("Shutdown");
-+    break;
-+  case LOCALISED_ID_SUSPEND:
-+    m_bStarted = false;
-+    g_application.ExecuteXBMCAction("Suspend");
-+    break;
-+  case LOCALISED_ID_QUIT:
-+    m_bStarted = false;
-+    g_application.ExecuteXBMCAction("Quit");
-+    break;
-+  case LOCALISED_ID_PAUSE:
-+    g_application.OnAction(CAction(ACTION_PAUSE));
-+    break;
-+  case LOCALISED_ID_STOP:
-+    g_application.StopPlaying();
-+    break;
-+  default:
-+    CLog::Log(LOGERROR, "%s - Unexpected [standby_pc_on_tv_standby] setting value", __FUNCTION__);
-+    break;
-+  }
-+}
-+
- void CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command* command)
- {
-   CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
-@@ -630,16 +663,10 @@ void CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command* command
-     switch (command->opcode)
-     {
-     case CEC_OPCODE_STANDBY:
--      /* a device was put in standby mode */
-       if (command->initiator == CECDEVICE_TV &&
--          (adapter->m_configuration.bPowerOffOnStandby == 1 || adapter->m_bShutdownOnStandby) &&
-           (!adapter->m_standbySent.IsValid() || CDateTime::GetCurrentDateTime() - adapter->m_standbySent > CDateTimeSpan(0, 0, 0, SCREENSAVER_TIMEOUT)))
-       {
--        adapter->m_bStarted = false;
--        if (adapter->m_configuration.bPowerOffOnStandby == 1)
--          g_application.ExecuteXBMCAction("Suspend");
--        else if (adapter->m_bShutdownOnStandby)
--          g_application.ExecuteXBMCAction("Shutdown");
-+        adapter->OnTvStandby();
-       }
-       break;
-     case CEC_OPCODE_SET_MENU_LANGUAGE:
-@@ -1360,8 +1387,8 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
-
-   // read the mutually exclusive boolean settings
-   int iStandbyAction(GetSettingInt("standby_pc_on_tv_standby"));
--  m_configuration.bPowerOffOnStandby = iStandbyAction == 13011 ? 1 : 0;
--  m_bShutdownOnStandby = iStandbyAction == 13005;
-+  m_configuration.bPowerOffOnStandby = iStandbyAction == LOCALISED_ID_SUSPEND ? 1 : 0;
-+  m_bShutdownOnStandby = iStandbyAction == LOCALISED_ID_POWEROFF;
-
- #if defined(CEC_DOUBLE_TAP_TIMEOUT_MS_OLD)
-   // double tap prevention timeout in ms. libCEC uses 50ms units for this in 2.2.0, so divide by 50
-@@ -1373,7 +1400,7 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
-
-   if (GetSettingBool("pause_playback_on_deactivate"))
-   {
--    SetSetting("pause_or_stop_playback_on_deactivate", 36045);
-+    SetSetting("pause_or_stop_playback_on_deactivate", LOCALISED_ID_PAUSE);
-     SetSetting("pause_playback_on_deactivate", false);
-   }
- }
-diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.h b/xbmc/peripherals/devices/PeripheralCecAdapter.h
-index 30b22c9..9274eab 100644
---- a/xbmc/peripherals/devices/PeripheralCecAdapter.h
-+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.h
-@@ -144,6 +144,7 @@ namespace PERIPHERALS
-
-     void SetAudioSystemConnected(bool bSetTo);
-     void SetMenuLanguage(const char *strLanguage);
-+    void OnTvStandby(void);
-
-     // callbacks from libCEC
-     static void CecLogMessage(void *cbParam, const CEC::cec_log_message* message);
-
-From f0e1725617e41e841c9c24a20f1fc9b37347c8c3 Mon Sep 17 00:00:00 2001
-From: Lars Op den Kamp <lars at opdenkamp.eu>
-Date: Fri, 11 Nov 2016 10:09:56 +0100
-Subject: [PATCH 3/4] [cec] add CEC IMX adapter as known type and set no
- polling.
-
-that eliminates extensive periodic /sys walkthrough
-
-(this is reused Lars's commit e59d7e028288464e6890141a830e4a83d4b9d065)
----
- xbmc/peripherals/PeripheralTypes.h                | 5 +++++
- xbmc/peripherals/bus/virtual/PeripheralBusCEC.cpp | 6 ++++++
- 2 files changed, 11 insertions(+)
-
-diff --git a/xbmc/peripherals/PeripheralTypes.h b/xbmc/peripherals/PeripheralTypes.h
-index 34ce2ef..c87242f 100644
---- a/xbmc/peripherals/PeripheralTypes.h
-+++ b/xbmc/peripherals/PeripheralTypes.h
-@@ -38,7 +38,8 @@
-     PERIPHERAL_BUS_USB,
-     PERIPHERAL_BUS_PCI,
-     PERIPHERAL_BUS_RPI,
--    PERIPHERAL_BUS_CEC
-+    PERIPHERAL_BUS_CEC,
-+    PERIPHERAL_BUS_IMX
-   };
-
-   enum PeripheralFeature
-@@ -173,6 +174,8 @@ namespace PERIPHERALS
-         return "pci";
-       case PERIPHERAL_BUS_RPI:
-         return "rpi";
-+      case PERIPHERAL_BUS_IMX:
-+        return "imx";
-       case PERIPHERAL_BUS_CEC:
-         return "cec";
-       case PERIPHERAL_BUS_ADDON:
-@@ -197,6 +200,8 @@ namespace PERIPHERALS
-         return PERIPHERAL_BUS_PCI;
-       else if (strTypeLowerCase == "rpi")
-         return PERIPHERAL_BUS_RPI;
-+      else if (strTypeLowerCase == "imx")
-+        return PERIPHERAL_BUS_IMX;
-       else if (strTypeLowerCase == "cec")
-         return PERIPHERAL_BUS_CEC;
-       else if (strTypeLowerCase == "addon")
-diff --git a/xbmc/peripherals/bus/virtual/PeripheralBusCEC.cpp b/xbmc/peripherals/bus/virtual/PeripheralBusCEC.cpp
-index b04fe00..abd0a6b 100644
---- a/xbmc/peripherals/bus/virtual/PeripheralBusCEC.cpp
-+++ b/xbmc/peripherals/bus/virtual/PeripheralBusCEC.cpp
-@@ -102,6 +102,12 @@ bool CPeripheralBusCEC::PerformDeviceScan(PeripheralScanResults &results)
-       /** the Pi's adapter cannot be removed, no need to rescan */
-       m_bNeedsPolling = false;
-       break;
-+#if defined(HAS_IMXVPU)
-+    case ADAPTERTYPE_IMX:
-+      result.m_mappedBusType = PERIPHERAL_BUS_IMX;
-+      m_bNeedsPolling = false;
-+      break;
-+#endif
-     default:
-       break;
-     }
-
-From cfcfb4c98cf1a6d756fc3962e6d803c297917684 Mon Sep 17 00:00:00 2001
-From: Lars Op den Kamp <lars at opdenkamp.eu>
-Date: Fri, 11 Nov 2016 10:10:07 +0100
-Subject: [PATCH 4/4] [cec] added: setting to make libCEC wake up the AVR
- explicitly when activating the source.
-
-ref: https://github.com/Pulse-Eight/libcec/issues/156
----
- addons/resource.language.en_gb/resources/strings.po | 7 ++++++-
- system/peripherals.xml                              | 3 ++-
- xbmc/peripherals/devices/PeripheralCecAdapter.cpp   | 1 +
- 3 files changed, 9 insertions(+), 2 deletions(-)
-
-diff --git a/system/peripherals.xml b/system/peripherals.xml
-index 1fa31e1..ed707b6 100644
---- a/system/peripherals.xml
-+++ b/system/peripherals.xml
-@@ -16,7 +16,7 @@
-     <setting key="send_inactive_source" type="bool" value="1" label="36025" order="5" />
-     <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="6" />
-     <setting key="cec_wake_screensaver" type="bool" value="1" label="36010" order="7" />
--    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="8" lvalues="36028|13005|13011|13009|36043|36045" />
-+    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="8" lvalues="36028|13005|13011|13009|36044|36046" />
-     <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="9" />
-     <setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="10" />
-     <setting key="pause_playback_on_deactivate" type="bool" value="1" label="36033" configurable="0" />
-@@ -24,6 +24,7 @@
-     <setting key="connected_device" type="enum" label="36019" value="36037" lvalues="36037|36038" order="12" />
-     <setting key="cec_hdmi_port" type="int" value="1" min="1" max="15" label="36015" order="13" />
-     <setting key="physical_address" type="string" label="36021" value="0" order="14" />
-+    <setting key="power_avr_on_as" type="bool" label="36045" value="0" order="15" />
-
-     <setting key="tv_vendor" type="int" value="0" configurable="0" />
-     <setting key="device_name" type="string" value="Kodi" configurable="0" />
-diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-index 1b7c38e..d032ffd 100644
---- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-@@ -1384,6 +1384,7 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
-   m_bPowerOffScreensaver               = GetSettingBool("cec_standby_screensaver") ? 1 : 0;
-   m_bPowerOnScreensaver                = GetSettingBool("cec_wake_screensaver") ? 1 : 0;
-   m_bSendInactiveSource                = GetSettingBool("send_inactive_source") ? 1 : 0;
-+  m_configuration.bAutoWakeAVR         = GetSettingBool("power_avr_on_as") ? 1 : 0;
-
-   // read the mutually exclusive boolean settings
-   int iStandbyAction(GetSettingInt("standby_pc_on_tv_standby"));

Deleted: 17804.patch
===================================================================
--- 17804.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ 17804.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,25 +0,0 @@
-From 977af616e53f21df97668ca4b76ceb20737df9f3 Mon Sep 17 00:00:00 2001
-From: nl6720 <nl6720 at gmail.com>
-Date: Tue, 5 May 2020 12:21:55 +0300
-Subject: [PATCH] [kodi-standalone.sh] Replace which with command -v
-
-The which utility is not guaranteed to be installed. Use the portable shell builtin command -v.
----
- tools/Linux/kodi-standalone.sh.pulse | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/tools/Linux/kodi-standalone.sh.pulse b/tools/Linux/kodi-standalone.sh.pulse
-index c4d556434427..5273094b5574 100644
---- a/tools/Linux/kodi-standalone.sh.pulse
-+++ b/tools/Linux/kodi-standalone.sh.pulse
-@@ -1,8 +1,8 @@
--PULSE_START="$(which start-pulseaudio-x11)"
-+PULSE_START="$(command -v start-pulseaudio-x11)"
- if [ -n "$PULSE_START" ]; then
-   $PULSE_START
- else
--  PULSE_SESSION="$(which pulse-session)"
-+  PULSE_SESSION="$(command -v pulse-session)"
-   if [ -n "$PULSE_SESSION" ]; then
-     XBMC="$PULSE_SESSION $XBMC"
-   fi

Deleted: 18131.patch
===================================================================
--- 18131.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ 18131.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,1256 +0,0 @@
-diff --git a/xbmc/network/WebServer.cpp b/xbmc/network/WebServer.cpp
-index 7834042..a1c6923 100644
---- a/xbmc/network/WebServer.cpp
-+++ b/xbmc/network/WebServer.cpp
-@@ -36,14 +36,18 @@
- 
- #define MAX_POST_BUFFER_SIZE 2048
- 
--#define PAGE_FILE_NOT_FOUND "<html><head><title>File not found</title></head><body>File not found</body></html>"
--#define NOT_SUPPORTED       "<html><head><title>Not Supported</title></head><body>The method you are trying to use is not supported by this server</body></html>"
-+#define PAGE_FILE_NOT_FOUND \
-+  "<html><head><title>File not found</title></head><body>File not found</body></html>"
-+#define NOT_SUPPORTED \
-+  "<html><head><title>Not Supported</title></head><body>The method you are trying to use is not " \
-+  "supported by this server</body></html>"
- 
- #define HEADER_VALUE_NO_CACHE "no-cache"
- 
--#define HEADER_NEWLINE        "\r\n"
-+#define HEADER_NEWLINE "\r\n"
- 
--typedef struct {
-+typedef struct
-+{
-   std::shared_ptr<XFILE::CFile> file;
-   CHttpRanges ranges;
-   size_t rangeCountTotal;
-@@ -62,7 +66,7 @@ CWebServer::CWebServer()
-     m_cert()
- {
- #if defined(TARGET_DARWIN)
--  void *stack_addr;
-+  void* stack_addr;
-   pthread_attr_t attr;
-   pthread_attr_init(&attr);
-   pthread_attr_getstack(&attr, &stack_addr, &m_thread_stacksize);
-@@ -86,16 +90,16 @@ static MHD_Response* create_response(size_t size, const void* data, int free, in
-   return MHD_create_response_from_buffer(size, const_cast<void*>(data), mode);
- }
- 
--int CWebServer::AskForAuthentication(const HTTPRequest& request) const
-+MHD_RESULT CWebServer::AskForAuthentication(const HTTPRequest& request) const
- {
--  struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO);
-+  struct MHD_Response* response = create_response(0, nullptr, MHD_NO, MHD_NO);
-   if (!response)
-   {
-     CLog::Log(LOGERROR, "CWebServer[%hu]: unable to create HTTP Unauthorized response", m_port);
-     return MHD_NO;
-   }
- 
--  int ret = AddHeader(response, MHD_HTTP_HEADER_CONNECTION, "close");
-+  MHD_RESULT ret = AddHeader(response, MHD_HTTP_HEADER_CONNECTION, "close");
-   if (!ret)
-   {
-     CLog::Log(LOGERROR, "CWebServer[%hu]: unable to prepare HTTP Unauthorized response", m_port);
-@@ -105,7 +109,10 @@ int CWebServer::AskForAuthentication(const HTTPRequest& request) const
- 
-   LogResponse(request, MHD_HTTP_UNAUTHORIZED);
- 
--  ret = MHD_queue_basic_auth_fail_response(request.connection, "XBMC", response);
-+  // This MHD_RESULT cast is only necessary for libmicrohttpd 0.9.71
-+  // The return type of MHD_queue_basic_auth_fail_response was fixed for future versions
-+  // See https://git.gnunet.org/libmicrohttpd.git/commit/?id=860b42e9180da4dcd7e8690a3fcdb4e37e5772c5
-+  ret = (MHD_RESULT) MHD_queue_basic_auth_fail_response(request.connection, "XBMC", response);
-   MHD_destroy_response(response);
- 
-   return ret;
-@@ -135,10 +142,14 @@ bool CWebServer::IsAuthenticated(const HTTPRequest& request) const
-   return authenticated;
- }
- 
--int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection,
--                      const char *url, const char *method,
--                      const char *version, const char *upload_data,
--                      size_t *upload_data_size, void **con_cls)
-+MHD_RESULT CWebServer::AnswerToConnection(void* cls,
-+                                          struct MHD_Connection* connection,
-+                                          const char* url,
-+                                          const char* method,
-+                                          const char* version,
-+                                          const char* upload_data,
-+                                          size_t* upload_data_size,
-+                                          void** con_cls)
- {
-   if (cls == nullptr || con_cls == nullptr || *con_cls == nullptr)
-   {
-@@ -146,7 +157,7 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection,
-     return MHD_NO;
-   }
- 
--  CWebServer *webServer = reinterpret_cast<CWebServer*>(cls);
-+  CWebServer* webServer = reinterpret_cast<CWebServer*>(cls);
-   if (webServer == nullptr)
-   {
-     CLog::Log(LOGERROR, "CWebServer[unknown]: invalid request received");
-@@ -155,15 +166,22 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection,
- 
-   ConnectionHandler* connectionHandler = reinterpret_cast<ConnectionHandler*>(*con_cls);
-   HTTPMethod methodType = GetHTTPMethod(method);
--  HTTPRequest request = { webServer, connection, connectionHandler->fullUri, url, methodType, version };
-+  HTTPRequest request = {webServer, connection, connectionHandler->fullUri,
-+                         url,       methodType, version};
- 
-   if (connectionHandler->isNew)
-     webServer->LogRequest(request);
- 
--  return webServer->HandlePartialRequest(connection, connectionHandler, request, upload_data, upload_data_size, con_cls);
-+  return webServer->HandlePartialRequest(connection, connectionHandler, request, upload_data,
-+                                         upload_data_size, con_cls);
- }
- 
--int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request, const char *upload_data, size_t *upload_data_size, void **con_cls)
-+MHD_RESULT CWebServer::HandlePartialRequest(struct MHD_Connection* connection,
-+                                            ConnectionHandler* connectionHandler,
-+                                            const HTTPRequest& request,
-+                                            const char* upload_data,
-+                                            size_t* upload_data_size,
-+                                            void** con_cls)
- {
-   std::unique_ptr<ConnectionHandler> conHandler(connectionHandler);
- 
-@@ -196,17 +214,18 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
-           if (handler->GetLastModifiedDate(lastModified) && lastModified.IsValid())
-           {
-             // handle If-Modified-Since or If-Unmodified-Since
--            std::string ifModifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_MODIFIED_SINCE);
--            std::string ifUnmodifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE);
-+            std::string ifModifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(
-+                connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_MODIFIED_SINCE);
-+            std::string ifUnmodifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(
-+                connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE);
- 
-             CDateTime ifModifiedSinceDate;
-             CDateTime ifUnmodifiedSinceDate;
-             // handle If-Modified-Since (but only if the response is cacheable)
--            if (cacheable &&
--              ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) &&
--              lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate)
-+            if (cacheable && ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) &&
-+                lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate)
-             {
--              struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO);
-+              struct MHD_Response* response = create_response(0, nullptr, MHD_NO, MHD_NO);
-               if (response == nullptr)
-               {
-                 CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP 304 response", m_port);
-@@ -217,7 +236,7 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
-             }
-             // handle If-Unmodified-Since
-             else if (ifUnmodifiedSinceDate.SetFromRFC1123DateTime(ifUnmodifiedSince) &&
--              lastModified.GetAsUTCDateTime() > ifUnmodifiedSinceDate)
-+                     lastModified.GetAsUTCDateTime() > ifUnmodifiedSinceDate)
-               return SendErrorResponse(request, MHD_HTTP_PRECONDITION_FAILED, request.method);
-           }
- 
-@@ -231,7 +250,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
-         // as ownership of the connection handler is passed to libmicrohttpd we must not destroy it
-         SetupPostDataProcessing(request, conHandler.get(), handler, con_cls);
- 
--        // as ownership of the connection handler has been passed to libmicrohttpd we must not destroy it
-+        // as ownership of the connection handler has been passed to libmicrohttpd we must not
-+        // destroy it
-         conHandler.release();
- 
-         return MHD_YES;
-@@ -249,7 +269,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
-       // process additional / remaining POST data
-       if (ProcessPostData(request, conHandler.get(), upload_data, upload_data_size, con_cls))
-       {
--        // as ownership of the connection handler has been passed to libmicrohttpd we must not destroy it
-+        // as ownership of the connection handler has been passed to libmicrohttpd we must not
-+        // destroy it
-         conHandler.release();
- 
-         return MHD_YES;
-@@ -266,7 +287,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
-       return HandleRequest(conHandler->requestHandler);
-     }
- 
--    // it's unusual to get more than one call to AnswerToConnection for none-POST requests, but let's handle it anyway
-+    // it's unusual to get more than one call to AnswerToConnection for none-POST requests, but
-+    // let's handle it anyway
-     auto requestHandler = FindRequestHandler(request);
-     if (requestHandler != nullptr)
-       return HandleRequest(requestHandler);
-@@ -276,15 +298,20 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
-   return SendErrorResponse(request, MHD_HTTP_NOT_FOUND, request.method);
- }
- 
--int CWebServer::HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key,
--                                const char *filename, const char *content_type,
--                                const char *transfer_encoding, const char *data, uint64_t off,
--                                size_t size)
-+MHD_RESULT CWebServer::HandlePostField(void* cls,
-+                                       enum MHD_ValueKind kind,
-+                                       const char* key,
-+                                       const char* filename,
-+                                       const char* content_type,
-+                                       const char* transfer_encoding,
-+                                       const char* data,
-+                                       uint64_t off,
-+                                       size_t size)
- {
--  ConnectionHandler *conHandler = (ConnectionHandler *)cls;
-+  ConnectionHandler* conHandler = (ConnectionHandler*)cls;
- 
--  if (conHandler == nullptr || conHandler->requestHandler == nullptr ||
--      key == nullptr || data == nullptr || size == 0)
-+  if (conHandler == nullptr || conHandler->requestHandler == nullptr || key == nullptr ||
-+      data == nullptr || size == 0)
-   {
-     CLog::Log(LOGERROR, "CWebServer: unable to handle HTTP POST field");
-     return MHD_NO;
-@@ -294,21 +321,21 @@ int CWebServer::HandlePostField(void *cls, enum MHD_ValueKind kind, const char *
-   return MHD_YES;
- }
- 
--int CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler)
-+MHD_RESULT CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler)
- {
-   if (handler == nullptr)
-     return MHD_NO;
- 
-   HTTPRequest request = handler->GetRequest();
--  int ret = handler->HandleRequest();
-+  MHD_RESULT ret = handler->HandleRequest();
-   if (ret == MHD_NO)
-   {
-     CLog::Log(LOGERROR, "CWebServer[%hu]: failed to handle HTTP request for %s", m_port, request.pathUrl.c_str());
-     return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
-   }
- 
--  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
--  struct MHD_Response *response = nullptr;
-+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
-+  struct MHD_Response* response = nullptr;
-   switch (responseDetails.type)
-   {
-     case HTTPNone:
-@@ -331,7 +358,8 @@ int CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handle
-       break;
- 
-     case HTTPError:
--      ret = CreateErrorResponse(request.connection, responseDetails.status, request.method, response);
-+      ret =
-+          CreateErrorResponse(request.connection, responseDetails.status, request.method, response);
-       break;
- 
-     default:
-@@ -348,13 +376,15 @@ int CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handle
-   return FinalizeRequest(handler, responseDetails.status, response);
- }
- 
--int CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler, int responseStatus, struct MHD_Response *response)
-+MHD_RESULT CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler,
-+                                       int responseStatus,
-+                                       struct MHD_Response* response)
- {
-   if (handler == nullptr || response == nullptr)
-     return MHD_NO;
- 
--  const HTTPRequest &request = handler->GetRequest();
--  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
-+  const HTTPRequest& request = handler->GetRequest();
-+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
- 
-   // if the request handler has set a content type and it hasn't been set as a header, add it
-   if (!responseDetails.contentType.empty())
-@@ -380,7 +410,8 @@ int CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& hand
- 
-     // if the response can't be cached or the maximum age is 0 force the client not to cache
-     if (!handler->CanBeCached() || maxAge == 0)
--      handler->AddResponseHeader(MHD_HTTP_HEADER_CACHE_CONTROL, "private, max-age=0, " HEADER_VALUE_NO_CACHE);
-+      handler->AddResponseHeader(MHD_HTTP_HEADER_CACHE_CONTROL,
-+                                 "private, max-age=0, " HEADER_VALUE_NO_CACHE);
-     else
-     {
-       // create the value of the Cache-Control header
-@@ -416,14 +447,14 @@ int CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& hand
-   return SendResponse(request, responseStatus, response);
- }
- 
--std::shared_ptr<IHTTPRequestHandler> CWebServer::FindRequestHandler(const HTTPRequest& request) const
-+std::shared_ptr<IHTTPRequestHandler> CWebServer::FindRequestHandler(
-+    const HTTPRequest& request) const
- {
-   // look for a IHTTPRequestHandler which can take care of the current request
-   auto requestHandlerIt = std::find_if(m_requestHandlers.cbegin(), m_requestHandlers.cend(),
--    [&request](const IHTTPRequestHandler* requestHandler)
--    {
--      return requestHandler->CanHandleRequest(request);
--    });
-+                                       [&request](const IHTTPRequestHandler* requestHandler) {
-+                                         return requestHandler->CanHandleRequest(request);
-+                                       });
- 
-   // we found a matching IHTTPRequestHandler so let's get a new instance for this request
-   if (requestHandlerIt != m_requestHandlers.cend())
-@@ -435,7 +466,8 @@ std::shared_ptr<IHTTPRequestHandler> CWebServer::FindRequestHandler(const HTTPRe
- bool CWebServer::IsRequestCacheable(const HTTPRequest& request) const
- {
-   // handle Cache-Control
--  std::string cacheControl = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CACHE_CONTROL);
-+  std::string cacheControl = HTTPRequestHandlerUtils::GetRequestHeaderValue(
-+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CACHE_CONTROL);
-   if (!cacheControl.empty())
-   {
-     std::vector<std::string> cacheControls = StringUtils::Split(cacheControl, ",");
-@@ -450,23 +482,26 @@ bool CWebServer::IsRequestCacheable(const HTTPRequest& request) const
-   }
- 
-   // handle Pragma
--  std::string pragma = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_PRAGMA);
-+  std::string pragma = HTTPRequestHandlerUtils::GetRequestHeaderValue(
-+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_PRAGMA);
-   if (pragma.compare(HEADER_VALUE_NO_CACHE) == 0)
-     return false;
- 
-   return true;
- }
- 
--bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &lastModified) const
-+bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime& lastModified) const
- {
-   // parse the Range header and store it in the request object
-   CHttpRanges ranges;
--  bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE));
-+  bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue(
-+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE));
- 
-   // handle If-Range header but only if the Range header is present
-   if (ranged && lastModified.IsValid())
-   {
--    std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE);
-+    std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue(
-+        request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE);
-     if (!ifRange.empty() && lastModified.IsValid())
-     {
-       CDateTime ifRangeDate;
-@@ -482,25 +517,33 @@ bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &la
-   return !ranges.IsEmpty();
- }
- 
--void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, ConnectionHandler *connectionHandler, std::shared_ptr<IHTTPRequestHandler> handler, void **con_cls) const
-+void CWebServer::SetupPostDataProcessing(const HTTPRequest& request,
-+                                         ConnectionHandler* connectionHandler,
-+                                         std::shared_ptr<IHTTPRequestHandler> handler,
-+                                         void** con_cls) const
- {
-   connectionHandler->requestHandler = handler;
- 
--  // we might need to handle the POST data ourselves which is done in the next call to AnswerToConnection
-+  // we might need to handle the POST data ourselves which is done in the next call to
-+  // AnswerToConnection
-   *con_cls = connectionHandler;
- 
-   // get the content-type of the POST data
--  const auto contentType = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE);
-+  const auto contentType = HTTPRequestHandlerUtils::GetRequestHeaderValue(
-+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE);
-   if (contentType.empty())
-     return;
- 
--  // if the content-type is neither application/x-ww-form-urlencoded nor multipart/form-data we need to handle it ourselves
-+  // if the content-type is neither application/x-ww-form-urlencoded nor multipart/form-data we need
-+  // to handle it ourselves
-   if (!StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_FORM_URLENCODED) &&
-       !StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))
-     return;
- 
-   // otherwise we can use MHD's POST processor
--  connectionHandler->postprocessor = MHD_create_post_processor(request.connection, MAX_POST_BUFFER_SIZE, &CWebServer::HandlePostField, static_cast<void*>(connectionHandler));
-+  connectionHandler->postprocessor = MHD_create_post_processor(
-+      request.connection, MAX_POST_BUFFER_SIZE, &CWebServer::HandlePostField,
-+      static_cast<void*>(connectionHandler));
- 
-   // MHD doesn't seem to be able to handle this post request
-   if (connectionHandler->postprocessor == nullptr)
-@@ -510,7 +553,11 @@ void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, ConnectionH
-   }
- }
- 
--bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler *connectionHandler, const char *upload_data, size_t *upload_data_size, void **con_cls) const
-+bool CWebServer::ProcessPostData(const HTTPRequest& request,
-+                                 ConnectionHandler* connectionHandler,
-+                                 const char* upload_data,
-+                                 size_t* upload_data_size,
-+                                 void** con_cls) const
- {
-   if (connectionHandler->requestHandler == nullptr)
-   {
-@@ -531,10 +578,12 @@ bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler *
-     bool postDataHandled = false;
-     // either use MHD's POST processor
-     if (connectionHandler->postprocessor != nullptr)
--      postDataHandled = MHD_post_process(connectionHandler->postprocessor, upload_data, *upload_data_size) == MHD_YES;
-+      postDataHandled = MHD_post_process(connectionHandler->postprocessor, upload_data,
-+                                         *upload_data_size) == MHD_YES;
-     // or simply copy the data to the handler
-     else if (connectionHandler->requestHandler != nullptr)
--      postDataHandled = connectionHandler->requestHandler->AddPostData(upload_data, *upload_data_size);
-+      postDataHandled =
-+          connectionHandler->requestHandler->AddPostData(upload_data, *upload_data_size);
- 
-     // abort if the received POST data couldn't be handled
-     if (!postDataHandled)
-@@ -554,7 +603,7 @@ bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler *
-   return true;
- }
- 
--void CWebServer::FinalizePostDataProcessing(ConnectionHandler *connectionHandler) const
-+void CWebServer::FinalizePostDataProcessing(ConnectionHandler* connectionHandler) const
- {
-   if (connectionHandler->postprocessor == nullptr)
-     return;
-@@ -562,13 +611,14 @@ void CWebServer::FinalizePostDataProcessing(ConnectionHandler *connectionHandler
-   MHD_destroy_post_processor(connectionHandler->postprocessor);
- }
- 
--int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const
-+MHD_RESULT CWebServer::CreateMemoryDownloadResponse(
-+    const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response*& response) const
- {
-   if (handler == nullptr)
-     return MHD_NO;
- 
--  const HTTPRequest &request = handler->GetRequest();
--  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
-+  const HTTPRequest& request = handler->GetRequest();
-+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
-   HttpResponseRanges responseRanges = handler->GetResponseData();
- 
-   // check if the response is completely empty
-@@ -577,7 +627,7 @@ int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestH
- 
-   // check if the response contains more ranges than the request asked for
-   if ((request.ranges.IsEmpty() && responseRanges.size() > 1) ||
--     (!request.ranges.IsEmpty() && responseRanges.size() > request.ranges.Size()))
-+      (!request.ranges.IsEmpty() && responseRanges.size() > request.ranges.Size()))
-   {
-     CLog::Log(LOGWARNING, "CWebServer[%hu]: response contains more ranges (%d) than the request asked for (%d)", m_port, (int)responseRanges.size(), (int)request.ranges.Size());
-     return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
-@@ -600,33 +650,38 @@ int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestH
- 
-     switch (responseDetails.type)
-     {
--    case HTTPMemoryDownloadNoFreeNoCopy:
--      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, false, false, response);
-+      case HTTPMemoryDownloadNoFreeNoCopy:
-+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
-+                                            false, false, response);
- 
--    case HTTPMemoryDownloadNoFreeCopy:
--      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, false, true, response);
-+      case HTTPMemoryDownloadNoFreeCopy:
-+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
-+                                            false, true, response);
- 
--    case HTTPMemoryDownloadFreeNoCopy:
--      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, true, false, response);
-+      case HTTPMemoryDownloadFreeNoCopy:
-+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
-+                                            true, false, response);
- 
--    case HTTPMemoryDownloadFreeCopy:
--      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, true, true, response);
-+      case HTTPMemoryDownloadFreeCopy:
-+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
-+                                            true, true, response);
- 
--    default:
--      return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
-+      default:
-+        return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
-     }
-   }
- 
-   return CreateRangedMemoryDownloadResponse(handler, response);
- }
- 
--int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const
-+MHD_RESULT CWebServer::CreateRangedMemoryDownloadResponse(
-+    const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response*& response) const
- {
-   if (handler == nullptr)
-     return MHD_NO;
- 
--  const HTTPRequest &request = handler->GetRequest();
--  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
-+  const HTTPRequest& request = handler->GetRequest();
-+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
-   HttpResponseRanges responseRanges = handler->GetResponseData();
- 
-   // if there's no or only one range this is not the right place
-@@ -658,8 +713,10 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
-   // adjust the HTTP status of the response
-   handler->SetResponseStatus(MHD_HTTP_PARTIAL_CONTENT);
-   // add Content-Range header
--  handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_RANGE,
--    HttpRangeUtils::GenerateContentRangeHeaderValue(firstRangePosition, lastRangePosition, responseDetails.totalLength));
-+  handler->AddResponseHeader(
-+      MHD_HTTP_HEADER_CONTENT_RANGE,
-+      HttpRangeUtils::GenerateContentRangeHeaderValue(firstRangePosition, lastRangePosition,
-+                                                      responseDetails.totalLength));
- 
-   // generate a multipart boundary
-   std::string multipartBoundary = HttpRangeUtils::GenerateMultipartBoundary();
-@@ -670,7 +727,8 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
-   handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_TYPE, contentType);
- 
-   // generate the multipart boundary with the Content-Type header field
--  std::string multipartBoundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundary, contentType);
-+  std::string multipartBoundaryWithHeader =
-+      HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundary, contentType);
- 
-   std::string result;
-   // add all the ranges to the result
-@@ -680,14 +738,18 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
-     if (range != ranges.begin())
-       result += HEADER_NEWLINE;
- 
--    // generate and append the multipart boundary with the full header (Content-Type and Content-Length)
--    result += HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundaryWithHeader, &*range);
-+    // generate and append the multipart boundary with the full header (Content-Type and
-+    // Content-Length)
-+    result +=
-+        HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundaryWithHeader, &*range);
- 
-     // and append the data of the range
--    result.append(static_cast<const char*>(range->GetData()), static_cast<size_t>(range->GetLength()));
-+    result.append(static_cast<const char*>(range->GetData()),
-+                  static_cast<size_t>(range->GetLength()));
- 
-     // check if we need to free the range data
--    if (responseDetails.type == HTTPMemoryDownloadFreeNoCopy || responseDetails.type == HTTPMemoryDownloadFreeCopy)
-+    if (responseDetails.type == HTTPMemoryDownloadFreeNoCopy ||
-+        responseDetails.type == HTTPMemoryDownloadFreeCopy)
-       free(const_cast<void*>(range->GetData()));
-   }
- 
-@@ -697,10 +759,13 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
-   handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_LENGTH, StringUtils::Format("%" PRIu64, static_cast<uint64_t>(result.size())));
- 
-   // finally create the response
--  return CreateMemoryDownloadResponse(request.connection, result.c_str(), result.size(), false, true, response);
-+  return CreateMemoryDownloadResponse(request.connection, result.c_str(), result.size(), false,
-+                                      true, response);
- }
- 
--int CWebServer::CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const
-+MHD_RESULT CWebServer::CreateRedirect(struct MHD_Connection* connection,
-+                                      const std::string& strURL,
-+                                      struct MHD_Response*& response) const
- {
-   response = create_response(0, nullptr, MHD_NO, MHD_NO);
-   if (response == nullptr)
-@@ -713,13 +778,14 @@ int CWebServer::CreateRedirect(struct MHD_Connection *connection, const std::str
-   return MHD_YES;
- }
- 
--int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const
-+MHD_RESULT CWebServer::CreateFileDownloadResponse(
-+    const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response*& response) const
- {
-   if (handler == nullptr)
-     return MHD_NO;
- 
--  const HTTPRequest &request = handler->GetRequest();
--  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
-+  const HTTPRequest& request = handler->GetRequest();
-+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
-   HttpResponseRanges responseRanges = handler->GetResponseData();
- 
-   std::shared_ptr<XFILE::CFile> file = std::make_shared<XFILE::CFile>();
-@@ -761,7 +827,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
-       if (!request.ranges.IsEmpty())
-         context->ranges = request.ranges;
-       else
--        HTTPRequestHandlerUtils::GetRequestedRanges(request.connection, fileLength, context->ranges);
-+        HTTPRequestHandlerUtils::GetRequestedRanges(request.connection, fileLength,
-+                                                    context->ranges);
-     }
- 
-     uint64_t firstPosition = 0;
-@@ -773,7 +840,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
-     {
-       handler->SetResponseStatus(MHD_HTTP_PARTIAL_CONTENT);
- 
--      // we need to remember that we are ranged because the range length might change and won't be reliable anymore for length comparisons
-+      // we need to remember that we are ranged because the range length might change and won't be
-+      // reliable anymore for length comparisons
-       ranged = true;
- 
-       context->ranges.GetFirstPosition(firstPosition);
-@@ -785,7 +853,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
-     // remember the total length
-     totalLength = context->ranges.GetLength();
- 
--    // adjust the MIME type and range length in case of multiple ranges which requires multipart boundaries
-+    // adjust the MIME type and range length in case of multiple ranges which requires multipart
-+    // boundaries
-     if (context->rangeCountTotal > 1)
-     {
-       context->boundary = HttpRangeUtils::GenerateMultipartBoundary();
-@@ -793,14 +862,19 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
- 
-       // build part of the boundary with the optional Content-Type header
-       // "--<boundary>\r\nContent-Type: <content-type>\r\n
--      context->boundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundary, context->contentType);
-+      context->boundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(
-+          context->boundary, context->contentType);
-       context->boundaryEnd = HttpRangeUtils::GenerateMultipartBoundaryEnd(context->boundary);
- 
-       // for every range, we need to add a boundary with header
--      for (HttpRanges::const_iterator range = context->ranges.Begin(); range != context->ranges.End(); ++range)
-+      for (HttpRanges::const_iterator range = context->ranges.Begin();
-+           range != context->ranges.End(); ++range)
-       {
--        // we need to temporarily add the Content-Range header to the boundary to be able to determine the length
--        std::string completeBoundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &*range);
-+        // we need to temporarily add the Content-Range header to the boundary to be able to
-+        // determine the length
-+        std::string completeBoundaryWithHeader =
-+            HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader,
-+                                                                &*range);
-         totalLength += completeBoundaryWithHeader.size();
- 
-         // add a newline before any new multipart boundary
-@@ -815,10 +889,9 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
-     context->ranges.GetFirstPosition(context->writePosition);
- 
-     // create the response object
--    response = MHD_create_response_from_callback(totalLength, 2048,
--                                                  &CWebServer::ContentReaderCallback,
--                                                  context.get(),
--                                                  &CWebServer::ContentReaderFreeCallback);
-+    response =
-+        MHD_create_response_from_callback(totalLength, 2048, &CWebServer::ContentReaderCallback,
-+                                          context.get(), &CWebServer::ContentReaderFreeCallback);
-     if (response == nullptr)
-     {
-       CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP response for %s to be filled from %s", m_port, request.pathUrl.c_str(), filePath.c_str());
-@@ -829,7 +902,9 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
- 
-     // add Content-Range header
-     if (ranged)
--      handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_RANGE, HttpRangeUtils::GenerateContentRangeHeaderValue(firstPosition, lastPosition, fileLength));
-+      handler->AddResponseHeader(
-+          MHD_HTTP_HEADER_CONTENT_RANGE,
-+          HttpRangeUtils::GenerateContentRangeHeaderValue(firstPosition, lastPosition, fileLength));
-   }
-   else
-   {
-@@ -850,10 +925,13 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
-   return MHD_YES;
- }
- 
--int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const
-+MHD_RESULT CWebServer::CreateErrorResponse(struct MHD_Connection* connection,
-+                                           int responseType,
-+                                           HTTPMethod method,
-+                                           struct MHD_Response*& response) const
- {
-   size_t payloadSize = 0;
--  const void *payload = nullptr;
-+  const void* payload = nullptr;
- 
-   if (method != HEAD)
-   {
-@@ -861,12 +939,12 @@ int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int respo
-     {
-       case MHD_HTTP_NOT_FOUND:
-         payloadSize = strlen(PAGE_FILE_NOT_FOUND);
--        payload = (const void *)PAGE_FILE_NOT_FOUND;
-+        payload = (const void*)PAGE_FILE_NOT_FOUND;
-         break;
- 
-       case MHD_HTTP_NOT_IMPLEMENTED:
-         payloadSize = strlen(NOT_SUPPORTED);
--        payload = (const void *)NOT_SUPPORTED;
-+        payload = (const void*)NOT_SUPPORTED;
-         break;
-     }
-   }
-@@ -881,9 +959,15 @@ int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int respo
-   return MHD_YES;
- }
- 
--int CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const
-+MHD_RESULT CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection* connection,
-+                                                    const void* data,
-+                                                    size_t size,
-+                                                    bool free,
-+                                                    bool copy,
-+                                                    struct MHD_Response*& response) const
- {
--  response = create_response(size, const_cast<void*>(data), free ? MHD_YES : MHD_NO, copy ? MHD_YES : MHD_NO);
-+  response = create_response(size, const_cast<void*>(data), free ? MHD_YES : MHD_NO,
-+                             copy ? MHD_YES : MHD_NO);
-   if (response == nullptr)
-   {
-     CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP download response", m_port);
-@@ -893,29 +977,33 @@ int CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection *connection,
-   return MHD_YES;
- }
- 
--int CWebServer::SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const
-+MHD_RESULT CWebServer::SendResponse(const HTTPRequest& request,
-+                                    int responseStatus,
-+                                    MHD_Response* response) const
- {
-   LogResponse(request, responseStatus);
- 
--  int ret = MHD_queue_response(request.connection, responseStatus, response);
-+  MHD_RESULT ret = MHD_queue_response(request.connection, responseStatus, response);
-   MHD_destroy_response(response);
- 
-   return ret;
- }
- 
--int CWebServer::SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const
-+MHD_RESULT CWebServer::SendErrorResponse(const HTTPRequest& request,
-+                                         int errorType,
-+                                         HTTPMethod method) const
- {
--  struct MHD_Response *response = nullptr;
--  int ret = CreateErrorResponse(request.connection, errorType, method, response);
-+  struct MHD_Response* response = nullptr;
-+  MHD_RESULT ret = CreateErrorResponse(request.connection, errorType, method, response);
-   if (ret == MHD_NO)
-     return MHD_NO;
- 
-   return SendResponse(request, errorType, response);
- }
- 
--void* CWebServer::UriRequestLogger(void *cls, const char *uri)
-+void* CWebServer::UriRequestLogger(void* cls, const char* uri)
- {
--  CWebServer *webServer = reinterpret_cast<CWebServer*>(cls);
-+  CWebServer* webServer = reinterpret_cast<CWebServer*>(cls);
- 
-   // log the full URI
-   if (webServer == nullptr)
-@@ -935,9 +1023,9 @@ void CWebServer::LogRequest(const char* uri) const
-   CLog::Log(LOGDEBUG, "CWebServer[%hu]: request received for %s", m_port, uri);
- }
- 
--ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, size_t max)
-+ssize_t CWebServer::ContentReaderCallback(void* cls, uint64_t pos, char* buf, size_t max)
- {
--  HttpFileDownloadContext *context = (HttpFileDownloadContext *)cls;
-+  HttpFileDownloadContext* context = (HttpFileDownloadContext*)cls;
-   if (context == nullptr || context->file == nullptr)
-     return -1;
- 
-@@ -978,7 +1066,8 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si
-     }
- 
-     // put together the boundary for the current range
--    std::string boundary = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &range);
-+    std::string boundary =
-+        HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &range);
- 
-     // copy the boundary into the buffer
-     memcpy(buf, boundary.c_str(), boundary.size());
-@@ -999,7 +1088,8 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si
-   maximum = std::min(maximum, end - context->writePosition + 1);
- 
-   // seek to the position if necessary
--  if (context->file->GetPosition() < 0 || context->writePosition != static_cast<uint64_t>(context->file->GetPosition()))
-+  if (context->file->GetPosition() < 0 ||
-+      context->writePosition != static_cast<uint64_t>(context->file->GetPosition()))
-     context->file->Seek(context->writePosition);
- 
-   // read data from the file
-@@ -1026,16 +1116,19 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si
-   return written;
- }
- 
--void CWebServer::ContentReaderFreeCallback(void *cls)
-+void CWebServer::ContentReaderFreeCallback(void* cls)
- {
--  HttpFileDownloadContext *context = (HttpFileDownloadContext *)cls;
-+  HttpFileDownloadContext* context = (HttpFileDownloadContext*)cls;
-   delete context;
- 
-   CLog::Log(LOGDEBUG, LOGWEBSERVER, "CWebServer [OUT] done");
- }
- 
- // local helper
--static void panicHandlerForMHD(void* unused, const char* file, unsigned int line, const char *reason)
-+static void panicHandlerForMHD(void* unused,
-+                               const char* file,
-+                               unsigned int line,
-+                               const char* reason)
- {
-   CLog::Log(LOGSEVERE, "CWebServer: MHD serious error: reason \"%s\" in file \"%s\" at line %ui", reason ? reason : "",
-             file ? file : "", line);
-@@ -1063,7 +1156,7 @@ static void logFromMHD(void* unused, const char* fmt, va_list ap)
-   }
- }
- 
--bool CWebServer::LoadCert(std::string &skey, std::string &scert)
-+bool CWebServer::LoadCert(std::string& skey, std::string& scert)
- {
-   XFILE::CFile file;
-   XFILE::auto_buffer buf;
-@@ -1106,63 +1199,52 @@ struct MHD_Daemon* CWebServer::StartMHD(unsigned int flags, int port)
- 
-   MHD_set_panic_func(&panicHandlerForMHD, nullptr);
- 
--  if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SERVICES_WEBSERVERSSL) &&
--      MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES &&
--      LoadCert(m_key, m_cert))
-+  if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
-+          CSettings::SETTING_SERVICES_WEBSERVERSSL) &&
-+      MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES && LoadCert(m_key, m_cert))
-     // SSL enabled
--    return MHD_start_daemon(flags |
--                          // one thread per connection
--                          // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
--                          // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
--                          MHD_USE_THREAD_PER_CONNECTION
-+    return MHD_start_daemon(
-+        flags |
-+            // one thread per connection
-+            // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
-+            // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
-+            MHD_USE_THREAD_PER_CONNECTION
- #if (MHD_VERSION >= 0x00095207)
--                          | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
-+            |
-+            MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with
-+                                               MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
- #endif
--                          | MHD_USE_DEBUG /* Print MHD error messages to log */
--                          | MHD_USE_SSL
--                          ,
--                          port,
--                          0,
--                          0,
--                          &CWebServer::AnswerToConnection,
--                          this,
--
--                          MHD_OPTION_CONNECTION_LIMIT, 512,
--                          MHD_OPTION_CONNECTION_TIMEOUT, timeout,
--                          MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this,
--                          MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0,
--                          MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize,
--                          MHD_OPTION_HTTPS_MEM_KEY, m_key.c_str(),
--                          MHD_OPTION_HTTPS_MEM_CERT, m_cert.c_str(),
--                          MHD_OPTION_HTTPS_PRIORITIES, ciphers,
--                          MHD_OPTION_END);
-+            | MHD_USE_DEBUG /* Print MHD error messages to log */
-+            | MHD_USE_SSL,
-+        port, 0, 0, &CWebServer::AnswerToConnection, this,
-+
-+        MHD_OPTION_CONNECTION_LIMIT, 512, MHD_OPTION_CONNECTION_TIMEOUT, timeout,
-+        MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this,
-+        MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0, MHD_OPTION_THREAD_STACK_SIZE,
-+        m_thread_stacksize, MHD_OPTION_HTTPS_MEM_KEY, m_key.c_str(), MHD_OPTION_HTTPS_MEM_CERT,
-+        m_cert.c_str(), MHD_OPTION_HTTPS_PRIORITIES, ciphers, MHD_OPTION_END);
- 
-   // No SSL
--  return MHD_start_daemon(flags |
--                          // one thread per connection
--                          // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
--                          // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
--                          MHD_USE_THREAD_PER_CONNECTION
-+  return MHD_start_daemon(
-+      flags |
-+          // one thread per connection
-+          // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
-+          // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
-+          MHD_USE_THREAD_PER_CONNECTION
- #if (MHD_VERSION >= 0x00095207)
--                          | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
-+          | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with
-+                                               MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
- #endif
--                          | MHD_USE_DEBUG /* Print MHD error messages to log */
--                          ,
--                          port,
--                          0,
--                          0,
--                          &CWebServer::AnswerToConnection,
--                          this,
--
--                          MHD_OPTION_CONNECTION_LIMIT, 512,
--                          MHD_OPTION_CONNECTION_TIMEOUT, timeout,
--                          MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this,
--                          MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0,
--                          MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize,
--                          MHD_OPTION_END);
-+          | MHD_USE_DEBUG /* Print MHD error messages to log */
-+      ,
-+      port, 0, 0, &CWebServer::AnswerToConnection, this,
-+
-+      MHD_OPTION_CONNECTION_LIMIT, 512, MHD_OPTION_CONNECTION_TIMEOUT, timeout,
-+      MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this, MHD_OPTION_EXTERNAL_LOGGER,
-+      &logFromMHD, 0, MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize, MHD_OPTION_END);
- }
- 
--bool CWebServer::Start(uint16_t port, const std::string &username, const std::string &password)
-+bool CWebServer::Start(uint16_t port, const std::string& username, const std::string& password)
- {
-   SetCredentials(username, password);
-   if (!m_running)
-@@ -1216,7 +1298,7 @@ bool CWebServer::WebServerSupportsSSL()
-   return MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES;
- }
- 
--void CWebServer::SetCredentials(const std::string &username, const std::string &password)
-+void CWebServer::SetCredentials(const std::string& username, const std::string& password)
- {
-   CSingleLock lock(m_critSection);
- 
-@@ -1225,7 +1307,7 @@ void CWebServer::SetCredentials(const std::string &username, const std::string &
-   m_authenticationRequired = !m_authenticationPassword.empty();
- }
- 
--void CWebServer::RegisterRequestHandler(IHTTPRequestHandler *handler)
-+void CWebServer::RegisterRequestHandler(IHTTPRequestHandler* handler)
- {
-   if (handler == nullptr)
-     return;
-@@ -1236,15 +1318,18 @@ void CWebServer::RegisterRequestHandler(IHTTPRequestHandler *handler)
- 
-   m_requestHandlers.push_back(handler);
-   std::sort(m_requestHandlers.begin(), m_requestHandlers.end(),
--    [](IHTTPRequestHandler* lhs, IHTTPRequestHandler* rhs) { return rhs->GetPriority() < lhs->GetPriority(); });
-+            [](IHTTPRequestHandler* lhs, IHTTPRequestHandler* rhs) {
-+              return rhs->GetPriority() < lhs->GetPriority();
-+            });
- }
- 
--void CWebServer::UnregisterRequestHandler(IHTTPRequestHandler *handler)
-+void CWebServer::UnregisterRequestHandler(IHTTPRequestHandler* handler)
- {
-   if (handler == nullptr)
-     return;
- 
--  m_requestHandlers.erase(std::remove(m_requestHandlers.begin(), m_requestHandlers.end(), handler), m_requestHandlers.end());
-+  m_requestHandlers.erase(std::remove(m_requestHandlers.begin(), m_requestHandlers.end(), handler),
-+                          m_requestHandlers.end());
- }
- 
- void CWebServer::LogRequest(const HTTPRequest& request) const
-@@ -1253,9 +1338,11 @@ void CWebServer::LogRequest(const HTTPRequest& request) const
-     return;
- 
-   std::multimap<std::string, std::string> headerValues;
--  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, headerValues);
-+  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND,
-+                                                  headerValues);
-   std::multimap<std::string, std::string> getValues;
--  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_GET_ARGUMENT_KIND, getValues);
-+  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_GET_ARGUMENT_KIND,
-+                                                  getValues);
- 
-   CLog::Log(LOGDEBUG, "CWebServer[%hu]  [IN] %s %s %s", m_port, request.version.c_str(), GetHTTPMethod(request.method).c_str(), request.pathUrlFull.c_str());
- 
-@@ -1278,7 +1365,8 @@ void CWebServer::LogResponse(const HTTPRequest& request, int responseStatus) con
-     return;
- 
-   std::multimap<std::string, std::string> headerValues;
--  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, headerValues);
-+  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND,
-+                                                  headerValues);
- 
-   CLog::Log(LOGDEBUG, "CWebServer[%hu] [OUT] %s %d %s", m_port, request.version.c_str(), responseStatus, request.pathUrlFull.c_str());
- 
-@@ -1286,7 +1374,7 @@ void CWebServer::LogResponse(const HTTPRequest& request, int responseStatus) con
-     CLog::Log(LOGDEBUG, "CWebServer[%hu] [OUT] %s: %s", m_port, header.first.c_str(), header.second.c_str());
- }
- 
--std::string CWebServer::CreateMimeTypeFromExtension(const char *ext)
-+std::string CWebServer::CreateMimeTypeFromExtension(const char* ext)
- {
-   if (strcmp(ext, ".kar") == 0)
-     return "audio/midi";
-@@ -1296,10 +1384,12 @@ std::string CWebServer::CreateMimeTypeFromExtension(const char *ext)
-   return CMime::GetMimeType(ext);
- }
- 
--int CWebServer::AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const
-+MHD_RESULT CWebServer::AddHeader(struct MHD_Response* response,
-+                                 const std::string& name,
-+                                 const std::string& value) const
- {
-   if (response == nullptr || name.empty())
--    return 0;
-+    return MHD_NO;
- 
-   CLog::Log(LOGDEBUG, LOGWEBSERVER, "CWebServer[%hu] [OUT] %s: %s", m_port, name.c_str(), value.c_str());
- 
-diff --git a/xbmc/network/WebServer.h b/xbmc/network/WebServer.h
-index c7a9093..1274a2e 100644
---- a/xbmc/network/WebServer.h
-+++ b/xbmc/network/WebServer.h
-@@ -56,17 +56,17 @@ protected:
- 
-   virtual void LogRequest(const char* uri) const;
- 
--  virtual int HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request,
-+  virtual MHD_RESULT HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request,
-                                    const char *upload_data, size_t *upload_data_size, void **con_cls);
--  virtual int HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler);
--  virtual int FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler, int responseStatus, struct MHD_Response *response);
-+  virtual MHD_RESULT HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler);
-+  virtual MHD_RESULT FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler, int responseStatus, struct MHD_Response *response);
- 
- private:
-   struct MHD_Daemon* StartMHD(unsigned int flags, int port);
- 
-   std::shared_ptr<IHTTPRequestHandler> FindRequestHandler(const HTTPRequest& request) const;
- 
--  int AskForAuthentication(const HTTPRequest& request) const;
-+  MHD_RESULT AskForAuthentication(const HTTPRequest& request) const;
-   bool IsAuthenticated(const HTTPRequest& request) const;
- 
-   bool IsRequestCacheable(const HTTPRequest& request) const;
-@@ -76,18 +76,18 @@ private:
-   bool ProcessPostData(const HTTPRequest& request, ConnectionHandler *connectionHandler, const char *upload_data, size_t *upload_data_size, void **con_cls) const;
-   void FinalizePostDataProcessing(ConnectionHandler *connectionHandler) const;
- 
--  int CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
--  int CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
-+  MHD_RESULT CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
-+  MHD_RESULT CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
- 
--  int CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const;
--  int CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
--  int CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const;
--  int CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const;
-+  MHD_RESULT CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const;
-+  MHD_RESULT CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
-+  MHD_RESULT CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const;
-+  MHD_RESULT CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const;
- 
--  int SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const;
--  int SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const;
-+  MHD_RESULT SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const;
-+  MHD_RESULT SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const;
- 
--  int AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const;
-+  MHD_RESULT AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const;
- 
-   void LogRequest(const HTTPRequest& request) const;
-   void LogResponse(const HTTPRequest& request, int responseStatus) const;
-@@ -100,11 +100,11 @@ private:
-   static ssize_t ContentReaderCallback (void *cls, uint64_t pos, char *buf, size_t max);
-   static void ContentReaderFreeCallback(void *cls);
- 
--  static int AnswerToConnection (void *cls, struct MHD_Connection *connection,
-+  static MHD_RESULT AnswerToConnection (void *cls, struct MHD_Connection *connection,
-                         const char *url, const char *method,
-                         const char *version, const char *upload_data,
-                         size_t *upload_data_size, void **con_cls);
--  static int HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key,
-+  static MHD_RESULT HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key,
-                              const char *filename, const char *content_type,
-                              const char *transfer_encoding, const char *data, uint64_t off,
-                              size_t size);
-diff --git a/xbmc/network/httprequesthandler/HTTPFileHandler.cpp b/xbmc/network/httprequesthandler/HTTPFileHandler.cpp
-index 2101d49..26e5390 100644
---- a/xbmc/network/httprequesthandler/HTTPFileHandler.cpp
-+++ b/xbmc/network/httprequesthandler/HTTPFileHandler.cpp
-@@ -23,7 +23,7 @@ CHTTPFileHandler::CHTTPFileHandler(const HTTPRequest &request)
-     m_lastModified()
- { }
- 
--int CHTTPFileHandler::HandleRequest()
-+MHD_RESULT CHTTPFileHandler::HandleRequest()
- {
-   return !m_url.empty() ? MHD_YES : MHD_NO;
- }
-diff --git a/xbmc/network/httprequesthandler/HTTPFileHandler.h b/xbmc/network/httprequesthandler/HTTPFileHandler.h
-index 3c74b52..6121315 100644
---- a/xbmc/network/httprequesthandler/HTTPFileHandler.h
-+++ b/xbmc/network/httprequesthandler/HTTPFileHandler.h
-@@ -19,7 +19,7 @@ class CHTTPFileHandler : public IHTTPRequestHandler
- public:
-   ~CHTTPFileHandler() override = default;
- 
--  int HandleRequest() override;
-+  MHD_RESULT HandleRequest() override;
- 
-   bool CanHandleRanges() const override { return m_canHandleRanges; }
-   bool CanBeCached() const override { return m_canBeCached; }
-diff --git a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp
-index de42e7f..6902be0 100644
---- a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp
-+++ b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp
-@@ -104,7 +104,7 @@ bool CHTTPImageTransformationHandler::CanHandleRequest(const HTTPRequest &reques
-           options.find(TRANSFORMATION_OPTION_HEIGHT) != options.end());
- }
- 
--int CHTTPImageTransformationHandler::HandleRequest()
-+MHD_RESULT CHTTPImageTransformationHandler::HandleRequest()
- {
-   if (m_response.type == HTTPError)
-     return MHD_YES;
-diff --git a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h
-index c55015e..0d17afc 100644
---- a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h
-+++ b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h
-@@ -23,7 +23,7 @@ public:
-   IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPImageTransformationHandler(request); }
-   bool CanHandleRequest(const HTTPRequest &request)const  override;
- 
--  int HandleRequest() override;
-+  MHD_RESULT HandleRequest() override;
- 
-   bool CanHandleRanges() const override { return true; }
-   bool CanBeCached() const override { return true; }
-diff --git a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp
-index e8e2fa3..a4c3c19 100644
---- a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp
-+++ b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp
-@@ -25,7 +25,7 @@ bool CHTTPJsonRpcHandler::CanHandleRequest(const HTTPRequest &request) const
-   return (request.pathUrl.compare("/jsonrpc") == 0);
- }
- 
--int CHTTPJsonRpcHandler::HandleRequest()
-+MHD_RESULT CHTTPJsonRpcHandler::HandleRequest()
- {
-   CHTTPClient client(m_request.method);
-   bool isRequest = false;
-diff --git a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h
-index 67c14b6..2659fd5 100644
---- a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h
-+++ b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h
-@@ -24,7 +24,7 @@ public:
-   IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPJsonRpcHandler(request); }
-   bool CanHandleRequest(const HTTPRequest &request) const override;
- 
--  int HandleRequest() override;
-+  MHD_RESULT HandleRequest() override;
- 
-   HttpResponseRanges GetResponseData() const override;
- 
-diff --git a/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp b/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp
-index 5f9aeef..a07ef0d 100644
---- a/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp
-+++ b/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp
-@@ -112,7 +112,7 @@ bool CHTTPPythonHandler::CanHandleRequest(const HTTPRequest &request) const
-   return true;
- }
- 
--int CHTTPPythonHandler::HandleRequest()
-+MHD_RESULT CHTTPPythonHandler::HandleRequest()
- {
-   if (m_response.type == HTTPError || m_response.type == HTTPRedirect)
-     return MHD_YES;
-diff --git a/xbmc/network/httprequesthandler/HTTPPythonHandler.h b/xbmc/network/httprequesthandler/HTTPPythonHandler.h
-index 03c1506..166430e 100644
---- a/xbmc/network/httprequesthandler/HTTPPythonHandler.h
-+++ b/xbmc/network/httprequesthandler/HTTPPythonHandler.h
-@@ -25,7 +25,7 @@ public:
-   bool CanBeCached() const override { return false; }
-   bool GetLastModifiedDate(CDateTime &lastModified) const override;
- 
--  int HandleRequest() override;
-+  MHD_RESULT HandleRequest() override;
- 
-   HttpResponseRanges GetResponseData() const override { return m_responseRanges; }
- 
-diff --git a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp
-index 80d1d67..f2ea1f2 100644
---- a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp
-+++ b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp
-@@ -61,7 +61,7 @@ bool HTTPRequestHandlerUtils::GetRequestedRanges(struct MHD_Connection *connecti
-   return ranges.Parse(GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE), totalLength);
- }
- 
--int HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
-+MHD_RESULT HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
- {
-   if (cls == nullptr || key == nullptr)
-     return MHD_NO;
-@@ -72,7 +72,7 @@ int HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind,
-   return MHD_YES;
- }
- 
--int HTTPRequestHandlerUtils::FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
-+MHD_RESULT HTTPRequestHandlerUtils::FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
- {
-   if (cls == nullptr || key == nullptr)
-     return MHD_NO;
-diff --git a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h
-index 9a07801..0ec5ed1 100644
---- a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h
-+++ b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h
-@@ -25,6 +25,6 @@ public:
- private:
-   HTTPRequestHandlerUtils() = delete;
- 
--  static int FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
--  static int FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
-+  static MHD_RESULT FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
-+  static MHD_RESULT FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
- };
-diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp
-index 01a6b50..0716a5d 100644
---- a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp
-+++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp
-@@ -18,7 +18,7 @@ bool CHTTPWebinterfaceAddonsHandler::CanHandleRequest(const HTTPRequest &request
-   return (request.pathUrl.compare("/addons") == 0 || request.pathUrl.compare("/addons/") == 0);
- }
- 
--int CHTTPWebinterfaceAddonsHandler::HandleRequest()
-+MHD_RESULT CHTTPWebinterfaceAddonsHandler::HandleRequest()
- {
-   m_responseData = ADDON_HEADER;
-   ADDON::VECADDONS addons;
-diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h
-index e9b1c6d..23cea36 100644
---- a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h
-+++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h
-@@ -21,7 +21,7 @@ public:
-   IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPWebinterfaceAddonsHandler(request); }
-   bool CanHandleRequest(const HTTPRequest &request) const override;
- 
--  int HandleRequest() override;
-+  MHD_RESULT HandleRequest() override;
- 
-   HttpResponseRanges GetResponseData() const override;
- 
-diff --git a/xbmc/network/httprequesthandler/IHTTPRequestHandler.h b/xbmc/network/httprequesthandler/IHTTPRequestHandler.h
-index 4b1e40a..8f605ad 100644
---- a/xbmc/network/httprequesthandler/IHTTPRequestHandler.h
-+++ b/xbmc/network/httprequesthandler/IHTTPRequestHandler.h
-@@ -22,6 +22,12 @@
- 
- #include "utils/HttpRangeUtils.h"
- 
-+#if MHD_VERSION >= 0x00097002
-+#define MHD_RESULT enum MHD_Result
-+#else
-+#define MHD_RESULT int
-+#endif
-+
- class CDateTime;
- class CWebServer;
- 
-@@ -114,7 +120,7 @@ public:
-    *
-    * \return MHD_NO if a severe error has occurred otherwise MHD_YES.
-    */
--  virtual int HandleRequest() = 0;
-+  virtual MHD_RESULT HandleRequest() = 0;
- 
-   /*!
-    * \brief Whether the HTTP response could also be provided in ranges.

Deleted: 9703.patch
===================================================================
--- 9703.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ 9703.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,1432 +0,0 @@
-From 8f82e51563f0e1bc9b7a8adf669ad2b66e7ce3e5 Mon Sep 17 00:00:00 2001
-From: Bernd Kuhls <bernd.kuhls at t-online.de>
-Date: Thu, 28 Apr 2016 17:17:40 +0200
-Subject: [PATCH] lib/cximage-6.0: fix compilation with gcc6
-
-For a quick fix I renamed min() to cxmin() and max() to cxmax() to
-prevent the conflict with the gcc definition.
-
-Forum thread for reference:
-http://forum.kodi.tv/showthread.php?tid=263884
----
- lib/cximage-6.0/CxImage/ximabmp.cpp  |   6 +-
- lib/cximage-6.0/CxImage/ximadef.h    |   8 +-
- lib/cximage-6.0/CxImage/ximadsp.cpp  | 182 +++++++++++++++++------------------
- lib/cximage-6.0/CxImage/ximage.cpp   |   4 +-
- lib/cximage-6.0/CxImage/ximagif.cpp  |   6 +-
- lib/cximage-6.0/CxImage/ximahist.cpp |  12 +--
- lib/cximage-6.0/CxImage/ximaint.cpp  |   8 +-
- lib/cximage-6.0/CxImage/ximaiter.h   |   4 +-
- lib/cximage-6.0/CxImage/ximajbg.cpp  |   2 +-
- lib/cximage-6.0/CxImage/ximapal.cpp  |  14 +--
- lib/cximage-6.0/CxImage/ximapng.cpp  |  12 +--
- lib/cximage-6.0/CxImage/ximaraw.cpp  |   4 +-
- lib/cximage-6.0/CxImage/ximasel.cpp  |  50 +++++-----
- lib/cximage-6.0/CxImage/ximath.cpp   |   8 +-
- lib/cximage-6.0/CxImage/ximatif.cpp  |   6 +-
- lib/cximage-6.0/CxImage/ximatran.cpp | 138 +++++++++++++-------------
- lib/cximage-6.0/CxImage/ximawnd.cpp  |  16 +--
- 17 files changed, 236 insertions(+), 244 deletions(-)
-
-diff --git a/lib/cximage-6.0/CxImage/ximabmp.cpp b/lib/cximage-6.0/CxImage/ximabmp.cpp
-index 726ff91..55842b1 100644
---- a/lib/cximage-6.0/CxImage/ximabmp.cpp
-+++ b/lib/cximage-6.0/CxImage/ximabmp.cpp
-@@ -46,7 +46,7 @@ bool CxImageBMP::Encode(CxFile * hFile)
- 		bihtoh(&infohdr);
- 
- 		// Write the file header
--		hFile->Write(&hdr,min(14,sizeof(BITMAPFILEHEADER)),1);
-+		hFile->Write(&hdr,cxmin(14,sizeof(BITMAPFILEHEADER)),1);
- 		hFile->Write(&infohdr,sizeof(BITMAPINFOHEADER),1);
- 		 //and DIB+ALPHA interlaced
- 		BYTE *srcalpha = AlphaGetPointer();
-@@ -64,7 +64,7 @@ bool CxImageBMP::Encode(CxFile * hFile)
- #endif //CXIMAGE_SUPPORT_ALPHA
- 	{
- 		// Write the file header
--		hFile->Write(&hdr,min(14,sizeof(BITMAPFILEHEADER)),1);
-+		hFile->Write(&hdr,cxmin(14,sizeof(BITMAPFILEHEADER)),1);
- 		//copy attributes
- 		memcpy(pDib,&head,sizeof(BITMAPINFOHEADER));
- 		bihtoh((BITMAPINFOHEADER*)pDib);
-@@ -86,7 +86,7 @@ bool CxImageBMP::Decode(CxFile * hFile)
- 	BITMAPFILEHEADER   bf;
- 	DWORD off = hFile->Tell(); //<CSC>
-   cx_try {
--	if (hFile->Read(&bf,min(14,sizeof(bf)),1)==0) cx_throw("Not a BMP");
-+	if (hFile->Read(&bf,cxmin(14,sizeof(bf)),1)==0) cx_throw("Not a BMP");
- 
- 	bf.bfSize = my_ntohl(bf.bfSize); 
- 	bf.bfOffBits = my_ntohl(bf.bfOffBits); 
-diff --git a/lib/cximage-6.0/CxImage/ximadef.h b/lib/cximage-6.0/CxImage/ximadef.h
-index fe383bf..53ea452 100644
---- a/lib/cximage-6.0/CxImage/ximadef.h
-+++ b/lib/cximage-6.0/CxImage/ximadef.h
-@@ -53,12 +53,8 @@
-  #define CXIMAGE_SUPPORT_WINDOWS 0
- #endif
- 
--#ifndef min
--#define min(a,b) (((a)<(b))?(a):(b))
--#endif
--#ifndef max
--#define max(a,b) (((a)>(b))?(a):(b))
--#endif
-+#define cxmin(a,b) (((a)<(b))?(a):(b))
-+#define cxmax(a,b) (((a)>(b))?(a):(b))
- 
- #ifndef PI
-  #define PI 3.141592653589793f
-diff --git a/lib/cximage-6.0/CxImage/ximadsp.cpp b/lib/cximage-6.0/CxImage/ximadsp.cpp
-index 8425bb2..813253b 100644
---- a/lib/cximage-6.0/CxImage/ximadsp.cpp
-+++ b/lib/cximage-6.0/CxImage/ximadsp.cpp
-@@ -389,8 +389,8 @@ RGBQUAD CxImage::RGBtoHSL(RGBQUAD lRGBColor)
- 	G = lRGBColor.rgbGreen;
- 	B = lRGBColor.rgbBlue;
- 
--	cMax = max( max(R,G), B);	/* calculate lightness */
--	cMin = min( min(R,G), B);
-+	cMax = cxmax( cxmax(R,G), B);	/* calculate lightness */
-+	cMin = cxmin( cxmin(R,G), B);
- 	L = (BYTE)((((cMax+cMin)*HSLMAX)+RGBMAX)/(2*RGBMAX));
- 
- 	if (cMax==cMin){			/* r=g=b --> achromatic case */
-@@ -489,9 +489,9 @@ RGBQUAD CxImage::YUVtoRGB(RGBQUAD lYUVColor)
- 	G = (int)( Y - 0.344f * U - 0.714f * V);
- 	B = (int)( Y + 1.770f * U);
- 
--	R= min(255,max(0,R));
--	G= min(255,max(0,G));
--	B= min(255,max(0,B));
-+	R= cxmin(255,cxmax(0,R));
-+	G= cxmin(255,cxmax(0,G));
-+	B= cxmin(255,cxmax(0,B));
- 	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
- 	return rgb;
- }
-@@ -510,9 +510,9 @@ RGBQUAD CxImage::RGBtoYUV(RGBQUAD lRGBColor)
- 	U = (int)((B-Y) * 0.565f + 128);
- 	V = (int)((R-Y) * 0.713f + 128);
- 
--	Y= min(255,max(0,Y));
--	U= min(255,max(0,U));
--	V= min(255,max(0,V));
-+	Y= cxmin(255,cxmax(0,Y));
-+	U= cxmin(255,cxmax(0,U));
-+	V= cxmin(255,cxmax(0,V));
- 	RGBQUAD yuv={(BYTE)V,(BYTE)U,(BYTE)Y,0};
- 	return yuv;
- }
-@@ -528,9 +528,9 @@ RGBQUAD CxImage::YIQtoRGB(RGBQUAD lYIQColor)
- 	G = (int)( Y - 0.273f * I - 0.647f * Q);
- 	B = (int)( Y - 1.104f * I + 1.701f * Q);
- 
--	R= min(255,max(0,R));
--	G= min(255,max(0,G));
--	B= min(255,max(0,B));
-+	R= cxmin(255,cxmax(0,R));
-+	G= cxmin(255,cxmax(0,G));
-+	B= cxmin(255,cxmax(0,B));
- 	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
- 	return rgb;
- }
-@@ -546,9 +546,9 @@ RGBQUAD CxImage::RGBtoYIQ(RGBQUAD lRGBColor)
- 	I = (int)( 0.5960f * R - 0.2742f * G - 0.3219f * B + 128);
- 	Q = (int)( 0.2109f * R - 0.5229f * G + 0.3120f * B + 128);
- 
--	Y= min(255,max(0,Y));
--	I= min(255,max(0,I));
--	Q= min(255,max(0,Q));
-+	Y= cxmin(255,cxmax(0,Y));
-+	I= cxmin(255,cxmax(0,I));
-+	Q= cxmin(255,cxmax(0,Q));
- 	RGBQUAD yiq={(BYTE)Q,(BYTE)I,(BYTE)Y,0};
- 	return yiq;
- }
-@@ -565,9 +565,9 @@ RGBQUAD CxImage::XYZtoRGB(RGBQUAD lXYZColor)
- 	G = (int)( -0.969256f * X + 1.875992f * Y + 0.041556f * Z * k);
- 	B = (int)(  0.055648f * X - 0.204043f * Y + 1.057311f * Z * k);
- 
--	R= min(255,max(0,R));
--	G= min(255,max(0,G));
--	B= min(255,max(0,B));
-+	R= cxmin(255,cxmax(0,R));
-+	G= cxmin(255,cxmax(0,G));
-+	B= cxmin(255,cxmax(0,B));
- 	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
- 	return rgb;
- }
-@@ -583,9 +583,9 @@ RGBQUAD CxImage::RGBtoXYZ(RGBQUAD lRGBColor)
- 	Y = (int)( 0.212671f * R + 0.715160f * G + 0.072169f * B);
- 	Z = (int)((0.019334f * R + 0.119193f * G + 0.950227f * B)*0.918483657f);
- 
--	//X= min(255,max(0,X));
--	//Y= min(255,max(0,Y));
--	//Z= min(255,max(0,Z));
-+	//X= cxmin(255,cxmax(0,X));
-+	//Y= cxmin(255,cxmax(0,Y));
-+	//Z= cxmin(255,cxmax(0,Z));
- 	RGBQUAD xyz={(BYTE)Z,(BYTE)Y,(BYTE)X,0};
- 	return xyz;
- }
-@@ -707,7 +707,7 @@ bool CxImage::Light(long brightness, long contrast)
- 
- 	BYTE cTable[256]; //<nipper>
- 	for (int i=0;i<256;i++)	{
--		cTable[i] = (BYTE)max(0,min(255,(int)((i-128)*c + brightness + 0.5f)));
-+		cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)((i-128)*c + brightness + 0.5f)));
- 	}
- 
- 	return Lut(cTable);
-@@ -830,11 +830,11 @@ bool CxImage::Filter(long* kernel, long Ksize, long Kfactor, long Koffset)
- 						}
- 					}
- 					if (Kfactor==0 || ksumcur==0){
--						cPtr2[iY1] = (BYTE)min(255, max(0,(int)(b + Koffset)));
-+						cPtr2[iY1] = (BYTE)cxmin(255, cxmax(0,(int)(b + Koffset)));
- 					} else if (ksumtot == ksumcur) {
--						cPtr2[iY1] = (BYTE)min(255, max(0,(int)(b/Kfactor + Koffset)));
-+						cPtr2[iY1] = (BYTE)cxmin(255, cxmax(0,(int)(b/Kfactor + Koffset)));
- 					} else {
--						cPtr2[iY1] = (BYTE)min(255, max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
-+						cPtr2[iY1] = (BYTE)cxmin(255, cxmax(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
- 					}
- 				}
- 			}
-@@ -863,17 +863,17 @@ bool CxImage::Filter(long* kernel, long Ksize, long Kfactor, long Koffset)
- 						}
- 					}
- 					if (Kfactor==0 || ksumcur==0){
--						c.rgbRed   = (BYTE)min(255, max(0,(int)(r + Koffset)));
--						c.rgbGreen = (BYTE)min(255, max(0,(int)(g + Koffset)));
--						c.rgbBlue  = (BYTE)min(255, max(0,(int)(b + Koffset)));
-+						c.rgbRed   = (BYTE)cxmin(255, cxmax(0,(int)(r + Koffset)));
-+						c.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(g + Koffset)));
-+						c.rgbBlue  = (BYTE)cxmin(255, cxmax(0,(int)(b + Koffset)));
- 					} else if (ksumtot == ksumcur) {
--						c.rgbRed   = (BYTE)min(255, max(0,(int)(r/Kfactor + Koffset)));
--						c.rgbGreen = (BYTE)min(255, max(0,(int)(g/Kfactor + Koffset)));
--						c.rgbBlue  = (BYTE)min(255, max(0,(int)(b/Kfactor + Koffset)));
-+						c.rgbRed   = (BYTE)cxmin(255, cxmax(0,(int)(r/Kfactor + Koffset)));
-+						c.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(g/Kfactor + Koffset)));
-+						c.rgbBlue  = (BYTE)cxmin(255, cxmax(0,(int)(b/Kfactor + Koffset)));
- 					} else {
--						c.rgbRed   = (BYTE)min(255, max(0,(int)((r*ksumtot)/(ksumcur*Kfactor) + Koffset)));
--						c.rgbGreen = (BYTE)min(255, max(0,(int)((g*ksumtot)/(ksumcur*Kfactor) + Koffset)));
--						c.rgbBlue  = (BYTE)min(255, max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
-+						c.rgbRed   = (BYTE)cxmin(255, cxmax(0,(int)((r*ksumtot)/(ksumcur*Kfactor) + Koffset)));
-+						c.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)((g*ksumtot)/(ksumcur*Kfactor) + Koffset)));
-+						c.rgbBlue  = (BYTE)cxmin(255, cxmax(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
- 					}
- 					tmp.BlindSetPixelColor(x,y,c);
- 				}
-@@ -1078,8 +1078,8 @@ bool CxImage::Edge(long Ksize)
- // 
- void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffset, bool bMixAlpha)
- {
--    long lWide = min(GetWidth(),imgsrc2.GetWidth()-lXOffset);
--    long lHeight = min(GetHeight(),imgsrc2.GetHeight()-lYOffset);
-+    long lWide = cxmin(GetWidth(),imgsrc2.GetWidth()-lXOffset);
-+    long lHeight = cxmin(GetHeight(),imgsrc2.GetHeight()-lYOffset);
- 
- 	bool bEditAlpha = imgsrc2.AlphaIsValid() & bMixAlpha;
- 
-@@ -1112,16 +1112,16 @@ void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffse
- 						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)((rgb1.rgbReserved+rgb2.rgbReserved)/2);
- 					break;
- 					case OpAdd:
--						rgbDest.rgbBlue = (BYTE)max(0,min(255,rgb1.rgbBlue+rgb2.rgbBlue));
--						rgbDest.rgbGreen = (BYTE)max(0,min(255,rgb1.rgbGreen+rgb2.rgbGreen));
--						rgbDest.rgbRed = (BYTE)max(0,min(255,rgb1.rgbRed+rgb2.rgbRed));
--						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)max(0,min(255,rgb1.rgbReserved+rgb2.rgbReserved));
-+						rgbDest.rgbBlue = (BYTE)cxmax(0,cxmin(255,rgb1.rgbBlue+rgb2.rgbBlue));
-+						rgbDest.rgbGreen = (BYTE)cxmax(0,cxmin(255,rgb1.rgbGreen+rgb2.rgbGreen));
-+						rgbDest.rgbRed = (BYTE)cxmax(0,cxmin(255,rgb1.rgbRed+rgb2.rgbRed));
-+						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)cxmax(0,cxmin(255,rgb1.rgbReserved+rgb2.rgbReserved));
- 					break;
- 					case OpSub:
--						rgbDest.rgbBlue = (BYTE)max(0,min(255,rgb1.rgbBlue-rgb2.rgbBlue));
--						rgbDest.rgbGreen = (BYTE)max(0,min(255,rgb1.rgbGreen-rgb2.rgbGreen));
--						rgbDest.rgbRed = (BYTE)max(0,min(255,rgb1.rgbRed-rgb2.rgbRed));
--						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)max(0,min(255,rgb1.rgbReserved-rgb2.rgbReserved));
-+						rgbDest.rgbBlue = (BYTE)cxmax(0,cxmin(255,rgb1.rgbBlue-rgb2.rgbBlue));
-+						rgbDest.rgbGreen = (BYTE)cxmax(0,cxmin(255,rgb1.rgbGreen-rgb2.rgbGreen));
-+						rgbDest.rgbRed = (BYTE)cxmax(0,cxmin(255,rgb1.rgbRed-rgb2.rgbRed));
-+						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)cxmax(0,cxmin(255,rgb1.rgbReserved-rgb2.rgbReserved));
- 					break;
- 					case OpAnd:
- 						rgbDest.rgbBlue = (BYTE)(rgb1.rgbBlue&rgb2.rgbBlue);
-@@ -1202,11 +1202,11 @@ void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffse
- 							double dSmallAmt = dSmall*((double)rgb2.rgbBlue);
- 
- 							if( lAverage < lThresh+1){
--								rgbDest.rgbBlue = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbBlue) +
-+								rgbDest.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(dLarge*((double)rgb1.rgbBlue) +
- 												dSmallAmt)));
--								rgbDest.rgbGreen = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbGreen) +
-+								rgbDest.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(dLarge*((double)rgb1.rgbGreen) +
- 												dSmallAmt)));
--								rgbDest.rgbRed = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbRed) +
-+								rgbDest.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(dLarge*((double)rgb1.rgbRed) +
- 												dSmallAmt)));
- 							}
- 							else
-@@ -1274,9 +1274,9 @@ bool CxImage::ShiftRGB(long r, long g, long b)
- #endif //CXIMAGE_SUPPORT_SELECTION
- 				{
- 					color = BlindGetPixelColor(x,y);
--					color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + r)));
--					color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + g)));
--					color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + b)));
-+					color.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbRed + r)));
-+					color.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbGreen + g)));
-+					color.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbBlue + b)));
- 					BlindSetPixelColor(x,y,color);
- 				}
- 			}
-@@ -1284,9 +1284,9 @@ bool CxImage::ShiftRGB(long r, long g, long b)
- 	} else {
- 		for(DWORD j=0; j<head.biClrUsed; j++){
- 			color = GetPaletteColor((BYTE)j);
--			color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + r)));
--			color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + g)));
--			color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + b)));
-+			color.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbRed + r)));
-+			color.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbGreen + g)));
-+			color.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbBlue + b)));
- 			SetPaletteColor((BYTE)j,color);
- 		}
- 	}
-@@ -1310,7 +1310,7 @@ bool CxImage::Gamma(float gamma)
- 
- 	BYTE cTable[256]; //<nipper>
- 	for (int i=0;i<256;i++)	{
--		cTable[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
-+		cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
- 	}
- 
- 	return Lut(cTable);
-@@ -1337,21 +1337,21 @@ bool CxImage::GammaRGB(float gammaR, float gammaG, float gammaB)
- 	dMax = pow(255.0, dinvgamma) / 255.0;
- 	BYTE cTableR[256];
- 	for (i=0;i<256;i++)	{
--		cTableR[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
-+		cTableR[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
- 	}
- 
- 	dinvgamma = 1/gammaG;
- 	dMax = pow(255.0, dinvgamma) / 255.0;
- 	BYTE cTableG[256];
- 	for (i=0;i<256;i++)	{
--		cTableG[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
-+		cTableG[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
- 	}
- 
- 	dinvgamma = 1/gammaB;
- 	dMax = pow(255.0, dinvgamma) / 255.0;
- 	BYTE cTableB[256];
- 	for (i=0;i<256;i++)	{
--		cTableB[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
-+		cTableB[i] = (BYTE)cxmax(0,cxmin(255,(int)( pow((double)i, dinvgamma) / dMax)));
- 	}
- 
- 	return Lut(cTableR, cTableG, cTableB);
-@@ -1442,11 +1442,11 @@ bool CxImage::Noise(long level)
- 			{
- 				color = BlindGetPixelColor(x,y);
- 				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
--				color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + n)));
-+				color.rgbRed = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbRed + n)));
- 				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
--				color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + n)));
-+				color.rgbGreen = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbGreen + n)));
- 				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
--				color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + n)));
-+				color.rgbBlue = (BYTE)cxmax(0,cxmin(255,(int)(color.rgbBlue + n)));
- 				BlindSetPixelColor(x,y,color);
- 			}
- 		}
-@@ -1561,8 +1561,8 @@ bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage
- 
- 	//DFT buffers
- 	double *real2,*imag2;
--	real2 = (double*)malloc(max(w,h) * sizeof(double));
--	imag2 = (double*)malloc(max(w,h) * sizeof(double));
-+	real2 = (double*)malloc(cxmax(w,h) * sizeof(double));
-+	imag2 = (double*)malloc(cxmax(w,h) * sizeof(double));
- 
- 	/* Transform the rows */
- 	real = (double *)malloc(w * sizeof(double));
-@@ -1617,7 +1617,7 @@ bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage
- 
- 	/* converting from double to byte, there is a HUGE loss in the dynamics
- 	  "nn" tries to keep an acceptable SNR, but 8bit=48dB: don't ask more */
--	double nn=pow((double)2,(double)log((double)max(w,h))/(double)log((double)2)-4);
-+	double nn=pow((double)2,(double)log((double)cxmax(w,h))/(double)log((double)2)-4);
- 	//reversed gain for reversed transform
- 	if (direction==-1) nn=1/nn;
- 	//bMagnitude : just to see it on the screen
-@@ -1626,15 +1626,15 @@ bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage
- 	for (j=0;j<h;j++) {
- 		for (k=0;k<w;k++) {
- 			if (bMagnitude){
--				tmpReal->SetPixelIndex(k,j,(BYTE)max(0,min(255,(nn*(3+log(_cabs(grid[k][j])))))));
-+				tmpReal->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(nn*(3+log(_cabs(grid[k][j])))))));
- 				if (grid[k][j].x==0){
--					tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128+(atan(grid[k][j].y/0.0000000001)*nn)))));
-+					tmpImag->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128+(atan(grid[k][j].y/0.0000000001)*nn)))));
- 				} else {
--					tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128+(atan(grid[k][j].y/grid[k][j].x)*nn)))));
-+					tmpImag->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128+(atan(grid[k][j].y/grid[k][j].x)*nn)))));
- 				}
- 			} else {
--				tmpReal->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128 + grid[k][j].x*nn))));
--				tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128 + grid[k][j].y*nn))));
-+				tmpReal->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128 + grid[k][j].x*nn))));
-+				tmpImag->SetPixelIndex(k,j,(BYTE)cxmax(0,cxmin(255,(128 + grid[k][j].y*nn))));
- 			}
- 		}
- 	}
-@@ -1922,7 +1922,7 @@ bool CxImage::RepairChannel(CxImage *ch, float radius)
- 
- 			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
- 
--			tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
-+			tmp.BlindSetPixelIndex(x,y,(BYTE)cxmin(255,cxmax(0,(xy0 + radius * correction + 0.5))));
- 		}
- 	}
- 
-@@ -1943,7 +1943,7 @@ bool CxImage::RepairChannel(CxImage *ch, float radius)
- 
- 			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
- 
--			tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
-+			tmp.BlindSetPixelIndex(x,y,(BYTE)cxmin(255,cxmax(0,(xy0 + radius * correction + 0.5))));
- 		}
- 	}
- 	for (x=0;x<=w;x+=w){
-@@ -1963,7 +1963,7 @@ bool CxImage::RepairChannel(CxImage *ch, float radius)
- 
- 			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
- 
--			tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
-+			tmp.BlindSetPixelIndex(x,y,(BYTE)cxmin(255,cxmax(0,(xy0 + radius * correction + 0.5))));
- 		}
- 	}
- 
-@@ -2621,8 +2621,8 @@ bool CxImage::SelectiveBlur(float radius, BYTE threshold, CxImage* iDst)
- 	}
- 
- 	//build the difference mask
--	BYTE thresh_dw = (BYTE)max( 0 ,(int)(128 - threshold));
--	BYTE thresh_up = (BYTE)min(255,(int)(128 + threshold));
-+	BYTE thresh_dw = (BYTE)cxmax( 0 ,(int)(128 - threshold));
-+	BYTE thresh_up = (BYTE)cxmin(255,(int)(128 + threshold));
- 	long kernel[]={-100,-100,-100,-100,801,-100,-100,-100,-100};
- 	if (!Tmp.Filter(kernel,3,800,128)){
- 		delete [] pPalette;
-@@ -2755,7 +2755,7 @@ bool CxImage::UnsharpMask(float radius /*= 5.0*/, float amount /*= 0.5*/, int th
- 					if (abs(diff) < threshold){
- 						dest_row[z] = cur_row[z];
- 					} else {
--						dest_row[z] = (BYTE)min(255, max(0,(int)(cur_row[z] + amount * diff)));
-+						dest_row[z] = (BYTE)cxmin(255, cxmax(0,(int)(cur_row[z] + amount * diff)));
- 					}
- 				}
- 			}
-@@ -2952,7 +2952,7 @@ bool CxImage::RedEyeRemove(float strength)
- 				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)));
- 				if (a<0) a=0;
- 				color = BlindGetPixelColor(x,y);
--				color.rgbRed = (BYTE)(a*min(color.rgbGreen,color.rgbBlue)+(1.0f-a)*color.rgbRed);
-+				color.rgbRed = (BYTE)(a*cxmin(color.rgbGreen,color.rgbBlue)+(1.0f-a)*color.rgbRed);
- 				BlindSetPixelColor(x,y,color);
- 			}
- 		}
-@@ -2990,7 +2990,7 @@ bool CxImage::Saturate(const long saturation, const long colorspace)
- 	case 1:
- 		{
- 			for (int i=0;i<256;i++)	{
--				cTable[i] = (BYTE)max(0,min(255,(int)(i + saturation)));
-+				cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)(i + saturation)));
- 			}
- 			for(long y=ymin; y<ymax; y++){
- 				info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
-@@ -3012,7 +3012,7 @@ bool CxImage::Saturate(const long saturation, const long colorspace)
- 	case 2:
- 		{
- 			for (int i=0;i<256;i++)	{
--				cTable[i] = (BYTE)max(0,min(255,(int)((i-128)*(100 + saturation)/100.0f + 128.5f)));
-+				cTable[i] = (BYTE)cxmax(0,cxmin(255,(int)((i-128)*(100 + saturation)/100.0f + 128.5f)));
- 			}
- 			for(long y=ymin; y<ymax; y++){
- 				info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
-@@ -3242,10 +3242,10 @@ int  CxImage::OptimalThreshold(long method, RECT * pBox, CxImage* pContrastMask)
- 
- 	long xmin,xmax,ymin,ymax;
- 	if (pBox){
--		xmin = max(pBox->left,0);
--		xmax = min(pBox->right,head.biWidth);
--		ymin = max(pBox->bottom,0);
--		ymax = min(pBox->top,head.biHeight);
-+		xmin = cxmax(pBox->left,0);
-+		xmax = cxmin(pBox->right,head.biWidth);
-+		ymin = cxmax(pBox->bottom,0);
-+		ymax = cxmin(pBox->top,head.biHeight);
- 	} else {
- 		xmin = ymin = 0;
- 		xmax = head.biWidth; ymax=head.biHeight;
-@@ -3463,7 +3463,7 @@ bool CxImage::AdaptiveThreshold(long method, long nBoxSize, CxImage* pContrastMa
- 			r.top = r.bottom + nBoxSize;
- 			int threshold = OptimalThreshold(method, &r, pContrastMask);
- 			if (threshold <0) return false;
--			mask.SetPixelIndex(x,y,(BYTE)max(0,min(255,nBias+((1.0f-fGlobalLocalBalance)*threshold + fGlobalLocalBalance*globalthreshold))));
-+			mask.SetPixelIndex(x,y,(BYTE)cxmax(0,cxmin(255,nBias+((1.0f-fGlobalLocalBalance)*threshold + fGlobalLocalBalance*globalthreshold))));
- 		}
- 	}
- 
-@@ -3490,10 +3490,6 @@ bool CxImage::AdaptiveThreshold(long method, long nBoxSize, CxImage* pContrastMa
-  * Note: nOpacity=0 && bSelectFilledArea=true act as a "magic wand"
-  * \return true if everything is ok
-  */
--#if defined(XBMC) && !defined(_WIN32)
--int max(int a, int b) { return a > b ? a : b; }
--int min(int a, int b) { return a < b ? a : b; }
--#endif
- 
- bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFillColor, const BYTE nTolerance,
- 						BYTE nOpacity, const bool bSelectFilledArea, const BYTE nSelectionLevel)
-@@ -3538,8 +3534,8 @@ bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFil
- 	if (IsIndexed()){ //--- Generic indexed image, no tolerance OR Grayscale image with tolerance
- 		BYTE idxRef = GetPixelIndex(xStart,yStart);
- 		BYTE idxFill = GetNearestIndex(cFillColor);
--		BYTE idxMin = (BYTE)min(255, max(0,(int)(idxRef - nTolerance)));
--		BYTE idxMax = (BYTE)min(255, max(0,(int)(idxRef + nTolerance)));
-+		BYTE idxMin = (BYTE)cxmin(255, cxmax(0,(int)(idxRef - nTolerance)));
-+		BYTE idxMax = (BYTE)cxmin(255, cxmax(0,(int)(idxRef + nTolerance)));
- 
- 		while(!q.empty())
- 		{
-@@ -3575,12 +3571,12 @@ bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFil
- 	} else { //--- RGB image
- 		RGBQUAD cRef = GetPixelColor(xStart,yStart);
- 		RGBQUAD cRefMin, cRefMax;
--		cRefMin.rgbRed   = (BYTE)min(255, max(0,(int)(cRef.rgbRed   - nTolerance)));
--		cRefMin.rgbGreen = (BYTE)min(255, max(0,(int)(cRef.rgbGreen - nTolerance)));
--		cRefMin.rgbBlue  = (BYTE)min(255, max(0,(int)(cRef.rgbBlue  - nTolerance)));
--		cRefMax.rgbRed   = (BYTE)min(255, max(0,(int)(cRef.rgbRed   + nTolerance)));
--		cRefMax.rgbGreen = (BYTE)min(255, max(0,(int)(cRef.rgbGreen + nTolerance)));
--		cRefMax.rgbBlue  = (BYTE)min(255, max(0,(int)(cRef.rgbBlue  + nTolerance)));
-+		cRefMin.rgbRed   = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbRed   - nTolerance)));
-+		cRefMin.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbGreen - nTolerance)));
-+		cRefMin.rgbBlue  = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbBlue  - nTolerance)));
-+		cRefMax.rgbRed   = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbRed   + nTolerance)));
-+		cRefMax.rgbGreen = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbGreen + nTolerance)));
-+		cRefMax.rgbBlue  = (BYTE)cxmin(255, cxmax(0,(int)(cRef.rgbBlue  + nTolerance)));
- 
- 		while(!q.empty())
- 		{
-diff --git a/lib/cximage-6.0/CxImage/ximage.cpp b/lib/cximage-6.0/CxImage/ximage.cpp
-index e81d3c6..26c6993 100644
---- a/lib/cximage-6.0/CxImage/ximage.cpp
-+++ b/lib/cximage-6.0/CxImage/ximage.cpp
-@@ -460,7 +460,7 @@ bool CxImage::CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dw
- 				src+=4;
- 			}
- 		} else {
--			memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
-+			memcpy(dst,src,cxmin(info.dwEffWidth,dwBytesperline));
- 		}
- 	}
- 	return true;
-@@ -500,7 +500,7 @@ bool CxImage::CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWOR
- 					src+=4;
- 				}
- 			} else {
--				memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
-+				memcpy(dst,src,cxmin(info.dwEffWidth,dwBytesperline));
- 			}
- 		}
- 	}
-diff --git a/lib/cximage-6.0/CxImage/ximagif.cpp b/lib/cximage-6.0/CxImage/ximagif.cpp
-index b89e061..64b1ccc 100644
---- a/lib/cximage-6.0/CxImage/ximagif.cpp
-+++ b/lib/cximage-6.0/CxImage/ximagif.cpp
-@@ -478,7 +478,7 @@ bool CxImageGIF::Encode(CxFile * fp, CxImage ** pImages, int pagecount, bool bLo
- 	ghost.EncodeHeader(fp);
- 
- 	if (m_loops!=1){
--		ghost.SetLoops(max(0,m_loops-1));
-+		ghost.SetLoops(cxmax(0,m_loops-1));
- 		ghost.EncodeLoopExtension(fp);
- 	}
- 
-@@ -1340,10 +1340,10 @@ void CxImageGIF::GetComment(char* sz_comment_out)
- ////////////////////////////////////////////////////////////////////////////////
- void CxImageGIF::GifMix(CxImage & imgsrc2, struct_image & imgdesc)
- {
--	long ymin = max(0,(long)(GetHeight()-imgdesc.t - imgdesc.h));
-+	long ymin = cxmax(0,(long)(GetHeight()-imgdesc.t - imgdesc.h));
- 	long ymax = GetHeight()-imgdesc.t;
- 	long xmin = imgdesc.l;
--	long xmax = min(GetWidth(), (DWORD)(imgdesc.l + imgdesc.w));
-+	long xmax = cxmin(GetWidth(), (DWORD)(imgdesc.l + imgdesc.w));
- 
- 	long ibg2= imgsrc2.GetTransIndex();
-     BYTE i2;
-diff --git a/lib/cximage-6.0/CxImage/ximahist.cpp b/lib/cximage-6.0/CxImage/ximahist.cpp
-index a2aed03..5391107 100644
---- a/lib/cximage-6.0/CxImage/ximahist.cpp
-+++ b/lib/cximage-6.0/CxImage/ximahist.cpp
-@@ -110,7 +110,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
- 	// calculate LUT
- 	BYTE lut[256];
- 	for (x = 0; x <256; x++){
--		lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
-+		lut[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minc) / (maxc - minc))));
- 	}
- 
- 	for (y=0; y<head.biHeight; y++)	{
-@@ -152,7 +152,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
- 		// calculate LUT
- 		BYTE lut[256];
- 		for (x = 0; x <256; x++){
--			lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
-+			lut[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minc) / (maxc - minc))));
- 		}
- 
- 		// normalize image
-@@ -225,7 +225,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
- 		BYTE range = maxR - minR;
- 		if (range != 0)	{
- 			for (x = 0; x <256; x++){
--				lutR[x] = (BYTE)max(0,min(255,(255 * (x - minR) / range)));
-+				lutR[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minR) / range)));
- 			}
- 		} else lutR[minR] = minR;
- 
-@@ -233,7 +233,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
- 		range = maxG - minG;
- 		if (range != 0)	{
- 			for (x = 0; x <256; x++){
--				lutG[x] = (BYTE)max(0,min(255,(255 * (x - minG) / range)));
-+				lutG[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minG) / range)));
- 			}
- 		} else lutG[minG] = minG;
- 			
-@@ -241,7 +241,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
- 		range = maxB - minB;
- 		if (range != 0)	{
- 			for (x = 0; x <256; x++){
--				lutB[x] = (BYTE)max(0,min(255,(255 * (x - minB) / range)));
-+				lutB[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minB) / range)));
- 			}
- 		} else lutB[minB] = minB;
- 
-@@ -292,7 +292,7 @@ bool CxImage::HistogramStretch(long method, double threshold)
- 		// calculate LUT
- 		BYTE lut[256];
- 		for (x = 0; x <256; x++){
--			lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
-+			lut[x] = (BYTE)cxmax(0,cxmin(255,(255 * (x - minc) / (maxc - minc))));
- 		}
- 
- 		for(y=0; y<head.biHeight; y++){
-diff --git a/lib/cximage-6.0/CxImage/ximaint.cpp b/lib/cximage-6.0/CxImage/ximaint.cpp
-index 989d76c..5d49213 100644
---- a/lib/cximage-6.0/CxImage/ximaint.cpp
-+++ b/lib/cximage-6.0/CxImage/ximaint.cpp
-@@ -26,8 +26,8 @@ void CxImage::OverflowCoordinates(long &x, long &y, OverflowMethod const ofMetho
-   switch (ofMethod) {
-     case OM_REPEAT:
-       //clip coordinates
--      x=max(x,0); x=min(x, head.biWidth-1);
--      y=max(y,0); y=min(y, head.biHeight-1);
-+      x=cxmax(x,0); x=cxmin(x, head.biWidth-1);
-+      y=cxmax(y,0); y=cxmin(y, head.biHeight-1);
-       break;
-     case OM_WRAP:
-       //wrap coordinates
-@@ -59,8 +59,8 @@ void CxImage::OverflowCoordinates(float &x, float &y, OverflowMethod const ofMet
-   switch (ofMethod) {
-     case OM_REPEAT:
-       //clip coordinates
--      x=max(x,0); x=min(x, head.biWidth-1);
--      y=max(y,0); y=min(y, head.biHeight-1);
-+      x=cxmax(x,0); x=cxmin(x, head.biWidth-1);
-+      y=cxmax(y,0); y=cxmin(y, head.biHeight-1);
-       break;
-     case OM_WRAP:
-       //wrap coordinates
-diff --git a/lib/cximage-6.0/CxImage/ximaiter.h b/lib/cximage-6.0/CxImage/ximaiter.h
-index 9788919..01a720b 100644
---- a/lib/cximage-6.0/CxImage/ximaiter.h
-+++ b/lib/cximage-6.0/CxImage/ximaiter.h
-@@ -140,7 +140,7 @@ inline void CImageIterator::SetY(int y)
- inline void CImageIterator::SetRow(BYTE *buf, int n)
- {
- 	if (n<0) n = (int)ima->GetEffWidth();
--	else n = min(n,(int)ima->GetEffWidth());
-+	else n = cxmin(n,(int)ima->GetEffWidth());
- 
- 	if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n);
- }
-@@ -148,7 +148,7 @@ inline void CImageIterator::SetRow(BYTE *buf, int n)
- inline void CImageIterator::GetRow(BYTE *buf, int n)
- {
- 	if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0))
--		memcpy(buf,IterImage,min(n,(int)ima->GetEffWidth()));
-+		memcpy(buf,IterImage,cxmin(n,(int)ima->GetEffWidth()));
- }
- /////////////////////////////////////////////////////////////////////
- inline BYTE* CImageIterator::GetRow()
-diff --git a/lib/cximage-6.0/CxImage/ximajbg.cpp b/lib/cximage-6.0/CxImage/ximajbg.cpp
-index 06fb9bf..8a01e28 100644
---- a/lib/cximage-6.0/CxImage/ximajbg.cpp
-+++ b/lib/cximage-6.0/CxImage/ximajbg.cpp
-@@ -145,7 +145,7 @@ bool CxImageJBG::Encode(CxFile * hFile)
- 	jbg_enc_init(&jbig_state, w, h, planes, &buffer, jbig_data_out, hFile);
- 
-     //jbg_enc_layers(&jbig_state, 2);
--    //jbg_enc_lrlmax(&jbig_state, 800, 600);
-+    //jbg_enc_lrlcxmax(&jbig_state, 800, 600);
- 
- 	// Specify a few other options (each is ignored if negative)
- 	int dl = -1, dh = -1, d = -1, l0 = -1, mx = -1;
-diff --git a/lib/cximage-6.0/CxImage/ximapal.cpp b/lib/cximage-6.0/CxImage/ximapal.cpp
-index b3bd3da..3788c98 100644
---- a/lib/cximage-6.0/CxImage/ximapal.cpp
-+++ b/lib/cximage-6.0/CxImage/ximapal.cpp
-@@ -398,8 +398,8 @@ void CxImage::RGBtoBGR(BYTE *buffer, int length)
- {
- 	if (buffer && (head.biClrUsed==0)){
- 		BYTE temp;
--		length = min(length,(int)info.dwEffWidth);
--		length = min(length,(int)(3*head.biWidth));
-+		length = cxmin(length,(int)info.dwEffWidth);
-+		length = cxmin(length,(int)(3*head.biWidth));
- 		for (int i=0;i<length;i+=3){
- 			temp = buffer[i]; buffer[i] = buffer[i+2]; buffer[i+2] = temp;
- 		}
-@@ -444,7 +444,7 @@ void CxImage::SetPalette(DWORD n, BYTE *r, BYTE *g, BYTE *b)
- 	if (!g) g = r;
- 	if (!b) b = g;
- 	RGBQUAD* ppal=GetPalette();
--	DWORD m=min(n,head.biClrUsed);
-+	DWORD m=cxmin(n,head.biClrUsed);
- 	for (DWORD i=0; i<m;i++){
- 		ppal[i].rgbRed=r[i];
- 		ppal[i].rgbGreen=g[i];
-@@ -457,7 +457,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
- {
- 	if ((!rgb)||(pDib==NULL)||(head.biClrUsed==0)) return;
- 	RGBQUAD* ppal=GetPalette();
--	DWORD m=min(nColors,head.biClrUsed);
-+	DWORD m=cxmin(nColors,head.biClrUsed);
- 	for (DWORD i=0; i<m;i++){
- 		ppal[i].rgbRed=rgb[i].r;
- 		ppal[i].rgbGreen=rgb[i].g;
-@@ -469,7 +469,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
- void CxImage::SetPalette(RGBQUAD* pPal,DWORD nColors)
- {
- 	if ((pPal==NULL)||(pDib==NULL)||(head.biClrUsed==0)) return;
--	memcpy(GetPalette(),pPal,min(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
-+	memcpy(GetPalette(),pPal,cxmin(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
- 	info.last_c_isvalid = false;
- }
- ////////////////////////////////////////////////////////////////////////////////
-@@ -654,10 +654,10 @@ void CxImage::SetClrImportant(DWORD ncolors)
- 
- 	switch(head.biBitCount){
- 	case 1:
--		head.biClrImportant = min(ncolors,2);
-+		head.biClrImportant = cxmin(ncolors,2);
- 		break;
- 	case 4:
--		head.biClrImportant = min(ncolors,16);
-+		head.biClrImportant = cxmin(ncolors,16);
- 		break;
- 	case 8:
- 		head.biClrImportant = ncolors;
-diff --git a/lib/cximage-6.0/CxImage/ximapng.cpp b/lib/cximage-6.0/CxImage/ximapng.cpp
-index a58441c..4b5cc50 100644
---- a/lib/cximage-6.0/CxImage/ximapng.cpp
-+++ b/lib/cximage-6.0/CxImage/ximapng.cpp
-@@ -206,9 +206,9 @@ bool CxImagePNG::Decode(CxFile *hFile)
- 	} else SetGrayPalette(); //<DP> needed for grayscale PNGs
- 	
- #ifdef USE_NEW_LIBPNG_API
--	int nshift = max(0,(_bit_depth>>3)-1)<<3;
-+	int nshift = cxmax(0,(_bit_depth>>3)-1)<<3;
- #else
--	int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3;
-+	int nshift = cxmax(0,(info_ptr->bit_depth>>3)-1)<<3;
- #endif
- 
- #ifdef USE_NEW_LIBPNG_API
-@@ -255,10 +255,10 @@ bool CxImagePNG::Decode(CxFile *hFile)
- 			if (pal){
- 				DWORD ip;
- #ifdef USE_NEW_LIBPNG_API
--				for (ip=0;ip<min(head.biClrUsed,(unsigned long)_num_trans);ip++)
-+				for (ip=0;ip<cxmin(head.biClrUsed,(unsigned long)_num_trans);ip++)
- 					pal[ip].rgbReserved=_trans_alpha[ip];
- #else
--				for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
-+				for (ip=0;ip<cxmin(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
- #if PNG_LIBPNG_VER > 10399
- 					pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
- #else
-@@ -737,9 +737,9 @@ bool CxImagePNG::Encode(CxFile *hFile)
- #endif // CXIMAGE_SUPPORT_ALPHA	// <vho>
- 
- #ifdef USE_NEW_LIBPNG_API
--	int row_size = max(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
-+	int row_size = cxmax(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
- #else
--	int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
-+	int row_size = cxmax(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
- 	info_ptr->rowbytes = row_size;
- #endif
- 	BYTE *row_pointers = new BYTE[row_size];
-diff --git a/lib/cximage-6.0/CxImage/ximaraw.cpp b/lib/cximage-6.0/CxImage/ximaraw.cpp
-index fd86f96..52d964d 100644
---- a/lib/cximage-6.0/CxImage/ximaraw.cpp
-+++ b/lib/cximage-6.0/CxImage/ximaraw.cpp
-@@ -216,7 +216,7 @@ bool CxImageRAW::Decode(CxFile *hFile)
- 
- 		DWORD size = dcr.width * (dcr.colors*dcr.opt.output_bps/8);
- 		RGBtoBGR(ppm,size);
--		memcpy(GetBits(dcr.height - 1 - row), ppm, min(size,GetEffWidth()));
-+		memcpy(GetBits(dcr.height - 1 - row), ppm, cxmin(size,GetEffWidth()));
- 	}
- 	free (ppm);
- 
-@@ -298,7 +298,7 @@ bool CxImageRAW::GetExifThumbnail(const char *filename, const char *outname, int
- 			// Resizing.
-       		if (image.GetWidth() > 256 || image.GetHeight() > 256)
- 		    {
--				float amount = 256.0f / max(image.GetWidth(), image.GetHeight());
-+				float amount = 256.0f / cxmax(image.GetWidth(), image.GetHeight());
- 				image.Resample((long)(image.GetWidth() * amount), (long)(image.GetHeight() * amount), 0);
- 		    }
- 	      	
-diff --git a/lib/cximage-6.0/CxImage/ximasel.cpp b/lib/cximage-6.0/CxImage/ximasel.cpp
-index 3a7c9a1..37cd10f 100644
---- a/lib/cximage-6.0/CxImage/ximasel.cpp
-+++ b/lib/cximage-6.0/CxImage/ximasel.cpp
-@@ -113,15 +113,15 @@ bool CxImage::SelectionAddRect(RECT r, BYTE level)
- 	if (r.left<r.right) {r2.left=r.left; r2.right=r.right; } else {r2.left=r.right ; r2.right=r.left; }
- 	if (r.bottom<r.top) {r2.bottom=r.bottom; r2.top=r.top; } else {r2.bottom=r.top ; r2.top=r.bottom; }
- 
--	if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = max(0L,min(head.biHeight,r2.top+1));
--	if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = max(0L,min(head.biWidth,r2.left));
--	if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = max(0L,min(head.biWidth,r2.right+1));
--	if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = max(0L,min(head.biHeight,r2.bottom));
-+	if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = cxmax(0L,cxmin(head.biHeight,r2.top+1));
-+	if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = cxmax(0L,cxmin(head.biWidth,r2.left));
-+	if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = cxmax(0L,cxmin(head.biWidth,r2.right+1));
-+	if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = cxmax(0L,cxmin(head.biHeight,r2.bottom));
- 
--	long ymin = max(0L,min(head.biHeight,r2.bottom));
--	long ymax = max(0L,min(head.biHeight,r2.top+1));
--	long xmin = max(0L,min(head.biWidth,r2.left));
--	long xmax = max(0L,min(head.biWidth,r2.right+1));
-+	long ymin = cxmax(0L,cxmin(head.biHeight,r2.bottom));
-+	long ymax = cxmax(0L,cxmin(head.biHeight,r2.top+1));
-+	long xmin = cxmax(0L,cxmin(head.biWidth,r2.left));
-+	long xmax = cxmax(0L,cxmin(head.biWidth,r2.right+1));
- 
- 	for (long y=ymin; y<ymax; y++)
- 		memset(pSelection + xmin + y * head.biWidth, level, xmax-xmin);
-@@ -144,18 +144,18 @@ bool CxImage::SelectionAddEllipse(RECT r, BYTE level)
- 	long xcenter = (r.right + r.left)/2;
- 	long ycenter = (r.top + r.bottom)/2;
- 
--	if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = max(0L,min(head.biWidth,(xcenter - xradius)));
--	if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = max(0L,min(head.biWidth,(xcenter + xradius + 1)));
--	if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = max(0L,min(head.biHeight,(ycenter - yradius)));
--	if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = max(0L,min(head.biHeight,(ycenter + yradius + 1)));
-+	if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = cxmax(0L,cxmin(head.biWidth,(xcenter - xradius)));
-+	if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = cxmax(0L,cxmin(head.biWidth,(xcenter + xradius + 1)));
-+	if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = cxmax(0L,cxmin(head.biHeight,(ycenter - yradius)));
-+	if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = cxmax(0L,cxmin(head.biHeight,(ycenter + yradius + 1)));
- 
--	long xmin = max(0L,min(head.biWidth,xcenter - xradius));
--	long xmax = max(0L,min(head.biWidth,xcenter + xradius + 1));
--	long ymin = max(0L,min(head.biHeight,ycenter - yradius));
--	long ymax = max(0L,min(head.biHeight,ycenter + yradius + 1));
-+	long xmin = cxmax(0L,cxmin(head.biWidth,xcenter - xradius));
-+	long xmax = cxmax(0L,cxmin(head.biWidth,xcenter + xradius + 1));
-+	long ymin = cxmax(0L,cxmin(head.biHeight,ycenter - yradius));
-+	long ymax = cxmax(0L,cxmin(head.biHeight,ycenter + yradius + 1));
- 
- 	long y,yo;
--	for (y=ymin; y<min(ycenter,ymax); y++){
-+	for (y=ymin; y<cxmin(ycenter,ymax); y++){
- 		for (long x=xmin; x<xmax; x++){
- 			yo = (long)(ycenter - yradius * sqrt(1-pow((float)(x - xcenter)/(float)xradius,2)));
- 			if (yo<y) pSelection[x + y * head.biWidth] = level;
-@@ -268,10 +268,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
- 		RECT r2;
- 		if (current->x < next->x) {r2.left=current->x; r2.right=next->x; } else {r2.left=next->x ; r2.right=current->x; }
- 		if (current->y < next->y) {r2.bottom=current->y; r2.top=next->y; } else {r2.bottom=next->y ; r2.top=current->y; }
--		if (localbox.top < r2.top) localbox.top = max(0L,min(head.biHeight-1,r2.top+1));
--		if (localbox.left > r2.left) localbox.left = max(0L,min(head.biWidth-1,r2.left-1));
--		if (localbox.right < r2.right) localbox.right = max(0L,min(head.biWidth-1,r2.right+1));
--		if (localbox.bottom > r2.bottom) localbox.bottom = max(0L,min(head.biHeight-1,r2.bottom-1));
-+		if (localbox.top < r2.top) localbox.top = cxmax(0L,cxmin(head.biHeight-1,r2.top+1));
-+		if (localbox.left > r2.left) localbox.left = cxmax(0L,cxmin(head.biWidth-1,r2.left-1));
-+		if (localbox.right < r2.right) localbox.right = cxmax(0L,cxmin(head.biWidth-1,r2.right+1));
-+		if (localbox.bottom > r2.bottom) localbox.bottom = cxmax(0L,cxmin(head.biHeight-1,r2.bottom-1));
- 
- 		i++;
- 	}
-@@ -385,10 +385,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
- 		for (x=localbox.left; x<=localbox.right; x++)
- 			if (plocal[x + yoffset]!=1) pSelection[x + yoffset]=level;
- 	}
--	if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = min(head.biHeight,localbox.top + 1);
--	if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = min(head.biWidth,localbox.left);
--	if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = min(head.biWidth,localbox.right + 1);
--	if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = min(head.biHeight,localbox.bottom);
-+	if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = cxmin(head.biHeight,localbox.top + 1);
-+	if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = cxmin(head.biWidth,localbox.left);
-+	if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = cxmin(head.biWidth,localbox.right + 1);
-+	if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = cxmin(head.biHeight,localbox.bottom);
- 
- 	free(plocal);
- 	free(pix);
-diff --git a/lib/cximage-6.0/CxImage/ximath.cpp b/lib/cximage-6.0/CxImage/ximath.cpp
-index 37533e2..f84eb72 100644
---- a/lib/cximage-6.0/CxImage/ximath.cpp
-+++ b/lib/cximage-6.0/CxImage/ximath.cpp
-@@ -64,10 +64,10 @@ CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const
-  */
- {
-   CxRect2 cs;
--  cs.botLeft.x=max(botLeft.x, r2.botLeft.x);
--  cs.botLeft.y=max(botLeft.y, r2.botLeft.y);
--  cs.topRight.x=min(topRight.x, r2.topRight.x);
--  cs.topRight.y=min(topRight.y, r2.topRight.y);
-+  cs.botLeft.x=cxmax(botLeft.x, r2.botLeft.x);
-+  cs.botLeft.y=cxmax(botLeft.y, r2.botLeft.y);
-+  cs.topRight.x=cxmin(topRight.x, r2.topRight.x);
-+  cs.topRight.y=cxmin(topRight.y, r2.topRight.y);
-   if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) {
-     return cs;
-   } else {
-diff --git a/lib/cximage-6.0/CxImage/ximatif.cpp b/lib/cximage-6.0/CxImage/ximatif.cpp
-index 658392a..002766c 100644
---- a/lib/cximage-6.0/CxImage/ximatif.cpp
-+++ b/lib/cximage-6.0/CxImage/ximatif.cpp
-@@ -470,9 +470,9 @@ bool CxImageTIF::Decode(CxFile * hFile)
- 						if ( cb > 0.00304 ) cb = 1.055 * pow(cb,0.41667) - 0.055;
- 							else            cb = 12.92 * cb;
- 
--						c.rgbRed  =(BYTE)max(0,min(255,(int)(cr*255)));
--						c.rgbGreen=(BYTE)max(0,min(255,(int)(cg*255)));
--						c.rgbBlue =(BYTE)max(0,min(255,(int)(cb*255)));
-+						c.rgbRed  =(BYTE)cxmax(0,cxmin(255,(int)(cr*255)));
-+						c.rgbGreen=(BYTE)cxmax(0,cxmin(255,(int)(cg*255)));
-+						c.rgbBlue =(BYTE)cxmax(0,cxmin(255,(int)(cb*255)));
- 
- 						SetPixelColor(xi,yi,c);
- #if CXIMAGE_SUPPORT_ALPHA
-diff --git a/lib/cximage-6.0/CxImage/ximatran.cpp b/lib/cximage-6.0/CxImage/ximatran.cpp
-index 64a71e7..84d5e03 100644
---- a/lib/cximage-6.0/CxImage/ximatran.cpp
-+++ b/lib/cximage-6.0/CxImage/ximatran.cpp
-@@ -302,12 +302,12 @@ bool CxImage::RotateLeft(CxImage* iDst)
- 			for (ys = 0; ys < newHeight; ys+=RBLOCK) {
- 				if (head.biBitCount==24) {
- 					//RGB24 optimized pixel access:
--					for (x = xs; x < min(newWidth, xs+RBLOCK); x++){    //do rotation
-+					for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){    //do rotation
- 						info.nProgress = (long)(100*x/newWidth);
- 						x2=newWidth-x-1;
- 						dstPtr = (BYTE*) imgDest.BlindGetPixelPointer(x,ys);
- 						srcPtr = (BYTE*) BlindGetPixelPointer(ys, x2);
--						for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+						for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 							//imgDest.SetPixelColor(x, y, GetPixelColor(y, x2));
- 							*(dstPtr) = *(srcPtr);
- 							*(dstPtr+1) = *(srcPtr+1);
-@@ -318,19 +318,19 @@ bool CxImage::RotateLeft(CxImage* iDst)
- 					}//for x
- 				} else {
- 					//anything else than 24bpp (and 1bpp): palette
--					for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
-+					for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
- 						info.nProgress = (long)(100*x/newWidth); //<Anatoly Ivasyuk>
- 						x2=newWidth-x-1;
--						for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+						for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 							imgDest.SetPixelIndex(x, y, BlindGetPixelIndex(y, x2));
- 						}//for y
- 					}//for x
- 				}//if (version selection)
- #if CXIMAGE_SUPPORT_ALPHA
- 				if (AlphaIsValid()) {
--					for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
-+					for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
- 						x2=newWidth-x-1;
--						for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+						for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 							imgDest.AlphaSet(x,y,BlindAlphaGet(y, x2));
- 						}//for y
- 					}//for x
-@@ -343,9 +343,9 @@ bool CxImage::RotateLeft(CxImage* iDst)
- 					imgDest.info.rSelectionBox.right = newWidth-info.rSelectionBox.bottom;
- 					imgDest.info.rSelectionBox.bottom = info.rSelectionBox.left;
- 					imgDest.info.rSelectionBox.top = info.rSelectionBox.right;
--					for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
-+					for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
- 						x2=newWidth-x-1;
--						for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+						for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 							imgDest.SelectionSet(x,y,BlindSelectionGet(y, x2));
- 						}//for y
- 					}//for x
-@@ -447,12 +447,12 @@ bool CxImage::RotateRight(CxImage* iDst)
- 			for (ys = 0; ys < newHeight; ys+=RBLOCK) {
- 				if (head.biBitCount==24) {
- 					//RGB24 optimized pixel access:
--					for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+					for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 						info.nProgress = (long)(100*y/newHeight); //<Anatoly Ivasyuk>
- 						y2=newHeight-y-1;
- 						dstPtr = (BYTE*) imgDest.BlindGetPixelPointer(xs,y);
- 						srcPtr = (BYTE*) BlindGetPixelPointer(y2, xs);
--						for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
-+						for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
- 							//imgDest.SetPixelColor(x, y, GetPixelColor(y2, x));
- 							*(dstPtr) = *(srcPtr);
- 							*(dstPtr+1) = *(srcPtr+1);
-@@ -463,19 +463,19 @@ bool CxImage::RotateRight(CxImage* iDst)
- 					}//for y
- 				} else {
- 					//anything else than BW & RGB24: palette
--					for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+					for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 						info.nProgress = (long)(100*y/newHeight); //<Anatoly Ivasyuk>
- 						y2=newHeight-y-1;
--						for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
-+						for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
- 							imgDest.SetPixelIndex(x, y, BlindGetPixelIndex(y2, x));
- 						}//for x
- 					}//for y
- 				}//if
- #if CXIMAGE_SUPPORT_ALPHA
- 				if (AlphaIsValid()){
--					for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+					for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 						y2=newHeight-y-1;
--						for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
-+						for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
- 							imgDest.AlphaSet(x,y,BlindAlphaGet(y2, x));
- 						}//for x
- 					}//for y
-@@ -488,9 +488,9 @@ bool CxImage::RotateRight(CxImage* iDst)
- 					imgDest.info.rSelectionBox.right = info.rSelectionBox.top;
- 					imgDest.info.rSelectionBox.bottom = newHeight-info.rSelectionBox.right;
- 					imgDest.info.rSelectionBox.top = newHeight-info.rSelectionBox.left;
--					for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
-+					for (y = ys; y < cxmin(newHeight, ys+RBLOCK); y++){
- 						y2=newHeight-y-1;
--						for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
-+						for (x = xs; x < cxmin(newWidth, xs+RBLOCK); x++){
- 							imgDest.SelectionSet(x,y,BlindSelectionGet(y2, x));
- 						}//for x
- 					}//for y
-@@ -608,10 +608,10 @@ bool CxImage::Rotate(float angle, CxImage* iDst)
- 	newP4.x = (float)(p4.x*cos_angle - p4.y*sin_angle);
- 	newP4.y = (float)(p4.x*sin_angle + p4.y*cos_angle);
- 
--	leftTop.x = min(min(newP1.x,newP2.x),min(newP3.x,newP4.x));
--	leftTop.y = min(min(newP1.y,newP2.y),min(newP3.y,newP4.y));
--	rightBottom.x = max(max(newP1.x,newP2.x),max(newP3.x,newP4.x));
--	rightBottom.y = max(max(newP1.y,newP2.y),max(newP3.y,newP4.y));
-+	leftTop.x = cxmin(cxmin(newP1.x,newP2.x),cxmin(newP3.x,newP4.x));
-+	leftTop.y = cxmin(cxmin(newP1.y,newP2.y),cxmin(newP3.y,newP4.y));
-+	rightBottom.x = cxmax(cxmax(newP1.x,newP2.x),cxmax(newP3.x,newP4.x));
-+	rightBottom.y = cxmax(cxmax(newP1.y,newP2.y),cxmax(newP3.y,newP4.y));
- 	leftBottom.x = leftTop.x;
- 	leftBottom.y = rightBottom.y;
- 	rightTop.x = rightBottom.x;
-@@ -740,10 +740,10 @@ bool CxImage::Rotate2(float angle,
- 	}//if
- 
- 	//(read new dimensions from location of corners)
--	float minx = (float) min(min(newp[0].x,newp[1].x),min(newp[2].x,newp[3].x));
--	float miny = (float) min(min(newp[0].y,newp[1].y),min(newp[2].y,newp[3].y));
--	float maxx = (float) max(max(newp[0].x,newp[1].x),max(newp[2].x,newp[3].x));
--	float maxy = (float) max(max(newp[0].y,newp[1].y),max(newp[2].y,newp[3].y));
-+	float minx = (float) cxmin(cxmin(newp[0].x,newp[1].x),cxmin(newp[2].x,newp[3].x));
-+	float miny = (float) cxmin(cxmin(newp[0].y,newp[1].y),cxmin(newp[2].y,newp[3].y));
-+	float maxx = (float) cxmax(cxmax(newp[0].x,newp[1].x),cxmax(newp[2].x,newp[3].x));
-+	float maxy = (float) cxmax(cxmax(newp[0].y,newp[1].y),cxmax(newp[2].y,newp[3].y));
- 	int newWidth = (int) floor(maxx-minx+0.5f);
- 	int newHeight= (int) floor(maxy-miny+0.5f);
- 	float ssx=((maxx+minx)- ((float) newWidth-1))/2.0f;   //start for x
-@@ -1003,12 +1003,12 @@ bool CxImage::Resample(long newx, long newy, int mode, CxImage* iDst)
- 				if (info.nEscape) break;
- 				fY = y * yScale;
- 				ifY = (int)fY;
--				ifY1 = min(ymax, ifY+1);
-+				ifY1 = cxmin(ymax, ifY+1);
- 				dy = fY - ifY;
- 				for(long x=0; x<newx; x++){
- 					fX = x * xScale;
- 					ifX = (int)fX;
--					ifX1 = min(xmax, ifX+1);
-+					ifX1 = cxmin(xmax, ifX+1);
- 					dx = fX - ifX;
- 					// Interpolate using the four nearest pixels in the source
- 					if (head.biClrUsed){
-@@ -1328,9 +1328,9 @@ bool CxImage::DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal, DWORD
- 				eb=(long)c.rgbBlue - (long)ce.rgbBlue;
- 
- 				c = GetPixelColor(x+1,y);
--				c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er*7)/16)));
--				c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg*7)/16)));
--				c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb*7)/16)));
-+				c.rgbRed = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbRed + ((er*7)/16)));
-+				c.rgbGreen = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbGreen + ((eg*7)/16)));
-+				c.rgbBlue = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbBlue + ((eb*7)/16)));
- 				SetPixelColor(x+1,y,c);
- 				int coeff=1;
- 				for(int i=-1; i<2; i++){
-@@ -1343,9 +1343,9 @@ bool CxImage::DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal, DWORD
- 						coeff=1; break;
- 					}
- 					c = GetPixelColor(x+i,y+1);
--					c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er * coeff)/16)));
--					c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg * coeff)/16)));
--					c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb * coeff)/16)));
-+					c.rgbRed = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbRed + ((er * coeff)/16)));
-+					c.rgbGreen = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbGreen + ((eg * coeff)/16)));
-+					c.rgbBlue = (BYTE)cxmin(255L,cxmax(0L,(long)c.rgbBlue + ((eb * coeff)/16)));
- 					SetPixelColor(x+i,y+1,c);
- 				}
- 			}
-@@ -1566,10 +1566,10 @@ bool CxImage::Dither(long method)
- 				}
- 
- 				nlevel = GetPixelIndex(x + 1, y) + (error * 8) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 1, y, level);
- 				nlevel = GetPixelIndex(x + 2, y) + (error * 4) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 2, y, level);
- 				int i;
- 				for (i = -2; i < 3; i++) {
-@@ -1591,7 +1591,7 @@ bool CxImage::Dither(long method)
- 						break;
- 					}
- 					nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
--					level = (BYTE)min(255, max(0, (int)nlevel));
-+					level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 					SetPixelIndex(x + i, y + 1, level);
- 				}
- 			}
-@@ -1620,10 +1620,10 @@ bool CxImage::Dither(long method)
- 				}
- 
- 				nlevel = GetPixelIndex(x + 1, y) + (error * 8) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 1, y, level);
- 				nlevel = GetPixelIndex(x + 2, y) + (error * 4) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 2, y, level);
- 				int i;
- 				for (i = -2; i < 3; i++) {
-@@ -1645,7 +1645,7 @@ bool CxImage::Dither(long method)
- 						break;
- 					}
- 					nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
--					level = (BYTE)min(255, max(0, (int)nlevel));
-+					level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 					SetPixelIndex(x + i, y + 1, level);
- 				}
- 				for (i = -2; i < 3; i++) {
-@@ -1667,7 +1667,7 @@ bool CxImage::Dither(long method)
- 						break;
- 					}
- 					nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
--					level = (BYTE)min(255, max(0, (int)nlevel));
-+					level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 					SetPixelIndex(x + i, y + 2, level);
- 				}
- 			}
-@@ -1696,10 +1696,10 @@ bool CxImage::Dither(long method)
- 				}
- 
- 				nlevel = GetPixelIndex(x + 1, y) + (error * 7) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 1, y, level);
- 				nlevel = GetPixelIndex(x + 2, y) + (error * 5) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 2, y, level);
- 				int i;
- 				for (i = -2; i < 3; i++) {
-@@ -1721,7 +1721,7 @@ bool CxImage::Dither(long method)
- 						break;
- 					}
- 					nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
--					level = (BYTE)min(255, max(0, (int)nlevel));
-+					level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 					SetPixelIndex(x + i, y + 1, level);
- 				}
- 				for (i = -2; i < 3; i++) {
-@@ -1743,7 +1743,7 @@ bool CxImage::Dither(long method)
- 						break;
- 					}
- 					nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
--					level = (BYTE)min(255, max(0, (int)nlevel));
-+					level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 					SetPixelIndex(x + i, y + 2, level);
- 				}
- 			}
-@@ -1772,10 +1772,10 @@ bool CxImage::Dither(long method)
- 				}
- 
- 				nlevel = GetPixelIndex(x + 1, y) + (error * 5) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 1, y, level);
- 				nlevel = GetPixelIndex(x + 2, y) + (error * 3) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(x + 2, y, level);
- 				int i;
- 				for (i = -2; i < 3; i++) {
-@@ -1797,7 +1797,7 @@ bool CxImage::Dither(long method)
- 						break;
- 					}
- 					nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
--					level = (BYTE)min(255, max(0, (int)nlevel));
-+					level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 					SetPixelIndex(x + i, y + 1, level);
- 				}
- 				for (i = -1; i < 2; i++) {
-@@ -1813,7 +1813,7 @@ bool CxImage::Dither(long method)
- 						break;
- 					}
- 					nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
--					level = (BYTE)min(255, max(0, (int)nlevel));
-+					level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 					SetPixelIndex(x + i, y + 2, level);
- 				}
- 			}
-@@ -1845,76 +1845,76 @@ bool CxImage::Dither(long method)
- 				int tmp_index_y = y;
- 				int tmp_coeff = 32;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x - 3;
- 				tmp_index_y = y + 1;
- 				tmp_coeff = 12;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x - 1;
- 				tmp_coeff = 26;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x + 1;
- 				tmp_coeff = 30;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x + 3;
- 				tmp_coeff = 16;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x - 2;
- 				tmp_index_y = y + 2;
- 				tmp_coeff = 12;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x;
- 				tmp_coeff = 26;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x + 2;
- 				tmp_coeff = 12;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x - 3;
- 				tmp_index_y = y + 3;
- 				tmp_coeff = 5;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x - 1;
- 				tmp_coeff = 12;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x + 1;
- 				tmp_coeff = 12;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 
- 				tmp_index_x = x + 3;
- 				tmp_coeff = 5;
- 				nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
--				level = (BYTE)min(255, max(0, (int)nlevel));
-+				level = (BYTE)cxmin(255, cxmax(0, (int)nlevel));
- 				SetPixelIndex(tmp_index_x, tmp_index_y, level);
- 			}
- 		}
-@@ -1941,7 +1941,7 @@ bool CxImage::Dither(long method)
- 			Bmatrix[i] = (BYTE)(dither);
- 		}
- 
--		int scale = max(0,(8-2*order));
-+		int scale = cxmax(0,(8-2*order));
- 		int level;
- 		for (long y=0;y<head.biHeight;y++){
- 			info.nProgress = (long)(100*y/head.biHeight);
-@@ -1981,7 +1981,7 @@ bool CxImage::Dither(long method)
- 				}
- 
- 				nlevel = GetPixelIndex(x+1,y) + (error * 7)/16;
--				level = (BYTE)min(255,max(0,(int)nlevel));
-+				level = (BYTE)cxmin(255,cxmax(0,(int)nlevel));
- 				SetPixelIndex(x+1,y,level);
- 				for(int i=-1; i<2; i++){
- 					switch(i){
-@@ -1993,7 +1993,7 @@ bool CxImage::Dither(long method)
- 						coeff=1; break;
- 					}
- 					nlevel = GetPixelIndex(x+i,y+1) + (error * coeff)/16;
--					level = (BYTE)min(255,max(0,(int)nlevel));
-+					level = (BYTE)cxmin(255,cxmax(0,(int)nlevel));
- 					SetPixelIndex(x+i,y+1,level);
- 				}
- 			}
-@@ -2031,7 +2031,7 @@ bool CxImage::CropRotatedRectangle( long topx, long topy, long width, long heigh
- 	if ( fabs(angle)<0.0002 )
- 		return Crop( topx, topy, topx+width, topy+height, iDst);
- 
--	startx = min(topx, topx - (long)(sin_angle*(double)height));
-+	startx = cxmin(topx, topx - (long)(sin_angle*(double)height));
- 	endx   = topx + (long)(cos_angle*(double)width);
- 	endy   = topy + (long)(cos_angle*(double)height + sin_angle*(double)width);
- 	// check: corners of the rectangle must be inside
-@@ -2079,10 +2079,10 @@ bool CxImage::Crop(long left, long top, long right, long bottom, CxImage* iDst)
- {
- 	if (!pDib) return false;
- 
--	long startx = max(0L,min(left,head.biWidth));
--	long endx = max(0L,min(right,head.biWidth));
--	long starty = head.biHeight - max(0L,min(top,head.biHeight));
--	long endy = head.biHeight - max(0L,min(bottom,head.biHeight));
-+	long startx = cxmax(0L,cxmin(left,head.biWidth));
-+	long endx = cxmax(0L,cxmin(right,head.biWidth));
-+	long starty = head.biHeight - cxmax(0L,cxmin(top,head.biHeight));
-+	long endy = head.biHeight - cxmax(0L,cxmin(bottom,head.biHeight));
- 
- 	if (startx==endx || starty==endy) return false;
- 
-@@ -2443,8 +2443,8 @@ bool CxImage::CircleTransform(int type,long rmax,float Koeff)
- 						nx=x+(x%32)-16;
- 						ny=y;
- 					}
--//					nx=max(xmin,min(nx,xmax));
--//					ny=max(ymin,min(ny,ymax));
-+//					nx=cxmax(xmin,cxmin(nx,xmax));
-+//					ny=cxmax(ymin,cxmin(ny,ymax));
- 				}
- 				else { nx=-1;ny=-1;}
- 				if (head.biClrUsed==0){
-diff --git a/lib/cximage-6.0/CxImage/ximawnd.cpp b/lib/cximage-6.0/CxImage/ximawnd.cpp
-index 2ae2f93..7029cc7 100644
---- a/lib/cximage-6.0/CxImage/ximawnd.cpp
-+++ b/lib/cximage-6.0/CxImage/ximawnd.cpp
-@@ -682,10 +682,10 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
- 	RECT clipbox,paintbox;
- 	GetClipBox(hdc,&clipbox);
- 
--	paintbox.top = min(clipbox.bottom,max(clipbox.top,y));
--	paintbox.left = min(clipbox.right,max(clipbox.left,x));
--	paintbox.right = max(clipbox.left,min(clipbox.right,x+cx));
--	paintbox.bottom = max(clipbox.top,min(clipbox.bottom,y+cy));
-+	paintbox.top = cxmin(clipbox.bottom,cxmax(clipbox.top,y));
-+	paintbox.left = cxmin(clipbox.right,cxmax(clipbox.left,x));
-+	paintbox.right = cxmax(clipbox.left,cxmin(clipbox.right,x+cx));
-+	paintbox.bottom = cxmax(clipbox.top,cxmin(clipbox.bottom,y+cy));
- 
- 	long destw = paintbox.right - paintbox.left;
- 	long desth = paintbox.bottom - paintbox.top;
-@@ -730,12 +730,12 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
- 
- 				for(yy=0;yy<desth;yy++){
- 					dy = head.biHeight-(ymax-yy-y)*fy;
--					sy = max(0L,(long)floor(dy));
-+					sy = cxmax(0L,(long)floor(dy));
- 					psrc = info.pImage+sy*info.dwEffWidth;
- 					pdst = pbase+yy*ew;
- 					for(xx=0;xx<destw;xx++){
- 						dx = (xx+xmin-x)*fx;
--						sx = max(0L,(long)floor(dx));
-+						sx = cxmax(0L,(long)floor(dx));
- #if CXIMAGE_SUPPORT_INTERPOLATION
- 						if (bSmooth){
- 							if (fx > 1 && fy > 1) { 
-@@ -813,7 +813,7 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
- 				
- 				for(yy=0;yy<desth;yy++){
- 					dy = head.biHeight-(ymax-yy-y)*fy;
--					sy = max(0L,(long)floor(dy));
-+					sy = cxmax(0L,(long)floor(dy));
- 
- 					alphaoffset = sy*head.biWidth;
- 					pdst = pbase + yy*ew;
-@@ -821,7 +821,7 @@ long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect, b
- 
- 					for(xx=0;xx<destw;xx++){
- 						dx = (xx+xmin-x)*fx;
--						sx = max(0L,(long)floor(dx));
-+						sx = cxmax(0L,(long)floor(dx));
- 
- 						if (bAlpha) a=pAlpha[alphaoffset+sx]; else a=255;
- 						a =(BYTE)((a*(1+info.nAlphaMax))>>8);

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2022-02-17 18:10:03 UTC (rev 1133790)
+++ PKGBUILD	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -20,7 +20,7 @@
 pkgbase=kodi
 pkgname=('kodi' 'kodi-eventclients' 'kodi-tools-texturepacker' 'kodi-dev')
 pkgver=19.3
-pkgrel=2
+pkgrel=3
 arch=('x86_64')
 url="https://kodi.tv"
 license=('GPL2')
@@ -38,6 +38,7 @@
   # gbm
   'libinput'
 )
+options=(!lto)
 
 _codename=Matrix
 
@@ -55,7 +56,7 @@
 _libudfread_version="1.1.0"
 
 source=(
-  "$pkgbase-$pkgver-3-$_codename.tar.gz::https://github.com/xbmc/xbmc/archive/$pkgver-$_codename.tar.gz"
+  "$pkgbase-$pkgver-$_codename.tar.gz::https://github.com/xbmc/xbmc/archive/$pkgver-$_codename.tar.gz"
   "$pkgbase-libdvdcss-$_libdvdcss_version.tar.gz::https://github.com/xbmc/libdvdcss/archive/$_libdvdcss_version.tar.gz"
   "$pkgbase-libdvdnav-$_libdvdnav_version.tar.gz::https://github.com/xbmc/libdvdnav/archive/$_libdvdnav_version.tar.gz"
   "$pkgbase-libdvdread-$_libdvdread_version.tar.gz::https://github.com/xbmc/libdvdread/archive/$_libdvdread_version.tar.gz"

Deleted: cheat-sse-build.patch
===================================================================
--- cheat-sse-build.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ cheat-sse-build.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,11 +0,0 @@
---- a/cmake/modules/FindSSE.cmake	2017-08-22 09:29:22.000000000 +0200
-+++ b/cmake/modules/FindSSE.cmake	2018-01-06 19:36:32.716303559 +0100
-@@ -4,7 +4,7 @@
- 
- if(CMAKE_SYSTEM_NAME MATCHES "Linux")
-    if(CPU MATCHES "x86_64" OR CPU MATCHES "i.86")
--     exec_program(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO)
-+     set(CPUINFO "sse sse2 pni ssse3 sse4_1 sse4_2 avx avx2")
- 
-      string(REGEX REPLACE "^.*(sse).*$" "\\1" _SSE_THERE ${CPUINFO})
-      string(COMPARE EQUAL "sse" "${_SSE_THERE}" _SSE_TRUE)

Added: cheat-sse-build.patch
===================================================================
--- cheat-sse-build.patch	                        (rev 0)
+++ cheat-sse-build.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -0,0 +1,11 @@
+--- a/cmake/modules/FindSSE.cmake	2017-08-22 09:29:22.000000000 +0200
++++ b/cmake/modules/FindSSE.cmake	2018-01-06 19:36:32.716303559 +0100
+@@ -4,7 +4,7 @@
+ 
+ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+    if(CPU MATCHES "x86_64" OR CPU MATCHES "i.86")
+-     exec_program(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO)
++     set(CPUINFO "sse sse2 pni ssse3 sse4_1 sse4_2 avx avx2")
+ 
+      string(REGEX REPLACE "^.*(sse).*$" "\\1" _SSE_THERE ${CPUINFO})
+      string(COMPARE EQUAL "sse" "${_SSE_THERE}" _SSE_TRUE)

Deleted: fix-ftpparse.patch
===================================================================
--- fix-ftpparse.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ fix-ftpparse.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,71 +0,0 @@
---- a/xbmc/filesystem/FTPParse.cpp	2017-05-24 22:49:32.000000000 +0200
-+++ b/xbmc/filesystem/FTPParse.cpp	2017-07-15 14:15:54.908823456 +0200
-@@ -34,7 +34,7 @@
-   m_time = 0;
- }
- 
--string CFTPParse::getName()
-+std::string CFTPParse::getName()
- {
-   return m_name;
- }
-@@ -59,16 +59,16 @@
-   return m_time;
- }
- 
--void CFTPParse::setTime(string str)
-+void CFTPParse::setTime(std::string str)
- {
-   /* Variables used to capture patterns via the regexes */
--  string month;
--  string day;
--  string year;
--  string hour;
--  string minute;
--  string second;
--  string am_or_pm;
-+  std::string month;
-+  std::string day;
-+  std::string year;
-+  std::string hour;
-+  std::string minute;
-+  std::string second;
-+  std::string am_or_pm;
- 
-   /* time struct used to set the time_t variable */
-   struct tm time_struct = {};
-@@ -338,21 +338,21 @@
-   return day_of_week;
- }
- 
--int CFTPParse::FTPParse(string str)
-+int CFTPParse::FTPParse(std::string str)
- {
-   /* Various variable to capture patterns via the regexes */
--  string permissions;
--  string link_count;
--  string owner;
--  string group;
--  string size;
--  string date;
--  string name;
--  string type;
--  string stuff;
--  string facts;
--  string version;
--  string file_id;
-+  std::string permissions;
-+  std::string link_count;
-+  std::string owner;
-+  std::string group;
-+  std::string size;
-+  std::string date;
-+  std::string name;
-+  std::string type;
-+  std::string stuff;
-+  std::string facts;
-+  std::string version;
-+  std::string file_id;
- 
-   /* Regex for standard Unix listing formats */
-   pcrecpp::RE unix_re("^([-bcdlps])" // type

Deleted: fix-python-lib-path.patch
===================================================================
--- fix-python-lib-path.patch	2022-02-17 18:10:03 UTC (rev 1133790)
+++ fix-python-lib-path.patch	2022-02-17 18:33:46 UTC (rev 1133791)
@@ -1,29 +0,0 @@
---- a/project/cmake/scripts/linux/Install.cmake	2017-03-20 17:17:49.000000000 +0100
-+++ b/project/cmake/scripts/linux/Install.cmake	2017-05-20 15:42:09.608550173 +0200
-@@ -199,7 +199,7 @@
-   install(PROGRAMS ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/bt/__init__.py
-                    ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/bt/bt.py
-                    ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/bt/hid.py
--          DESTINATION lib/python2.7/dist-packages/${APP_NAME_LC}/bt
-+          DESTINATION lib/python2.7/site-packages/${APP_NAME_LC}/bt
-           COMPONENT kodi-eventclients-common)
- 
-   # Install kodi-eventclients-common PS3 python files
-@@ -208,7 +208,7 @@
-                    ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/sixaxis.py
-                    ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/sixpair.py
-                    ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/sixwatch.py
--          DESTINATION lib/python2.7/dist-packages/${APP_NAME_LC}/ps3
-+          DESTINATION lib/python2.7/site-packages/${APP_NAME_LC}/ps3
-           COMPONENT kodi-eventclients-common)
- 
-   # Install kodi-eventclients-common python files
-@@ -218,7 +218,7 @@
-                    "${CORE_SOURCE_DIR}/tools/EventClients/Clients/PS3 BD Remote/ps3_remote.py"
-                    ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/xbmcclient.py
-                    ${CORE_SOURCE_DIR}/tools/EventClients/lib/python/zeroconf.py
--          DESTINATION lib/python2.7/dist-packages/${APP_NAME_LC}
-+          DESTINATION lib/python2.7/site-packages/${APP_NAME_LC}
-           COMPONENT kodi-eventclients-common)
- 
-   # Install kodi-eventclients-common icons



More information about the arch-commits mailing list