From f0aa85dfbbc8f5fada922b20198c33d1c424eb86 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 27 Jul 2010 03:52:40 +0000 Subject: [PATCH] Delete the quicktime provider, as it's unmaintained and doesn't work Originally committed to SVN as r4715. --- .../aegisub_vs2008/aegisub_vs2008.vcproj | 24 -- aegisub/configure.in | 12 - aegisub/src/Makefile.am | 8 - aegisub/src/audio_provider.cpp | 6 - aegisub/src/audio_provider_quicktime.cpp | 205 -------------- aegisub/src/audio_provider_quicktime.h | 115 -------- aegisub/src/config/config_windows0.h | 6 - aegisub/src/quicktime_common.cpp | 166 ------------ aegisub/src/quicktime_common.h | 102 ------- aegisub/src/setup.cpp | 4 - aegisub/src/video_provider_manager.cpp | 6 - aegisub/src/video_provider_quicktime.cpp | 256 ------------------ aegisub/src/video_provider_quicktime.h | 131 --------- 13 files changed, 1041 deletions(-) delete mode 100644 aegisub/src/audio_provider_quicktime.cpp delete mode 100644 aegisub/src/audio_provider_quicktime.h delete mode 100644 aegisub/src/quicktime_common.cpp delete mode 100644 aegisub/src/quicktime_common.h delete mode 100644 aegisub/src/video_provider_quicktime.cpp delete mode 100644 aegisub/src/video_provider_quicktime.h diff --git a/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj b/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj index 910adf689..7f4596bb5 100644 --- a/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj +++ b/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj @@ -507,14 +507,6 @@ RelativePath="..\..\src\audio_provider_pcm.h" > - - - - @@ -611,14 +603,6 @@ RelativePath="..\..\src\mkv_wrap.h" > - - - - @@ -1435,14 +1419,6 @@ RelativePath="..\..\src\video_provider_manager.h" > - - - - diff --git a/aegisub/configure.in b/aegisub/configure.in index 9f216223d..9d35cfa52 100644 --- a/aegisub/configure.in +++ b/aegisub/configure.in @@ -777,18 +777,6 @@ AC_SUBST(LIBPOSTPROC_LIBS) AC_SUBST(LIBPOSTPROC_CFLAGS) -################### -# QuickTime Support -# (mac/windows only) -################### - -AM_CONDITIONAL([HAVE_QUICKTIME], [test "$build_darwin" = "yes"]) - -if test "$build_darwin" = "yes"; then - AC_DEFINE([WITH_QUICKTIME], [1], [QuickTime support.]), -fi - - ################### # Subtitle Provider ################### diff --git a/aegisub/src/Makefile.am b/aegisub/src/Makefile.am index da869c033..a2defeaa3 100644 --- a/aegisub/src/Makefile.am +++ b/aegisub/src/Makefile.am @@ -95,14 +95,6 @@ aegisub_2_2_LDADD += libaudiovideo_ffmpegsource.a ../libffms/libffmpegsource_aeg aegisub_2_2_LDFLAGS += @LIBPOSTPROC_LIBS@ endif -if HAVE_QUICKTIME -noinst_LIBRARIES += libaudiovideo_quicktime.a -libaudiovideo_quicktime_a_SOURCES = audio_provider_quicktime.cpp quicktime_common.cpp video_provider_quicktime.cpp -libaudiovideo_quicktime_a_CPPFLAGS = -I/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/QuickTime.framework/Versions/A/Headers -aegisub_2_2_LDADD += libaudiovideo_quicktime.a -aegisub_2_2_LDFLAGS += -framework QuickTime -endif - noinst_LIBRARIES += libsubtitle_provider.a libsubtitle_provider_a_SOURCES = subtitles_provider.cpp libsubtitle_provider_a_CPPFLAGS = @CSRI_CFLAGS@ diff --git a/aegisub/src/audio_provider.cpp b/aegisub/src/audio_provider.cpp index 75f242763..417ad9e87 100644 --- a/aegisub/src/audio_provider.cpp +++ b/aegisub/src/audio_provider.cpp @@ -53,9 +53,6 @@ #endif #include "audio_provider_hd.h" #include "audio_provider_pcm.h" -#ifdef WITH_QUICKTIME -#include "audio_provider_quicktime.h" -#endif #include "audio_provider_ram.h" #include "compat.h" #include "main.h" @@ -318,9 +315,6 @@ void AudioProviderFactoryManager::RegisterProviders() { #ifdef WITH_FFMPEGSOURCE RegisterFactory(new FFmpegSourceAudioProviderFactory(),_T("FFmpegSource")); #endif -#ifdef WITH_QUICKTIME - RegisterFactory(new QuickTimeAudioProviderFactory(), _T("QuickTime")); -#endif } diff --git a/aegisub/src/audio_provider_quicktime.cpp b/aegisub/src/audio_provider_quicktime.cpp deleted file mode 100644 index 68b75a612..000000000 --- a/aegisub/src/audio_provider_quicktime.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright (c) 2009, Karl Blomster -// 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_quicktime.cpp -/// @brief QuickTime-based audio provider -/// @ingroup audio_input quicktime -/// - - -#include "config.h" - -#ifdef WITH_QUICKTIME - -#include - -#include "audio_provider_quicktime.h" - - -/// @brief DOCME -/// @param filename -/// -QuickTimeAudioProvider::QuickTimeAudioProvider(wxString filename) { - movie = NULL; - in_dataref = NULL; - extract_ref = NULL; - inited = false; - qt_err = noErr; - qt_status = noErr; - errmsg = _T("QuickTime audio provider: "); - - // try to init quicktime - try { - InitQuickTime(); - } - catch (wxString temp) { - errmsg.Append(temp); - throw errmsg; - } - catch (...) { - throw; - } - - // try to load audio - try { - LoadAudio(filename); - } - catch (wxString temp) { - errmsg.Append(temp); - throw errmsg; - } - catch (...) { - throw; - } -} - - - -/// @brief DOCME -/// -QuickTimeAudioProvider::~QuickTimeAudioProvider() { - Close(); - DeInitQuickTime(); -} - - - -/// @brief DOCME -/// -void QuickTimeAudioProvider::Close() { - if (movie) - DisposeMovie(movie); - movie = NULL; - if (in_dataref) - DisposeHandle(in_dataref); - in_dataref = NULL; - if (inited) - MovieAudioExtractionEnd(extract_ref); - inited = false; -} - - - -/// @brief DOCME -/// @param filename -/// -void QuickTimeAudioProvider::LoadAudio(wxString filename) { - OSType in_dataref_type; - wxStringToDataRef(filename, &in_dataref, &in_dataref_type); - - // verify that file is openable - if (!CanOpen(in_dataref, in_dataref_type)) - throw wxString(_T("QuickTime cannot open file as audio")); - - // actually open file - short res_id = 0; - qt_err = NewMovieFromDataRef(&movie, 0, &res_id, in_dataref, in_dataref_type); - QTCheckError(qt_err, wxString(_T("Failed to open file"))); - - // disable automagic screen rendering just to be safe - qt_err = SetMovieVisualContext(movie, NULL); - QTCheckError(qt_err, wxString(_T("Failed to disable visual context"))); - - qt_status = MovieAudioExtractionBegin(movie, 0, &extract_ref); - QTCheckError(qt_status, wxString(_T("Failed to initialize audio extraction"))); - inited = true; - - // and here I thought I knew what "verbose" meant... - AudioStreamBasicDescription asbd; - qt_status = MovieAudioExtractionGetProperty(extract_ref, kQTPropertyClass_MovieAudioExtraction_Audio, - kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, sizeof(asbd), &asbd, NULL); - QTCheckError(qt_status, wxString(_T("Failed to retreive audio properties"))); - - sample_rate = (int)asbd.mSampleRate; - channels = 1; // FIXME: allow more than one channel - bytes_per_sample = 2; - - // lazy hack: set the movie time scale to same as the sample rate, to allow for easy seeking - SetMovieTimeScale(movie, (TimeScale)asbd.mSampleRate); - num_samples = GetMovieDuration(movie); - - asbd.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked | kAudioFormatFlagsNativeEndian; - asbd.mBitsPerChannel = sizeof(int16_t) * 8; - asbd.mBytesPerFrame = sizeof(int16_t); - asbd.mBytesPerPacket = asbd.mBytesPerFrame; - asbd.mChannelsPerFrame = 1; - - qt_status = MovieAudioExtractionSetProperty(extract_ref, kQTPropertyClass_MovieAudioExtraction_Audio, - kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, sizeof(asbd), &asbd); - QTCheckError(qt_status, wxString(_T("Failed to set audio properties"))); - - AudioChannelLayout ch_layout; - ch_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Mono; - ch_layout.mChannelBitmap = 0; - ch_layout.mNumberChannelDescriptions = 0; - qt_status = MovieAudioExtractionSetProperty(extract_ref, kQTPropertyClass_MovieAudioExtraction_Audio, - kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, sizeof(ch_layout), &ch_layout); - QTCheckError(qt_status, wxString(_T("Failed to set channel layout"))); -} - - - -/// @brief DOCME -/// @param buf -/// @param start -/// @param count -/// -void QuickTimeAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { - TimeRecord trec; - trec.scale = GetMovieTimeScale(movie); - trec.base = NULL; - trec.value.hi = (int32_t)(start >> 32); - trec.value.lo = (int32_t)((start & 0xFFFFFFFF00000000ULL) >> 32); - - qt_status = MovieAudioExtractionSetProperty(extract_ref, kQTPropertyClass_MovieAudioExtraction_Movie, - kQTMovieAudioExtractionMoviePropertyID_CurrentTime, sizeof(TimeRecord), &trec); - QTCheckError(qt_status, wxString(_T("QuickTime audio provider: Failed to seek in file"))); - - // FIXME: hack something up to actually handle very big counts correctly, - // maybe with multiple buffers? - AudioBufferList dst_buflist; - dst_buflist.mNumberBuffers = 1; - dst_buflist.mBuffers[0].mNumberChannels = 1; - dst_buflist.mBuffers[0].mDataByteSize = count * bytes_per_sample; - dst_buflist.mBuffers[0].mData = buf; - - UInt32 flags; - UInt32 decode_count = (UInt32)count; - qt_status = MovieAudioExtractionFillBuffer(extract_ref, &decode_count, &dst_buflist, &flags); - QTCheckError(qt_status, wxString(_T("QuickTime audio provider: Failed to decode audio"))); - - LOG_W_IF(count != decode_count, "audio/provider/quicktime") << "decoded samplecount " << decode_count << "not same as requested count" << (uint32_t)count); -} - - -#endif /* WITH_QUICKTIME */ - - diff --git a/aegisub/src/audio_provider_quicktime.h b/aegisub/src/audio_provider_quicktime.h deleted file mode 100644 index 0ead5ca12..000000000 --- a/aegisub/src/audio_provider_quicktime.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2009, Karl Blomster -// 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_quicktime.h -/// @see audio_provider_quicktime.cpp -/// @ingroup audio_input quicktime -/// - - -#ifdef WITH_QUICKTIME -#include "quicktime_common.h" - -#ifndef AGI_PRE -#include -#endif - -#include "include/aegisub/audio_provider.h" - - - -/// DOCME -/// @class QuickTimeAudioProvider -/// @brief DOCME -/// -/// DOCME -class QuickTimeAudioProvider : public AudioProvider, QuickTimeProvider { -private: - - /// DOCME - Movie movie; // input file - - /// DOCME - Handle in_dataref; // input file handle - - /// DOCME - MovieAudioExtractionRef extract_ref; // extraction session object - - - /// DOCME - bool inited; - - - /// DOCME - OSErr qt_err; // quicktime error code - - /// DOCME - OSStatus qt_status; // another quicktime error code - - /// DOCME - wxString errmsg; // aegisub error messages - - void Close(); - void LoadAudio(wxString filename); - -public: - QuickTimeAudioProvider(wxString filename); - virtual ~QuickTimeAudioProvider(); - - - /// @brief DOCME - /// @return - /// - bool AreSamplesNativeEndian() { return true; } - - virtual void GetAudio(void *buf, int64_t start, int64_t count); -}; - - - -/// DOCME -/// @class QuickTimeAudioProviderFactory -/// @brief DOCME -/// -/// DOCME -class QuickTimeAudioProviderFactory : public AudioProviderFactory { -public: - - /// @brief DOCME - /// @param file - /// - AudioProvider *CreateProvider(wxString file) { return new QuickTimeAudioProvider(file); } -}; - - -#endif /* WITH_QUICKTIME */ - - diff --git a/aegisub/src/config/config_windows0.h b/aegisub/src/config/config_windows0.h index 0438f3d2d..d0e31b26a 100644 --- a/aegisub/src/config/config_windows0.h +++ b/aegisub/src/config/config_windows0.h @@ -155,9 +155,3 @@ // Display trace-level diagnostic messages during startup // Only enable for making special builds for end users having trouble with starting Aegisub //#define WITH_STARTUPLOG - - -// Enable QuickTime video provider -// Requires QuickTime SDK and (on Windows) a QuickTime7 (or later) installation -//#define WITH_QUICKTIME - diff --git a/aegisub/src/quicktime_common.cpp b/aegisub/src/quicktime_common.cpp deleted file mode 100644 index cb163040d..000000000 --- a/aegisub/src/quicktime_common.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) 2009, Karl Blomster -// 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 quicktime_common.cpp -/// @brief Common code between QuickTime-based video and audio providers -/// @ingroup quicktime -/// - - -#include "config.h" - -#ifdef WITH_QUICKTIME - -#ifndef AGI_PRE -#include -#include -#endif - -#include "quicktime_common.h" - -/// DOCME -int QuickTimeProvider::qt_initcount = 0; - -/// DOCME -GWorldPtr QuickTimeProvider::default_gworld = NULL; - - - -/// @brief DOCME -/// -void QuickTimeProvider::InitQuickTime() { - OSErr qt_err; -#ifdef WIN32 - qt_err = InitializeQTML(0L); - QTCheckError(qt_err, wxString(_T("Failed to initialize QTML (do you have QuickTime installed?)"))); -#endif - - qt_err = EnterMovies(); - QTCheckError(qt_err, wxString(_T("EnterMovies failed"))); - - // have we been inited before? - if (qt_initcount <= 0) { - // We haven't, allocate an offscreen render target. - // We need to do this before we actually open anything, or quicktime may crash. (heh) - Rect def_box; - def_box.top = 0; - def_box.left = 0; - def_box.bottom = 320; // pick some random dimensions for now; - def_box.right = 240; // we won't actually use this buffer to render anything - QDErr qd_err = NewGWorld(&default_gworld, 32, &def_box, NULL, NULL, keepLocal); - if (qd_err != noErr) - throw wxString(_T("Failed to initialize temporary offscreen drawing buffer")); - SetGWorld(default_gworld, NULL); - } - - qt_initcount++; -} - - - -/// @brief DOCME -/// -void QuickTimeProvider::DeInitQuickTime() { -#ifdef WIN32 - // calls to InitializeQTML() must be balanced with an equal number of calls to TerminateQTML() - TerminateQTML(); -#endif - qt_initcount--; - - if (qt_initcount <= 0) { - ExitMovies(); - DisposeGWorld(default_gworld); - } -} - - - -/// @brief convert a wxstring containing a filename to a QT data reference -/// @param string -/// @param dataref -/// @param dataref_type -/// -void QuickTimeProvider::wxStringToDataRef(const wxString &string, Handle *dataref, OSType *dataref_type) { - // convert filename, first to a CFStringRef... - wxString wx_filename = wxFileName(string).GetShortPath(); - CFStringRef qt_filename = CFStringCreateWithCString(NULL, wx_filename.utf8_str(), kCFStringEncodingUTF8); - - // and then to a data reference - OSErr qt_err = QTNewDataReferenceFromFullPathCFString(qt_filename, kQTNativeDefaultPathStyle, 0, - dataref, dataref_type); - QTCheckError(qt_err, wxString(_T("Failed to convert filename to data reference"))); -} - - - -/// @brief check if this error code signifies an error, and if it does, throw an exception -/// @param err -/// @param errmsg -/// -void QuickTimeProvider::QTCheckError(OSErr err, wxString errmsg) { - if (err != noErr) - throw errmsg; - /* CheckError(err, errmsg.c_str()); // I wonder if this actually works on Mac, and if so, what it does */ -} - -/// @brief DOCME -/// @param err -/// @param errmsg -/// @return -/// -void QuickTimeProvider::QTCheckError(OSStatus err, wxString errmsg) { - if (err != noErr) - throw errmsg; -} - - - -/// @brief return true if QT considers file openable -/// @param dataref -/// @param dataref_type -/// -bool QuickTimeProvider::CanOpen(const Handle& dataref, const OSType dataref_type) { - Boolean can_open; - Boolean prefer_img; - OSErr qt_err = CanQuickTimeOpenDataRef(dataref, dataref_type, NULL, &can_open, &prefer_img, 0); - QTCheckError(qt_err, wxString(_T("Checking if file is openable failed"))); - - // don't bother trying to open things quicktime considers images - if (can_open && !prefer_img) - return true; - else - return false; -} - - -#endif /* WITH_QUICKTIME */ - - diff --git a/aegisub/src/quicktime_common.h b/aegisub/src/quicktime_common.h deleted file mode 100644 index e58d45bde..000000000 --- a/aegisub/src/quicktime_common.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2009, Karl Blomster -// 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 quicktime_common.h -/// @see quicktime_common.cpp -/// @ingroup quicktime -/// - - - -#include "config.h" - -#ifdef WITH_QUICKTIME - -#ifndef AGI_PRE -#include -#endif - -#include "include/aegisub/aegisub.h" - - -// QT stuff -#ifdef _MSC_VER - -/// DOCME -#define _STDINT_H // avoid conflicts between MSVC's stdint.h and QT's stdint.h -#pragma warning(disable: 4004) // get MSVC to shut up about a macro redefinition in QT's ConditionalMacros.h -#endif -extern "C" { -#ifdef WIN32 -#include -#include -#include -#include -#else -#include // not sure about this path, someone on mac needs to test it -#endif -} - - - -/// DOCME -/// @class QuickTimeProvider -/// @brief DOCME -/// -/// DOCME -class QuickTimeProvider { -public: - void InitQuickTime(); - void DeInitQuickTime(); - void wxStringToDataRef(const wxString &string, Handle *dataref, OSType *dataref_type); - bool CanOpen(const Handle& dataref, const OSType dataref_type); - - - void QTCheckError(OSErr err, wxString errmsg); - void QTCheckError(OSStatus err, wxString errmsg); - - - /// DOCME - static int qt_initcount; - - /// DOCME - static GWorldPtr default_gworld; - - - /// @brief DOCME - /// - virtual ~QuickTimeProvider() {}; -}; - -#endif /* WITH_QUICKTIME */ - - - diff --git a/aegisub/src/setup.cpp b/aegisub/src/setup.cpp index d657a7abe..d1e6a8035 100644 --- a/aegisub/src/setup.cpp +++ b/aegisub/src/setup.cpp @@ -102,10 +102,6 @@ #pragma comment(lib, "ffms2.lib") #endif -#ifdef WITH_QUICKTIME -#pragma comment(lib, "QTMLClient.lib") -#endif - #ifdef WITH_PORTAUDIO #pragma comment(lib,"portaudio_x86.lib") #endif diff --git a/aegisub/src/video_provider_manager.cpp b/aegisub/src/video_provider_manager.cpp index 0ec30f4ba..80d917b83 100644 --- a/aegisub/src/video_provider_manager.cpp +++ b/aegisub/src/video_provider_manager.cpp @@ -50,9 +50,6 @@ #include "video_provider_ffmpegsource.h" #endif #include "video_provider_manager.h" -#ifdef WITH_QUICKTIME -#include "video_provider_quicktime.h" -#endif #include "video_provider_yuv4mpeg.h" @@ -119,9 +116,6 @@ void VideoProviderFactoryManager::RegisterProviders() { #ifdef WITH_FFMPEGSOURCE RegisterFactory(new FFmpegSourceVideoProviderFactory(),_T("FFmpegSource")); #endif -#ifdef WITH_QUICKTIME - RegisterFactory(new QuickTimeVideoProviderFactory(),_T("QuickTime")); -#endif } diff --git a/aegisub/src/video_provider_quicktime.cpp b/aegisub/src/video_provider_quicktime.cpp deleted file mode 100644 index 60230250e..000000000 --- a/aegisub/src/video_provider_quicktime.cpp +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright (c) 2009, Karl Blomster -// 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 video_provider_quicktime.cpp -/// @brief QuickTime-based video provider -/// @ingroup video_input quicktime -/// - - -#include "config.h" - -#ifdef WITH_QUICKTIME - -#ifndef AGI_PRE -#include -#endif - -#include "aegisub_endian.h" -#include "video_provider_quicktime.h" - -// this function has a different name on win32 because the original name -// conflicts with a windows api function -#ifndef WIN32 - -/// DOCME -#define MacOffsetRect OffsetRect -#endif - -/// @brief DOCME -/// @param filename -/// -QuickTimeVideoProvider::QuickTimeVideoProvider(wxString filename) { - in_dataref = NULL; - movie = NULL; - gw = NULL; - w = 0; - h = 0; - cur_fn = -1; - num_frames = 0; - keyframes.clear(); - - qt_err = noErr; - errmsg = _T("QuickTime video provider: "); - - // try to init quicktime - try { - InitQuickTime(); - } - catch (wxString temp) { - errmsg.Append(temp); - throw errmsg; - } - catch (...) { - throw; - } - - // try loading the file - try { - LoadVideo(filename); - } - catch (wxString temp) { - Close(); - errmsg.Append(temp); - throw errmsg; - } - catch (...) { - Close(); - throw; - } -} - -/// @brief DOCME -/// -QuickTimeVideoProvider::~QuickTimeVideoProvider() { - Close(); - DeInitQuickTime(); -} - -/// @brief DOCME -/// -void QuickTimeVideoProvider::Close() { - if (movie) - DisposeMovie(movie); - movie = NULL; - if (gw) - DisposeGWorld(gw); - gw = NULL; - if (in_dataref) - DisposeHandle(in_dataref); - in_dataref = NULL; - - keyframes.clear(); - qt_timestamps.clear(); -} - -/// @brief DOCME -/// @param _filename -/// -void QuickTimeVideoProvider::LoadVideo(const wxString _filename) { - Close(); - - OSType in_dataref_type; - wxStringToDataRef(_filename, &in_dataref, &in_dataref_type); - - // verify that file is openable - if (!CanOpen(in_dataref, in_dataref_type)) - throw wxString(_T("QuickTime cannot open file as video")); - - // actually open file - short res_id = 0; - qt_err = NewMovieFromDataRef(&movie, newMovieActive, &res_id, in_dataref, in_dataref_type); - QTCheckError(qt_err, wxString(_T("Failed to open file"))); - - // disable automagic screen rendering - qt_err = SetMovieVisualContext(movie, NULL); - QTCheckError(qt_err, wxString(_T("Failed to disable visual context"))); - - // set offscreen buffer size to actual movie dimensions - Rect m_box; - GetMovieBox(movie, &m_box); - // make sure its top left corner is at (0,0) - MacOffsetRect(&m_box, -m_box.left, -m_box.top); - SetMovieBox(movie, &m_box); - w = m_box.right; - h = m_box.bottom; - // allocate a new offscreen rendering buffer with the correct dimensions - QDErr qd_err = NewGWorld(&gw, 32, &m_box, NULL, NULL, keepLocal); - QTCheckError(qd_err, wxString(_T("Failed to initialize offscreen drawing buffer"))); - - // select our new offscreen render target - SetMovieGWorld(movie, gw, NULL); - - // get timestamps, keyframes and framecount - std::vector timecodes = IndexFile(); - if (timecodes.size() == 0) - throw wxString(_T("QuickTime video provider: failed to index file")); - - // ask about vfr override etc - vfr_fps = agi::vfr::Framerate(timecodes); - - cur_fn = 0; -} - -/// @brief DOCME -/// @return -/// -std::vector QuickTimeVideoProvider::IndexFile() { - TimeScale scale = GetMovieTimeScale(movie); - OSType v_type[1]; - v_type[0] = VisualMediaCharacteristic; - std::vector timecodes; - std::map timestamp_map; // TODO: just do a binary search instead - - int framecount = 1; - TimeValue cur_timeval = 0; - - // get the first frame - GetMovieNextInterestingTime(movie, nextTimeMediaSample + nextTimeEdgeOK, 1, v_type, cur_timeval, 0, &cur_timeval, NULL); - - // first, find timestamps and count frames - while (cur_timeval >= 0) { - qt_timestamps.push_back(cur_timeval); - timestamp_map.insert(std::pair(cur_timeval, framecount)); - timecodes.push_back((cur_timeval * 1000) / scale); - framecount++; - GetMovieNextInterestingTime(movie, nextTimeMediaSample, 1, v_type, cur_timeval, 0, &cur_timeval, NULL); - } - // GetMovieNextInterestingTime() returns -1 when there are no more interesting times, - // so we incremented framecount once too much - num_frames = --framecount; - - - // next, find keyframes - cur_timeval = 0; - keyframes.push_back(0); // interesting assumption? - while (cur_timeval >= 0) { - GetMovieNextInterestingTime(movie, nextTimeSyncSample, 1, v_type, cur_timeval, 0, &cur_timeval, NULL); - keyframes.push_back(timestamp_map[cur_timeval]); - } - - return timecodes; -} - -/// @brief DOCME -/// @param n -/// @return -/// -const AegiVideoFrame QuickTimeVideoProvider::GetFrame(int n) { - if (n < 0) - n = 0; - if (n >= num_frames) - n = num_frames-1; - cur_fn = n; - - // seek - SetMovieTimeValue(movie, qt_timestamps[n]); - qt_err = GetMoviesError(); - QTCheckError(qt_err, wxString::Format(_T("QuickTime video provider: failed to seek to TimeValue %d"), qt_timestamps[n])); - - // render to offscreen buffer - qt_err = UpdateMovie(movie); - QTCheckError(qt_err, wxString(_T("QuickTime video provider: failed to render frame"))); - MoviesTask(movie, 0L); - qt_err = GetMoviesError(); - QTCheckError(qt_err, wxString(_T("QuickTime video provider: failed to render frame"))); - - // set up destination - AegiVideoFrame dst_frame; - dst_frame.format = FORMAT_RGB32; - dst_frame.w = w; - dst_frame.h = h; - dst_frame.invertChannels = true; - dst_frame.flipped = false; - dst_frame.pitch[0] = w * 4; // 4 bytes per sample - dst_frame.Allocate(); - - // copy data from offscreen buffer - Ptr src_ptr8 = GetPixBaseAddr(GetGWorldPixMap(gw)); - uint32_t *src_ptr = reinterpret_cast(src_ptr8); - uint32_t *dst_ptr = reinterpret_cast(dst_frame.data[0]); - for (int i=0; i<(w*h); i++) - // swap endian if needed; quickdraw always renders big-endian - *dst_ptr++ = Endian::BigToMachine(*src_ptr++); // fun with pointers! - - return dst_frame; -} - -#endif /* WITH_QUICKTIME */ diff --git a/aegisub/src/video_provider_quicktime.h b/aegisub/src/video_provider_quicktime.h deleted file mode 100644 index a8eb40fd1..000000000 --- a/aegisub/src/video_provider_quicktime.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) 2009, Karl Blomster -// 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 video_provider_quicktime.h -/// @see video_provider_quicktime.cpp -/// @ingroup video_input quicktime -/// - - - -#include "quicktime_common.h" - -#ifdef WITH_QUICKTIME -#ifndef AGI_PRE -#include -#include - -#include -#include -#endif - - -#include "include/aegisub/video_provider.h" - -/// DOCME -/// @class QuickTimeVideoProvider -/// @brief DOCME -/// -/// DOCME -class QuickTimeVideoProvider : public VideoProvider, QuickTimeProvider { - /// source object - Movie movie; - - /// render buffer - GWorldPtr gw; - - /// input data handle - Handle in_dataref; - - - /// DOCME - - /// width/height - int w, h; - - /// length of file in frames - int num_frames; - - /// current frame number - int cur_fn; - - /// vfr framerate - Framerate vfr_fps; - - /// list of keyframes - std::vector keyframes; - - /// qt timestamps (used for seeking) - std::vector qt_timestamps; - - - /// quicktime error code - OSErr qt_err; - - /// aegisub error message - wxString errmsg; - - void LoadVideo(const wxString filename); - std::vector IndexFile(); - void Close(); - -public: - QuickTimeVideoProvider(wxString filename); - ~QuickTimeVideoProvider(); - - const AegiVideoFrame GetFrame(int n); - - int GetPosition() const { return cur_fn; } - int GetFrameCount() const { return num_frames; } - int GetWidth() const { return w; } - int GetHeight() const { return h; } - agi::vfr::Framerate GetFPS() const { return vfr_fps; } - std::vector GetKeyFrames() const { return keyframes; }; - wxString GetDecoderName() const { return L"QuickTime"; }; - bool WantsCaching() const { return true; }; - wxString GetWarning() const { return errmsg; } -}; - -/// DOCME -/// @class QuickTimeVideoProviderFactory -/// @brief DOCME -/// -/// DOCME -class QuickTimeVideoProviderFactory : public VideoProviderFactory { -public: - - /// @brief DOCME - /// @param video - /// - VideoProvider *CreateProvider(wxString video) { return new QuickTimeVideoProvider(video); } -}; - -#endif /* WITH_QUICKTIME */