Skip to content

Commit 08022aa

Browse files
plbossartlgirdwood
authored andcommitted
Revert "pcm_converter: Convert linear memory regions"
This reverts commit 1f092df. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
1 parent b7bb801 commit 08022aa

File tree

1 file changed

+66
-78
lines changed

1 file changed

+66
-78
lines changed

src/audio/pcm_converter/pcm_converter_generic.c

Lines changed: 66 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -26,126 +26,114 @@
2626

2727
#if CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S24LE
2828

29-
static void pcm_convert_s16_to_s24_lin(const void *psrc, void *pdst,
30-
uint32_t samples)
31-
{
32-
const int16_t *src = psrc;
33-
int32_t *dst = pdst;
34-
uint32_t i;
35-
36-
for (i = 0; i < samples; i++)
37-
dst[i] = src[i] << 8;
38-
}
39-
40-
static void pcm_convert_s24_to_s16_lin(const void *psrc, void *pdst,
41-
uint32_t samples)
42-
{
43-
const int32_t *src = psrc;
44-
int16_t *dst = pdst;
45-
uint32_t i;
46-
47-
for (i = 0; i < samples; i++)
48-
dst[i] = sat_int16(Q_SHIFT_RND(sign_extend_s24(src[i]), 23, 15));
49-
}
50-
5129
static void pcm_convert_s16_to_s24(const struct audio_stream *source,
5230
uint32_t ioffset, struct audio_stream *sink,
5331
uint32_t ooffset, uint32_t samples)
5432
{
55-
pcm_convert_as_linear(source, ioffset, sink, ooffset, samples,
56-
pcm_convert_s16_to_s24_lin);
33+
uint32_t buff_frag = 0;
34+
int16_t *src;
35+
int32_t *dst;
36+
uint32_t i;
37+
38+
for (i = 0; i < samples; i++) {
39+
src = audio_stream_read_frag_s16(source, buff_frag + ioffset);
40+
dst = audio_stream_write_frag_s32(sink, buff_frag + ooffset);
41+
*dst = *src << 8;
42+
buff_frag++;
43+
}
5744
}
5845

5946
static void pcm_convert_s24_to_s16(const struct audio_stream *source,
6047
uint32_t ioffset, struct audio_stream *sink,
6148
uint32_t ooffset, uint32_t samples)
6249
{
63-
pcm_convert_as_linear(source, ioffset, sink, ooffset, samples,
64-
pcm_convert_s24_to_s16_lin);
65-
}
66-
67-
#endif /* CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S24LE */
68-
69-
#if CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S32LE
70-
71-
static void pcm_convert_s16_to_s32_lin(const void *psrc, void *pdst,
72-
uint32_t samples)
73-
{
74-
const int32_t *src = psrc;
75-
int32_t *dst = pdst;
50+
uint32_t buff_frag = 0;
51+
int32_t *src;
52+
int16_t *dst;
7653
uint32_t i;
7754

78-
for (i = 0; i < samples; i++)
79-
dst[i] = src[i] << 16;
55+
for (i = 0; i < samples; i++) {
56+
src = audio_stream_read_frag_s32(source, buff_frag + ioffset);
57+
dst = audio_stream_write_frag_s16(sink, buff_frag + ooffset);
58+
*dst = sat_int16(Q_SHIFT_RND(sign_extend_s24(*src), 23, 15));
59+
buff_frag++;
60+
}
8061
}
8162

82-
static void pcm_convert_s32_to_s16_lin(const void *psrc, void *pdst,
83-
uint32_t samples)
84-
{
85-
const int32_t *src = psrc;
86-
int32_t *dst = pdst;
87-
uint32_t i;
63+
#endif /* CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S24LE */
8864

89-
for (i = 0; i < samples; i++)
90-
dst[i] = sat_int16(Q_SHIFT_RND(src[i], 31, 15));
91-
}
65+
#if CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S32LE
9266

