Merge "remove WEBP_FORCE_ALIGNED and use memcpy() instead."

This commit is contained in:
James Zern 2016-08-18 03:38:43 +00:00 committed by Gerrit Code Review
commit 48c810b85c
6 changed files with 5 additions and 38 deletions

View File

@ -6,7 +6,6 @@ project(libwebp C)
option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." OFF)
option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." OFF)
option(WEBP_EXPERIMENTAL_FEATURES "Build with experimental features." OFF)
option(WEBP_FORCE_ALIGNED "Force aligned memory operations." OFF)
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF)
set(WEBP_DEP_LIBRARIES)

View File

@ -103,9 +103,6 @@
/* Enable experimental code */
#cmakedefine WEBP_EXPERIMENTAL_FEATURES 1
/* Define to 1 to force aligned memory operations */
#cmakedefine WEBP_FORCE_ALIGNED 1
/* Set to 1 if AVX2 is supported */
#cmakedefine WEBP_HAVE_AVX2 1

View File

@ -596,19 +596,6 @@ if test "$enable_wic" = "yes"; then
fi
esac
dnl === If --enable-aligned is defined, define WEBP_FORCE_ALIGNED
AC_MSG_CHECKING(if --enable-aligned option is specified)
AC_ARG_ENABLE([aligned],
AS_HELP_STRING([--enable-aligned],
[Force aligned memory operations in non-dsp code
(may be slower)]))
if test "$enable_aligned" = "yes"; then
AC_DEFINE(WEBP_FORCE_ALIGNED, [1],
[Define to 1 to force aligned memory operations])
fi
AC_MSG_RESULT(${enable_aligned-no})
dnl === If --enable-swap-16bit-csp is defined, add -DWEBP_SWAP_16BIT_CSP
USE_SWAP_16BIT_CSP=""

View File

@ -111,8 +111,7 @@ extern "C" {
#define WEBP_UBSAN_IGNORE_UNDEF
#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
#if !defined(WEBP_FORCE_ALIGNED) && defined(__clang__) && \
defined(__has_attribute)
#if defined(__clang__) && defined(__has_attribute)
#if __has_attribute(no_sanitize)
// This macro prevents the undefined behavior sanitizer from reporting
// failures. This is only meant to silence unaligned loads on platforms that

View File

@ -20,9 +20,7 @@
#include "../webp/config.h"
#endif
#ifdef WEBP_FORCE_ALIGNED
#include <string.h> // memcpy
#endif
#include <string.h> // for memcpy
#include "../dsp/dsp.h"
#include "./bit_reader.h"
@ -62,10 +60,7 @@ void VP8LoadNewBytes(VP8BitReader* const br) {
if (br->buf_ < br->buf_max_) {
// convert memory type to register type (with some zero'ing!)
bit_t bits;
#if defined(WEBP_FORCE_ALIGNED)
lbit_t in_bits;
memcpy(&in_bits, br->buf_, sizeof(in_bits));
#elif defined(WEBP_USE_MIPS32)
#if defined(WEBP_USE_MIPS32)
// This is needed because of un-aligned read.
lbit_t in_bits;
lbit_t* p_buf_ = (lbit_t*)br->buf_;
@ -80,7 +75,8 @@ void VP8LoadNewBytes(VP8BitReader* const br) {
: "memory", "at"
);
#else
const lbit_t in_bits = *(const lbit_t*)br->buf_;
lbit_t in_bits;
memcpy(&in_bits, br->buf_, sizeof(in_bits));
#endif
br->buf_ += BITS >> 3;
#if !defined(WORDS_BIGENDIAN)

View File

@ -54,7 +54,6 @@ WEBP_EXTERN(void) WebPSafeFree(void* const ptr);
#define WEBP_ALIGN_CST 31
#define WEBP_ALIGN(PTR) (((uintptr_t)(PTR) + WEBP_ALIGN_CST) & ~WEBP_ALIGN_CST)
#if defined(WEBP_FORCE_ALIGNED)
#include <string.h>
// memcpy() is the safe way of moving potentially unaligned 32b memory.
static WEBP_INLINE uint32_t WebPMemToUint32(const uint8_t* const ptr) {
@ -65,16 +64,6 @@ static WEBP_INLINE uint32_t WebPMemToUint32(const uint8_t* const ptr) {
static WEBP_INLINE void WebPUint32ToMem(uint8_t* const ptr, uint32_t val) {
memcpy(ptr, &val, sizeof(val));
}
#else
static WEBP_UBSAN_IGNORE_UNDEF WEBP_INLINE
uint32_t WebPMemToUint32(const uint8_t* const ptr) {
return *(const uint32_t*)ptr;
}
static WEBP_UBSAN_IGNORE_UNDEF WEBP_INLINE
void WebPUint32ToMem(uint8_t* const ptr, uint32_t val) {
*(uint32_t*)ptr = val;
}
#endif
//------------------------------------------------------------------------------
// Reading/writing data.