Permalink
Browse files

SwResample: Map swr_alloc_set_opts, swr_init, swr_free and swr_conver…

…t functions.

That way we can use the libswresample API instead of the private libavcodec::audioconvert API.
  • Loading branch information...
1 parent da1ee8a commit 563ad420f9ff2683779a522d2449322f06ecfdde @aballier committed Apr 14, 2012
Showing with 24 additions and 2 deletions.
  1. +24 −2 lib/DllSwResample.h
View
@@ -42,11 +42,20 @@ extern "C" {
#endif
}
+class DllSwResampleInterface
+{
+public:
+ virtual ~DllSwResampleInterface() {}
+ 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)=0;
+ virtual int swr_init(struct SwrContext *s)=0;
+ virtual void swr_free(struct SwrContext **s)=0;
+ virtual int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count)=0;
+};
#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
// Use direct mapping
-class DllSwResample : public DllDynamic
+class DllSwResample : public DllDynamic, DllSwResampleInterface
{
public:
virtual ~DllSwResample() {}
@@ -58,17 +67,30 @@ class DllSwResample : public DllDynamic
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) { return ::swr_alloc_set_opts(s, out_ch_layout, out_sample_fmt, out_sample_rate, in_ch_layout, in_sample_fmt, in_sample_rate, log_offset, log_ctx); }
+ virtual int swr_init(struct SwrContext *s) { return ::swr_init(s); }
+ 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
-class DllSwResample : public DllDynamic
+class DllSwResample : public DllDynamic, DllSwResampleInterface
{
DECLARE_DLL_WRAPPER(DllSwResample, DLL_PATH_LIBSWRESAMPLE)
LOAD_SYMBOLS()
+ DEFINE_METHOD9(SwrContext*, swr_alloc_set_opts, (struct SwrContext *p1, int64_t p2, enum AVSampleFormat p3, int p4, int64_t p5, enum AVSampleFormat p6, int p7, int p8, void * p9));
+ DEFINE_METHOD1(int, swr_init, (struct SwrContext *p1))
+ DEFINE_METHOD1(void, swr_free, (struct SwrContext **p1))
+ DEFINE_METHOD5(int, swr_convert, (struct SwrContext *p1, uint8_t **p2, int p3, const uint8_t **p4, int p5))
+
BEGIN_METHOD_RESOLVE()
+ RESOLVE_METHOD(swr_alloc_set_opts)
+ RESOLVE_METHOD(swr_init)
+ RESOLVE_METHOD(swr_free)
+ RESOLVE_METHOD(swr_convert)
END_METHOD_RESOLVE()
/* dependencies of libavformat */

0 comments on commit 563ad42

Please sign in to comment.