summaryrefslogtreecommitdiff
path: root/thirdparty
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty')
-rw-r--r--thirdparty/README.md20
-rw-r--r--thirdparty/enet/enet/enet.h21
-rw-r--r--thirdparty/enet/enet/godot.h72
-rw-r--r--thirdparty/enet/enet/unix.h47
-rw-r--r--thirdparty/enet/enet/win32.h57
-rw-r--r--thirdparty/enet/godot.cpp233
-rw-r--r--thirdparty/enet/host.c2
-rw-r--r--thirdparty/enet/protocol.c9
-rw-r--r--thirdparty/enet/unix.c616
-rw-r--r--thirdparty/enet/win32.c435
-rw-r--r--thirdparty/libpng/png.c14
-rw-r--r--thirdparty/libpng/png.h29
-rw-r--r--thirdparty/libpng/pngconf.h2
-rw-r--r--thirdparty/libpng/pnglibconf.h6
-rw-r--r--thirdparty/libpng/pngpriv.h90
-rw-r--r--thirdparty/libpng/pngrtran.c12
-rw-r--r--thirdparty/libpng/pngrutil.c6
-rw-r--r--thirdparty/libpng/pngwutil.c19
-rw-r--r--thirdparty/opus/silk/NLSF_stabilize.c2
-rw-r--r--thirdparty/squish/squish.cpp24
-rw-r--r--thirdparty/squish/squish.h9
21 files changed, 501 insertions, 1224 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 8c2a3e6af3..f6edff490f 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -16,13 +16,18 @@ TODO.
Files extracted from upstream source:
-- all .c files in the main directory
-- the include/enet/ folder as enet/
+- all .c files in the main directory (except unix.c win32.c)
+- the include/enet/ folder as enet/ (except unix.h win32.h)
- LICENSE file
-Important: Some files have been modified by Godot developers so that they work
-for all platforms (especially UWP). Check the diff with the 1.3.13 tarball
-before the next update.
+Important: enet.h, host.c, protocol.c have been slightly modified
+to be usable by godot socket implementation and allow IPv6.
+Two files (godot.cpp and enet/godot.h) have been added to provide
+enet socket implementation using Godot classes.
+It is still possible to build against a system wide ENet but doing so
+will limit it's functionality to IPv4 only.
+Check the diff of enet.h, protocol.c, and host.c with the 1.3.13
+tarball before the next update.
## fonts
@@ -151,7 +156,7 @@ TODO.
## opus
- Upstream: https://opus-codec.org
-- Version: 1.1.3 (opus) and 0.8 (opusfile)
+- Version: 1.1.4 (opus) and 0.8 (opusfile)
- License: BSD-3-Clause
Files extracted from upstream source:
@@ -159,6 +164,7 @@ Files extracted from upstream source:
- all .c and .h files in src/ (both opus and opusfile),
except `opus_demo.c`
- all .h files in include/ (both opus and opusfile) as opus/
+- celt/ and silk/ subfolders
- COPYING
@@ -199,7 +205,7 @@ Files extracted from upstream source:
## squish
- Upstream: https://sourceforge.net/projects/libsquish
-- Version: 1.14
+- Version: 1.15
- License: MIT
Files extracted from upstream source:
diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h
index 650b199ee5..8c9ad5463e 100644
--- a/thirdparty/enet/enet/enet.h
+++ b/thirdparty/enet/enet/enet.h
@@ -12,11 +12,7 @@ extern "C"
#include <stdlib.h>
-#ifdef _WIN32
-#include "enet/win32.h"
-#else
-#include "enet/unix.h"
-#endif
+#include "enet/godot.h"
#include "enet/types.h"
#include "enet/protocol.h"
@@ -72,7 +68,6 @@ typedef enum _ENetSocketShutdown
ENET_SOCKET_SHUTDOWN_READ_WRITE = 2
} ENetSocketShutdown;
-#define ENET_HOST_ANY 0
#define ENET_HOST_BROADCAST 0xFFFFFFFFU
#define ENET_PORT_ANY 0
@@ -88,9 +83,11 @@ typedef enum _ENetSocketShutdown
*/
typedef struct _ENetAddress
{
- enet_uint32 host;
+ uint8_t host[16];
enet_uint16 port;
+ uint8_t wildcard;
} ENetAddress;
+#define enet_host_equal(host_a, host_b) (memcmp(&host_a, &host_b,16) == 0)
/**
* Packet flag bit constants.
@@ -519,6 +516,16 @@ ENET_API int enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSock
*/
ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName);
+/** Sets the host field in the address parameter from ip struct.
+ @param address destination to store resolved address
+ @param ip the ip struct to read from
+ @param size the size of the ip struct.
+ @retval 0 on success
+ @retval != 0 on failure
+ @returns the address of the given ip in address on success.
+*/
+ENET_API void enet_address_set_ip(ENetAddress * address, const uint8_t * ip, size_t size);
+
/** Gives the printable form of the IP address specified in the address parameter.
@param address address printed
@param hostName destination for name, must not be NULL
diff --git a/thirdparty/enet/enet/godot.h b/thirdparty/enet/enet/godot.h
new file mode 100644
index 0000000000..75645153dd
--- /dev/null
+++ b/thirdparty/enet/enet/godot.h
@@ -0,0 +1,72 @@
+/*************************************************************************/
+/* godot.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+/**
+ @file godot.h
+ @brief ENet Godot header
+*/
+
+#ifndef __ENET_GODOT_H__
+#define __ENET_GODOT_H__
+
+#ifdef WINDOWS_ENABLED
+#include <stdint.h>
+#include <winsock2.h>
+#endif
+#ifdef UNIX_ENABLED
+#include <arpa/inet.h>
+#endif
+
+#ifdef MSG_MAXIOVLEN
+#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN
+#endif
+
+typedef void *ENetSocket;
+
+#define ENET_SOCKET_NULL NULL
+
+#define ENET_HOST_TO_NET_16(value) (htons(value)) /**< macro that converts host to net byte-order of a 16-bit value */
+#define ENET_HOST_TO_NET_32(value) (htonl(value)) /**< macro that converts host to net byte-order of a 32-bit value */
+
+#define ENET_NET_TO_HOST_16(value) (ntohs(value)) /**< macro that converts net to host byte-order of a 16-bit value */
+#define ENET_NET_TO_HOST_32(value) (ntohl(value)) /**< macro that converts net to host byte-order of a 32-bit value */
+
+typedef struct
+{
+ void *data;
+ size_t dataLength;
+} ENetBuffer;
+
+#define ENET_CALLBACK
+
+#define ENET_API extern
+
+typedef void ENetSocketSet;
+
+#endif /* __ENET_GODOT_H__ */
diff --git a/thirdparty/enet/enet/unix.h b/thirdparty/enet/enet/unix.h
deleted file mode 100644
index a59e340606..0000000000
--- a/thirdparty/enet/enet/unix.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- @file unix.h
- @brief ENet Unix header
-*/
-#ifndef __ENET_UNIX_H__
-#define __ENET_UNIX_H__
-
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <unistd.h>
-
-#ifdef MSG_MAXIOVLEN
-#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN
-#endif
-
-typedef int ENetSocket;
-
-#define ENET_SOCKET_NULL -1
-
-#define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */
-#define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */
-
-#define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */
-#define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */
-
-typedef struct
-{
- void * data;
- size_t dataLength;
-} ENetBuffer;
-
-#define ENET_CALLBACK
-
-#define ENET_API extern
-
-typedef fd_set ENetSocketSet;
-
-#define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset))
-#define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset))
-#define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset))
-#define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset))
-
-#endif /* __ENET_UNIX_H__ */
-
diff --git a/thirdparty/enet/enet/win32.h b/thirdparty/enet/enet/win32.h
deleted file mode 100644
index e73ca9d052..0000000000
--- a/thirdparty/enet/enet/win32.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- @file win32.h
- @brief ENet Win32 header
-*/
-#ifndef __ENET_WIN32_H__
-#define __ENET_WIN32_H__
-
-#ifdef _MSC_VER
-#ifdef ENET_BUILDING_LIB
-#pragma warning (disable: 4267) // size_t to int conversion
-#pragma warning (disable: 4244) // 64bit to 32bit int
-#pragma warning (disable: 4018) // signed/unsigned mismatch
-#pragma warning (disable: 4146) // unary minus operator applied to unsigned type
-#endif
-#endif
-
-#include <stdlib.h>
-#include <winsock2.h>
-
-typedef SOCKET ENetSocket;
-
-#define ENET_SOCKET_NULL INVALID_SOCKET
-
-#define ENET_HOST_TO_NET_16(value) (htons (value))
-#define ENET_HOST_TO_NET_32(value) (htonl (value))
-
-#define ENET_NET_TO_HOST_16(value) (ntohs (value))
-#define ENET_NET_TO_HOST_32(value) (ntohl (value))
-
-typedef struct
-{
- size_t dataLength;
- void * data;
-} ENetBuffer;
-
-#define ENET_CALLBACK __cdecl
-
-#ifdef ENET_DLL
-#ifdef ENET_BUILDING_LIB
-#define ENET_API __declspec( dllexport )
-#else
-#define ENET_API __declspec( dllimport )
-#endif /* ENET_BUILDING_LIB */
-#else /* !ENET_DLL */
-#define ENET_API extern
-#endif /* ENET_DLL */
-
-typedef fd_set ENetSocketSet;
-
-#define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset))
-#define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset))
-#define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset))
-#define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset))
-
-#endif /* __ENET_WIN32_H__ */
-
-
diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp
new file mode 100644
index 0000000000..f050b7b916
--- /dev/null
+++ b/thirdparty/enet/godot.cpp
@@ -0,0 +1,233 @@
+/*************************************************************************/
+/* godot.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+/**
+ @file godot.cpp
+ @brief ENet Godot specific functions
+*/
+
+#include "core/io/ip.h"
+#include "core/io/packet_peer_udp.h"
+#include "core/os/os.h"
+
+// This must be last for windows to compile (tested with MinGW)
+#include "enet/enet.h"
+
+static enet_uint32 timeBase = 0;
+
+int enet_initialize(void) {
+
+ return 0;
+}
+
+void enet_deinitialize(void) {
+}
+
+enet_uint32 enet_host_random_seed(void) {
+
+ return (enet_uint32)OS::get_singleton()->get_unix_time();
+}
+
+enet_uint32 enet_time_get(void) {
+
+ return OS::get_singleton()->get_ticks_msec() - timeBase;
+}
+
+void enet_time_set(enet_uint32 newTimeBase) {
+
+ timeBase = OS::get_singleton()->get_ticks_msec() - newTimeBase;
+}
+
+int enet_address_set_host(ENetAddress *address, const char *name) {
+
+ IP_Address ip = IP::get_singleton()->resolve_hostname(name);
+ ERR_FAIL_COND_V(!ip.is_valid(), -1);
+
+ enet_address_set_ip(address, ip.get_ipv6(), 16);
+ return 0;
+}
+
+void enet_address_set_ip(ENetAddress *address, const uint8_t *ip, size_t size) {
+
+ int len = size > 16 ? 16 : size;
+ memset(address->host, 0, 16);
+ memcpy(address->host, ip, len);
+}
+
+int enet_address_get_host_ip(const ENetAddress *address, char *name, size_t nameLength) {
+
+ return -1;
+}
+
+int enet_address_get_host(const ENetAddress *address, char *name, size_t nameLength) {
+
+ return -1;
+}
+
+int enet_socket_bind(ENetSocket socket, const ENetAddress *address) {
+
+ IP_Address ip;
+ if (address->wildcard) {
+ ip = IP_Address("*");
+ } else {
+ ip.set_ipv6(address->host);
+ }
+
+ PacketPeerUDP *sock = (PacketPeerUDP *)socket;
+ if (sock->listen(address->port, ip) != OK) {
+ return -1;
+ }
+ return 0;
+}
+
+ENetSocket enet_socket_create(ENetSocketType type) {
+
+ PacketPeerUDP *socket = PacketPeerUDP::create();
+ socket->set_blocking_mode(false);
+
+ return socket;
+}
+
+void enet_socket_destroy(ENetSocket socket) {
+ PacketPeerUDP *sock = (PacketPeerUDP *)socket;
+ sock->close();
+ memdelete(sock);
+}
+
+int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBuffer *buffers, size_t bufferCount) {
+
+ ERR_FAIL_COND_V(address == NULL, -1);
+
+ PacketPeerUDP *sock = (PacketPeerUDP *)socket;
+ IP_Address dest;
+ Error err;
+ size_t i = 0;
+
+ dest.set_ipv6(address->host);
+ sock->set_dest_address(dest, address->port);
+
+ // Create a single packet.
+ PoolVector<uint8_t> out;
+ PoolVector<uint8_t>::Write w;
+ int size = 0;
+ int pos = 0;
+ for (i = 0; i < bufferCount; i++) {
+ size += buffers[i].dataLength;
+ }
+
+ out.resize(size);
+ w = out.write();
+ for (i = 0; i < bufferCount; i++) {
+ memcpy(&w[pos], buffers[i].data, buffers[i].dataLength);
+ pos += buffers[i].dataLength;
+ }
+
+ err = sock->put_packet((const uint8_t *)&w[0], size);
+ if (err != OK) {
+
+ if (err == ERR_UNAVAILABLE) { // blocking call
+ return 0;
+ }
+
+ WARN_PRINT("Sending failed!");
+ return -1;
+ }
+
+ return size;
+}
+
+int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buffers, size_t bufferCount) {
+
+ ERR_FAIL_COND_V(bufferCount != 1, -1);
+
+ PacketPeerUDP *sock = (PacketPeerUDP *)socket;
+
+ if (sock->get_available_packet_count() == 0) {
+ return 0;
+ }
+
+ const uint8_t *buffer;
+ int buffer_size;
+ Error err = sock->get_packet(&buffer, buffer_size);
+ if (err)
+ return -1;
+
+ copymem(buffers[0].data, buffer, buffer_size);
+
+ enet_address_set_ip(address, sock->get_packet_address().get_ipv6(), 16);
+ address->port = sock->get_packet_port();
+
+ return buffer_size;
+}
+
+// Not implemented
+int enet_socket_wait(ENetSocket socket, enet_uint32 *condition, enet_uint32 timeout) {
+
+ return 0; // do we need this function?
+}
+
+int enet_socket_get_address(ENetSocket socket, ENetAddress *address) {
+
+ return -1; // do we need this function?
+}
+
+int enet_socketset_select(ENetSocket maxSocket, ENetSocketSet *readSet, ENetSocketSet *writeSet, enet_uint32 timeout) {
+
+ return -1;
+}
+
+int enet_socket_listen(ENetSocket socket, int backlog) {
+
+ return -1;
+}
+
+int enet_socket_set_option(ENetSocket socket, ENetSocketOption option, int value) {
+
+ return -1;
+}
+
+int enet_socket_get_option(ENetSocket socket, ENetSocketOption option, int *value) {
+
+ return -1;
+}
+
+int enet_socket_connect(ENetSocket socket, const ENetAddress *address) {
+
+ return -1;
+}
+
+ENetSocket enet_socket_accept(ENetSocket socket, ENetAddress *address) {
+
+ return NULL;
+}
+
+int enet_socket_shutdown(ENetSocket socket, ENetSocketShutdown how) {
+
+ return -1;
+}
diff --git a/thirdparty/enet/host.c b/thirdparty/enet/host.c
index 3be6c0922c..fc4da4ca67 100644
--- a/thirdparty/enet/host.c
+++ b/thirdparty/enet/host.c
@@ -87,7 +87,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
host -> commandCount = 0;
host -> bufferCount = 0;
host -> checksum = NULL;
- host -> receivedAddress.host = ENET_HOST_ANY;
+ memset(host -> receivedAddress.host, 0, 16);
host -> receivedAddress.port = 0;
host -> receivedData = NULL;
host -> receivedDataLength = 0;
diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c
index 4a2a4ed185..cbeea1a763 100644
--- a/thirdparty/enet/protocol.c
+++ b/thirdparty/enet/protocol.c
@@ -299,7 +299,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
}
else
if (currentPeer -> state != ENET_PEER_STATE_CONNECTING &&
- currentPeer -> address.host == host -> receivedAddress.host)
+ enet_host_equal(currentPeer -> address.host, host -> receivedAddress.host))
{
if (currentPeer -> address.port == host -> receivedAddress.port &&
currentPeer -> connectID == command -> connect.connectID)
@@ -1011,9 +1011,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||
peer -> state == ENET_PEER_STATE_ZOMBIE ||
- ((host -> receivedAddress.host != peer -> address.host ||
- host -> receivedAddress.port != peer -> address.port) &&
- peer -> address.host != ENET_HOST_BROADCAST) ||
+ (!enet_host_equal(host -> receivedAddress.host, peer -> address.host) ||
+ host -> receivedAddress.port != peer -> address.port) ||
(peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID &&
sessionID != peer -> incomingSessionID))
return 0;
@@ -1055,7 +1054,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
if (peer != NULL)
{
- peer -> address.host = host -> receivedAddress.host;
+ enet_address_set_ip(&(peer -> address), host -> receivedAddress.host, 16);
peer -> address.port = host -> receivedAddress.port;
peer -> incomingDataTotal += host -> receivedDataLength;
}
diff --git a/thirdparty/enet/unix.c b/thirdparty/enet/unix.c
deleted file mode 100644
index 3138cc04b6..0000000000
--- a/thirdparty/enet/unix.c
+++ /dev/null
@@ -1,616 +0,0 @@
-/**
- @file unix.c
- @brief ENet Unix system specific functions
-*/
-#ifndef _WIN32
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <arpa/inet.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <time.h>
-
-#define ENET_BUILDING_LIB 1
-#include "enet/enet.h"
-
-//@godot: added this since enet takes them fromt he build system
-#define HAS_POLL
-#define HAS_FCNTL
-#define HAS_SOCKLEN_T
-
-
-#ifdef __APPLE__
-#ifdef HAS_POLL
-#undef HAS_POLL
-#endif
-#ifndef HAS_FCNTL
-#define HAS_FCNTL 1
-#endif
-#ifndef HAS_INET_PTON
-#define HAS_INET_PTON 1
-#endif
-#ifndef HAS_INET_NTOP
-#define HAS_INET_NTOP 1
-#endif
-#ifndef HAS_MSGHDR_FLAGS
-#define HAS_MSGHDR_FLAGS 1
-#endif
-#ifndef HAS_SOCKLEN_T
-#define HAS_SOCKLEN_T 1
-#endif
-#ifndef HAS_GETADDRINFO
-#define HAS_GETADDRINFO 1
-#endif
-#ifndef HAS_GETNAMEINFO
-#define HAS_GETNAMEINFO 1
-#endif
-#endif
-
-#ifdef HAS_FCNTL
-#include <fcntl.h>
-#endif
-
-#ifdef HAS_POLL
-#include <sys/poll.h>
-#endif
-
-#ifndef HAS_SOCKLEN_T
-typedef int socklen_t;
-#endif
-
-#ifndef MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-
-static enet_uint32 timeBase = 0;
-
-int
-enet_initialize (void)
-{
- return 0;
-}
-
-void
-enet_deinitialize (void)
-{
-}
-
-enet_uint32
-enet_host_random_seed (void)
-{
- return (enet_uint32) time (NULL);
-}
-
-enet_uint32
-enet_time_get (void)
-{
- struct timeval timeVal;
-
- gettimeofday (& timeVal, NULL);
-
- return timeVal.tv_sec * 1000 + timeVal.tv_usec / 1000 - timeBase;
-}
-
-void
-enet_time_set (enet_uint32 newTimeBase)
-{
- struct timeval timeVal;
-
- gettimeofday (& timeVal, NULL);
-
- timeBase = timeVal.tv_sec * 1000 + timeVal.tv_usec / 1000 - newTimeBase;
-}
-
-int
-enet_address_set_host (ENetAddress * address, const char * name)
-{
-#ifdef HAS_GETADDRINFO
- struct addrinfo hints, * resultList = NULL, * result = NULL;
-
- memset (& hints, 0, sizeof (hints));
- hints.ai_family = AF_INET;
-
- if (getaddrinfo (name, NULL, NULL, & resultList) != 0)
- return -1;
-
- for (result = resultList; result != NULL; result = result -> ai_next)
- {
- if (result -> ai_family == AF_INET && result -> ai_addr != NULL && result -> ai_addrlen >= sizeof (struct sockaddr_in))
- {
- struct sockaddr_in * sin = (struct sockaddr_in *) result -> ai_addr;
-
- address -> host = sin -> sin_addr.s_addr;
-
- freeaddrinfo (resultList);
-
- return 0;
- }
- }
-
- if (resultList != NULL)
- freeaddrinfo (resultList);
-#else
- struct hostent * hostEntry = NULL;
-#ifdef HAS_GETHOSTBYNAME_R
- struct hostent hostData;
- char buffer [2048];
- int errnum;
-
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
- gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
-#else
- hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum);
-#endif
-#else
- hostEntry = gethostbyname (name);
-#endif
-
- if (hostEntry != NULL && hostEntry -> h_addrtype == AF_INET)
- {
- address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
-
- return 0;
- }
-#endif
-
-#ifdef HAS_INET_PTON
- if (! inet_pton (AF_INET, name, & address -> host))
-#else
- if (! inet_aton (name, (struct in_addr *) & address -> host))
-#endif
- return -1;
-
- return 0;
-}
-
-int
-enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameLength)
-{
-#ifdef HAS_INET_NTOP
- if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL)
-#else
- char * addr = inet_ntoa (* (struct in_addr *) & address -> host);
- if (addr != NULL)
- {
- size_t addrLen = strlen(addr);
- if (addrLen >= nameLength)
- return -1;
- memcpy (name, addr, addrLen + 1);
- }
- else
-#endif
- return -1;
- return 0;
-}
-
-int
-enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength)
-{
-#ifdef HAS_GETNAMEINFO
- struct sockaddr_in sin;
- int err;
-
- memset (& sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
- sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
- sin.sin_addr.s_addr = address -> host;
-
- err = getnameinfo ((struct sockaddr *) & sin, sizeof (sin), name, nameLength, NULL, 0, NI_NAMEREQD);
- if (! err)
- {
- if (name != NULL && nameLength > 0 && ! memchr (name, '\0', nameLength))
- return -1;
- return 0;
- }
- if (err != EAI_NONAME)
- return -1;
-#else
- struct in_addr in;
- struct hostent * hostEntry = NULL;
-#ifdef HAS_GETHOSTBYADDR_R
- struct hostent hostData;
- char buffer [2048];
- int errnum;
-
- in.s_addr = address -> host;
-
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
- gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
-#else
- hostEntry = gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & errnum);
-#endif
-#else
- in.s_addr = address -> host;
-
- hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
-#endif
-
- if (hostEntry != NULL)
- {
- size_t hostLen = strlen (hostEntry -> h_name);
- if (hostLen >= nameLength)
- return -1;
- memcpy (name, hostEntry -> h_name, hostLen + 1);
- return 0;
- }
-#endif
-
- return enet_address_get_host_ip (address, name, nameLength);
-}
-
-int
-enet_socket_bind (ENetSocket socket, const ENetAddress * address)
-{
- struct sockaddr_in sin;
-
- memset (& sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
-
- if (address != NULL)
- {
- sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
- sin.sin_addr.s_addr = address -> host;
- }
- else
- {
- sin.sin_port = 0;
- sin.sin_addr.s_addr = INADDR_ANY;
- }
-
- return bind (socket,
- (struct sockaddr *) & sin,
- sizeof (struct sockaddr_in));
-}
-
-int
-enet_socket_get_address (ENetSocket socket, ENetAddress * address)
-{
- struct sockaddr_in sin;
- socklen_t sinLength = sizeof (struct sockaddr_in);
-
- if (getsockname (socket, (struct sockaddr *) & sin, & sinLength) == -1)
- return -1;
-
- address -> host = (enet_uint32) sin.sin_addr.s_addr;
- address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
-
- return 0;
-}
-
-int
-enet_socket_listen (ENetSocket socket, int backlog)
-{
- return listen (socket, backlog < 0 ? SOMAXCONN : backlog);
-}
-
-ENetSocket
-enet_socket_create (ENetSocketType type)
-{
- return socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0);
-}
-
-int
-enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
-{
- int result = -1;
- switch (option)
- {
- case ENET_SOCKOPT_NONBLOCK:
-#ifdef HAS_FCNTL
- result = fcntl (socket, F_SETFL, (value ? O_NONBLOCK : 0) | (fcntl (socket, F_GETFL) & ~O_NONBLOCK));
-#else
- result = ioctl (socket, FIONBIO, & value);
-#endif
- break;
-
- case ENET_SOCKOPT_BROADCAST:
- result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_REUSEADDR:
- result = setsockopt (socket, SOL_SOCKET, SO_REUSEADDR, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_RCVBUF:
- result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_SNDBUF:
- result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_RCVTIMEO:
- {
- struct timeval timeVal;
- timeVal.tv_sec = value / 1000;
- timeVal.tv_usec = (value % 1000) * 1000;
- result = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) & timeVal, sizeof (struct timeval));
- break;
- }
-
- case ENET_SOCKOPT_SNDTIMEO:
- {
- struct timeval timeVal;
- timeVal.tv_sec = value / 1000;
- timeVal.tv_usec = (value % 1000) * 1000;
- result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & timeVal, sizeof (struct timeval));
- break;
- }
-
- case ENET_SOCKOPT_NODELAY:
- result = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY, (char *) & value, sizeof (int));
- break;
-
- default:
- break;
- }
- return result == -1 ? -1 : 0;
-}
-
-int
-enet_socket_get_option (ENetSocket socket, ENetSocketOption option, int * value)
-{
- int result = -1;
- socklen_t len;
- switch (option)
- {
- case ENET_SOCKOPT_ERROR:
- len = sizeof (int);
- result = getsockopt (socket, SOL_SOCKET, SO_ERROR, value, & len);
- break;
-
- default:
- break;
- }
- return result == -1 ? -1 : 0;
-}
-
-int
-enet_socket_connect (ENetSocket socket, const ENetAddress * address)
-{
- struct sockaddr_in sin;
- int result;
-
- memset (& sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
- sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
- sin.sin_addr.s_addr = address -> host;
-
- result = connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in));
- if (result == -1 && errno == EINPROGRESS)
- return 0;
-
- return result;
-}
-
-ENetSocket
-enet_socket_accept (ENetSocket socket, ENetAddress * address)
-{
- int result;
- struct sockaddr_in sin;
- socklen_t sinLength = sizeof (struct sockaddr_in);
-
- result = accept (socket,
- address != NULL ? (struct sockaddr *) & sin : NULL,
- address != NULL ? & sinLength : NULL);
-
- if (result == -1)
- return ENET_SOCKET_NULL;
-
- if (address != NULL)
- {
- address -> host = (enet_uint32) sin.sin_addr.s_addr;
- address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
- }
-
- return result;
-}
-
-int
-enet_socket_shutdown (ENetSocket socket, ENetSocketShutdown how)
-{
- return shutdown (socket, (int) how);
-}
-
-void
-enet_socket_destroy (ENetSocket socket)
-{
- if (socket != -1)
- close (socket);
-}
-
-int
-enet_socket_send (ENetSocket socket,
- const ENetAddress * address,
- const ENetBuffer * buffers,
- size_t bufferCount)
-{
- struct msghdr msgHdr;
- struct sockaddr_in sin;
- int sentLength;
-
- memset (& msgHdr, 0, sizeof (struct msghdr));
-
- if (address != NULL)
- {
- memset (& sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
- sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
- sin.sin_addr.s_addr = address -> host;
-
- msgHdr.msg_name = & sin;
- msgHdr.msg_namelen = sizeof (struct sockaddr_in);
- }
-
- msgHdr.msg_iov = (struct iovec *) buffers;
- msgHdr.msg_iovlen = bufferCount;
-
- sentLength = sendmsg (socket, & msgHdr, MSG_NOSIGNAL);
-
- if (sentLength == -1)
- {
- if (errno == EWOULDBLOCK)
- return 0;
-
- return -1;
- }
-
- return sentLength;
-}
-
-int
-enet_socket_receive (ENetSocket socket,
- ENetAddress * address,
- ENetBuffer * buffers,
- size_t bufferCount)
-{
- struct msghdr msgHdr;
- struct sockaddr_in sin;
- int recvLength;
-
- memset (& msgHdr, 0, sizeof (struct msghdr));
-
- if (address != NULL)
- {
- msgHdr.msg_name = & sin;
- msgHdr.msg_namelen = sizeof (struct sockaddr_in);
- }
-
- msgHdr.msg_iov = (struct iovec *) buffers;
- msgHdr.msg_iovlen = bufferCount;
-
- recvLength = recvmsg (socket, & msgHdr, MSG_NOSIGNAL);
-
- if (recvLength == -1)
- {
- if (errno == EWOULDBLOCK)
- return 0;
-
- return -1;
- }
-
-#ifdef HAS_MSGHDR_FLAGS
- if (msgHdr.msg_flags & MSG_TRUNC)
- return -1;
-#endif
-
- if (address != NULL)
- {
- address -> host = (enet_uint32) sin.sin_addr.s_addr;
- address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
- }
-
- return recvLength;
-}
-
-int
-enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocketSet * writeSet, enet_uint32 timeout)
-{
- struct timeval timeVal;
-
- timeVal.tv_sec = timeout / 1000;
- timeVal.tv_usec = (timeout % 1000) * 1000;
-
- return select (maxSocket + 1, readSet, writeSet, NULL, & timeVal);
-}
-
-int
-enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout)
-{
-#ifdef HAS_POLL
- struct pollfd pollSocket;
- int pollCount;
-
- pollSocket.fd = socket;
- pollSocket.events = 0;
-
- if (* condition & ENET_SOCKET_WAIT_SEND)
- pollSocket.events |= POLLOUT;
-
- if (* condition & ENET_SOCKET_WAIT_RECEIVE)
- pollSocket.events |= POLLIN;
-
- pollCount = poll (& pollSocket, 1, timeout);
-
- if (pollCount < 0)
- {
- if (errno == EINTR && * condition & ENET_SOCKET_WAIT_INTERRUPT)
- {
- * condition = ENET_SOCKET_WAIT_INTERRUPT;
-
- return 0;
- }
-
- return -1;
- }
-
- * condition = ENET_SOCKET_WAIT_NONE;
-
- if (pollCount == 0)
- return 0;
-
- if (pollSocket.revents & POLLOUT)
- * condition |= ENET_SOCKET_WAIT_SEND;
-
- if (pollSocket.revents & POLLIN)
- * condition |= ENET_SOCKET_WAIT_RECEIVE;
-
- return 0;
-#else
- fd_set readSet, writeSet;
- struct timeval timeVal;
- int selectCount;
-
- timeVal.tv_sec = timeout / 1000;
- timeVal.tv_usec = (timeout % 1000) * 1000;
-
- FD_ZERO (& readSet);
- FD_ZERO (& writeSet);
-
- if (* condition & ENET_SOCKET_WAIT_SEND)
- FD_SET (socket, & writeSet);
-
- if (* condition & ENET_SOCKET_WAIT_RECEIVE)
- FD_SET (socket, & readSet);
-
- selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal);
-
- if (selectCount < 0)
- {
- if (errno == EINTR && * condition & ENET_SOCKET_WAIT_INTERRUPT)
- {
- * condition = ENET_SOCKET_WAIT_INTERRUPT;
-
- return 0;
- }
-
- return -1;
- }
-
- * condition = ENET_SOCKET_WAIT_NONE;
-
- if (selectCount == 0)
- return 0;
-
- if (FD_ISSET (socket, & writeSet))
- * condition |= ENET_SOCKET_WAIT_SEND;
-
- if (FD_ISSET (socket, & readSet))
- * condition |= ENET_SOCKET_WAIT_RECEIVE;
-
- return 0;
-#endif
-}
-
-#endif
-
diff --git a/thirdparty/enet/win32.c b/thirdparty/enet/win32.c
deleted file mode 100644
index f8e0d4efd4..0000000000
--- a/thirdparty/enet/win32.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/**
- @file win32.c
- @brief ENet Win32 system specific functions
-*/
-#ifdef _WIN32
-
-#define ENET_BUILDING_LIB 0
-#include "enet/enet.h"
-#include <windows.h>
-#include <mmsystem.h>
-
-static enet_uint32 timeBase = 0;
-
-int
-enet_initialize (void)
-{
- WORD versionRequested = MAKEWORD (1, 1);
- WSADATA wsaData;
-
- if (WSAStartup (versionRequested, & wsaData))
- return -1;
-
- if (LOBYTE (wsaData.wVersion) != 1||
- HIBYTE (wsaData.wVersion) != 1)
- {
- WSACleanup ();
-
- return -1;
- }
-
-#ifndef UWP_ENABLED
- timeBeginPeriod (1);
-#endif
-
- return 0;
-}
-
-void
-enet_deinitialize (void)
-{
-#ifndef UWP_ENABLED
- timeEndPeriod (1);
-#endif
-
- WSACleanup ();
-}
-
-#ifdef UWP_ENABLED
-enet_uint32
-timeGetTime() {
- ULONGLONG ticks = GetTickCount64();
- return (enet_uint32)ticks;
-}
-#endif
-
-
-enet_uint32
-enet_host_random_seed (void)
-{
- return (enet_uint32) timeGetTime ();
-}
-
-enet_uint32
-enet_time_get (void)
-{
- return (enet_uint32) timeGetTime () - timeBase;
-}
-
-void
-enet_time_set (enet_uint32 newTimeBase)
-{
- timeBase = (enet_uint32) timeGetTime () - newTimeBase;
-}
-
-int
-enet_address_set_host (ENetAddress * address, const char * name)
-{
- struct hostent * hostEntry;
-
- hostEntry = gethostbyname (name);
- if (hostEntry == NULL ||
- hostEntry -> h_addrtype != AF_INET)
- {
- unsigned long host = inet_addr (name);
- if (host == INADDR_NONE)
- return -1;
- address -> host = host;
- return 0;
- }
-
- address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
-
- return 0;
-}
-
-int
-enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameLength)
-{
- char * addr = inet_ntoa (* (struct in_addr *) & address -> host);
- if (addr == NULL)
- return -1;
- else
- {
- size_t addrLen = strlen(addr);
- if (addrLen >= nameLength)
- return -1;
- memcpy (name, addr, addrLen + 1);
- }
- return 0;
-}
-
-int
-enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength)
-{
- struct in_addr in;
- struct hostent * hostEntry;
-
- in.s_addr = address -> host;
-
- hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
- if (hostEntry == NULL)
- return enet_address_get_host_ip (address, name, nameLength);
- else
- {
- size_t hostLen = strlen (hostEntry -> h_name);
- if (hostLen >= nameLength)
- return -1;
- memcpy (name, hostEntry -> h_name, hostLen + 1);
- }
-
- return 0;
-}
-
-int
-enet_socket_bind (ENetSocket socket, const ENetAddress * address)
-{
- struct sockaddr_in sin;
-
- memset (& sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
-
- if (address != NULL)
- {
- sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
- sin.sin_addr.s_addr = address -> host;
- }
- else
- {
- sin.sin_port = 0;
- sin.sin_addr.s_addr = INADDR_ANY;
- }
-
- return bind (socket,
- (struct sockaddr *) & sin,
- sizeof (struct sockaddr_in)) == SOCKET_ERROR ? -1 : 0;
-}
-
-int
-enet_socket_get_address (ENetSocket socket, ENetAddress * address)
-{
- struct sockaddr_in sin;
- int sinLength = sizeof (struct sockaddr_in);
-
- if (getsockname (socket, (struct sockaddr *) & sin, & sinLength) == -1)
- return -1;
-
- address -> host = (enet_uint32) sin.sin_addr.s_addr;
- address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
-
- return 0;
-}
-
-int
-enet_socket_listen (ENetSocket socket, int backlog)
-{
- return listen (socket, backlog < 0 ? SOMAXCONN : backlog) == SOCKET_ERROR ? -1 : 0;
-}
-
-ENetSocket
-enet_socket_create (ENetSocketType type)
-{
- return socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0);
-}
-
-int
-enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
-{
- int result = SOCKET_ERROR;
- switch (option)
- {
- case ENET_SOCKOPT_NONBLOCK:
- {
- u_long nonBlocking = (u_long) value;
- result = ioctlsocket (socket, FIONBIO, & nonBlocking);
- break;
- }
-
- case ENET_SOCKOPT_BROADCAST:
- result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_REUSEADDR:
- result = setsockopt (socket, SOL_SOCKET, SO_REUSEADDR, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_RCVBUF:
- result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_SNDBUF:
- result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_RCVTIMEO:
- result = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_SNDTIMEO:
- result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & value, sizeof (int));
- break;
-
- case ENET_SOCKOPT_NODELAY:
- result = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY, (char *) & value, sizeof (int));
- break;
-
- default:
- break;
- }
- return result == SOCKET_ERROR ? -1 : 0;
-}
-
-int
-enet_socket_get_option (ENetSocket socket, ENetSocketOption option, int * value)
-{
- int result = SOCKET_ERROR, len;
- switch (option)
- {
- case ENET_SOCKOPT_ERROR:
- len = sizeof(int);
- result = getsockopt (socket, SOL_SOCKET, SO_ERROR, (char *) value, & len);
- break;
-
- default:
- break;
- }
- return result == SOCKET_ERROR ? -1 : 0;
-}
-
-int
-enet_socket_connect (ENetSocket socket, const ENetAddress * address)
-{
- struct sockaddr_in sin;
- int result;
-
- memset (& sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
- sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
- sin.sin_addr.s_addr = address -> host;
-
- result = connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in));
- if (result == SOCKET_ERROR && WSAGetLastError () != WSAEWOULDBLOCK)
- return -1;
-
- return 0;
-}
-
-ENetSocket
-enet_socket_accept (ENetSocket socket, ENetAddress * address)
-{
- SOCKET result;
- struct sockaddr_in sin;
- int sinLength = sizeof (struct sockaddr_in);
-
- result = accept (socket,
- address != NULL ? (struct sockaddr *) & sin : NULL,
- address != NULL ? & sinLength : NULL);
-
- if (result == INVALID_SOCKET)
- return ENET_SOCKET_NULL;
-
- if (address != NULL)
- {
- address -> host = (enet_uint32) sin.sin_addr.s_addr;
- address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
- }
-
- return result;
-}
-
-int
-enet_socket_shutdown (ENetSocket socket, ENetSocketShutdown how)
-{
- return shutdown (socket, (int) how) == SOCKET_ERROR ? -1 : 0;
-}
-
-void
-enet_socket_destroy (ENetSocket socket)
-{
- if (socket != INVALID_SOCKET)
- closesocket (socket);
-}
-
-int
-enet_socket_send (ENetSocket socket,
- const ENetAddress * address,
- const ENetBuffer * buffers,
- size_t bufferCount)
-{
- struct sockaddr_in sin;
- DWORD sentLength;
-
- if (address != NULL)
- {
- memset (& sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
- sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
- sin.sin_addr.s_addr = address -> host;
- }
-
- if (WSASendTo (socket,
- (LPWSABUF) buffers,
- (DWORD) bufferCount,
- & sentLength,
- 0,
- address != NULL ? (struct sockaddr *) & sin : NULL,
- address != NULL ? sizeof (struct sockaddr_in) : 0,
- NULL,
- NULL) == SOCKET_ERROR)
- {
- if (WSAGetLastError () == WSAEWOULDBLOCK)
- return 0;
-
- return -1;
- }
-
- return (int) sentLength;
-}
-
-int
-enet_socket_receive (ENetSocket socket,
- ENetAddress * address,
- ENetBuffer * buffers,
- size_t bufferCount)
-{
- INT sinLength = sizeof (struct sockaddr_in);
- DWORD flags = 0,
- recvLength;
- struct sockaddr_in sin;
-
- if (WSARecvFrom (socket,
- (LPWSABUF) buffers,
- (DWORD) bufferCount,
- & recvLength,
- & flags,
- address != NULL ? (struct sockaddr *) & sin : NULL,
- address != NULL ? & sinLength : NULL,
- NULL,
- NULL) == SOCKET_ERROR)
- {
- switch (WSAGetLastError ())
- {
- case WSAEWOULDBLOCK:
- case WSAECONNRESET:
- return 0;
- }
-
- return -1;
- }
-
- if (flags & MSG_PARTIAL)
- return -1;
-
- if (address != NULL)
- {
- address -> host = (enet_uint32) sin.sin_addr.s_addr;
- address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
- }
-
- return (int) recvLength;
-}
-
-int
-enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocketSet * writeSet, enet_uint32 timeout)
-{
- struct timeval timeVal;
-
- timeVal.tv_sec = timeout / 1000;
- timeVal.tv_usec = (timeout % 1000) * 1000;
-
- return select (maxSocket + 1, readSet, writeSet, NULL, & timeVal);
-}
-
-int
-enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout)
-{
- fd_set readSet, writeSet;
- struct timeval timeVal;
- int selectCount;
-
- timeVal.tv_sec = timeout / 1000;
- timeVal.tv_usec = (timeout % 1000) * 1000;
-
- FD_ZERO (& readSet);
- FD_ZERO (& writeSet);
-
- if (* condition & ENET_SOCKET_WAIT_SEND)
- FD_SET (socket, & writeSet);
-
- if (* condition & ENET_SOCKET_WAIT_RECEIVE)
- FD_SET (socket, & readSet);
-
- selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal);
-
- if (selectCount < 0)
- return -1;
-
- * condition = ENET_SOCKET_WAIT_NONE;
-
- if (selectCount == 0)
- return 0;
-
- if (FD_ISSET (socket, & writeSet))
- * condition |= ENET_SOCKET_WAIT_SEND;
-
- if (FD_ISSET (socket, & readSet))
- * condition |= ENET_SOCKET_WAIT_RECEIVE;
-
- return 0;
-}
-
-#endif
-
diff --git a/thirdparty/libpng/png.c b/thirdparty/libpng/png.c
index 78ce39f46d..2c9fea2123 100644
--- a/thirdparty/libpng/png.c
+++ b/thirdparty/libpng/png.c
@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
- * Last changed in libpng 1.6.28 [January 5, 2017]
+ * Last changed in libpng 1.6.29 [March 16, 2017]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_28 Your_png_h_is_not_version_1_6_28;
+typedef png_libpng_version_1_6_29 Your_png_h_is_not_version_1_6_29;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -776,14 +776,14 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
- "libpng version 1.6.28 - January 5, 2017" PNG_STRING_NEWLINE \
+ "libpng version 1.6.29 - March 16, 2017" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
- return "libpng version 1.6.28 - January 5, 2017\
+ return "libpng version 1.6.29 - March 16, 2017\
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -4260,13 +4260,13 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
(option & 1) == 0)
{
- png_uint_32 mask = 3 << option;
- png_uint_32 setting = (2 + (onoff != 0)) << option;
+ png_uint_32 mask = 3U << option;
+ png_uint_32 setting = (2U + (onoff != 0)) << option;
png_uint_32 current = png_ptr->options;
png_ptr->options = (png_uint_32)(((current & ~mask) | setting) & 0xff);
- return (current & mask) >> option;
+ return (int)(current & mask) >> option;
}
return PNG_OPTION_INVALID;
diff --git a/thirdparty/libpng/png.h b/thirdparty/libpng/png.h
index e4cf032816..2431e0dfc0 100644
--- a/thirdparty/libpng/png.h
+++ b/thirdparty/libpng/png.h
@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.6.28, January 5, 2017
+ * libpng version 1.6.29, March 16, 2017
*
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -12,7 +12,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
- * libpng versions 0.97, January 1998, through 1.6.28, January 5, 2017:
+ * libpng versions 0.97, January 1998, through 1.6.29, March 16, 2017:
* Glenn Randers-Pehrson.
* See also "Contributing Authors", below.
*/
@@ -25,7 +25,7 @@
*
* This code is released under the libpng license.
*
- * libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
+ * libpng versions 1.0.7, July 1, 2000 through 1.6.29, March 16, 2017 are
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
* derived from libpng-1.0.6, and are distributed according to the same
* disclaimer and license as libpng-1.0.6 with the following individuals
@@ -38,6 +38,8 @@
* Gilles Vollant
* James Yu
* Mandar Sahastrabuddhe
+ * Google Inc.
+ * Vadim Barkov
*
* and with the following additions to the disclaimer:
*
@@ -211,7 +213,7 @@
* ...
* 1.5.28 15 10527 15.so.15.28[.0]
* ...
- * 1.6.28 16 10628 16.so.16.28[.0]
+ * 1.6.29 16 10629 16.so.16.29[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -239,13 +241,13 @@
* Y2K compliance in libpng:
* =========================
*
- * January 5, 2017
+ * March 16, 2017
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
- * upward through 1.6.28 are Y2K compliant. It is my belief that
+ * upward through 1.6.29 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -307,8 +309,8 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.28"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.28 - January 5, 2017\n"
+#define PNG_LIBPNG_VER_STRING "1.6.29"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.6.29 - March 16, 2017\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -316,7 +318,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
-#define PNG_LIBPNG_VER_RELEASE 28
+#define PNG_LIBPNG_VER_RELEASE 29
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
@@ -347,7 +349,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
-#define PNG_LIBPNG_VER 10628 /* 1.6.28 */
+#define PNG_LIBPNG_VER 10629 /* 1.6.29 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -457,7 +459,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
-typedef char* png_libpng_version_1_6_28;
+typedef char* png_libpng_version_1_6_29;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -3224,7 +3226,10 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
#endif
#define PNG_IGNORE_ADLER32 8
-#define PNG_OPTION_NEXT 10 /* Next option - numbers must be even */
+#ifdef PNG_POWERPC_VSX_API_SUPPORTED
+# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
+#endif
+#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */
/* Return values: NOTE: there are four values and 'off' is *not* zero */
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
diff --git a/thirdparty/libpng/pngconf.h b/thirdparty/libpng/pngconf.h
index 5e8b40bcfb..78d8b92b0e 100644
--- a/thirdparty/libpng/pngconf.h
+++ b/thirdparty/libpng/pngconf.h
@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
- * libpng version 1.6.28, January 5, 2017
+ * libpng version 1.6.29, March 16, 2017
*
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/thirdparty/libpng/pnglibconf.h b/thirdparty/libpng/pnglibconf.h
index ee70573605..82f6ba4619 100644
--- a/thirdparty/libpng/pnglibconf.h
+++ b/thirdparty/libpng/pnglibconf.h
@@ -1,8 +1,8 @@
-/* libpng 1.6.28 STANDARD API DEFINITION */
+/* libpng 1.6.29 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
-/* Libpng version 1.6.28 - January 5, 2017 */
+/* Libpng version 1.6.29 - March 16, 2017 */
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
@@ -20,6 +20,8 @@
#define PNG_ALIGNED_MEMORY_SUPPORTED
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
+/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
+/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
#define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
diff --git a/thirdparty/libpng/pngpriv.h b/thirdparty/libpng/pngpriv.h
index ed61165b2d..6d2e424d2e 100644
--- a/thirdparty/libpng/pngpriv.h
+++ b/thirdparty/libpng/pngpriv.h
@@ -1,8 +1,8 @@
/* pngpriv.h - private declarations for use inside libpng
*
- * Last changed in libpng 1.6.26 [October 20, 2016]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.29 [March 16, 2017]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -190,6 +190,50 @@
# endif
#endif
+#ifndef PNG_POWERPC_VSX_OPT
+# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__)
+# define PNG_POWERPC_VSX_OPT 2
+# else
+# define PNG_POWERPC_VSX_OPT 0
+# endif
+#endif
+
+#ifndef PNG_INTEL_SSE_OPT
+# ifdef PNG_INTEL_SSE
+ /* Only check for SSE if the build configuration has been modified to
+ * enable SSE optimizations. This means that these optimizations will
+ * be off by default. See contrib/intel for more details.
+ */
+# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
+ defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
+ (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
+# define PNG_INTEL_SSE_OPT 1
+# endif
+# endif
+#endif
+
+#if PNG_INTEL_SSE_OPT > 0
+# ifndef PNG_INTEL_SSE_IMPLEMENTATION
+# if defined(__SSE4_1__) || defined(__AVX__)
+ /* We are not actually using AVX, but checking for AVX is the best
+ way we can detect SSE4.1 and SSSE3 on MSVC.
+ */
+# define PNG_INTEL_SSE_IMPLEMENTATION 3
+# elif defined(__SSSE3__)
+# define PNG_INTEL_SSE_IMPLEMENTATION 2
+# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
+ (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
+# define PNG_INTEL_SSE_IMPLEMENTATION 1
+# else
+# define PNG_INTEL_SSE_IMPLEMENTATION 0
+# endif
+# endif
+
+# if PNG_INTEL_SSE_IMPLEMENTATION > 0
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2
+# endif
+#endif
+
#if PNG_MIPS_MSA_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
@@ -210,6 +254,11 @@
# endif
#endif /* PNG_MIPS_MSA_OPT > 0 */
+#if PNG_POWERPC_VSX_OPT > 0
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
+# define PNG_POWERPC_VSX_IMPLEMENTATION 1
+#endif
+
/* Is this a build of a DLL where compilation of the object modules requires
* different preprocessor settings to those required for a simple library? If
@@ -1256,6 +1305,38 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
+#if PNG_POWERPC_VSX_OPT > 0
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info,
+ png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_vsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_vsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_vsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_vsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_vsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
+
+#if PNG_INTEL_SSE_IMPLEMENTATION > 0
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
+
/* Choose the best filter to use and filter the row data */
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
png_row_infop row_info),PNG_EMPTY);
@@ -1991,6 +2072,11 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
+
+# if PNG_INTEL_SSE_IMPLEMENTATION > 0
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
+ (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+# endif
#endif
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
diff --git a/thirdparty/libpng/pngrtran.c b/thirdparty/libpng/pngrtran.c
index 0b4f4f9068..16c1ed6086 100644
--- a/thirdparty/libpng/pngrtran.c
+++ b/thirdparty/libpng/pngrtran.c
@@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * Last changed in libpng 1.6.24 [August 4, 2016]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.29 [March 16, 2017]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -4302,7 +4302,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
if (num_trans > 0)
{
sp = row + (png_size_t)row_width - 1;
- dp = row + (png_size_t)(row_width << 2) - 1;
+ dp = row + ((png_size_t)row_width << 2) - 1;
for (i = 0; i < row_width; i++)
{
@@ -4463,7 +4463,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{
gray = gray & 0xff;
sp = row + (png_size_t)row_width - 1;
- dp = row + (png_size_t)(row_width << 1) - 1;
+ dp = row + ((png_size_t)row_width << 1) - 1;
for (i = 0; i < row_width; i++)
{
@@ -4519,7 +4519,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_byte green = (png_byte)(trans_color->green & 0xff);
png_byte blue = (png_byte)(trans_color->blue & 0xff);
sp = row + (png_size_t)row_info->rowbytes - 1;
- dp = row + (png_size_t)(row_width << 2) - 1;
+ dp = row + ((png_size_t)row_width << 2) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
@@ -4542,7 +4542,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_byte green_low = (png_byte)(trans_color->green & 0xff);
png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
sp = row + row_info->rowbytes - 1;
- dp = row + (png_size_t)(row_width << 3) - 1;
+ dp = row + ((png_size_t)row_width << 3) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 5) == red_high &&
diff --git a/thirdparty/libpng/pngrutil.c b/thirdparty/libpng/pngrutil.c
index bee0ea1158..76f079a69f 100644
--- a/thirdparty/libpng/pngrutil.c
+++ b/thirdparty/libpng/pngrutil.c
@@ -1,8 +1,8 @@
/* pngrutil.c - utilities to read a PNG file
*
- * Last changed in libpng 1.6.27 [January 5, 2017]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.29 [March 16, 2017]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -418,7 +418,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
}
-#if ZLIB_VERNUM >= 0x1281 && \
+#if ZLIB_VERNUM >= 0x1290 && \
defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
/* Turn off validation of the ADLER32 checksum in IDAT chunks */
diff --git a/thirdparty/libpng/pngwutil.c b/thirdparty/libpng/pngwutil.c
index d1a82d45e1..0f98d582da 100644
--- a/thirdparty/libpng/pngwutil.c
+++ b/thirdparty/libpng/pngwutil.c
@@ -675,6 +675,7 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
int interlace_type)
{
png_byte buf[13]; /* Buffer to store the IHDR info */
+ int is_invalid_depth;
png_debug(1, "in png_write_IHDR");
@@ -700,11 +701,11 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
break;
case PNG_COLOR_TYPE_RGB:
+ is_invalid_depth = (bit_depth != 8);
#ifdef PNG_WRITE_16BIT_SUPPORTED
- if (bit_depth != 8 && bit_depth != 16)
-#else
- if (bit_depth != 8)
+ is_invalid_depth = (is_invalid_depth && bit_depth != 16);
#endif
+ if (is_invalid_depth)
png_error(png_ptr, "Invalid bit depth for RGB image");
png_ptr->channels = 3;
@@ -726,18 +727,22 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
break;
case PNG_COLOR_TYPE_GRAY_ALPHA:
- if (bit_depth != 8 && bit_depth != 16)
+ is_invalid_depth = (bit_depth != 8);
+#ifdef PNG_WRITE_16BIT_SUPPORTED
+ is_invalid_depth = (is_invalid_depth && bit_depth != 16);
+#endif
+ if (is_invalid_depth)
png_error(png_ptr, "Invalid bit depth for grayscale+alpha image");
png_ptr->channels = 2;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
+ is_invalid_depth = (bit_depth != 8);
#ifdef PNG_WRITE_16BIT_SUPPORTED
- if (bit_depth != 8 && bit_depth != 16)
-#else
- if (bit_depth != 8)
+ is_invalid_depth = (is_invalid_depth && bit_depth != 16);
#endif
+ if (is_invalid_depth)
png_error(png_ptr, "Invalid bit depth for RGBA image");
png_ptr->channels = 4;
diff --git a/thirdparty/opus/silk/NLSF_stabilize.c b/thirdparty/opus/silk/NLSF_stabilize.c
index 1fa1ea379b..8f3426b91e 100644
--- a/thirdparty/opus/silk/NLSF_stabilize.c
+++ b/thirdparty/opus/silk/NLSF_stabilize.c
@@ -130,7 +130,7 @@ void silk_NLSF_stabilize(
/* Keep delta_min distance between the NLSFs */
for( i = 1; i < L; i++ )
- NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], NLSF_Q15[i-1] + NDeltaMin_Q15[i] );
+ NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
/* Last NLSF should be no higher than 1 - NDeltaMin[L] */
NLSF_Q15[L-1] = silk_min_int( NLSF_Q15[L-1], (1<<15) - NDeltaMin_Q15[L] );
diff --git a/thirdparty/squish/squish.cpp b/thirdparty/squish/squish.cpp
index d3cbabbafd..1d22a64ad6 100644
--- a/thirdparty/squish/squish.cpp
+++ b/thirdparty/squish/squish.cpp
@@ -177,13 +177,17 @@ void CompressImage( u8 const* rgba, int width, int height, int pitch, void* bloc
// fix any bad flags
flags = FixFlags( flags );
- // initialise the block output
- u8* targetBlock = reinterpret_cast< u8* >( blocks );
- int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16;
-
// loop over blocks
+#ifdef SQUISH_USE_OPENMP
+# pragma omp parallel for
+#endif
for( int y = 0; y < height; y += 4 )
{
+ // initialise the block output
+ u8* targetBlock = reinterpret_cast< u8* >( blocks );
+ int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16;
+ targetBlock += ( (y / 4) * ( (width + 3) / 4) ) * bytesPerBlock;
+
for( int x = 0; x < width; x += 4 )
{
// build the 4x4 block of pixels
@@ -232,13 +236,17 @@ void DecompressImage( u8* rgba, int width, int height, int pitch, void const* bl
// fix any bad flags
flags = FixFlags( flags );
- // initialise the block input
- u8 const* sourceBlock = reinterpret_cast< u8 const* >( blocks );
- int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16;
-
// loop over blocks
+#ifdef SQUISH_USE_OPENMP
+# pragma omp parallel for
+#endif
for( int y = 0; y < height; y += 4 )
{
+ // initialise the block input
+ u8 const* sourceBlock = reinterpret_cast< u8 const* >( blocks );
+ int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16;
+ sourceBlock += ( (y / 4) * ( (width + 3) / 4) ) * bytesPerBlock;
+
for( int x = 0; x < width; x += 4 )
{
// decompress the block
diff --git a/thirdparty/squish/squish.h b/thirdparty/squish/squish.h
index 7c46e37ff1..14c9bb59fb 100644
--- a/thirdparty/squish/squish.h
+++ b/thirdparty/squish/squish.h
@@ -239,6 +239,15 @@ int GetStorageRequirements( int width, int height, int flags );
allows for pixels outside the image to take arbitrary values. The function
squish::GetStorageRequirements can be called to compute the amount of memory
to allocate for the compressed output.
+
+ Note on compression quality: When compressing textures with
+ libsquish it is recommended to apply a gamma-correction
+ beforehand. This will reduce the blockiness in dark areas. The
+ level of necessary gamma-correction is platform dependent. For
+ example, a gamma correction with gamma = 0.5 before compression
+ and gamma = 2.0 after decompression yields good results on the
+ Windows platform but for other platforms like MacOS X a different
+ gamma value may be more suitable.
*/
void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 );
void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 );