xref: /aosp_15_r20/external/libwebm/common/webm_endian.h (revision 103e46e4cd4b6efcf6001f23fa8665fb110abf8d)
1*103e46e4SHarish Mahendrakar // Copyright (c) 2012 The WebM project authors. All Rights Reserved.
2*103e46e4SHarish Mahendrakar //
3*103e46e4SHarish Mahendrakar // Use of this source code is governed by a BSD-style license
4*103e46e4SHarish Mahendrakar // that can be found in the LICENSE file in the root of the source
5*103e46e4SHarish Mahendrakar // tree. An additional intellectual property rights grant can be found
6*103e46e4SHarish Mahendrakar // in the file PATENTS.  All contributing project authors may
7*103e46e4SHarish Mahendrakar // be found in the AUTHORS file in the root of the source tree.
8*103e46e4SHarish Mahendrakar 
9*103e46e4SHarish Mahendrakar #ifndef LIBWEBM_COMMON_WEBM_ENDIAN_H_
10*103e46e4SHarish Mahendrakar #define LIBWEBM_COMMON_WEBM_ENDIAN_H_
11*103e46e4SHarish Mahendrakar 
12*103e46e4SHarish Mahendrakar #include <stdint.h>
13*103e46e4SHarish Mahendrakar 
14*103e46e4SHarish Mahendrakar namespace libwebm {
15*103e46e4SHarish Mahendrakar 
16*103e46e4SHarish Mahendrakar // Swaps unsigned 32 bit values to big endian if needed. Returns |value| if
17*103e46e4SHarish Mahendrakar // architecture is big endian. Returns big endian value if architecture is
18*103e46e4SHarish Mahendrakar // little endian. Returns 0 otherwise.
19*103e46e4SHarish Mahendrakar uint32_t host_to_bigendian(uint32_t value);
20*103e46e4SHarish Mahendrakar 
21*103e46e4SHarish Mahendrakar // Swaps unsigned 32 bit values to little endian if needed. Returns |value| if
22*103e46e4SHarish Mahendrakar // architecture is big endian. Returns little endian value if architecture is
23*103e46e4SHarish Mahendrakar // little endian. Returns 0 otherwise.
24*103e46e4SHarish Mahendrakar uint32_t bigendian_to_host(uint32_t value);
25*103e46e4SHarish Mahendrakar 
26*103e46e4SHarish Mahendrakar // Swaps unsigned 64 bit values to big endian if needed. Returns |value| if
27*103e46e4SHarish Mahendrakar // architecture is big endian. Returns big endian value if architecture is
28*103e46e4SHarish Mahendrakar // little endian. Returns 0 otherwise.
29*103e46e4SHarish Mahendrakar uint64_t host_to_bigendian(uint64_t value);
30*103e46e4SHarish Mahendrakar 
31*103e46e4SHarish Mahendrakar // Swaps unsigned 64 bit values to little endian if needed. Returns |value| if
32*103e46e4SHarish Mahendrakar // architecture is big endian. Returns little endian value if architecture is
33*103e46e4SHarish Mahendrakar // little endian. Returns 0 otherwise.
34*103e46e4SHarish Mahendrakar uint64_t bigendian_to_host(uint64_t value);
35*103e46e4SHarish Mahendrakar 
36*103e46e4SHarish Mahendrakar }  // namespace libwebm
37*103e46e4SHarish Mahendrakar 
38*103e46e4SHarish Mahendrakar #endif  // LIBWEBM_COMMON_WEBM_ENDIAN_H_
39