mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
configure.ac: add AC_C_BIGENDIAN
this defines WORDS_BIGENDIAN, replacing uses of __BIG_ENDIAN__/__BYTE_ORDER__ with it + fixes lossless BGRA output with big-endian toolchains that do not define __BIG_ENDIAN__ (codesourcery mips gcc) Change-Id: Ieaccd623292d235343b5e34b7a720fc251c432d7
This commit is contained in:
parent
ee70a90187
commit
380cca4f2c
@ -15,6 +15,9 @@ AM_PROG_CC_C_O
|
|||||||
dnl === Enable less verbose output when building.
|
dnl === Enable less verbose output when building.
|
||||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||||
|
|
||||||
|
dnl == test endianness
|
||||||
|
AC_C_BIGENDIAN
|
||||||
|
|
||||||
dnl === SET_IF_UNSET(shell_var, value)
|
dnl === SET_IF_UNSET(shell_var, value)
|
||||||
dnl === Set the shell variable 'shell_var' to 'value' if it is unset.
|
dnl === Set the shell variable 'shell_var' to 'value' if it is unset.
|
||||||
AC_DEFUN([SET_IF_UNSET], [test "${$1+set}" = "set" || $1=$2])
|
AC_DEFUN([SET_IF_UNSET], [test "${$1+set}" = "set" || $1=$2])
|
||||||
|
@ -97,7 +97,7 @@ int ReadTIFF(const char* const filename,
|
|||||||
pic->width = width;
|
pic->width = width;
|
||||||
pic->height = height;
|
pic->height = height;
|
||||||
// TIFF data is ABGR
|
// TIFF data is ABGR
|
||||||
#ifdef __BIG_ENDIAN__
|
#ifdef WORDS_BIGENDIAN
|
||||||
TIFFSwabArrayOfLong(raster, width * height);
|
TIFFSwabArrayOfLong(raster, width * height);
|
||||||
#endif
|
#endif
|
||||||
pic->use_argb = 1;
|
pic->use_argb = 1;
|
||||||
|
@ -1360,7 +1360,7 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst,
|
|||||||
while (src < src_end) {
|
while (src < src_end) {
|
||||||
const uint32_t argb = *src++;
|
const uint32_t argb = *src++;
|
||||||
|
|
||||||
#if !defined(__BIG_ENDIAN__)
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
#if !defined(WEBP_REFERENCE_IMPLEMENTATION)
|
#if !defined(WEBP_REFERENCE_IMPLEMENTATION)
|
||||||
*(uint32_t*)dst = BSwap32(argb);
|
*(uint32_t*)dst = BSwap32(argb);
|
||||||
#else // WEBP_REFERENCE_IMPLEMENTATION
|
#else // WEBP_REFERENCE_IMPLEMENTATION
|
||||||
@ -1369,7 +1369,7 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst,
|
|||||||
dst[2] = (argb >> 8) & 0xff;
|
dst[2] = (argb >> 8) & 0xff;
|
||||||
dst[3] = (argb >> 0) & 0xff;
|
dst[3] = (argb >> 0) & 0xff;
|
||||||
#endif
|
#endif
|
||||||
#else // __BIG_ENDIAN__
|
#else // WORDS_BIGENDIAN
|
||||||
dst[0] = (argb >> 0) & 0xff;
|
dst[0] = (argb >> 0) & 0xff;
|
||||||
dst[1] = (argb >> 8) & 0xff;
|
dst[1] = (argb >> 8) & 0xff;
|
||||||
dst[2] = (argb >> 16) & 0xff;
|
dst[2] = (argb >> 16) & 0xff;
|
||||||
|
@ -70,7 +70,7 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) {
|
|||||||
const lbit_t in_bits = *(const lbit_t*)br->buf_;
|
const lbit_t in_bits = *(const lbit_t*)br->buf_;
|
||||||
#endif
|
#endif
|
||||||
br->buf_ += BITS >> 3;
|
br->buf_ += BITS >> 3;
|
||||||
#if !defined(__BIG_ENDIAN__)
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
#if (BITS > 32)
|
#if (BITS > 32)
|
||||||
bits = BSwap64(in_bits);
|
bits = BSwap64(in_bits);
|
||||||
bits >>= 64 - BITS;
|
bits >>= 64 - BITS;
|
||||||
@ -83,7 +83,7 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) {
|
|||||||
#else // BITS == 8
|
#else // BITS == 8
|
||||||
bits = (bit_t)in_bits;
|
bits = (bit_t)in_bits;
|
||||||
#endif // BITS > 32
|
#endif // BITS > 32
|
||||||
#else // BIG_ENDIAN
|
#else // WORDS_BIGENDIAN
|
||||||
bits = (bit_t)in_bits;
|
bits = (bit_t)in_bits;
|
||||||
if (BITS != 8 * sizeof(bit_t)) bits >>= (8 * sizeof(bit_t) - BITS);
|
if (BITS != 8 * sizeof(bit_t)) bits >>= (8 * sizeof(bit_t) - BITS);
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,12 +12,17 @@
|
|||||||
#ifndef WEBP_UTILS_ENDIAN_INL_H_
|
#ifndef WEBP_UTILS_ENDIAN_INL_H_
|
||||||
#define WEBP_UTILS_ENDIAN_INL_H_
|
#define WEBP_UTILS_ENDIAN_INL_H_
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "../webp/config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../webp/types.h"
|
#include "../webp/types.h"
|
||||||
|
|
||||||
// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
|
// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
|
||||||
#if !defined(__BIG_ENDIAN__) && defined(__BYTE_ORDER__) && \
|
#if !defined(WORDS_BIGENDIAN) && \
|
||||||
(__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
(defined(__BIG_ENDIAN__) || \
|
||||||
#define __BIG_ENDIAN__
|
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)))
|
||||||
|
#define WORDS_BIGENDIAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// endian-specific htoleXX() definition
|
// endian-specific htoleXX() definition
|
||||||
|
Loading…
Reference in New Issue
Block a user