MythTV master
inlines.h
Go to the documentation of this file.
1// Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
2//
3// Use, modification and distribution is allowed without limitation,
4// warranty, or liability of any kind.
5//
6
7#ifndef INLINES_H
8#define INLINES_H
9
10// *fast* convenience functions
11
12static inline void stereo16_from_stereopcm8(short *l,
13 short *r,
14 const uchar *c,
15 long cnt)
16{
17 while (cnt >= 4L) {
18 l[0] = c[0];
19 r[0] = c[1];
20 l[1] = c[2];
21 r[1] = c[3];
22 l[2] = c[4];
23 r[2] = c[5];
24 l[3] = c[6];
25 r[3] = c[7];
26 l += 4;
27 r += 4;
28 c += 8;
29 cnt -= 4L;
30 }
31
32 if (cnt > 0L) {
33 l[0] = c[0];
34 r[0] = c[1];
35 if (cnt > 1L) {
36 l[1] = c[2];
37 r[1] = c[3];
38 if (cnt > 2L) {
39 l[2] = c[4];
40 r[2] = c[5];
41 }
42 }
43 }
44}
45
46
47static inline void stereo16_from_stereopcm16(short *l,
48 short *r,
49 const short *s,
50 long cnt)
51{
52 while (cnt >= 4L) {
53 l[0] = s[0];
54 r[0] = s[1];
55 l[1] = s[2];
56 r[1] = s[3];
57 l[2] = s[4];
58 r[2] = s[5];
59 l[3] = s[6];
60 r[3] = s[7];
61 l += 4;
62 r += 4;
63 s += 8;
64 cnt -= 4L;
65 }
66
67 if (cnt > 0L) {
68 l[0] = s[0];
69 r[0] = s[1];
70 if (cnt > 1L) {
71 l[1] = s[2];
72 r[1] = s[3];
73 if (cnt > 2L) {
74 l[2] = s[4];
75 r[2] = s[5];
76 }
77 }
78 }
79}
80
81
82static inline void stereo16_from_stereopcm32(short *l,
83 short *r,
84 int *s,
85 long cnt)
86{
87 while (cnt--) {
88 *l++ = (short)(*s++ >> 16);
89 *r++ = (short)(*s++ >> 16);
90 }
91}
92
93
94static inline void stereo16_from_stereopcmfloat(short *l,
95 short *r,
96 float *s,
97 long cnt)
98{
99 while (cnt--) {
100 *l++ = (short)(*s++ * 32767.0F);
101 *r++ = (short)(*s++ * 32767.0F);
102 }
103}
104
105
106static inline void mono16_from_monopcm8(short *l,
107 const uchar *c,
108 long cnt)
109{
110 while (cnt >= 4L) {
111 l[0] = c[0];
112 l[1] = c[1];
113 l[2] = c[2];
114 l[3] = c[3];
115 l += 4;
116 c += 4;
117 cnt -= 4L;
118 }
119
120 if (cnt > 0L) {
121 l[0] = c[0];
122 if (cnt > 1L) {
123 l[1] = c[1];
124 if (cnt > 2L) {
125 l[2] = c[2];
126 }
127 }
128 }
129}
130
131
132static inline void mono16_from_monopcm16(short *l,
133 const short *s,
134 long cnt)
135{
136 while (cnt >= 4L) {
137 l[0] = s[0];
138 l[1] = s[1];
139 l[2] = s[2];
140 l[3] = s[3];
141 l += 4;
142 s += 4;
143 cnt -= 4L;
144 }
145
146 if (cnt > 0L) {
147 l[0] = s[0];
148 if (cnt > 1L) {
149 l[1] = s[1];
150 if (cnt > 2L) {
151 l[2] = s[2];
152 }
153 }
154 }
155}
156
157
158static inline void mono16_from_monopcm32(short *l,
159 int *s,
160 long cnt)
161{
162 while (cnt--)
163 *l++ = (short)(*s++ >> 16);
164}
165
166
167static inline void mono16_from_monopcmfloat(short *l,
168 float *s,
169 long cnt)
170{
171 while (cnt--)
172 *l++ = (short)(*s++ * 32767.0F);
173}
174
175#endif // INLINES_H
static void mono16_from_monopcm16(short *l, const short *s, long cnt)
Definition: inlines.h:132
static void stereo16_from_stereopcmfloat(short *l, short *r, float *s, long cnt)
Definition: inlines.h:94
static void mono16_from_monopcm8(short *l, const uchar *c, long cnt)
Definition: inlines.h:106
static void stereo16_from_stereopcm8(short *l, short *r, const uchar *c, long cnt)
Definition: inlines.h:12
static void mono16_from_monopcmfloat(short *l, float *s, long cnt)
Definition: inlines.h:167
static void stereo16_from_stereopcm32(short *l, short *r, int *s, long cnt)
Definition: inlines.h:82
static void stereo16_from_stereopcm16(short *l, short *r, const short *s, long cnt)
Definition: inlines.h:47
static void mono16_from_monopcm32(short *l, int *s, long cnt)
Definition: inlines.h:158