1 /* $NetBSD: auconv.h,v 1.4 2005/12/24 21:48:16 perry Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
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
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);
54 change_sign8(u_char
*p
, int cc
)
63 change_sign16_le(u_char
*p
, int cc
)
65 while ((cc
-= 2) >= 0) {
72 change_sign16_be(u_char
*p
, int cc
)
74 while ((cc
-= 2) >= 0) {
81 change_sign32_le(u_char
*p
, int cc
)
83 while ((cc
-= 4) >= 0) {
90 change_sign32_be(u_char
*p
, int cc
)
92 while ((cc
-= 4) >= 0) {
99 swap_bytes(u_char
*p
, int cc
)
103 while ((cc
-= 2) >= 0) {
112 swap_bytes32(u_char
*p
, int cc
)
116 while ((cc
-= 4) >= 0) {
128 swap_bytes_change_sign16_le(u_char
*p
, int cc
)
132 while ((cc
-= 2) >= 0) {
141 swap_bytes_change_sign16_be(u_char
*p
, int cc
)
145 while ((cc
-= 2) >= 0) {
154 change_sign16_swap_bytes_le(u_char
*p
, int cc
)
156 swap_bytes_change_sign16_be(p
, cc
);
160 change_sign16_swap_bytes_be(u_char
*p
, int cc
)
162 swap_bytes_change_sign16_le(p
, cc
);
166 swap_bytes_change_sign32_le(u_char
*p
, int cc
)
170 while ((cc
-= 4) >= 0) {
182 swap_bytes_change_sign32_be(u_char
*p
, int cc
)
186 while ((cc
-= 4) >= 0) {
198 change_sign32_swap_bytes_le(u_char
*p
, int cc
)
200 swap_bytes_change_sign32_be(p
, cc
);
204 change_sign32_swap_bytes_be(u_char
*p
, int cc
)
206 swap_bytes_change_sign32_le(p
, cc
);