From 04bfeac6ccfe4e4c981a241f53138c765a0864a7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 8 Mar 2014 01:48:04 +0000 Subject: Support for unsigned 8-bit audio. --- src/lib/ffmpeg_decoder.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/lib/ffmpeg_decoder.cc') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 16da64c60..347d8cc08 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -199,6 +199,23 @@ FFmpegDecoder::deinterleave_audio (uint8_t** data, int size) shared_ptr audio (new AudioBuffers (_ffmpeg_content->audio_channels(), frames)); switch (audio_sample_format()) { + case AV_SAMPLE_FMT_U8: + { + uint8_t* p = reinterpret_cast (data[0]); + int sample = 0; + int channel = 0; + for (int i = 0; i < total_samples; ++i) { + audio->data(channel)[sample] = float(*p++) / (1 << 23); + + ++channel; + if (channel == _ffmpeg_content->audio_channels()) { + channel = 0; + ++sample; + } + } + } + break; + case AV_SAMPLE_FMT_S16: { int16_t* p = reinterpret_cast (data[0]); -- cgit v1.2.3