aboutsummaryrefslogtreecommitdiff
path: root/src/pcm_mix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pcm_mix.c')
-rw-r--r--src/pcm_mix.c124
1 files changed, 50 insertions, 74 deletions
diff --git a/src/pcm_mix.c b/src/pcm_mix.c
index 9f344f78..ac1fd7a0 100644
--- a/src/pcm_mix.c
+++ b/src/pcm_mix.c
@@ -112,46 +112,33 @@ pcm_add_vol_float(float *buffer1, const float *buffer2,
}
}
-static bool
-pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
- int vol1, int vol2,
- enum sample_format format)
+static bool pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
+ int vol1, int vol2,
+ enum AVSampleFormat format)
{
- switch (format) {
- case SAMPLE_FORMAT_UNDEFINED:
- /* not implemented */
- return false;
-
- case SAMPLE_FORMAT_S8:
- pcm_add_vol_8((int8_t *)buffer1, (const int8_t *)buffer2,
- size, vol1, vol2);
- return true;
-
- case SAMPLE_FORMAT_S16:
- pcm_add_vol_16((int16_t *)buffer1, (const int16_t *)buffer2,
- size / 2, vol1, vol2);
- return true;
-
- case SAMPLE_FORMAT_S24_P32:
- pcm_add_vol_24((int32_t *)buffer1, (const int32_t *)buffer2,
- size / 4, vol1, vol2);
- return true;
-
- case SAMPLE_FORMAT_S32:
- pcm_add_vol_32((int32_t *)buffer1, (const int32_t *)buffer2,
- size / 4, vol1, vol2);
- return true;
-
- case SAMPLE_FORMAT_FLOAT:
- pcm_add_vol_float(buffer1, buffer2, size / 4,
- pcm_volume_to_float(vol1),
- pcm_volume_to_float(vol2));
- return true;
- }
-
- /* unreachable */
- assert(false);
- return false;
+ switch (format) {
+ case AV_SAMPLE_FMT_U8:
+ pcm_add_vol_8((int8_t *)buffer1, (const int8_t *)buffer2,
+ size, vol1, vol2);
+ return true;
+ case AV_SAMPLE_FMT_S16:
+ pcm_add_vol_16((int16_t *)buffer1, (const int16_t *)buffer2,
+ size / 2, vol1, vol2);
+ return true;
+ case AV_SAMPLE_FMT_S32:
+ pcm_add_vol_32((int32_t *)buffer1, (const int32_t *)buffer2,
+ size / 4, vol1, vol2);
+ return true;
+
+ case AV_SAMPLE_FMT_FLT:
+ pcm_add_vol_float(buffer1, buffer2, size / 4,
+ pcm_volume_to_float(vol1),
+ pcm_volume_to_float(vol2));
+ return true;
+ default:
+ /* not implemented */
+ return false;
+ }
}
static void
@@ -221,44 +208,33 @@ pcm_add_float(float *buffer1, const float *buffer2, unsigned num_samples)
}
}
-static bool
-pcm_add(void *buffer1, const void *buffer2, size_t size,
- enum sample_format format)
+static bool pcm_add(void *buffer1, const void *buffer2, size_t size,
+ enum AVSampleFormat format)
{
- switch (format) {
- case SAMPLE_FORMAT_UNDEFINED:
- /* not implemented */
- return false;
-
- case SAMPLE_FORMAT_S8:
- pcm_add_8((int8_t *)buffer1, (const int8_t *)buffer2, size);
- return true;
-
- case SAMPLE_FORMAT_S16:
- pcm_add_16((int16_t *)buffer1, (const int16_t *)buffer2, size / 2);
- return true;
-
- case SAMPLE_FORMAT_S24_P32:
- pcm_add_24((int32_t *)buffer1, (const int32_t *)buffer2, size / 4);
- return true;
-
- case SAMPLE_FORMAT_S32:
- pcm_add_32((int32_t *)buffer1, (const int32_t *)buffer2, size / 4);
- return true;
-
- case SAMPLE_FORMAT_FLOAT:
- pcm_add_float(buffer1, buffer2, size / 4);
- return true;
- }
-
- /* unreachable */
- assert(false);
- return false;
+ switch (format) {
+ case AV_SAMPLE_FMT_U8:
+ pcm_add_8((int8_t *)buffer1, (const int8_t *)buffer2, size);
+ return true;
+
+ case AV_SAMPLE_FMT_S16:
+ pcm_add_16((int16_t *)buffer1, (const int16_t *)buffer2, size / 2);
+ return true;
+
+ case AV_SAMPLE_FMT_S32:
+ pcm_add_32((int32_t *)buffer1, (const int32_t *)buffer2, size / 4);
+ return true;
+
+ case AV_SAMPLE_FMT_FLT:
+ pcm_add_float(buffer1, buffer2, size / 4);
+ return true;
+ default:
+ /* not implemented */
+ return false;
+ }
}
-bool
-pcm_mix(void *buffer1, const void *buffer2, size_t size,
- enum sample_format format, float portion1)
+bool pcm_mix(void *buffer1, const void *buffer2, size_t size,
+ enum AVSampleFormat format, float portion1)
{
int vol1;
float s;