9367
static void pcm_convert_s16_to_s32(const struct audio_stream *source,
9468
uint32_t ioffset, struct audio_stream *sink,
9569
uint32_t ooffset, uint32_t samples)
9670
{
97-
pcm_convert_as_linear(source, ioffset, sink, ooffset, samples,
98-
pcm_convert_s16_to_s32_lin);
71+
uint32_t buff_frag = 0;
72+
int16_t *src;
73+
int32_t *dst;
74+
uint32_t i;
75+
76+
for (i = 0; i < samples; i++) {
77+
src = audio_stream_read_frag_s16(source, buff_frag + ioffset);
78+
dst = audio_stream_write_frag_s32(sink, buff_frag + ooffset);
79+
*dst = *src << 16;
80+
buff_frag++;
81+
}
9982
}
10083

10184
static void pcm_convert_s32_to_s16(const struct audio_stream *source,
10285
uint32_t ioffset, struct audio_stream *sink,
10386
uint32_t ooffset, uint32_t samples)
10487
{
105-
pcm_convert_as_linear(source, ioffset, sink, ooffset, samples,
106-
pcm_convert_s32_to_s16_lin);
107-
}
108-
109-
#endif /* CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S32LE */
110-
111-
#if CONFIG_FORMAT_S24LE && CONFIG_FORMAT_S32LE
112-
113-
static void pcm_convert_s24_to_s32_lin(const void *psrc, void *pdst,
114-
uint32_t samples)
115-
{
116-
const int32_t *src = psrc;
117-
int32_t *dst = pdst;
88+
uint32_t buff_frag = 0;
89+
int32_t *src;
90+
int16_t *dst;
11891
uint32_t i;
11992

120-
for (i = 0; i < samples; i++)
121-
dst[i] = src[i] << 8;
93+
for (i = 0; i < samples; i++) {
94+
src = audio_stream_read_frag_s32(source, buff_frag + ioffset);
95+
dst = audio_stream_write_frag_s16(sink, buff_frag + ooffset);
96+
*dst = sat_int16(Q_SHIFT_RND(*src, 31, 15));
97+
buff_frag++;
98+
}
12299
}
123100

124-
static void pcm_convert_s32_to_s24_lin(const void *psrc, void *pdst,
125-
uint32_t samples)
126-
{
127-
const int32_t *src = psrc;
128-
int32_t *dst = pdst;
129-
uint32_t i;
101+
#endif /* CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S32LE */
130102

131-
for (i = 0; i < samples; i++)
132-
dst[i] = sat_int24(Q_SHIFT_RND(src[i], 31, 23));
133-
}
103+
#if CONFIG_FORMAT_S24LE && CONFIG_FORMAT_S32LE
134104

135105
static void pcm_convert_s24_to_s32(const struct audio_stream *source,
136106
uint32_t ioffset, struct audio_stream *sink,
137107
uint32_t ooffset, uint32_t samples)
138108
{
139-
pcm_convert_as_linear(source, ioffset, sink, ooffset, samples,
140-
pcm_convert_s24_to_s32_lin);
109+
uint32_t buff_frag = 0;
110+
int32_t *src;
111+
int32_t *dst;
112+
uint32_t i;
113+
114+
for (i = 0; i < samples; i++) {
115+
src = audio_stream_read_frag_s32(source, buff_frag + ioffset);
116+
dst = audio_stream_write_frag_s32(sink, buff_frag + ooffset);
117+
*dst = *src << 8;
118+
buff_frag++;
119+
}
141120
}
142121

143122
static void pcm_convert_s32_to_s24(const struct audio_stream *source,
144123
uint32_t ioffset, struct audio_stream *sink,
145124
uint32_t ooffset, uint32_t samples)
146125
{
147-
pcm_convert_as_linear(source, ioffset, sink, ooffset, samples,
148-
pcm_convert_s32_to_s24_lin);
126+
uint32_t buff_frag = 0;
127+
int32_t *src;
128+
int32_t *dst;
129+
uint32_t i;
130+
131+
for (i = 0; i < samples; i++) {
132+
src = audio_stream_read_frag_s32(source, buff_frag + ioffset);
133+
dst = audio_stream_write_frag_s32(sink, buff_frag + ooffset);
134+
*dst = sat_int24(Q_SHIFT_RND(*src, 31, 23));
135+
buff_frag++;
136+
}
149137
}
150138

151139
#endif /* CONFIG_FORMAT_S24LE && CONFIG_FORMAT_S32LE */

0 commit comments

Comments
 (0)