diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-04-23 15:30:50 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2015-02-20 09:18:29 +0100 |
commit | 0bbe5ac82ef2845efafbf190044f16712db113b2 (patch) | |
tree | ac8745fba01c8a3e902e886f46f90ad56576559f /src/pcm_mix.c | |
parent | c69c8ffa9ec55c94dee7ce69af26b4edbd61647e (diff) |
Switch to Libav sample formats everywhere.
Drop 24bit format for now. It should be restored later by properly
distinguishing between internal and packed formats.
Diffstat (limited to 'src/pcm_mix.c')
-rw-r--r-- | src/pcm_mix.c | 124 |
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; |