Commit 72e80db8 authored by Max Kellermann's avatar Max Kellermann

pcm_*: add "restrict" keywords

Allow more compiler optimizations.
parent 7b33c343
...@@ -25,8 +25,9 @@ ...@@ -25,8 +25,9 @@
#include <assert.h> #include <assert.h>
static void static void
pcm_convert_channels_16_1_to_2(int16_t *dest, const int16_t *src, pcm_convert_channels_16_1_to_2(int16_t *restrict dest,
const int16_t *src_end) const int16_t *restrict src,
const int16_t *restrict src_end)
{ {
while (src < src_end) { while (src < src_end) {
int16_t value = *src++; int16_t value = *src++;
...@@ -37,8 +38,9 @@ pcm_convert_channels_16_1_to_2(int16_t *dest, const int16_t *src, ...@@ -37,8 +38,9 @@ pcm_convert_channels_16_1_to_2(int16_t *dest, const int16_t *src,
} }
static void static void
pcm_convert_channels_16_2_to_1(int16_t *dest, const int16_t *src, pcm_convert_channels_16_2_to_1(int16_t *restrict dest,
const int16_t *src_end) const int16_t *restrict src,
const int16_t *restrict src_end)
{ {
while (src < src_end) { while (src < src_end) {
int32_t a = *src++, b = *src++; int32_t a = *src++, b = *src++;
...@@ -48,9 +50,10 @@ pcm_convert_channels_16_2_to_1(int16_t *dest, const int16_t *src, ...@@ -48,9 +50,10 @@ pcm_convert_channels_16_2_to_1(int16_t *dest, const int16_t *src,
} }
static void static void
pcm_convert_channels_16_n_to_2(int16_t *dest, pcm_convert_channels_16_n_to_2(int16_t *restrict dest,
unsigned src_channels, const int16_t *src, unsigned src_channels,
const int16_t *src_end) const int16_t *restrict src,
const int16_t *restrict src_end)
{ {
unsigned c; unsigned c;
...@@ -98,8 +101,9 @@ pcm_convert_channels_16(struct pcm_buffer *buffer, ...@@ -98,8 +101,9 @@ pcm_convert_channels_16(struct pcm_buffer *buffer,
} }
static void static void
pcm_convert_channels_24_1_to_2(int32_t *dest, const int32_t *src, pcm_convert_channels_24_1_to_2(int32_t *restrict dest,
const int32_t *src_end) const int32_t *restrict src,
const int32_t *restrict src_end)
{ {
while (src < src_end) { while (src < src_end) {
int32_t value = *src++; int32_t value = *src++;
...@@ -110,8 +114,9 @@ pcm_convert_channels_24_1_to_2(int32_t *dest, const int32_t *src, ...@@ -110,8 +114,9 @@ pcm_convert_channels_24_1_to_2(int32_t *dest, const int32_t *src,
} }
static void static void
pcm_convert_channels_24_2_to_1(int32_t *dest, const int32_t *src, pcm_convert_channels_24_2_to_1(int32_t *restrict dest,
const int32_t *src_end) const int32_t *restrict src,
const int32_t *restrict src_end)
{ {
while (src < src_end) { while (src < src_end) {
int32_t a = *src++, b = *src++; int32_t a = *src++, b = *src++;
...@@ -121,9 +126,10 @@ pcm_convert_channels_24_2_to_1(int32_t *dest, const int32_t *src, ...@@ -121,9 +126,10 @@ pcm_convert_channels_24_2_to_1(int32_t *dest, const int32_t *src,
} }
static void static void
pcm_convert_channels_24_n_to_2(int32_t *dest, pcm_convert_channels_24_n_to_2(int32_t *restrict dest,
unsigned src_channels, const int32_t *src, unsigned src_channels,
const int32_t *src_end) const int32_t *restrict src,
const int32_t *restrict src_end)
{ {
unsigned c; unsigned c;
...@@ -178,8 +184,9 @@ pcm_convert_channels_32_1_to_2(int32_t *dest, const int32_t *src, ...@@ -178,8 +184,9 @@ pcm_convert_channels_32_1_to_2(int32_t *dest, const int32_t *src,
} }
static void static void
pcm_convert_channels_32_2_to_1(int32_t *dest, const int32_t *src, pcm_convert_channels_32_2_to_1(int32_t *restrict dest,
const int32_t *src_end) const int32_t *restrict src,
const int32_t *restrict src_end)
{ {
while (src < src_end) { while (src < src_end) {
int64_t a = *src++, b = *src++; int64_t a = *src++, b = *src++;
......
...@@ -137,7 +137,9 @@ pcm_convert_16_to_24(int32_t *out, const int16_t *in, const int16_t *in_end) ...@@ -137,7 +137,9 @@ pcm_convert_16_to_24(int32_t *out, const int16_t *in, const int16_t *in_end)
} }
static void static void
pcm_convert_32_to_24(int32_t *out, const int32_t *in, const int32_t *in_end) pcm_convert_32_to_24(int32_t *restrict out,
const int32_t *restrict in,
const int32_t *restrict in_end)
{ {
while (in < in_end) while (in < in_end)
*out++ = *in++ >> 8; *out++ = *in++ >> 8;
...@@ -208,7 +210,9 @@ pcm_convert_16_to_32(int32_t *out, const int16_t *in, const int16_t *in_end) ...@@ -208,7 +210,9 @@ pcm_convert_16_to_32(int32_t *out, const int16_t *in, const int16_t *in_end)
} }
static void static void
pcm_convert_24_to_32(int32_t *out, const int32_t *in, const int32_t *in_end) pcm_convert_24_to_32(int32_t *restrict out,
const int32_t *restrict in,
const int32_t *restrict in_end)
{ {
while (in < in_end) while (in < in_end)
*out++ = *in++ << 8; *out++ = *in++ << 8;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment