|
26 | 26 |
|
27 | 27 | #if CONFIG_FORMAT_S16LE && CONFIG_FORMAT_S24LE |
28 | 28 |
|
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 | | - |
51 | 29 | static void pcm_convert_s16_to_s24(const struct audio_stream *source, |
52 | 30 | uint32_t ioffset, struct audio_stream *sink, |
53 | 31 | uint32_t ooffset, uint32_t samples) |
54 | 32 | { |
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 | + } |
57 | 44 | } |
58 | 45 |
|
59 | 46 | static void pcm_convert_s24_to_s16(const struct audio_stream *source, |
60 | 47 | uint32_t ioffset, struct audio_stream *sink, |
61 | 48 | uint32_t ooffset, uint32_t samples) |
62 | 49 | { |
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; |
76 | 53 | uint32_t i; |
77 | 54 |
|
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 | + } |
80 | 61 | } |
81 | 62 |
|
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 */ |
88 | 64 |
|
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 |
92 | 66 |
|
93 | 67 | static void pcm_convert_s16_to_s32(const struct audio_stream *source, |
94 | 68 | uint32_t ioffset, struct audio_stream *sink, |
95 | 69 | uint32_t ooffset, uint32_t samples) |
96 | 70 | { |
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 | + } |
99 | 82 | } |
100 | 83 |
|
101 | 84 | static void pcm_convert_s32_to_s16(const struct audio_stream *source, |
102 | 85 | uint32_t ioffset, struct audio_stream *sink, |
103 | 86 | uint32_t ooffset, uint32_t samples) |
104 | 87 | { |
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; |
118 | 91 | uint32_t i; |
119 | 92 |
|
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 | + } |
122 | 99 | } |
123 | 100 |
|
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 */ |
130 | 102 |
|
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 |
134 | 104 |
|
135 | 105 | static void pcm_convert_s24_to_s32(const struct audio_stream *source, |
136 | 106 | uint32_t ioffset, struct audio_stream *sink, |
137 | 107 | uint32_t ooffset, uint32_t samples) |
138 | 108 | { |
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 | + } |
141 | 120 | } |
142 | 121 |
|
143 | 122 | static void pcm_convert_s32_to_s24(const struct audio_stream *source, |
144 | 123 | uint32_t ioffset, struct audio_stream *sink, |
145 | 124 | uint32_t ooffset, uint32_t samples) |
146 | 125 | { |
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 | + } |
149 | 137 | } |
150 | 138 |
|
151 | 139 | #endif /* CONFIG_FORMAT_S24LE && CONFIG_FORMAT_S32LE */ |
|
0 commit comments