From 82059cbfe25b0739b415f2ff8749ea60886b0834 Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Fri, 5 Sep 2008 12:55:45 +0000 Subject: [PATCH] add some support for sample formats other than 16-bit int to the lavc audio provider. untested and will probably break spectacularly. Originally committed to SVN as r2320. --- aegisub/audio_provider_lavc.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/aegisub/audio_provider_lavc.cpp b/aegisub/audio_provider_lavc.cpp index 14c3c086b..cdb950bd1 100644 --- a/aegisub/audio_provider_lavc.cpp +++ b/aegisub/audio_provider_lavc.cpp @@ -56,14 +56,9 @@ /* - done in posix/defines.h */ - -extern "C" { -#include -#include -} +#include "audio_provider_lavc.h" #include "mkv_wrap.h" #include "lavc_file.h" -#include "audio_provider_lavc.h" #include "lavc_file.h" #include "utils.h" #include "options.h" @@ -123,11 +118,13 @@ LAVCAudioProvider::LAVCAudioProvider(Aegisub::String _filename) /* we rely on the intermediate audio provider to do downmixing for us later if necessary */ channels = codecContext->channels; - /* FIXME: we need support for more audio types than just 16-bit int */ + /* TODO: test if anything but S16 actually works! */ switch (codecContext->sample_fmt) { - case SAMPLE_FMT_S16: bytes_per_sample = 2; break; + case SAMPLE_FMT_U8: bytes_per_sample = 1; break; + case SAMPLE_FMT_S16: bytes_per_sample = 2; break; + case SAMPLE_FMT_S32: bytes_per_sample = 4; break; /* downmixing provider doesn't support this, will definitely not work */ default: - throw _T("ffmpeg audio provider: Only 16-bit audio is supported"); + throw _T("ffmpeg audio provider: Unknown or unsupported sample format"); } /* initiate resampling if necessary */