aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pcm_convert.c3
-rw-r--r--src/pcm_format.c2
-rw-r--r--src/pcm_pack.c12
-rw-r--r--src/pcm_pack.h4
4 files changed, 11 insertions, 10 deletions
diff --git a/src/pcm_convert.c b/src/pcm_convert.c
index 4dbeee41f..c145e437a 100644
--- a/src/pcm_convert.c
+++ b/src/pcm_convert.c
@@ -200,7 +200,8 @@ pcm_convert_24_packed(struct pcm_convert_state *state,
size_t dest_size = num_samples * 3;
uint8_t *dest = pcm_buffer_get(&state->pack_buffer, dest_size);
- pcm_pack_24(dest, buffer, num_samples, dest_format->reverse_endian);
+ pcm_pack_24(dest, buffer, buffer + num_samples,
+ dest_format->reverse_endian);
*dest_size_r = dest_size;
return dest;
diff --git a/src/pcm_format.c b/src/pcm_format.c
index 544b0ccd9..21459f0f4 100644
--- a/src/pcm_format.c
+++ b/src/pcm_format.c
@@ -54,7 +54,7 @@ pcm_convert_24_to_24p32(struct pcm_buffer *buffer, const uint8_t *src,
unsigned num_samples)
{
int32_t *dest = pcm_buffer_get(buffer, num_samples * 4);
- pcm_unpack_24(dest, src, num_samples, false);
+ pcm_unpack_24(dest, src, src + num_samples * 3, false);
return dest;
}
diff --git a/src/pcm_pack.c b/src/pcm_pack.c
index 680d2a32f..94fda5910 100644
--- a/src/pcm_pack.c
+++ b/src/pcm_pack.c
@@ -35,19 +35,19 @@ pack_sample(uint8_t *dest, const int32_t *src0, bool reverse_endian)
}
void
-pcm_pack_24(uint8_t *dest, const int32_t *src, unsigned num_samples,
+pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end,
bool reverse_endian)
{
/* duplicate loop to help the compiler's optimizer (constant
parameter to the pack_sample() inline function) */
if (G_LIKELY(!reverse_endian)) {
- while (num_samples-- > 0) {
+ while (src < src_end) {
pack_sample(dest, src++, false);
dest += 3;
}
} else {
- while (num_samples-- > 0) {
+ while (src < src_end) {
pack_sample(dest, src++, true);
dest += 3;
}
@@ -73,19 +73,19 @@ unpack_sample(int32_t *dest0, const uint8_t *src, bool reverse_endian)
}
void
-pcm_unpack_24(int32_t *dest, const uint8_t *src, unsigned num_samples,
+pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end,
bool reverse_endian)
{
/* duplicate loop to help the compiler's optimizer (constant
parameter to the unpack_sample() inline function) */
if (G_LIKELY(!reverse_endian)) {
- while (num_samples-- > 0) {
+ while (src < src_end) {
unpack_sample(dest++, src, false);
src += 3;
}
} else {
- while (num_samples-- > 0) {
+ while (src < src_end) {
unpack_sample(dest++, src, true);
src += 3;
}
diff --git a/src/pcm_pack.h b/src/pcm_pack.h
index 0055e91df..6f275608c 100644
--- a/src/pcm_pack.h
+++ b/src/pcm_pack.h
@@ -40,7 +40,7 @@
* @param reverse_endian is src and dest in non-host byte order?
*/
void
-pcm_pack_24(uint8_t *dest, const int32_t *src, unsigned num_samples,
+pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end,
bool reverse_endian);
/**
@@ -53,7 +53,7 @@ pcm_pack_24(uint8_t *dest, const int32_t *src, unsigned num_samples,
* @param reverse_endian is src and dest in non-host byte order?
*/
void
-pcm_unpack_24(int32_t *dest, const uint8_t *src, unsigned num_samples,
+pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end,
bool reverse_endian);
#endif