aboutsummaryrefslogtreecommitdiff
path: root/lib/DllSwResample.h
diff options
context:
space:
mode:
authorAlexis Ballier <aballier@gentoo.org>2012-08-14 12:25:38 -0400
committerAlexis Ballier <aballier@gentoo.org>2012-08-14 12:25:38 -0400
commit274679ddf932af1de2e9c3f01e9801099ff77b0c (patch)
treea9ce5f13086b93ba0fdba26fe7ec9cee5212c2b8 /lib/DllSwResample.h
parentf00b0c2352e0477238706263746d63e328dfd3ed (diff)
DllSwResample: Use libavresample if libswresample is not available.
Diffstat (limited to 'lib/DllSwResample.h')
-rw-r--r--lib/DllSwResample.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/DllSwResample.h b/lib/DllSwResample.h
index 7ac6a8889a..acf2a6c9a4 100644
--- a/lib/DllSwResample.h
+++ b/lib/DllSwResample.h
@@ -36,7 +36,14 @@ extern "C" {
#pragma warning(disable:4244)
#endif
#if (defined USE_EXTERNAL_FFMPEG)
- #include <libswresample/swresample.h>
+ #if HAVE_LIBSWRESAMPLE_SWRESAMPLE_H
+ #include <libswresample/swresample.h>
+ #elif HAVE_LIBAVRESAMPLE_AVRESAMPLE_H
+ #include <libavresample/avresample.h>
+ #define SwrContext AVAudioResampleContext
+ #else
+ #error "Either libswresample or libavresample is needed!"
+ #endif
#else
#include "libswresample/swresample.h"
#endif
@@ -54,6 +61,7 @@ public:
#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if HAVE_LIBSWRESAMPLE_SWRESAMPLE_H || (defined TARGET_DARWIN)
// Use direct mapping
class DllSwResample : public DllDynamic, DllSwResampleInterface
{
@@ -72,6 +80,35 @@ public:
virtual void swr_free(struct SwrContext **s){ return ::swr_free(s); }
virtual int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count){ return ::swr_convert(s, out, out_count, in, in_count); }
};
+#else
+// Wrap the same API through libavresample.
+class DllSwResample : public DllDynamic, DllSwResampleInterface
+{
+public:
+ virtual ~DllSwResample() {}
+
+ // DLL faking.
+ virtual bool ResolveExports() { return true; }
+ virtual bool Load() {
+ CLog::Log(LOGDEBUG, "DllAvFormat: Using libavresample system library");
+ return true;
+ }
+ virtual void Unload() {}
+ virtual struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx) {
+ AVAudioResampleContext *ret = ::avresample_alloc_context();
+ av_opt_set_int(ret, "out_channel_layout", out_ch_layout , 0);
+ av_opt_set_int(ret, "out_sample_fmt" , out_sample_fmt , 0);
+ av_opt_set_int(ret, "out_sample_rate" , out_sample_rate, 0);
+ av_opt_set_int(ret, "in_channel_layout" , in_ch_layout , 0);
+ av_opt_set_int(ret, "in_sample_fmt" , in_sample_fmt , 0);
+ av_opt_set_int(ret, "in_sample_rate" , in_sample_rate , 0);
+ return ret;
+ }
+ virtual int swr_init(struct SwrContext *s) { return ::avresample_open(s); }
+ virtual void swr_free(struct SwrContext **s){ ::avresample_close(*s); *s = NULL; }
+ virtual int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count){ return ::avresample_convert(s, (void**)out, 0, out_count, (void**)in, 0,in_count); }
+};
+#endif
#else