From b23ffefb21e43f0dc9d1bf031156331ea56e474d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 18 Dec 2012 20:02:32 +0000 Subject: Support non-planar float audio. --- src/lib/ffmpeg_decoder.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/lib/ffmpeg_decoder.cc') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 911714d7b..3c607a7fb 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -438,7 +438,25 @@ FFmpegDecoder::deinterleave_audio (uint8_t* data, int size) } } } + break; + + case AV_SAMPLE_FMT_FLT: + { + float* p = reinterpret_cast (data); + int sample = 0; + int channel = 0; + for (int i = 0; i < total_samples; ++i) { + audio->data(channel)[sample] = *p++; + ++channel; + if (channel == _film->audio_channels()) { + channel = 0; + ++sample; + } + } + } + break; + case AV_SAMPLE_FMT_FLTP: { float* p = reinterpret_cast (data); -- cgit v1.2.3 From 49e418c1fc725d0e734aaa51b14e3d8fbe12a3b0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 18 Dec 2012 23:14:03 +0000 Subject: Try to add support for signed 16-bit planar; tidy a couple of C-style casts. --- src/lib/ffmpeg_decoder.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/lib/ffmpeg_decoder.cc') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 3c607a7fb..b96e2b67c 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -408,7 +408,7 @@ FFmpegDecoder::deinterleave_audio (uint8_t* data, int size) switch (audio_sample_format()) { case AV_SAMPLE_FMT_S16: { - int16_t* p = (int16_t *) data; + int16_t* p = reinterpret_cast (data); int sample = 0; int channel = 0; for (int i = 0; i < total_samples; ++i) { @@ -423,13 +423,24 @@ FFmpegDecoder::deinterleave_audio (uint8_t* data, int size) } break; + case AV_SAMPLE_FMT_S16P: + { + int16_t* p = reinterpret_cast (data); + for (int i = 0; i < _film->audio_channels(); ++i) { + for (int j = 0; j < frames; ++j) { + audio->data(i)[j] = static_cast(*p++) / (1 << 15); + } + } + } + break; + case AV_SAMPLE_FMT_S32: { - int32_t* p = (int32_t *) data; + int32_t* p = reinterpret_cast (data); int sample = 0; int channel = 0; for (int i = 0; i < total_samples; ++i) { - audio->data(channel)[sample] = float(*p++) / (1 << 31); + audio->data(channel)[sample] = static_cast(*p++) / (1 << 31); ++channel; if (channel == _film->audio_channels()) { -- cgit v1.2.3