diff options
author | v0lt <v0lt@rambler.ru> | 2013-01-09 01:22:17 +0400 |
---|---|---|
committer | v0lt <v0lt@rambler.ru> | 2013-01-09 01:22:17 +0400 |
commit | 93346654dea436fa5bc4fb98c6352df9c88e9eab (patch) | |
tree | 95047fb630c03d933ae89ed71ede5451de323dbe /src/filters/parser/MpegSplitter | |
parent | 91d655597e89cd7b8795c8c445033c8a0e0f30e9 (diff) |
MpegSplitter: added the ability to select a track by number (tickets #1025, #1054)
Diffstat (limited to 'src/filters/parser/MpegSplitter')
-rw-r--r-- | src/filters/parser/MpegSplitter/MpegSplitter.cpp | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp index cc0074a30..62be8823f 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp @@ -812,23 +812,20 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
CString lang = _T("");
- CAtlList<CString> lang_list_audio;
- CAtlList<CString> lang_list_subpic;
- int Idx_audio = 99;
- int Idx_subpic = 99;
+ CAtlArray<CString> lang_list_audio;
+ CAtlArray<CString> lang_list_subpic;
+ int Idx_audio = 0;
+ int Idx_subpic = 0;
if (!m_csAudioLanguageOrder.IsEmpty()) {
int tPos = 0;
lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
while (tPos != -1) {
if (!lang.IsEmpty()) {
- lang_list_audio.AddTail(lang);
+ lang_list_audio.Add(lang);
}
lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
}
- if (!lang.IsEmpty()) {
- lang_list_audio.AddTail(lang);
- }
}
if (!m_csSubtitlesLanguageOrder.IsEmpty()) {
@@ -836,13 +833,10 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
while (tPos != -1) {
if (!lang.IsEmpty()) {
- lang_list_subpic.AddTail(lang);
+ lang_list_subpic.Add(lang);
}
lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
}
- if (!lang.IsEmpty()) {
- lang_list_subpic.AddTail(lang);
- }
}
for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
@@ -884,42 +878,46 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CString str_tmp = str;
str_tmp.MakeLower();
if (i == CMpegSplitterFile::audio) {
- if (lang_list_audio.GetCount() > 0) {
- int idx = 0;
- POSITION pos = lang_list_audio.GetHeadPosition();
- while (pos) {
- lang = lang_list_audio.GetNext(pos).MakeLower();
- if (-1 != str_tmp.Find(lang)) {
- if (idx < Idx_audio) {
- cs_audioProgram = str;
- Idx_audio = idx;
- break;
- }
+ if (Idx_audio == 0) {
+ Idx_audio = 1;
+ } else {
+ Idx_audio++;
+ }
+ for (size_t j = 0; j < lang_list_audio.GetCount(); j++) {
+ int num = _tstoi(lang_list_audio[j]);
+ if (num > 0) { // this is track number
+ if (Idx_audio != num) {
+ continue; // not matched
+ }
+ } else { // this is lang string
+ int len = lang_list_audio[j].GetLength();
+ if (str_tmp.Left(len) != lang_list_audio[j] && str_tmp.Find(_T("[")+ lang_list_audio[j]) >= 0) {
+ continue; // not matched
}
- idx++;
}
- }
- if (!Idx_audio && !cs_audioProgram.IsEmpty()) {
+ cs_audioProgram = str;
break;
}
}
if (i == CMpegSplitterFile::subpic) {
- if (lang_list_subpic.GetCount() > 0) {
- int idx = 0;
- POSITION pos = lang_list_subpic.GetHeadPosition();
- while (pos) {
- lang = lang_list_subpic.GetNext(pos).MakeLower();
- if (-1 != str_tmp.Find(lang)) {
- if (idx < Idx_subpic) {
- cs_subpicProgram = str;
- Idx_subpic = idx;
- break;
- }
+ if (Idx_subpic == 0) {
+ Idx_subpic = 1;
+ } else {
+ Idx_subpic++;
+ }
+ for (size_t j = 0; j < lang_list_subpic.GetCount(); j++) {
+ int num = _tstoi(lang_list_subpic[j]);
+ if (num > 0) { // this is track number
+ if (Idx_subpic != num) {
+ continue; // not matched
+ }
+ } else { // this is lang string
+ int len = lang_list_subpic[j].GetLength();
+ if (str_tmp.Left(len) != lang_list_subpic[j] && str_tmp.Find(_T("[")+ lang_list_subpic[j]) >= 0) {
+ continue; // not matched
}
- idx++;
}
- }
- if (!Idx_subpic && !cs_subpicProgram.IsEmpty()) {
+ cs_subpicProgram = str;
break;
}
}
|