OSDN Git Service

Use <endian.h>
authorGlenn Kasten <gkasten@google.com>
Thu, 4 Jun 2015 23:00:40 +0000 (16:00 -0700)
committerGlenn Kasten <gkasten@google.com>
Thu, 4 Jun 2015 23:00:40 +0000 (16:00 -0700)
Change-Id: I1eb73afb0580064e5abc592f8235cc882e5dd6be

audio_utils/channels.c
audio_utils/primitives.c

index 0a80ede..16dbd2a 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <endian.h>
 #include <string.h>
 #include <audio_utils/channels.h>
 #include "private/private.h"
@@ -33,7 +34,7 @@ static inline int32_t clamp24(int32_t sample)
  * Converts a uint8x3_t into an int32_t
  */
 inline int32_t uint8x3_to_int32(uint8x3_t val) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
     int32_t temp = (val.c[0] << 24 | val.c[1] << 16 | val.c[2] << 8) >> 8;
 #else
     int32_t temp = (val.c[2] << 24 | val.c[1] << 16 | val.c[0] << 8) >> 8;
@@ -46,7 +47,7 @@ inline int32_t uint8x3_to_int32(uint8x3_t val) {
  */
 inline uint8x3_t int32_to_uint8x3(int32_t in) {
     uint8x3_t out;
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
     out.c[2] = in;
     out.c[1] = in >> 8;
     out.c[0] = in >> 16;
index 254f3af..664c095 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <endian.h>
 #include <cutils/bitops.h>  /* for popcount() */
 #include <audio_utils/primitives.h>
 #include "private/private.h"
@@ -101,7 +102,7 @@ void memcpy_to_float_from_p24(float *dst, const uint8_t *src, size_t count)
 void memcpy_to_i16_from_p24(int16_t *dst, const uint8_t *src, size_t count)
 {
     while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
         *dst++ = src[1] | (src[0] << 8);
 #else
         *dst++ = src[1] | (src[2] << 8);
@@ -113,7 +114,7 @@ void memcpy_to_i16_from_p24(int16_t *dst, const uint8_t *src, size_t count)
 void memcpy_to_i32_from_p24(int32_t *dst, const uint8_t *src, size_t count)
 {
     while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
         *dst++ = (src[2] << 8) | (src[1] << 16) | (src[0] << 24);
 #else
         *dst++ = (src[0] << 8) | (src[1] << 16) | (src[2] << 24);
@@ -125,7 +126,7 @@ void memcpy_to_i32_from_p24(int32_t *dst, const uint8_t *src, size_t count)
 void memcpy_to_p24_from_i16(uint8_t *dst, const int16_t *src, size_t count)
 {
     while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
         *dst++ = *src >> 8;
         *dst++ = *src++;
         *dst++ = 0;
@@ -142,7 +143,7 @@ void memcpy_to_p24_from_float(uint8_t *dst, const float *src, size_t count)
     while (count--) {
         int32_t ival = clamp24_from_float(*src++);
 
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
         *dst++ = ival >> 16;
         *dst++ = ival >> 8;
         *dst++ = ival;
@@ -159,7 +160,7 @@ void memcpy_to_p24_from_q8_23(uint8_t *dst, const int32_t *src, size_t count)
     while (count--) {
         int32_t ival = clamp24_from_q8_23(*src++);
 
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
         *dst++ = ival >> 16;
         *dst++ = ival >> 8;
         *dst++ = ival;
@@ -176,7 +177,7 @@ void memcpy_to_p24_from_i32(uint8_t *dst, const int32_t *src, size_t count)
     while (count--) {
         int32_t ival = *src++ >> 8;
 
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
         *dst++ = ival >> 16;
         *dst++ = ival >> 8;
         *dst++ = ival;
@@ -205,7 +206,7 @@ void memcpy_to_q8_23_from_float_with_clamp(int32_t *dst, const float *src, size_
 void memcpy_to_q8_23_from_p24(int32_t *dst, const uint8_t *src, size_t count)
 {
     while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
         *dst++ = (int8_t)src[0] << 16 | src[1] << 8 | src[2];
 #else
         *dst++ = (int8_t)src[2] << 16 | src[1] << 8 | src[0];