| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // The contents of this file are subject to the Mozilla Public License |
| // Version 1.1 (the "License"); you may not use this file except in |
| // compliance with the License. You may obtain a copy of the License at |
| // http://www.mozilla.org/MPL/ |
| // |
| // Software distributed under the License is distributed on an "AS IS" |
| // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
| // License for the specific language governing rights and limitations |
| // under the License. |
| // |
| // The Original Code is MP4v2. |
| // |
| // The Initial Developer of the Original Code is Kona Blend. |
| // Portions created by Kona Blend are Copyright (C) 2008. |
| // All Rights Reserved. |
| // |
| // Contributors: |
| // Kona Blend, kona8lend@@gmail.com |
| // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| #ifndef MP4V2_PLATFORM_ENDIAN_H |
| #define MP4V2_PLATFORM_ENDIAN_H |
| |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| #define MP4V2_BYTESWAP_16(x) \ |
| mp4v2::platform::uint16_t( ((mp4v2::platform::uint16_t(x) & 0xff00U) >> 8) \ |
| | ((mp4v2::platform::uint16_t(x) & 0x00ffU) << 8) ) |
| |
| #define MP4V2_BYTESWAP_32(x) \ |
| mp4v2::platform::uint32_t( ((mp4v2::platform::uint32_t(x) & 0xff000000U) >> 24) \ |
| | ((mp4v2::platform::uint32_t(x) & 0x00ff0000U) >> 8) \ |
| | ((mp4v2::platform::uint32_t(x) & 0x0000ff00U) << 8) \ |
| | ((mp4v2::platform::uint32_t(x) & 0x000000ffU) << 24) ) |
| |
| #define MP4V2_BYTESWAP_64(x) \ |
| mp4v2::platform::uint64_t( ((mp4v2::platform::uint64_t(x) & 0xff00000000000000ULL) >> 56) \ |
| | ((mp4v2::platform::uint64_t(x) & 0x00ff000000000000ULL) >> 40) \ |
| | ((mp4v2::platform::uint64_t(x) & 0x0000ff0000000000ULL) >> 24) \ |
| | ((mp4v2::platform::uint64_t(x) & 0x000000ff00000000ULL) >> 8) \ |
| | ((mp4v2::platform::uint64_t(x) & 0x00000000ff000000ULL) << 8) \ |
| | ((mp4v2::platform::uint64_t(x) & 0x0000000000ff0000ULL) << 24) \ |
| | ((mp4v2::platform::uint64_t(x) & 0x000000000000ff00ULL) << 40) \ |
| | ((mp4v2::platform::uint64_t(x) & 0x00000000000000ffULL) << 56) ) |
| |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| #if defined( __BIG_ENDIAN__ ) |
| # define MP4V2_HTONS(x) (x) |
| # define MP4V2_HTONL(x) (x) |
| # define MP4V2_NTOHS(x) (x) |
| # define MP4V2_NTOHL(x) (x) |
| #else |
| # define MP4V2_HTONS(x) MP4V2_BYTESWAP_16(x) |
| # define MP4V2_HTONL(x) MP4V2_BYTESWAP_32(x) |
| # define MP4V2_NTOHS(x) MP4V2_BYTESWAP_16(x) |
| # define MP4V2_NTOHL(x) MP4V2_BYTESWAP_32(x) |
| #endif |
| |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| #endif // MP4V2_PLATFORM_ENDIAN_H |