No empty .Rs/.Re
[netbsd-mini2440.git] / usr.bin / audio / common / auconv.h
blob08e9da2e5aea6d50d1fb4f29deffa182fcaefc35
1 /* $NetBSD: auconv.h,v 1.4 2005/12/24 21:48:16 perry Exp $ */
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/types.h>
33 #include <sys/audioio.h>
35 /* Convert between signed and unsigned. */
36 static inline void change_sign8(u_char *, int);
37 static inline void change_sign16_le(u_char *, int);
38 static inline void change_sign16_be(u_char *, int);
39 static inline void change_sign32_le(u_char *, int);
40 static inline void change_sign32_be(u_char *, int);
41 /* Convert between little and big endian. */
42 static inline void swap_bytes(u_char *, int);
43 static inline void swap_bytes32(u_char *, int);
44 static inline void swap_bytes_change_sign16_le(u_char *, int);
45 static inline void swap_bytes_change_sign16_be(u_char *, int);
46 static inline void change_sign16_swap_bytes_le(u_char *, int);
47 static inline void change_sign16_swap_bytes_be(u_char *, int);
48 static inline void swap_bytes_change_sign32_le(u_char *, int);
49 static inline void swap_bytes_change_sign32_be(u_char *, int);
50 static inline void change_sign32_swap_bytes_le(u_char *, int);
51 static inline void change_sign32_swap_bytes_be(u_char *, int);
53 static inline void
54 change_sign8(u_char *p, int cc)
56 while (--cc >= 0) {
57 *p ^= 0x80;
58 ++p;
62 static inline void
63 change_sign16_le(u_char *p, int cc)
65 while ((cc -= 2) >= 0) {
66 p[1] ^= 0x80;
67 p += 2;
71 static inline void
72 change_sign16_be(u_char *p, int cc)
74 while ((cc -= 2) >= 0) {
75 p[0] ^= 0x80;
76 p += 2;
80 static inline void
81 change_sign32_le(u_char *p, int cc)
83 while ((cc -= 4) >= 0) {
84 p[3] ^= 0x80;
85 p += 4;
89 static inline void
90 change_sign32_be(u_char *p, int cc)
92 while ((cc -= 4) >= 0) {
93 p[0] ^= 0x80;
94 p += 4;
98 static inline void
99 swap_bytes(u_char *p, int cc)
101 u_char t;
103 while ((cc -= 2) >= 0) {
104 t = p[0];
105 p[0] = p[1];
106 p[1] = t;
107 p += 2;
111 static inline void
112 swap_bytes32(u_char *p, int cc)
114 u_char t;
116 while ((cc -= 4) >= 0) {
117 t = p[0];
118 p[0] = p[3];
119 p[3] = t;
120 t = p[1];
121 p[1] = p[2];
122 p[2] = t;
123 p += 4;
127 static inline void
128 swap_bytes_change_sign16_le(u_char *p, int cc)
130 u_char t;
132 while ((cc -= 2) >= 0) {
133 t = p[1];
134 p[1] = p[0] ^ 0x80;
135 p[0] = t;
136 p += 2;
140 static inline void
141 swap_bytes_change_sign16_be(u_char *p, int cc)
143 u_char t;
145 while ((cc -= 2) >= 0) {
146 t = p[0];
147 p[0] = p[1] ^ 0x80;
148 p[1] = t;
149 p += 2;
153 static inline void
154 change_sign16_swap_bytes_le(u_char *p, int cc)
156 swap_bytes_change_sign16_be(p, cc);
159 static inline void
160 change_sign16_swap_bytes_be(u_char *p, int cc)
162 swap_bytes_change_sign16_le(p, cc);
165 static inline void
166 swap_bytes_change_sign32_le(u_char *p, int cc)
168 u_char t;
170 while ((cc -= 4) >= 0) {
171 t = p[3];
172 p[3] = p[0] ^ 0x80;
173 p[0] = t;
174 t = p[1];
175 p[1] = p[2];
176 p[2] = t;
177 p += 4;
181 static inline void
182 swap_bytes_change_sign32_be(u_char *p, int cc)
184 u_char t;
186 while ((cc -= 4) >= 0) {
187 t = p[0];
188 p[0] = p[3] ^ 0x80;
189 p[3] = t;
190 t = p[1];
191 p[1] = p[2];
192 p[2] = t;
193 p += 4;
197 static inline void
198 change_sign32_swap_bytes_le(u_char *p, int cc)
200 swap_bytes_change_sign32_be(p, cc);
203 static inline void
204 change_sign32_swap_bytes_be(u_char *p, int cc)
206 swap_bytes_change_sign32_le(p, cc);