pcm_pack: pass an "end" pointer instead of a sample count
This commit is contained in:
parent
e93dd374a4
commit
a47e9d1a4b
@ -200,7 +200,8 @@ pcm_convert_24_packed(struct pcm_convert_state *state,
|
|||||||
size_t dest_size = num_samples * 3;
|
size_t dest_size = num_samples * 3;
|
||||||
|
|
||||||
uint8_t *dest = pcm_buffer_get(&state->pack_buffer, dest_size);
|
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;
|
*dest_size_r = dest_size;
|
||||||
return dest;
|
return dest;
|
||||||
|
@ -54,7 +54,7 @@ pcm_convert_24_to_24p32(struct pcm_buffer *buffer, const uint8_t *src,
|
|||||||
unsigned num_samples)
|
unsigned num_samples)
|
||||||
{
|
{
|
||||||
int32_t *dest = pcm_buffer_get(buffer, num_samples * 4);
|
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;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,19 +35,19 @@ pack_sample(uint8_t *dest, const int32_t *src0, bool reverse_endian)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
bool reverse_endian)
|
||||||
{
|
{
|
||||||
/* duplicate loop to help the compiler's optimizer (constant
|
/* duplicate loop to help the compiler's optimizer (constant
|
||||||
parameter to the pack_sample() inline function) */
|
parameter to the pack_sample() inline function) */
|
||||||
|
|
||||||
if (G_LIKELY(!reverse_endian)) {
|
if (G_LIKELY(!reverse_endian)) {
|
||||||
while (num_samples-- > 0) {
|
while (src < src_end) {
|
||||||
pack_sample(dest, src++, false);
|
pack_sample(dest, src++, false);
|
||||||
dest += 3;
|
dest += 3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (num_samples-- > 0) {
|
while (src < src_end) {
|
||||||
pack_sample(dest, src++, true);
|
pack_sample(dest, src++, true);
|
||||||
dest += 3;
|
dest += 3;
|
||||||
}
|
}
|
||||||
@ -73,19 +73,19 @@ unpack_sample(int32_t *dest0, const uint8_t *src, bool reverse_endian)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
bool reverse_endian)
|
||||||
{
|
{
|
||||||
/* duplicate loop to help the compiler's optimizer (constant
|
/* duplicate loop to help the compiler's optimizer (constant
|
||||||
parameter to the unpack_sample() inline function) */
|
parameter to the unpack_sample() inline function) */
|
||||||
|
|
||||||
if (G_LIKELY(!reverse_endian)) {
|
if (G_LIKELY(!reverse_endian)) {
|
||||||
while (num_samples-- > 0) {
|
while (src < src_end) {
|
||||||
unpack_sample(dest++, src, false);
|
unpack_sample(dest++, src, false);
|
||||||
src += 3;
|
src += 3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (num_samples-- > 0) {
|
while (src < src_end) {
|
||||||
unpack_sample(dest++, src, true);
|
unpack_sample(dest++, src, true);
|
||||||
src += 3;
|
src += 3;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
* @param reverse_endian is src and dest in non-host byte order?
|
* @param reverse_endian is src and dest in non-host byte order?
|
||||||
*/
|
*/
|
||||||
void
|
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);
|
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?
|
* @param reverse_endian is src and dest in non-host byte order?
|
||||||
*/
|
*/
|
||||||
void
|
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);
|
bool reverse_endian);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,7 +44,7 @@ test_pcm_pack_24(void)
|
|||||||
|
|
||||||
uint8_t dest[N * 3];
|
uint8_t dest[N * 3];
|
||||||
|
|
||||||
pcm_pack_24(dest, src, N, false);
|
pcm_pack_24(dest, src, src + N, false);
|
||||||
|
|
||||||
for (unsigned i = 0; i < N; ++i) {
|
for (unsigned i = 0; i < N; ++i) {
|
||||||
int32_t d;
|
int32_t d;
|
||||||
@ -71,7 +71,7 @@ test_pcm_unpack_24(void)
|
|||||||
|
|
||||||
int32_t dest[N];
|
int32_t dest[N];
|
||||||
|
|
||||||
pcm_unpack_24(dest, src, N, false);
|
pcm_unpack_24(dest, src, src + G_N_ELEMENTS(src), false);
|
||||||
|
|
||||||
for (unsigned i = 0; i < N; ++i) {
|
for (unsigned i = 0; i < N; ++i) {
|
||||||
int32_t s;
|
int32_t s;
|
||||||
|
Loading…
Reference in New Issue
Block a user