From e247cc290e3eae127226f1b91ed7702ce460ef28 Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Sun, 28 Sep 2008 00:40:37 +0000 Subject: [PATCH] update ffms2 providers to account for latest API breakage and rename ffmpegsource2.lib to ffms2.lib in setup.cpp Originally committed to SVN as r2395. --- aegisub/audio_provider_ffmpegsource.cpp | 13 ++++++++++--- aegisub/ffmpegsource_common.cpp | 4 ++-- aegisub/ffmpegsource_common.h | 3 +-- aegisub/setup.cpp | 2 +- aegisub/video_provider_ffmpegsource.cpp | 13 +++++++++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/aegisub/audio_provider_ffmpegsource.cpp b/aegisub/audio_provider_ffmpegsource.cpp index 70951c269..9049c95a9 100644 --- a/aegisub/audio_provider_ffmpegsource.cpp +++ b/aegisub/audio_provider_ffmpegsource.cpp @@ -77,7 +77,7 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) { if (Index == NULL) { // index didn't exist or was invalid, we'll have to (re)create it try { - Index = DoIndexing(Index, FileNameWX, CacheName, FFMSTrackMaskAll); + Index = DoIndexing(Index, FileNameWX, CacheName, FFMSTrackMaskAll, false); } catch (wxString temp) { MsgString << temp; throw MsgString; @@ -102,7 +102,7 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) { if (FFMS_GetNumFrames(FrameData, FFMSErrMsg, MsgSize) <= 0 && (FFMS_GetTrackType(FrameData, FFMSErrMsg, MsgSize) == FFMS_TYPE_AUDIO)) { // found an unindexed audio track, we'll need to reindex try { - Index = DoIndexing(Index, FileNameWX, CacheName, FFMSTrackMaskAll); + Index = DoIndexing(Index, FileNameWX, CacheName, FFMSTrackMaskAll, false); } catch (wxString temp) { MsgString << temp; throw MsgString; @@ -117,7 +117,14 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) { } // FIXME: provide a way to choose which audio track to load? - AudioSource = FFMS_CreateAudioSource(FileNameWX.char_str(), FFMSFirstSuitableTrack, Index, FFMSErrMsg, MsgSize); + int TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, FFMSErrMsg, MsgSize); + if (TrackNumber < 0) { + wxString temp(FFMSErrMsg, wxConvUTF8); + MsgString << _T("couldn't find any audio tracks: ") << temp; + throw MsgString; + } + + AudioSource = FFMS_CreateAudioSource(FileNameWX.char_str(), TrackNumber, Index, FFMSErrMsg, MsgSize); if (!AudioSource) { wxString temp(FFMSErrMsg, wxConvUTF8); MsgString << _T("failed to open audio track: ") << temp; diff --git a/aegisub/ffmpegsource_common.cpp b/aegisub/ffmpegsource_common.cpp index dc7aa7fce..8b94106af 100644 --- a/aegisub/ffmpegsource_common.cpp +++ b/aegisub/ffmpegsource_common.cpp @@ -56,7 +56,7 @@ int __stdcall FFmpegSourceProvider::UpdateIndexingProgress(int State, int64_t Cu /////////// // Do indexing -FrameIndex *FFmpegSourceProvider::DoIndexing(FrameIndex *Index, wxString FileNameWX, wxString CacheName, int Trackmask) { +FrameIndex *FFmpegSourceProvider::DoIndexing(FrameIndex *Index, wxString FileNameWX, wxString CacheName, int Trackmask, bool IgnoreDecodeErrors) { char FFMSErrMsg[1024]; unsigned MsgSize = sizeof(FFMSErrMsg); wxString MsgString; @@ -69,7 +69,7 @@ FrameIndex *FFmpegSourceProvider::DoIndexing(FrameIndex *Index, wxString FileNam Progress.ProgressDialog->SetProgress(0,1); // index all audio tracks - Index = FFMS_MakeIndex(FileNameWX.char_str(), Trackmask, FFMSTrackMaskNone, NULL, FFmpegSourceProvider::UpdateIndexingProgress, &Progress, FFMSErrMsg, MsgSize); + Index = FFMS_MakeIndex(FileNameWX.char_str(), Trackmask, FFMSTrackMaskNone, NULL, IgnoreDecodeErrors, FFmpegSourceProvider::UpdateIndexingProgress, &Progress, FFMSErrMsg, MsgSize); if (!Index) { Progress.ProgressDialog->Destroy(); wxString temp(FFMSErrMsg, wxConvUTF8); diff --git a/aegisub/ffmpegsource_common.h b/aegisub/ffmpegsource_common.h index d5695f4d4..62de9d0ae 100644 --- a/aegisub/ffmpegsource_common.h +++ b/aegisub/ffmpegsource_common.h @@ -47,7 +47,6 @@ class FFmpegSourceProvider { public: static const int FFMSTrackMaskAll = -1; static const int FFMSTrackMaskNone = 0; - static const int FFMSFirstSuitableTrack = -1; struct IndexingProgressDialog { volatile bool IndexingCanceled; @@ -55,7 +54,7 @@ public: }; static int __stdcall UpdateIndexingProgress(int State, int64_t Current, int64_t Total, void *Private); - FrameIndex *DoIndexing(FrameIndex *Index, wxString Filename, wxString Cachename, int Trackmask); + FrameIndex *DoIndexing(FrameIndex *Index, wxString Filename, wxString Cachename, int Trackmask, bool IgnoreDecodeErrors); }; #endif /* WITH_FFMPEGSOURCE */ \ No newline at end of file diff --git a/aegisub/setup.cpp b/aegisub/setup.cpp index e87225661..e5942e8c2 100644 --- a/aegisub/setup.cpp +++ b/aegisub/setup.cpp @@ -126,7 +126,7 @@ //////////////// // FFMpegSource #ifdef WITH_FFMPEGSOURCE -#pragma comment(lib, "ffmpegsource2.lib") +#pragma comment(lib, "ffms2.lib") #endif diff --git a/aegisub/video_provider_ffmpegsource.cpp b/aegisub/video_provider_ffmpegsource.cpp index 42cf64408..0a9f23cf4 100644 --- a/aegisub/video_provider_ffmpegsource.cpp +++ b/aegisub/video_provider_ffmpegsource.cpp @@ -90,7 +90,8 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps) if (Index == NULL) { // index didn't exist or was invalid, we'll have to (re)create it try { - Index = DoIndexing(Index, FileNameWX, CacheName, FFMSTrackMaskAll); + // ignore audio decoding errors here, we don't care right now + Index = DoIndexing(Index, FileNameWX, CacheName, FFMSTrackMaskAll, true); } catch (wxString temp) { ErrorMsg << temp; throw ErrorMsg; @@ -112,7 +113,15 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps) else SeekMode = 1; - VideoSource = FFMS_CreateVideoSource(FileNameWX.char_str(), FFMSFirstSuitableTrack, Index, "", Threads, SeekMode, FFMSErrorMessage, MessageSize); + // FIXME: provide a way to choose which audio track to load? + int TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_VIDEO, FFMSErrorMessage, MessageSize); + if (TrackNumber < 0) { + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("couldn't find any video tracks: ") << temp; + throw ErrorMsg; + } + + VideoSource = FFMS_CreateVideoSource(FileNameWX.char_str(), TrackNumber, Index, "", Threads, SeekMode, FFMSErrorMessage, MessageSize); if (VideoSource == NULL) { wxString temp(FFMSErrorMessage, wxConvUTF8); ErrorMsg << _T("failed to open video track: ") << temp;