Add a test using VP9E_SET_LOSSLESS
[aom.git] / vpx_ports / mem_ops_aligned.h
blob24743c8d6944cbee4a77eff766f6c4dea28cc36a
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
11 #ifndef VPX_PORTS_MEM_OPS_ALIGNED_H_
12 #define VPX_PORTS_MEM_OPS_ALIGNED_H_
14 #include "vpx/vpx_integer.h"
16 /* \file
17 * \brief Provides portable memory access primitives for operating on aligned
18 * data
20 * This file is split from mem_ops.h for easier maintenance. See mem_ops.h
21 * for a more detailed description of these primitives.
23 #ifndef INCLUDED_BY_MEM_OPS_H
24 #error Include mem_ops.h, not mem_ops_aligned.h directly.
25 #endif
27 /* Architectures that provide instructions for doing this byte swapping
28 * could redefine these macros.
30 #define swap_endian_16(val,raw) do {\
31 val = ((raw>>8) & 0x00ff) \
32 | ((raw<<8) & 0xff00);\
33 } while(0)
34 #define swap_endian_32(val,raw) do {\
35 val = ((raw>>24) & 0x000000ff) \
36 | ((raw>>8) & 0x0000ff00) \
37 | ((raw<<8) & 0x00ff0000) \
38 | ((raw<<24) & 0xff000000); \
39 } while(0)
40 #define swap_endian_16_se(val,raw) do {\
41 swap_endian_16(val,raw);\
42 val = ((val << 16) >> 16);\
43 } while(0)
44 #define swap_endian_32_se(val,raw) swap_endian_32(val,raw)
46 #define mem_get_ne_aligned_generic(end,sz) \
47 static unsigned MEM_VALUE_T mem_get_##end##sz##_aligned(const void *vmem) {\
48 const uint##sz##_t *mem = (const uint##sz##_t *)vmem;\
49 return *mem;\
52 #define mem_get_sne_aligned_generic(end,sz) \
53 static signed MEM_VALUE_T mem_get_s##end##sz##_aligned(const void *vmem) {\
54 const int##sz##_t *mem = (const int##sz##_t *)vmem;\
55 return *mem;\
58 #define mem_get_se_aligned_generic(end,sz) \
59 static unsigned MEM_VALUE_T mem_get_##end##sz##_aligned(const void *vmem) {\
60 const uint##sz##_t *mem = (const uint##sz##_t *)vmem;\
61 unsigned MEM_VALUE_T val, raw = *mem;\
62 swap_endian_##sz(val,raw);\
63 return val;\
66 #define mem_get_sse_aligned_generic(end,sz) \
67 static signed MEM_VALUE_T mem_get_s##end##sz##_aligned(const void *vmem) {\
68 const int##sz##_t *mem = (const int##sz##_t *)vmem;\
69 unsigned MEM_VALUE_T val, raw = *mem;\
70 swap_endian_##sz##_se(val,raw);\
71 return val;\
74 #define mem_put_ne_aligned_generic(end,sz) \
75 static void mem_put_##end##sz##_aligned(void *vmem, MEM_VALUE_T val) {\
76 uint##sz##_t *mem = (uint##sz##_t *)vmem;\
77 *mem = (uint##sz##_t)val;\
80 #define mem_put_se_aligned_generic(end,sz) \
81 static void mem_put_##end##sz##_aligned(void *vmem, MEM_VALUE_T val) {\
82 uint##sz##_t *mem = (uint##sz##_t *)vmem, raw;\
83 swap_endian_##sz(raw,val);\
84 *mem = (uint##sz##_t)raw;\
87 #include "vpx_config.h"
88 #if CONFIG_BIG_ENDIAN
89 #define mem_get_be_aligned_generic(sz) mem_get_ne_aligned_generic(be,sz)
90 #define mem_get_sbe_aligned_generic(sz) mem_get_sne_aligned_generic(be,sz)
91 #define mem_get_le_aligned_generic(sz) mem_get_se_aligned_generic(le,sz)
92 #define mem_get_sle_aligned_generic(sz) mem_get_sse_aligned_generic(le,sz)
93 #define mem_put_be_aligned_generic(sz) mem_put_ne_aligned_generic(be,sz)
94 #define mem_put_le_aligned_generic(sz) mem_put_se_aligned_generic(le,sz)
95 #else
96 #define mem_get_be_aligned_generic(sz) mem_get_se_aligned_generic(be,sz)
97 #define mem_get_sbe_aligned_generic(sz) mem_get_sse_aligned_generic(be,sz)
98 #define mem_get_le_aligned_generic(sz) mem_get_ne_aligned_generic(le,sz)
99 #define mem_get_sle_aligned_generic(sz) mem_get_sne_aligned_generic(le,sz)
100 #define mem_put_be_aligned_generic(sz) mem_put_se_aligned_generic(be,sz)
101 #define mem_put_le_aligned_generic(sz) mem_put_ne_aligned_generic(le,sz)
102 #endif
104 #undef mem_get_be16_aligned
105 #define mem_get_be16_aligned mem_ops_wrap_symbol(mem_get_be16_aligned)
106 mem_get_be_aligned_generic(16)
108 #undef mem_get_be32_aligned
109 #define mem_get_be32_aligned mem_ops_wrap_symbol(mem_get_be32_aligned)
110 mem_get_be_aligned_generic(32)
112 #undef mem_get_le16_aligned
113 #define mem_get_le16_aligned mem_ops_wrap_symbol(mem_get_le16_aligned)
114 mem_get_le_aligned_generic(16)
116 #undef mem_get_le32_aligned
117 #define mem_get_le32_aligned mem_ops_wrap_symbol(mem_get_le32_aligned)
118 mem_get_le_aligned_generic(32)
120 #undef mem_get_sbe16_aligned
121 #define mem_get_sbe16_aligned mem_ops_wrap_symbol(mem_get_sbe16_aligned)
122 mem_get_sbe_aligned_generic(16)
124 #undef mem_get_sbe32_aligned
125 #define mem_get_sbe32_aligned mem_ops_wrap_symbol(mem_get_sbe32_aligned)
126 mem_get_sbe_aligned_generic(32)
128 #undef mem_get_sle16_aligned
129 #define mem_get_sle16_aligned mem_ops_wrap_symbol(mem_get_sle16_aligned)
130 mem_get_sle_aligned_generic(16)
132 #undef mem_get_sle32_aligned
133 #define mem_get_sle32_aligned mem_ops_wrap_symbol(mem_get_sle32_aligned)
134 mem_get_sle_aligned_generic(32)
136 #undef mem_put_be16_aligned
137 #define mem_put_be16_aligned mem_ops_wrap_symbol(mem_put_be16_aligned)
138 mem_put_be_aligned_generic(16)
140 #undef mem_put_be32_aligned
141 #define mem_put_be32_aligned mem_ops_wrap_symbol(mem_put_be32_aligned)
142 mem_put_be_aligned_generic(32)
144 #undef mem_put_le16_aligned
145 #define mem_put_le16_aligned mem_ops_wrap_symbol(mem_put_le16_aligned)
146 mem_put_le_aligned_generic(16)
148 #undef mem_put_le32_aligned
149 #define mem_put_le32_aligned mem_ops_wrap_symbol(mem_put_le32_aligned)
150 mem_put_le_aligned_generic(32)
152 #undef mem_get_ne_aligned_generic
153 #undef mem_get_se_aligned_generic
154 #undef mem_get_sne_aligned_generic
155 #undef mem_get_sse_aligned_generic
156 #undef mem_put_ne_aligned_generic
157 #undef mem_put_se_aligned_generic
158 #undef swap_endian_16
159 #undef swap_endian_32
160 #undef swap_endian_16_se
161 #undef swap_endian_32_se
163 #endif // VPX_PORTS_MEM_OPS_ALIGNED_H_