diff --git a/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj b/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj
index e06fa785d..ab1a64920 100644
--- a/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj
+++ b/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj
@@ -457,10 +457,6 @@
RelativePath="..\..\libaegisub\include\libaegisub\mru.h"
>
-
-
diff --git a/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj b/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj
index a262bd495..8055a8eff 100644
--- a/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj
+++ b/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj
@@ -60,11 +60,9 @@
-
-
@@ -97,7 +95,6 @@
-
diff --git a/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj.filters b/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj.filters
index 0ad646cf3..697d6f0b0 100644
--- a/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj.filters
+++ b/aegisub/build/msbuild/libaegisub/libaegisub.vcxproj.filters
@@ -59,9 +59,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -116,9 +113,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -187,9 +181,6 @@
Source Files\Windows
-
- Source Files\Common
-
Source Files\Common
diff --git a/aegisub/configure.in b/aegisub/configure.in
index 75490c984..faa3632fe 100644
--- a/aegisub/configure.in
+++ b/aegisub/configure.in
@@ -206,18 +206,6 @@ AC_SUBST(DMG_STRING)
ACX_PTHREAD([], [AC_MSG_FAILURE([You must have working pthreads.])])
CC="$PTHREAD_CC"
-AC_AGI_COMPILE([pthread_rwlock_*], [pthread_rwlock], [$PTHREAD_CFLAGS], [$PTHREAD_LIBS],[
-#include
-#define _XOPEN_SOURCE 500
-int main(void) {
- pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
- pthread_rwlock_rdlock(&l);
- return 0;
-}])
-
-AS_IF([test x$agi_cv_with_pthread_rwlock = xyes],
- [AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])])
-
######################
# Check compiler flags
######################
diff --git a/aegisub/libaegisub/Makefile b/aegisub/libaegisub/Makefile
index aec294110..32ee0a468 100644
--- a/aegisub/libaegisub/Makefile
+++ b/aegisub/libaegisub/Makefile
@@ -32,7 +32,6 @@ SRC = \
common/option.cpp \
common/option_visit.cpp \
common/path.cpp \
- common/progress.cpp \
common/keyframe.cpp \
common/util.cpp \
common/log.cpp \
diff --git a/aegisub/libaegisub/common/progress.cpp b/aegisub/libaegisub/common/progress.cpp
deleted file mode 100644
index bd8de8bea..000000000
--- a/aegisub/libaegisub/common/progress.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2011, Niels Martin Hansen
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-// $Id$
-
-/// @file progress.cpp
-/// @brief Progress bars.
-/// @ingroup libaegisub
-
-#ifndef LAG_PRE
-#include
-
-#include
-#include
-#include
-#include
-#endif
-
-#include "libaegisub/progress.h"
-
-
-namespace agi {
-
-
-class NullProgressSink : public ProgressSink {
-public:
- virtual void set_progress(int steps, int max) { }
- virtual void set_operation(const std::string &operation) { }
- virtual bool get_cancelled() const { return false; }
-};
-
-ProgressSink * NullProgressSinkFactory::create_progress_sink(const std::string &title) const {
- return new NullProgressSink;
-}
-
-
-class StdioProgressSink : public ProgressSink {
-private:
- std::string operation;
- float progress;
-
- void print();
-
-public:
- StdioProgressSink(const std::string &title);
- virtual ~StdioProgressSink();
- virtual void set_progress(int steps, int max);
- virtual void set_operation(const std::string &operation);
- virtual bool get_cancelled() const { return false; } // or maybe see if there is an ESC waiting or get a ^C sent flag
-};
-
-ProgressSink * StdioProgressSinkFactory::create_progress_sink(const std::string &title) const {
- return new StdioProgressSink(title);
-}
-
-
-StdioProgressSink::StdioProgressSink(const std::string &title)
-: operation(title)
-, progress(0) {
- std::cout << title << ": ";
- print();
-}
-
-StdioProgressSink::~StdioProgressSink()
-{
- std::cout << "end" << std::endl;
-}
-
-
-void StdioProgressSink::set_progress(int steps, int max) {
- assert(steps >= 0);
- assert(steps <= max);
-
- float old_progress = progress;
- progress = (100.f * steps)/max;
-
- if (std::fabs(progress-old_progress) > 0.8)
- {
- print();
- }
-}
-
-
-void StdioProgressSink::set_operation(const std::string &operation) {
- this->operation = operation;
- print();
-}
-
-
-void StdioProgressSink::print() {
- std::cout << operation << ": " << std::setprecision(2) << progress << std::endl;
-}
-
-
-
-} // namespace agi
diff --git a/aegisub/libaegisub/include/libaegisub/mutex.h b/aegisub/libaegisub/include/libaegisub/mutex.h
deleted file mode 100644
index dab895799..000000000
--- a/aegisub/libaegisub/include/libaegisub/mutex.h
+++ /dev/null
@@ -1,325 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// ---
-// Author: Craig Silverstein.
-//
-// A simple mutex wrapper, supporting locks and read-write locks.
-// You should assume the locks are *not* re-entrant.
-//
-// To use: you should define the following macros in your configure.ac:
-// ACX_PTHREAD
-// AC_RWLOCK
-// The latter is defined in ../autoconf.
-//
-// This class is meant to be internal-only and should be wrapped by an
-// internal namespace. Before you use this module, please give the
-// name of your internal namespace for this module. Or, if you want
-// to expose it, you'll want to move it to the Google namespace. We
-// cannot put this class in global namespace because there can be some
-// problems when we have multiple versions of Mutex in each shared object.
-//
-// NOTE: by default, we have #ifdef'ed out the TryLock() method.
-// This is for two reasons:
-// 1) TryLock() under Windows is a bit annoying (it requires a
-// #define to be defined very early).
-// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
-// mode.
-// If you need TryLock(), and either these two caveats are not a
-// problem for you, or you're willing to work around them, then
-// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
-// in the code below.
-//
-// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy:
-// http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html
-// Because of that, we might as well use windows locks for
-// cygwin. They seem to be more reliable than the cygwin pthreads layer.
-//
-// TRICKY IMPLEMENTATION NOTE:
-// This class is designed to be safe to use during
-// dynamic-initialization -- that is, by global constructors that are
-// run before main() starts. The issue in this case is that
-// dynamic-initialization happens in an unpredictable order, and it
-// could be that someone else's dynamic initializer could call a
-// function that tries to acquire this mutex -- but that all happens
-// before this mutex's constructor has run. (This can happen even if
-// the mutex and the function that uses the mutex are in the same .cc
-// file.) Basically, because Mutex does non-trivial work in its
-// constructor, it's not, in the naive implementation, safe to use
-// before dynamic initialization has run on it.
-//
-// The solution used here is to pair the actual mutex primitive with a
-// bool that is set to true when the mutex is dynamically initialized.
-// (Before that it's false.) Then we modify all mutex routines to
-// look at the bool, and not try to lock/unlock until the bool makes
-// it to true (which happens after the Mutex constructor has run.)
-//
-// This works because before main() starts -- particularly, during
-// dynamic initialization -- there are no threads, so a) it's ok that
-// the mutex operations are a no-op, since we don't need locking then
-// anyway; and b) we can be quite confident our bool won't change
-// state between a call to Lock() and a call to Unlock() (that would
-// require a global constructor in one translation unit to call Lock()
-// and another global constructor in another translation unit to call
-// Unlock() later, which is pretty perverse).
-//
-// That said, it's tricky, and can conceivably fail; it's safest to
-// avoid trying to acquire a mutex in a global constructor, if you
-// can. One way it can fail is that a really smart compiler might
-// initialize the bool to true at static-initialization time (too
-// early) rather than at dynamic-initialization time. To discourage
-// that, we set is_safe_ to true in code (not the constructor
-// colon-initializer) and set it to true via a function that always
-// evaluates to true, but that the compiler can't know always
-// evaluates to true. This should be good enough.
-
-#ifndef GOOGLE_MUTEX_H_
-#define GOOGLE_MUTEX_H_
-
-#if defined(NO_THREADS)
- typedef int MutexType; // to keep a lock-count
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-# define WIN32_LEAN_AND_MEAN // We only need minimal includes
-# ifdef GMUTEX_TRYLOCK
- // We need Windows NT or later for TryEnterCriticalSection(). If you
- // don't need that functionality, you can remove these _WIN32_WINNT
- // lines, and change TryLock() to assert(0) or something.
-# ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0400
-# endif
-# endif
-// To avoid macro definition of ERROR.
-# define NOGDI
-// To avoid macro definition of min/max.
-# ifndef NOMINMAX
-# define NOMINMAX
-# endif // NOMINMAX
-# include
- typedef CRITICAL_SECTION MutexType;
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
- // Needed for pthread_rwlock_*. If it causes problems, you could take it
- // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
- // *does* cause problems for FreeBSD, or MacOSX, but isn't needed
- // for locking there.)
-# ifdef __linux__
-# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
-# endif
-# include
- typedef pthread_rwlock_t MutexType;
-#elif defined(HAVE_PTHREAD)
-# include
- typedef pthread_mutex_t MutexType;
-#else
-# error Need to implement mutex.h for your architecture, or #define NO_THREADS
-#endif
-
-// We need to include these header files after defining _XOPEN_SOURCE
-// as they may define the _XOPEN_SOURCE macro.
-#include
-#include // for abort()
-
-#define MUTEX_NAMESPACE agi
-
-namespace MUTEX_NAMESPACE {
-
-class Mutex {
- public:
- // Create a Mutex that is not held by anybody. This constructor is
- // typically used for Mutexes allocated on the heap or the stack.
- // See below for a recommendation for constructing global Mutex
- // objects.
- inline Mutex();
-
- // Destructor
- inline ~Mutex();
-
- inline void Lock(); // Block if needed until free then acquire exclusively
- inline void Unlock(); // Release a lock acquired via Lock()
-#ifdef GMUTEX_TRYLOCK
- inline bool TryLock(); // If free, Lock() and return true, else return false
-#endif
- // Note that on systems that don't support read-write locks, these may
- // be implemented as synonyms to Lock() and Unlock(). So you can use
- // these for efficiency, but don't use them anyplace where being able
- // to do shared reads is necessary to avoid deadlock.
- inline void ReaderLock(); // Block until free or shared then acquire a share
- inline void ReaderUnlock(); // Release a read share of this Mutex
- inline void WriterLock() { Lock(); } // Acquire an exclusive lock
- inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
-
- // TODO(hamaji): Do nothing, implement correctly.
- inline void AssertHeld() {}
-
- private:
- MutexType mutex_;
- // We want to make sure that the compiler sets is_safe_ to true only
- // when we tell it to, and never makes assumptions is_safe_ is
- // always true. volatile is the most reliable way to do that.
- volatile bool is_safe_;
-
- inline void SetIsSafe() { is_safe_ = true; }
-
- // Catch the error of writing Mutex when intending MutexLock.
- Mutex(Mutex* /*ignored*/) {}
- // Disallow "evil" constructors
- Mutex(const Mutex&);
- void operator=(const Mutex&);
-};
-
-// Now the implementation of Mutex for various systems
-#if defined(NO_THREADS)
-
-// When we don't have threads, we can be either reading or writing,
-// but not both. We can have lots of readers at once (in no-threads
-// mode, that's most likely to happen in recursive function calls),
-// but only one writer. We represent this by having mutex_ be -1 when
-// writing and a number > 0 when reading (and 0 when no lock is held).
-//
-// In debug mode, we assert these invariants, while in non-debug mode
-// we do nothing, for efficiency. That's why everything is in an
-// assert.
-
-Mutex::Mutex() : mutex_(0) { }
-Mutex::~Mutex() { assert(mutex_ == 0); }
-void Mutex::Lock() { assert(--mutex_ == -1); }
-void Mutex::Unlock() { assert(mutex_++ == -1); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; }
-#endif
-void Mutex::ReaderLock() { assert(++mutex_ > 0); }
-void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
-
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-
-Mutex::Mutex() { InitializeCriticalSection(&mutex_); SetIsSafe(); }
-Mutex::~Mutex() { DeleteCriticalSection(&mutex_); }
-void Mutex::Lock() { if (is_safe_) EnterCriticalSection(&mutex_); }
-void Mutex::Unlock() { if (is_safe_) LeaveCriticalSection(&mutex_); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock() { return is_safe_ ?
- TryEnterCriticalSection(&mutex_) != 0 : true; }
-#endif
-void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
-void Mutex::ReaderUnlock() { Unlock(); }
-
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-
-#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
- if (is_safe_ && fncall(&mutex_) != 0) abort(); \
-} while (0)
-
-Mutex::Mutex() {
- SetIsSafe();
- if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex() { SAFE_PTHREAD(pthread_rwlock_destroy); }
-void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock); }
-void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock() { return is_safe_ ?
- pthread_rwlock_trywrlock(&mutex_) == 0 :
- true; }
-#endif
-void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock); }
-void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#undef SAFE_PTHREAD
-
-#elif defined(HAVE_PTHREAD)
-
-#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
- if (is_safe_ && fncall(&mutex_) != 0) abort(); \
-} while (0)
-
-Mutex::Mutex() {
- SetIsSafe();
- if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex() { SAFE_PTHREAD(pthread_mutex_destroy); }
-void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock); }
-void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock() { return is_safe_ ?
- pthread_mutex_trylock(&mutex_) == 0 : true; }
-#endif
-void Mutex::ReaderLock() { Lock(); }
-void Mutex::ReaderUnlock() { Unlock(); }
-#undef SAFE_PTHREAD
-
-#endif
-
-// --------------------------------------------------------------------------
-// Some helper classes
-
-// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
-class MutexLock {
- public:
- explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
- ~MutexLock() { mu_->Unlock(); }
- private:
- Mutex * const mu_;
- // Disallow "evil" constructors
- MutexLock(const MutexLock&);
- void operator=(const MutexLock&);
-};
-
-// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
-class ReaderMutexLock {
- public:
- explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
- ~ReaderMutexLock() { mu_->ReaderUnlock(); }
- private:
- Mutex * const mu_;
- // Disallow "evil" constructors
- ReaderMutexLock(const ReaderMutexLock&);
- void operator=(const ReaderMutexLock&);
-};
-
-class WriterMutexLock {
- public:
- explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
- ~WriterMutexLock() { mu_->WriterUnlock(); }
- private:
- Mutex * const mu_;
- // Disallow "evil" constructors
- WriterMutexLock(const WriterMutexLock&);
- void operator=(const WriterMutexLock&);
-};
-
-// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
-#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
-#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
-#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
-
-} // namespace MUTEX_NAMESPACE
-
-using namespace MUTEX_NAMESPACE;
-
-#undef MUTEX_NAMESPACE
-
-#endif /* #define GOOGLE_MUTEX_H__ */
diff --git a/aegisub/libaegisub/include/libaegisub/progress.h b/aegisub/libaegisub/include/libaegisub/progress.h
deleted file mode 100644
index 9402b4728..000000000
--- a/aegisub/libaegisub/include/libaegisub/progress.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2011, Niels Martin Hansen
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-// $Id$
-
-/// @file progress.h
-/// @brief Progress bars.
-/// @ingroup libaegisub
-
-#ifndef LAG_PRE
-#include
-#endif
-
-namespace agi {
-
-class ProgressSink;
-
-class ProgressSinkFactory {
-public:
- virtual ~ProgressSinkFactory() { }
- virtual ProgressSink * create_progress_sink(const std::string &title) const = 0;
-};
-
-
-class ProgressSink {
-public:
- virtual ~ProgressSink() { }
- virtual void set_progress(int steps, int max) = 0;
- virtual void set_operation(const std::string &operation) = 0;
- virtual bool get_cancelled() const = 0;
-};
-
-
-class NullProgressSinkFactory : public ProgressSinkFactory {
-public:
- virtual ProgressSink * create_progress_sink(const std::string &title) const;
-};
-
-
-class StdioProgressSinkFactory : public ProgressSinkFactory {
-private:
-
-public:
- StdioProgressSinkFactory();
- virtual ProgressSink * create_progress_sink(const std::string &title) const;
-};
-
-} // namespace agi
diff --git a/aegisub/libmedia/Makefile b/aegisub/libmedia/Makefile
deleted file mode 100644
index 7e6097340..000000000
--- a/aegisub/libmedia/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# $Id$
-include ../Makefile.inc
-
-
-LIB_SHARED = libmedia_aegisub-3.0.so
-LIB_SHARED_INSTALL = yes
-LIB_VERSION = 3
-
-CXXFLAGS = -Iinclude -I../libaegisub/include -I../src -I.. -DMAGI -fPIC -Wno-variadic-macros
-
-PRECOMPILED_HEADER_NAME = magi_pre.h
-magi_pre.h.gch: CXXFLAGS := $(CXXFLAGS)
-
-#######################
-# AUDIO / VIDEO SUPPORT
-#######################
-ifeq (yes, $(HAVE_PROVIDER_FFMPEGSOURCE))
-SRC_OPT += audio/ffms_audio.cpp common/ffms_common.cpp video/ffms_video.cpp
-common/ffms_common.o: CXXFLAGS += $(CFLAGS_FFMPEGSOURCE) $(CFLAGS_LIBAVFORMAT) $(CFLAGS_LIBAVCODEC) $(CFLAGS_LIBSWSCALE) $(CFLAGS_LIBAVUTIL) $(CFLAGS_LIBPOSTPROC)
-audio/ffms_audio.o: CXXFLAGS += $(CFLAGS_FFMPEGSOURCE) $(CFLAGS_LIBAVFORMAT) $(CFLAGS_LIBAVCODEC) $(CFLAGS_LIBSWSCALE) $(CFLAGS_LIBAVUTIL) $(CFLAGS_LIBPOSTPROC)
-video/ffms_video.o: CXXFLAGS += $(CFLAGS_FFMPEGSOURCE) $(CFLAGS_LIBAVFORMAT) $(CFLAGS_LIBAVCODEC) $(CFLAGS_LIBSWSCALE) $(CFLAGS_LIBAVUTIL) $(CFLAGS_LIBPOSTPROC)
-LDFLAGS_POST += $(LDFLAGS_FFMPEGSOURCE)
-endif
-
-
-SRC = \
- audio/downmix.cpp \
- audio/convert.cpp \
- audio/dummy_audio.cpp \
- audio/pcm.cpp \
- cache/audio_ram.cpp \
- cache/audio_hd.cpp \
- cache/video_cache.cpp \
- common/audio_manager.cpp \
- common/video_frame.cpp \
- common/video_manager.cpp \
- video/yuv4mpeg.cpp \
- $(SRC_OPT)
-
-HEADERS = \
- */*.h \
- include/libmedia/*.h \
-
-
-include ../Makefile.target
--include */*.d
diff --git a/aegisub/libmedia/audio/avs_audio.cpp b/aegisub/libmedia/audio/avs_audio.cpp
deleted file mode 100644
index 035a420dc..000000000
--- a/aegisub/libmedia/audio/avs_audio.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2005-2006, Rodrigo Braz Monteiro, Fredrik Mellbin
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_avs.cpp
-/// @brief Avisynth-based audio provider
-/// @ingroup audio_input
-///
-
-#include "config.h"
-
-#ifdef WITH_AVISYNTH
-
-#ifndef AGI_PRE
-#include
-#include
-
-#include
-#endif
-
-#include "audio_provider_avs.h"
-#include "charset_conv.h"
-#include "compat.h"
-#include "main.h"
-#include "standard_paths.h"
-#include "utils.h"
-
-namespace media {
-
-/// @brief Constructor
-/// @param _filename
-///
-AvisynthAudioProvider::AvisynthAudioProvider(wxString filename) try : filename(filename) {
- AVSValue script;
- wxMutexLocker lock(AviSynthMutex);
-
- wxFileName fn(filename);
- if (!fn.FileExists())
- throw agi::FileNotFoundError(STD_STR(filename));
-
- // Include
- if (filename.EndsWith(_T(".avs"))) {
- char *fname = env->SaveString(fn.GetShortPath().mb_str(csConvLocal));
- script = env->Invoke("Import", fname);
- }
-
- // Use DirectShowSource
- else {
- const char * argnames[3] = { 0, "video", "audio" };
- AVSValue args[3] = { env->SaveString(fn.GetShortPath().mb_str(csConvLocal)), false, true };
-
- // Load DirectShowSource.dll from app dir if it exists
- wxFileName dsspath(StandardPaths::DecodePath(_T("?data/DirectShowSource.dll")));
- if (dsspath.FileExists()) {
- env->Invoke("LoadPlugin",env->SaveString(dsspath.GetShortPath().mb_str(csConvLocal)));
- }
-
- // Load audio with DSS if it exists
- if (env->FunctionExists("DirectShowSource")) {
- script = env->Invoke("DirectShowSource", AVSValue(args,3),argnames);
- }
- // Otherwise fail
- else {
- throw AudioOpenError("No suitable audio source filter found. Try placing DirectShowSource.dll in the Aegisub application directory.");
- }
- }
-
- LoadFromClip(script);
-}
-catch (AvisynthError &err) {
- throw AudioOpenError("Avisynth error: " + std::string(err.msg));
-}
-
-/// @brief Read from environment
-/// @param _clip
-///
-void AvisynthAudioProvider::LoadFromClip(AVSValue _clip) {
- AVSValue script;
-
- // Check if it has audio
- VideoInfo vi = _clip.AsClip()->GetVideoInfo();
- if (!vi.HasAudio()) throw AudioOpenError("No audio found.");
-
- // Convert to one channel
- char buffer[1024];
- strcpy(buffer,lagi_wxString(OPT_GET("Audio/Downmixer")->GetString()).mb_str(csConvLocal));
- script = env->Invoke(buffer, _clip);
-
- // Convert to 16 bits per sample
- script = env->Invoke("ConvertAudioTo16bit", script);
- vi = script.AsClip()->GetVideoInfo();
-
- // Convert sample rate
- int setsample = OPT_GET("Provider/Audio/AVS/Sample Rate")->GetInt();
- if (vi.SamplesPerSecond() < 32000) setsample = 44100;
- if (setsample != 0) {
- AVSValue args[2] = { script, setsample };
- script = env->Invoke("ResampleAudio", AVSValue(args,2));
- }
-
- // Set clip
- PClip tempclip = script.AsClip();
- vi = tempclip->GetVideoInfo();
-
- // Read properties
- channels = vi.AudioChannels();
- num_samples = vi.num_audio_samples;
- sample_rate = vi.SamplesPerSecond();
- bytes_per_sample = vi.BytesPerAudioSample();
-
- clip = tempclip;
-}
-
-/// @brief Get audio
-/// @param buf
-/// @param start
-/// @param count
-///
-void AvisynthAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const {
- // Requested beyond the length of audio
- if (start+count > num_samples) {
- int64_t oldcount = count;
- count = num_samples-start;
- if (count < 0) count = 0;
-
- // Fill beyond with zero
- if (bytes_per_sample == 1) {
- char *temp = (char *) buf;
- for (int i=count;iGetAudio(buf,start,count,env);
- }
-}
-#endif
-
-} // namespace
diff --git a/aegisub/libmedia/audio/avs_audio.h b/aegisub/libmedia/audio/avs_audio.h
deleted file mode 100644
index 9c7fb0d51..000000000
--- a/aegisub/libmedia/audio/avs_audio.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2005-2006, Rodrigo Braz Monteiro, Fredrik Mellbin
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_avs.h
-/// @see audio_provider_avs.cpp
-/// @ingroup audio_input
-///
-
-#ifdef WITH_AVISYNTH
-#include "include/aegisub/audio_provider.h"
-#include "avisynth_wrap.h"
-
-
-namespace media {
-
-/// DOCME
-/// @class AvisynthAudioProvider
-/// @brief DOCME
-///
-/// DOCME
-class AvisynthAudioProvider : public AudioProvider, public AviSynthWrapper {
- /// DOCME
- wxString filename;
-
- /// DOCME
- PClip clip;
-
- void LoadFromClip(AVSValue clip);
- void SetFile();
-
-public:
- AvisynthAudioProvider(wxString _filename);
-
- wxString GetFilename() const { return filename; }
-
- bool AreSamplesNativeEndian() const { return true; }
- bool NeedsCache() const { return true; }
-
- void GetAudio(void *buf, int64_t start, int64_t count) const;
- void GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int samples,float scale);
-};
-#endif
-
-} // namespace
-
diff --git a/aegisub/libmedia/audio/convert.cpp b/aegisub/libmedia/audio/convert.cpp
deleted file mode 100644
index 435921449..000000000
--- a/aegisub/libmedia/audio/convert.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-// Copyright (c) 2008, Rodrigo Braz Monteiro
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_convert.cpp
-/// @brief Intermediate sample format-converting audio provider
-/// @ingroup audio_input
-///
-
-#include "config.h"
-
-#include "aegisub_endian.h"
-#include "convert.h"
-#include "downmix.h"
-
-
-namespace media {
-
-/// @brief Constructor
-/// @param src
-///
-ConvertAudioProvider::ConvertAudioProvider(AudioProvider *src) : source(src) {
- channels = source->GetChannels();
- num_samples = source->GetNumSamples();
- sample_rate = source->GetSampleRate();
- bytes_per_sample = 2;
-
- sampleMult = 1;
- if (sample_rate < 16000) sampleMult = 4;
- else if (sample_rate < 32000) sampleMult = 2;
- sample_rate *= sampleMult;
- num_samples *= sampleMult;
-}
-
-/// @brief Convert to 16-bit
-/// @param src
-/// @param dst
-/// @param count
-///
-void ConvertAudioProvider::Make16Bit(const char *src, short *dst, int64_t count) const {
- for (int64_t i=0;i
-
-/// @brief DOCME
-/// @param src
-/// @param dst
-/// @param count
-/// @param converter
-///
-void ConvertAudioProvider::ChangeSampleRate(const short *src, short *dst, int64_t count, const SampleConverter &converter) const {
- // Upsample by 2
- if (sampleMult == 2) {
- int64_t size = count/2;
- short cur;
- short next = 0;
- for (int64_t i=0;i 0) {
- *dst++ = converter(*src++);
- }
- }
-}
-
-/// DOCME
-struct NullSampleConverter {
- inline short operator()(const short val) const {
- return val;
- }
-};
-
-/// DOCME
-struct EndianSwapSampleConverter {
- inline short operator()(const short val) const {
- return (short)Endian::Reverse((uint16_t)val);
- };
-};
-
-
-/// @brief Get audio
-/// @param destination
-/// @param start
-/// @param count
-///
-void ConvertAudioProvider::GetAudio(void *destination, int64_t start, int64_t count) const {
- // Bits per sample
- int srcBps = source->GetBytesPerSample();
-
- // Nothing to do
- if (sampleMult == 1 && srcBps == 2) {
- source->GetAudio(destination,start,count);
- }
-
- // Convert
- else {
- // Allocate buffers with sufficient size for the entire operation
- size_t fullSize = count;
- int64_t srcCount = count / sampleMult;
- short *buffer1 = NULL;
- short *buffer2 = NULL;
- short *last = NULL;
-
- // Read audio
- buffer1 = new short[fullSize * channels];
- source->GetAudio(buffer1,start/sampleMult,srcCount);
-
- // Convert from 8-bit to 16-bit
- if (srcBps == 1) {
- if (sampleMult == 1) {
- Make16Bit((const char*)buffer1,(short*)destination,srcCount * channels);
- }
- else {
- buffer2 = new short[fullSize * channels];
- Make16Bit((const char*)buffer1,buffer2,srcCount * channels);
- last = buffer2;
- }
- }
-
- // Already 16-bit
- else if (srcBps == 2) last = buffer1;
-
- // Convert sample rate
- if (sampleMult != 1 && source->AreSamplesNativeEndian()) {
- ChangeSampleRate(last,(short*)destination,count * channels, NullSampleConverter());
- }
- else if (!source->AreSamplesNativeEndian()) {
- ChangeSampleRate(last,(short*)destination,count * channels, EndianSwapSampleConverter());
- }
-
- delete [] buffer1;
- delete [] buffer2;
- }
-}
-
-
-/// @brief See if we need to downmix the number of channels
-/// @param source_provider
-///
-AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider) {
- AudioProvider *provider = source_provider;
-
- // Aegisub requires 16 bit samples,
- // some audio players break with low samplerates,
- // everything breaks with wrong-ended samples.
- if (provider->GetBytesPerSample() != 2 ||
- provider->GetSampleRate() < 32000 ||
- !provider->AreSamplesNativeEndian())
- {
- // @todo add support for more bitdepths (i.e. 24- and 32-bit audio)
- if (provider->GetBytesPerSample() > 2)
- throw AudioOpenError("Audio format converter: audio with bitdepths greater than 16 bits/sample is currently unsupported");
-
- provider = new ConvertAudioProvider(provider);
- }
-
- // We also require mono audio for historical reasons
- if (provider->GetChannels() != 1)
- {
- provider = new DownmixingAudioProvider(provider);
- }
-
- return provider;
-}
-
-} // namespace
-
diff --git a/aegisub/libmedia/audio/convert.h b/aegisub/libmedia/audio/convert.h
deleted file mode 100644
index d66c6d9c8..000000000
--- a/aegisub/libmedia/audio/convert.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) 2008, Rodrigo Braz Monteiro
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_convert.h
-/// @see audio_provider_convert.cpp
-/// @ingroup audio_input
-///
-
-#include "libmedia/audio.h"
-
-#ifndef AGI_PRE
-#include
-#endif
-
-namespace media {
-
-/// DOCME
-/// @class ConvertAudioProvider
-/// @brief DOCME
-///
-/// DOCME
-class ConvertAudioProvider : public AudioProvider {
- /// DOCME
- int sampleMult;
-
- /// DOCME
- std::tr1::shared_ptr source;
- void Make16Bit(const char *src, short *dst, int64_t count) const;
- template
- void ChangeSampleRate(const short *src, short *dst, int64_t count, const SampleConverter &converter) const;
-
-public:
- ConvertAudioProvider(AudioProvider *source);
-
- /// By its nature, the ConvertAudioProvider always delivers machine endian.
- /// That's one of the points of it!
- bool AreSamplesNativeEndian() const { return true; }
-
- void GetAudio(void *buf, int64_t start, int64_t count) const;
-
- std::string GetFilename() const { return source->GetFilename(); }
-};
-
-AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider);
-
-} // namespace
-
diff --git a/aegisub/libmedia/audio/downmix.cpp b/aegisub/libmedia/audio/downmix.cpp
deleted file mode 100644
index 9c2ac6614..000000000
--- a/aegisub/libmedia/audio/downmix.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2007-2008, Niels Martin Hansen
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_downmix.cpp
-/// @brief Intermediate audio provider downmixing the signal to mono
-/// @ingroup audio_input
-///
-
-
-//////////////////
-// Headers
-#include "config.h"
-
-#include "downmix.h"
-
-
-namespace media {
-
-/// @brief Constructor
-/// @param source
-///
-DownmixingAudioProvider::DownmixingAudioProvider(AudioProvider *source) : provider(source) {
- filename = source->GetFilename();
- channels = 1; // target
- src_channels = source->GetChannels();
- num_samples = source->GetNumSamples();
- bytes_per_sample = source->GetBytesPerSample();
- sample_rate = source->GetSampleRate();
-
- if (!(bytes_per_sample == 1 || bytes_per_sample == 2))
- throw AudioOpenError("Downmixing Audio Provider: Can only downmix 8 and 16 bit audio");
- if (!source->AreSamplesNativeEndian())
- throw AudioOpenError("Downmixing Audio Provider: Source must have machine endian samples");
-}
-
-/// @brief Actual work happens here
-/// @param buf
-/// @param start
-/// @param count
-///
-void DownmixingAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const {
- if (count == 0) return;
-
- // We can do this ourselves
- if (start >= num_samples) {
- if (bytes_per_sample == 1)
- // 8 bit formats are usually unsigned with bias 127
- memset(buf, 127, count);
- else
- // While everything else is signed
- memset(buf, 0, count*bytes_per_sample);
-
- return;
- }
-
- // So alloc some temporary memory for this
- // Depending on use, this might be made faster by using
- // a pre-allocced block of memory...?
- char *tmp = new char[count*bytes_per_sample*src_channels];
-
- try {
- provider->GetAudio(tmp, start, count);
- }
- catch (...) {
- delete tmp;
- throw;
- }
-
- // Now downmix
- // Just average the samples over the channels (really bad if they're out of phase!)
- // XXX: Assuming here that sample data are in machine endian, an upstream provider should ensure that
- if (bytes_per_sample == 1) {
- uint8_t *src = (uint8_t *)tmp;
- uint8_t *dst = (uint8_t *)buf;
-
- while (count > 0) {
- int sum = 0;
- for (int c = 0; c < src_channels; c++)
- sum += *(src++);
- *(dst++) = (uint8_t)(sum / src_channels);
- count--;
- }
- }
- else if (bytes_per_sample == 2) {
- int16_t *src = (int16_t *)tmp;
- int16_t *dst = (int16_t *)buf;
-
- while (count > 0) {
- int sum = 0;
- for (int c = 0; c < src_channels; c++)
- sum += *(src++);
- *(dst++) = (int16_t)(sum / src_channels);
- count--;
- }
- }
-
- // Done downmixing, free the work buffer
- delete[] tmp;
-}
-
-} // namespace
-
diff --git a/aegisub/libmedia/audio/downmix.h b/aegisub/libmedia/audio/downmix.h
deleted file mode 100644
index 88fe3d6a7..000000000
--- a/aegisub/libmedia/audio/downmix.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2007-2008, Niels Martin Hansen
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_downmix.h
-/// @see audio_provider_downmix.cpp
-/// @ingroup audio_input
-///
-
-#include "libmedia/audio.h"
-
-#ifndef AGI_PRE
-#include
-#endif
-
-namespace media {
-
-/// DOCME
-/// @class DownmixingAudioProvider
-/// @brief DOCME
-///
-/// DOCME
-class DownmixingAudioProvider : public AudioProvider {
- std::tr1::shared_ptr provider;
-
- /// DOCME
- int src_channels;
-public:
- DownmixingAudioProvider(AudioProvider *source);
-
- /// @brief Downmixing requires samples to be native endian beforehand
- ///
- bool AreSamplesNativeEndian() const { return true; }
-
- void GetAudio(void *buf, int64_t start, int64_t count) const;
-};
-
-} // namespace
-
diff --git a/aegisub/libmedia/audio/dummy_audio.cpp b/aegisub/libmedia/audio/dummy_audio.cpp
deleted file mode 100644
index 501b6c20b..000000000
--- a/aegisub/libmedia/audio/dummy_audio.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2005-2006, Rodrigo Braz Monteiro, Fredrik Mellbin
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_dummy.cpp
-/// @brief Dummy (silence or noise) audio provider
-/// @ingroup audio_input
-///
-
-#include "config.h"
-
-#include "dummy_audio.h"
-
-
-namespace media {
-
-/// @brief Constructor
-/// @param dur_ms
-/// @param _noise
-///
-DummyAudioProvider::DummyAudioProvider(unsigned long dur_ms, bool _noise) {
- noise = _noise;
- channels = 1;
- sample_rate = 44100;
- bytes_per_sample = 2;
- num_samples = (int64_t)dur_ms * sample_rate / 1000;
-}
-
-/// @brief Destructor
-///
-DummyAudioProvider::~DummyAudioProvider() {
-}
-
-/// @brief Get audio
-/// @param buf
-/// @param start
-/// @param count
-///
-void DummyAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const {
- short *workbuf = (short*)buf;
-
- if (noise) {
- while (--count > 0)
- *workbuf++ = (rand() - RAND_MAX/2) * 10000 / RAND_MAX;
- }
- else {
- while (--count > 0)
- *workbuf++ = 0;
- }
-}
-
-} // namespace
-
diff --git a/aegisub/libmedia/audio/dummy_audio.h b/aegisub/libmedia/audio/dummy_audio.h
deleted file mode 100644
index 0f40d8ed5..000000000
--- a/aegisub/libmedia/audio/dummy_audio.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2006, Niels Martin Hansen
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_dummy.h
-/// @see audio_provider_dummy.cpp
-/// @ingroup audio_input
-///
-
-#include "libmedia/audio.h"
-
-namespace media {
-
-/// DOCME
-/// @class DummyAudioProvider
-/// @brief DOCME
-///
-/// DOCME
-class DummyAudioProvider : public AudioProvider {
- /// DOCME
- bool noise;
-
-public:
- DummyAudioProvider(unsigned long dur_ms, bool _noise);
- ~DummyAudioProvider();
-
- bool AreSamplesNativeEndian() const { return true; }
- void GetAudio(void *buf, int64_t start, int64_t count) const;
-};
-
-} // namespace
-
diff --git a/aegisub/libmedia/audio/ffms_audio.cpp b/aegisub/libmedia/audio/ffms_audio.cpp
deleted file mode 100644
index c1eb0e7f7..000000000
--- a/aegisub/libmedia/audio/ffms_audio.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-// Copyright (c) 2008-2009, Karl Blomster
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-// $Id$
-
-/// @file ffms_audio.cpp
-/// @brief FFmpegSource Audio support.
-/// @ingroup fmms audio
-
-
-#include "config.h"
-
-#ifndef AGI_PRE
-#endif
-
-#include "ffms_audio.h"
-#include "libmedia/audio.h"
-
-
-namespace media {
- namespace ffms {
-
-
-/// @brief Constructor
-/// @param filename
-///
-FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(std::string filename)
-: AudioSource(NULL)
-, COMInited(false)
-{
-#ifdef WIN32
- HRESULT res;
- res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- if (SUCCEEDED(res))
- COMInited = true;
- else if (res != RPC_E_CHANGED_MODE)
- throw AudioOpenError("COM initialization failure");
-#endif
- // initialize ffmpegsource
- // FIXME: CPU detection?
-#if FFMS_VERSION >= ((2 << 24) | (14 << 16) | (0 << 8) | 0)
- FFMS_Init(0, 1);
-#else
- FFMS_Init(0);
-#endif
-
- ErrInfo.Buffer = FFMSErrMsg;
- ErrInfo.BufferSize = sizeof(FFMSErrMsg);
- ErrInfo.ErrorType = FFMS_ERROR_SUCCESS;
- ErrInfo.SubType = FFMS_ERROR_SUCCESS;
-// SetLogLevel();
-
- try {
- LoadAudio(filename);
- } catch (...) {
- Close();
- throw;
- }
-}
-
-/// @brief Load audio file
-/// @param filename
-///
-void FFmpegSourceAudioProvider::LoadAudio(std::string filename) {
-// wxString FileNameShort = wxFileName(filename).GetShortPath();
-
- FFMS_Indexer *Indexer = FFMS_CreateIndexer(filename.c_str(), &ErrInfo);
- if (Indexer == NULL) {
- throw agi::FileNotFoundError(ErrInfo.Buffer);
- }
-
- std::map TrackList = GetTracksOfType(Indexer, FFMS_TYPE_AUDIO);
- if (TrackList.size() <= 0)
- throw AudioOpenError("no audio tracks found");
-
- // initialize the track number to an invalid value so we can detect later on
- // whether the user actually had to choose a track or not
- int TrackNumber = -1;
- if (TrackList.size() > 1) {
- TrackNumber = AskForTrackSelection(TrackList, FFMS_TYPE_AUDIO);
- // if it's still -1 here, user pressed cancel
- if (TrackNumber == -1)
- throw agi::UserCancelException("audio loading cancelled by user");
- }
-
- // generate a name for the cache file
- std::string CacheName = GetCacheFilename(filename);
-
- // try to read index
- FFMS_Index *Index = NULL;
- Index = FFMS_ReadIndex(CacheName.c_str(), &ErrInfo);
- bool IndexIsValid = false;
- if (Index != NULL) {
- if (FFMS_IndexBelongsToFile(Index, filename.c_str(), &ErrInfo)) {
- FFMS_DestroyIndex(Index);
- Index = NULL;
- }
- else
- IndexIsValid = true;
- }
-
- // index valid but track number still not set?
- if (IndexIsValid) {
- // track number not set? just grab the first track
- if (TrackNumber < 0)
- TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo);
- if (TrackNumber < 0) {
- FFMS_DestroyIndex(Index);
- Index = NULL;
- throw AudioOpenError(std::string("Couldn't find any audio tracks: ") + ErrInfo.Buffer);
- }
-
- // index is valid and track number is now set,
- // but do we have indexing info for the desired audio track?
- FFMS_Track *TempTrackData = FFMS_GetTrackFromIndex(Index, TrackNumber);
- if (FFMS_GetNumFrames(TempTrackData) <= 0) {
- IndexIsValid = false;
- FFMS_DestroyIndex(Index);
- Index = NULL;
- }
- }
- // no valid index exists and the file only has one audio track, index it
- else if (TrackNumber < 0)
- TrackNumber = FFMS_TRACKMASK_ALL;
- // else: do nothing (keep track mask as it is)
-
- // moment of truth
- if (!IndexIsValid) {
- int TrackMask;
-// if (OPT_GET("Provider/FFmpegSource/Index All Tracks")->GetBool() || TrackNumber == FFMS_TRACKMASK_ALL)
- if (TrackNumber == FFMS_TRACKMASK_ALL)
- TrackMask = FFMS_TRACKMASK_ALL;
- else
- TrackMask = (1 << TrackNumber);
-
- try {
- Index = DoIndexing(Indexer, CacheName, TrackMask, GetErrorHandlingMode());
- }
- catch (std::string const& err) {
- throw AudioOpenError(err);
- }
-
- // if tracknumber still isn't set we need to set it now
- if (TrackNumber == FFMS_TRACKMASK_ALL)
- TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo);
- }
-
- // update access time of index file so it won't get cleaned away
-///XXX: Add something to libaegisub to support this.
-// if (!wxFileName(CacheName).Touch()) {
- // warn user?
-// }
-
-#if FFMS_VERSION >= ((2 << 24) | (14 << 16) | (1 << 8) | 0)
- AudioSource = FFMS_CreateAudioSource(filename.c_str(), TrackNumber, Index, -1, &ErrInfo);
-#else
- AudioSource = FFMS_CreateAudioSource(filename.c_str(), TrackNumber, Index, &ErrInfo);
-#endif
- FFMS_DestroyIndex(Index);
- Index = NULL;
- if (!AudioSource) {
- throw AudioOpenError(std::string("Failed to open audio track: %s") + ErrInfo.Buffer);
- }
-
- const FFMS_AudioProperties AudioInfo = *FFMS_GetAudioProperties(AudioSource);
-
- channels = AudioInfo.Channels;
- sample_rate = AudioInfo.SampleRate;
- num_samples = AudioInfo.NumSamples;
- if (channels <= 0 || sample_rate <= 0 || num_samples <= 0)
- throw AudioOpenError("sanity check failed, consult your local psychiatrist");
-
- // FIXME: use the actual sample format too?
- // why not just bits_per_sample/8? maybe there's some oddball format with half bytes out there somewhere...
- switch (AudioInfo.BitsPerSample) {
- case 8: bytes_per_sample = 1; break;
- case 16: bytes_per_sample = 2; break;
- case 24: bytes_per_sample = 3; break;
- case 32: bytes_per_sample = 4; break;
- default:
- throw AudioOpenError("unknown or unsupported sample format");
- }
-}
-
-/// @brief Destructor
-///
-FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
- Close();
-}
-
-/// @brief Clean up
-///
-void FFmpegSourceAudioProvider::Close() {
- if (AudioSource) FFMS_DestroyAudioSource(AudioSource);
-#ifdef WIN32
- if (COMInited)
- CoUninitialize();
-#endif
-}
-
-/// @brief Get audio
-/// @param Buf
-/// @param Start
-/// @param Count
-///
-void FFmpegSourceAudioProvider::GetAudio(void *Buf, int64_t Start, int64_t Count) const {
- if (FFMS_GetAudio(AudioSource, Buf, Start, Count, &ErrInfo)) {
- throw AudioDecodeError(std::string("Failed to get audio samples: ") + ErrInfo.Buffer);
- }
-}
- } // namespace ffms
-} // namespace media
-
-
diff --git a/aegisub/libmedia/audio/ffms_audio.h b/aegisub/libmedia/audio/ffms_audio.h
deleted file mode 100644
index fa34d29ea..000000000
--- a/aegisub/libmedia/audio/ffms_audio.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2008-2009, Karl Blomster
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-// $Id$
-
-/// @file ffms_audio.h
-/// @brief FFmpegSource Audio support.
-/// @ingroup fmms audio
-
-#include "../../libffms/include/ffms.h"
-#include
-
-#ifndef AGI_PRE
-#ifdef WIN32
-#include
-#endif
-
-#include