mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
remove WEBP_FORCE_ALIGNED and use memcpy() instead.
BUG=webp:297 Change-Id: I89a08debec7bb1b3f411c897260ab1bb63f77df2
This commit is contained in:
committed by
James Zern
parent
005e15b10a
commit
3884972e3f
@ -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)
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user