Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2013-06-23 22:46:36 +0400
committerUnderground78 <underground78@users.sourceforge.net>2013-06-29 23:56:22 +0400
commitf46c1fd78e595b889bb27148a986cdbd0e4913c0 (patch)
treefbd90a5b738081dc615b1083382907cb228e6b3a /src/filters/parser
parent51e719b03f2e1ace5bf49b1512b340f278cb586e (diff)
Remove now deprecated filters.
Diffstat (limited to 'src/filters/parser')
-rw-r--r--src/filters/parser/AviSplitter/AviFile.cpp652
-rw-r--r--src/filters/parser/AviSplitter/AviFile.h89
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.cpp988
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.def5
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.h115
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.rc108
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.vcxproj258
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters70
-rw-r--r--src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp95
-rw-r--r--src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h53
-rw-r--r--src/filters/parser/AviSplitter/IAviSplitterFilter.h30
-rw-r--r--src/filters/parser/AviSplitter/resource.h17
-rw-r--r--src/filters/parser/AviSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/AviSplitter/stdafx.h27
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.cpp924
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.def5
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.h96
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.rc102
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.vcxproj256
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters55
-rw-r--r--src/filters/parser/FLVSplitter/resource.h14
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.h27
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp101
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h47
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.cpp2114
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.def5
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.h107
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.rc104
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.vcxproj263
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters67
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.cpp63
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.h38
-rw-r--r--src/filters/parser/MP4Splitter/resource.h14
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.h29
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.cpp1595
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.h593
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp1687
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.def5
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.h131
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc102
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj258
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters61
-rw-r--r--src/filters/parser/MatroskaSplitter/resource.h14
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.h28
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.cpp235
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.def5
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.h62
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.rc102
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.vcxproj255
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters61
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.cpp431
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.h58
-rw-r--r--src/filters/parser/MpaSplitter/resource.h15
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.h31
-rw-r--r--src/filters/parser/MpegSplitter/IMpegSplitterFilter.h50
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.cpp2087
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.def5
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.h148
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.rc115
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.vcxproj258
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters70
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.cpp1134
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.h180
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp152
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h74
-rw-r--r--src/filters/parser/MpegSplitter/resource.h24
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.h27
-rw-r--r--src/filters/parser/OggSplitter/OggFile.cpp104
-rw-r--r--src/filters/parser/OggSplitter/OggFile.h97
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.cpp1318
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.def5
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.h206
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.rc102
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.vcxproj255
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters61
-rw-r--r--src/filters/parser/OggSplitter/resource.h14
-rw-r--r--src/filters/parser/OggSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/OggSplitter/stdafx.h27
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp2672
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.def5
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.h366
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc102
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj256
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters55
-rw-r--r--src/filters/parser/RealMediaSplitter/resource.h14
-rw-r--r--src/filters/parser/RealMediaSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/RealMediaSplitter/stdafx.h27
92 files changed, 0 insertions, 22853 deletions
diff --git a/src/filters/parser/AviSplitter/AviFile.cpp b/src/filters/parser/AviSplitter/AviFile.cpp
deleted file mode 100644
index 896b36d1b..000000000
--- a/src/filters/parser/AviSplitter/AviFile.cpp
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "AviFile.h"
-#include <math.h>
-
-//
-// CAviFile
-//
-
-CAviFile::CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
-{
- if (FAILED(hr)) {
- return;
- }
- m_isamv = false;
- hr = Init();
-}
-
-HRESULT CAviFile::Init()
-{
- Seek(0);
- DWORD dw[3];
- if (S_OK != Read(dw) || dw[0] != FCC('RIFF') || (dw[2] != FCC('AVI ') && dw[2] != FCC('AVIX') && dw[2] != FCC('AMV '))) {
- return E_FAIL;
- }
-
- m_isamv = (dw[2] == FCC('AMV '));
- Seek(0);
- HRESULT hr = Parse(0, GetLength());
- UNREFERENCED_PARAMETER(hr);
- if (m_movis.IsEmpty()) { // FAILED(hr) is allowed as long as there was a movi chunk found
- return E_FAIL;
- }
-
- if (m_avih.dwStreams == 0 && !m_strms.IsEmpty()) {
- m_avih.dwStreams = (DWORD)m_strms.GetCount();
- }
-
- if (m_avih.dwStreams != m_strms.GetCount()) {
- return E_FAIL;
- }
-
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- if (s->strh.fccType != FCC('auds')) {
- continue;
- }
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)s->strf.GetData();
- if (wfe->wFormatTag == 0x55 && wfe->nBlockAlign == 1152
- && s->strh.dwScale == 1 && s->strh.dwRate != wfe->nSamplesPerSec) {
- // correcting encoder bugs...
- s->strh.dwScale = 1152;
- s->strh.dwRate = wfe->nSamplesPerSec;
- }
- }
-
- if (!m_isamv && (FAILED(BuildIndex()))) {
- EmptyIndex();
- }
-
- return S_OK;
-}
-
-HRESULT CAviFile::BuildAMVIndex()
-{
- strm_t::chunk NewChunk;
- DWORD ulType;
- DWORD ulSize;
-
- ZeroMemory(&NewChunk, sizeof(strm_t::chunk));
- while ((Read(ulType) == S_OK) && (Read(ulSize) == S_OK)) {
- switch (ulType) {
- case FCC('00dc'): // 01bw: JPeg
- NewChunk.size = ulSize;
- NewChunk.filepos = GetPos();
- NewChunk.orgsize = ulSize;
- NewChunk.fKeyFrame = true;
- m_strms[0]->cs.Add(NewChunk);
- break;
- case FCC('01wb'): // 00dc: Audio
- NewChunk.size = ulSize;
- NewChunk.orgsize = ulSize;
- NewChunk.fKeyFrame = true;
- NewChunk.filepos = GetPos();
- m_strms[1]->cs.Add(NewChunk);
- break;
- }
- Seek(GetPos() + ulSize);
- }
-
- TRACE(_T("Video packet : %d Audio packet :%d\n"), m_strms[0]->cs.GetCount(), m_strms[1]->cs.GetCount());
- return S_OK;
-}
-
-HRESULT CAviFile::Parse(DWORD parentid, __int64 end)
-{
- HRESULT hr = S_OK;
-
- CAutoPtr<strm_t> strm;
-
- while (S_OK == hr && GetPos() < end) {
- UINT64 pos = GetPos();
-
- DWORD id = 0, size;
- if (S_OK != Read(id) || id == 0) {
- return E_FAIL;
- }
-
- if (id == FCC('RIFF') || id == FCC('LIST')) {
- if (S_OK != Read(size) || S_OK != Read(id)) {
- return E_FAIL;
- }
-
- if (m_isamv) {
- size = (DWORD)(min(end, DWORD_MAX) - GetPos() - 8); // No size set in AVM : guess end of file...
- }
- size += (size & 1) + 8;
-
- TRACE(_T("CAviFile::Parse(..): LIST '%c%c%c%c'\n"),
- TCHAR((id >> 0) & 0xff),
- TCHAR((id >> 8) & 0xff),
- TCHAR((id >> 16) & 0xff),
- TCHAR((id >> 24) & 0xff));
-
- if (id == FCC('movi')) {
- m_movis.AddTail(pos);
- if (m_isamv) {
- BuildAMVIndex();
- }
- } else {
- hr = Parse(id, pos + size);
- }
- } else {
- if (S_OK != Read(size)) {
- return E_FAIL;
- }
- if (GetPos() + size > end) {
- return E_FAIL; // broken chunk
- }
-
- TRACE(_T("CAviFile::Parse(..): '%c%c%c%c'\n"),
- TCHAR((id >> 0) & 0xff),
- TCHAR((id >> 8) & 0xff),
- TCHAR((id >> 16) & 0xff),
- TCHAR((id >> 24) & 0xff));
-
- if (parentid == FCC('INFO') && size > 0) {
- switch (id) {
- case FCC('IARL'): // Archival Location. Indicates where the subject of the file is archived.
- case FCC('IART'): // Artist. Lists the artist of the original subject of the file; for example, "Michaelangelo."
- case FCC('ICMS'): // Commissioned. Lists the name of the person or organization that commissioned the subject of the file; for example, "Pope Julian II."
- case FCC('ICMT'): // Comments. Provides general comments about the file or the subject of the file. If the comment is several sentences long, end each sentence with a period. Do not include new-line characters.
- case FCC('ICOP'): // Copyright. Records the copyright information for the file; for example, "Copyright Encyclopedia International 1991." If there are multiple copyrights, separate them by a semicolon followed by a space.
- case FCC('ICRD'): // Creation date. Specifies the date the subject of the file was created. List dates in year-month-day format, padding one-digit months and days with a zero on the left; for example, "1553-05-03" for May 3, 1553.
- case FCC('ICRP'): // Cropped. Describes whether an image has been cropped and, if so, how it was cropped; for example, "lower-right corner."
- case FCC('IDIM'): // Dimensions. Specifies the size of the original subject of the file; for example, "8.5 in h, 11 in w."
- case FCC('IDPI'): // Dots Per Inch. Stores dots per inch setting of the digitizer used to produce the file, such as "300."
- case FCC('IENG'): // Engineer. Stores the name of the engineer who worked on the file. If there are multiple engineers, separate the names by a semicolon and a blank; for example, "Smith, John; Adams, Joe."
- case FCC('IGNR'): // Genre. Describes the original work, such as "landscape," "portrait," "still life," etc.
- case FCC('IKEY'): // Keywords. Provides a list of keywords that refer to the file or subject of the file. Separate multiple keywords with a semicolon and a blank; for example, "Seattle; aerial view; scenery."
- case FCC('ILGT'): // Lightness. Describes the changes in lightness settings on the digitizer required to produce the file. Note that the format of this information depends on hardware used.
- case FCC('IMED'): // Medium. Describes the original subject of the file, such as "computer image," "drawing," "lithograph," and so on.
- case FCC('INAM'): // Name. Stores the title of the subject of the file, such as "Seattle From Above."
- case FCC('IPLT'): // Palette Setting. Specifies the number of colors requested when digitizing an image, such as "256."
- case FCC('IPRD'): // Product. Specifies the name of the title the file was originally intended for, such as "Encyclopedia of Pacific Northwest Geography."
- case FCC('ISBJ'): // Subject. Describes the contents of the file, such as "Aerial view of Seattle."
- case FCC('ISFT'): // Software. Identifies the name of the software package used to create the file, such as "Microsoft WaveEdit."
- case FCC('ISHP'): // Sharpness. Identifies the changes in sharpness for the digitizer required to produce the file (the format depends on the hardware used).
- case FCC('ISRC'): // Source. Identifies the name of the person or organization who supplied the original subject of the file; for example, "Trey Research."
- case FCC('ISRF'): // Source Form. Identifies the original form of the material that was digitized, such as "slide," "paper," "map," and so on. This is not necessarily the same as IMED.
- case FCC('ITCH'): { // Technician. Identifies the technician who digitized the subject file; for example, "Smith, John."
- CStringA str;
- if (S_OK != ByteRead((BYTE*)str.GetBufferSetLength(size), size)) {
- return E_FAIL;
- }
- m_info[id] = str;
- break;
- }
- }
- }
-
- switch (id) {
- case FCC('amvh'):
- case FCC('avih'):
- m_avih.fcc = id;
- m_avih.cb = size;
- if (S_OK != Read(m_avih, 8)) {
- return E_FAIL;
- }
- break;
- case FCC('strh'):
- if (!strm) {
- strm.Attach(DEBUG_NEW strm_t());
- }
- strm->strh.fcc = FCC('strh');
- strm->strh.cb = size;
- if (S_OK != Read(strm->strh, 8)) {
- return E_FAIL;
- }
- if (m_isamv) {
- // First alway video, second always audio
- strm->strh.fccType = m_strms.IsEmpty() ? FCC('vids') : FCC('amva');
- strm->strh.dwRate = m_avih.dwReserved[0] * 1000; // dwReserved[0] = fps!
- strm->strh.dwScale = 1000;
- }
- break;
- case FCC('strn'):
- if (S_OK != ByteRead((BYTE*)strm->strn.GetBufferSetLength(size), size)) {
- return E_FAIL;
- }
- break;
- case FCC('strf'):
- if (!strm) {
- strm.Attach(DEBUG_NEW strm_t());
- }
- strm->strf.SetCount(size);
- if (S_OK != ByteRead(strm->strf.GetData(), size)) {
- return E_FAIL;
- }
- if (m_isamv) {
- if (strm->strh.fccType == FCC('vids')) {
- strm->strf.SetCount(sizeof(BITMAPINFOHEADER));
- BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)strm->strf.GetData())->bmiHeader;
- pbmi->biSize = sizeof(BITMAPINFOHEADER);
- pbmi->biHeight = m_avih.dwHeight;
- pbmi->biWidth = m_avih.dwWidth;
- pbmi->biCompression = FCC('AMVV');
- pbmi->biPlanes = 1;
- pbmi->biBitCount = 24;
- pbmi->biSizeImage = pbmi->biHeight * pbmi->biWidth * (pbmi->biBitCount / 8);
- }
- m_strms.Add(strm);
- }
-
- break;
- case FCC('indx'):
- if (!strm) {
- strm.Attach(DEBUG_NEW strm_t());
- }
- ASSERT(strm->indx == nullptr);
- AVISUPERINDEX* pSuperIndex;
- if (size < MAXDWORD - 8) {
- // Fix buffer overrun vulnerability
- try {
- pSuperIndex = (AVISUPERINDEX*)DEBUG_NEW unsigned char [(size_t)(size + 8)];
- } catch (CMemoryException* e) {
- pSuperIndex = nullptr;
- e->Delete();
- }
- if (pSuperIndex) {
- strm->indx.Attach(pSuperIndex);
- strm->indx->fcc = FCC('indx');
- strm->indx->cb = size;
- if (S_OK != ByteRead((BYTE*)(AVISUPERINDEX*)strm->indx + 8, size)) {
- return E_FAIL;
- }
- ASSERT(strm->indx->wLongsPerEntry == 4 && strm->indx->bIndexType == AVI_INDEX_OF_INDEXES);
- }
- }
- break;
- case FCC('dmlh'):
- if (S_OK != Read(m_dmlh)) {
- return E_FAIL;
- }
- break;
- case FCC('vprp'):
- //if (S_OK != Read(m_vprp)) return E_FAIL;
- break;
- case FCC('idx1'):
- ASSERT(m_idx1 == nullptr);
- m_idx1.Attach((AVIOLDINDEX*)DEBUG_NEW BYTE[size + 8]);
- m_idx1->fcc = FCC('idx1');
- m_idx1->cb = size;
- if (S_OK != ByteRead((BYTE*)(AVIOLDINDEX*)m_idx1 + 8, size)) {
- return E_FAIL;
- }
- break;
- default:
- TRACE(_T("CAviFile::Parse(..): unknown tag '%c%c%c%c'\n"),
- TCHAR((id >> 0) & 0xff),
- TCHAR((id >> 8) & 0xff),
- TCHAR((id >> 16) & 0xff),
- TCHAR((id >> 24) & 0xff));
- break;
- }
-
- size += (size & 1) + 8;
- }
-
- Seek(pos + size);
- }
-
- if (strm) {
- m_strms.Add(strm);
- }
-
- return hr;
-}
-
-REFERENCE_TIME CAviFile::GetTotalTime()
-{
- REFERENCE_TIME t = 0/*10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames*/;
-
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
-
- if (s->IsRawSubtitleStream()) {
- continue;
- }
-
- REFERENCE_TIME t2 = s->GetRefTime((DWORD)s->cs.GetCount(), s->totalsize);
- t = max(t, t2);
- }
-
- if (t == 0) {
- t = 10i64 * m_avih.dwMicroSecPerFrame * m_avih.dwTotalFrames;
- }
-
- return t;
-}
-
-HRESULT CAviFile::BuildIndex()
-{
- EmptyIndex();
-
- DWORD nSuperIndexes = 0;
-
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- strm_t* s = m_strms[track];
- if (s->indx && s->indx->nEntriesInUse > 0) {
- nSuperIndexes++;
- }
- }
-
- if (nSuperIndexes == m_avih.dwStreams) {
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- strm_t* s = m_strms[track];
-
- AVISUPERINDEX* idx = (AVISUPERINDEX*)s->indx;
-
- DWORD nEntriesInUse = 0;
-
- for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
- Seek(idx->aIndex[j].qwOffset);
-
- AVISTDINDEX stdidx;
- if (S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex))) {
- EmptyIndex();
- return E_FAIL;
- }
-
- nEntriesInUse += stdidx.nEntriesInUse;
- }
-
- s->cs.SetCount(nEntriesInUse);
-
- DWORD frame = 0;
- UINT64 size = 0;
-
- for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
- Seek(idx->aIndex[j].qwOffset);
-
- CAutoPtr<AVISTDINDEX> p((AVISTDINDEX*)DEBUG_NEW BYTE[idx->aIndex[j].dwSize]);
- if (!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize) || p->qwBaseOffset >= (DWORDLONG)GetLength()) {
- EmptyIndex();
- return E_FAIL;
- }
-
- for (DWORD k = 0; k < p->nEntriesInUse; ++k) {
- s->cs[frame].size = size;
- s->cs[frame].filepos = p->qwBaseOffset + p->aIndex[k].dwOffset;
- s->cs[frame].fKeyFrame = !(p->aIndex[k].dwSize & AVISTDINDEX_DELTAFRAME)
- || s->strh.fccType == FCC('auds');
- s->cs[frame].fChunkHdr = false;
- s->cs[frame].orgsize = p->aIndex[k].dwSize & AVISTDINDEX_SIZEMASK;
-
- if (m_idx1) {
- s->cs[frame].filepos -= 8;
- s->cs[frame].fChunkHdr = true;
- }
-
- ++frame;
- size += s->GetChunkSize(p->aIndex[k].dwSize & AVISTDINDEX_SIZEMASK);
- }
- }
-
- s->totalsize = size;
- }
- } else if (AVIOLDINDEX* idx = m_idx1) {
- size_t len = idx->cb / sizeof(idx->aIndex[0]);
-
- UINT64 offset = m_movis.GetHead() + 8;
-
- //detect absolute chunk addressing (TODO: read AVI specification and make it better)
- if (idx->aIndex[0].dwOffset > offset) {
- DWORD id;
- Seek(offset + idx->aIndex[0].dwOffset);
- Read(id);
- if (id != idx->aIndex[0].dwChunkId) {
- TRACE(_T("WARNING: CAviFile::Init() detected absolute chunk addressing in \'idx1\'\n"));
- offset = 0;
- }
- }
-
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- strm_t* s = m_strms[track];
-
- // calculate the number of frames and set index size before using it
- size_t nFrames = 0;
- for (size_t i = 0; i < len; i++) {
- if (TRACKNUM(idx->aIndex[i].dwChunkId) == track) {
- nFrames++;
- }
- }
- s->cs.SetCount(nFrames);
-
- // read index
- size_t frame = 0;
- UINT64 size = 0;
- for (size_t i = 0; i < len; i++) {
- if (TRACKNUM(idx->aIndex[i].dwChunkId) == track) {
- s->cs[frame].size = size;
- s->cs[frame].filepos = offset + idx->aIndex[i].dwOffset;
- s->cs[frame].fKeyFrame = (idx->aIndex[i].dwFlags & AVIIF_KEYFRAME)
- || s->strh.fccType == FCC('auds') // FIXME: some audio index is without any kf flag
- || frame == 0; // grrr
- s->cs[frame].fChunkHdr = i + 1 == len || idx->aIndex[i].dwOffset != idx->aIndex[i + 1].dwOffset;
- s->cs[frame].orgsize = idx->aIndex[i].dwSize;
-
- frame++;
- size += s->GetChunkSize(idx->aIndex[i].dwSize);
- }
- }
-
- s->totalsize = size;
- }
- }
-
- m_idx1.Free();
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- m_strms[track]->indx.Free();
- }
-
- return S_OK;
-}
-
-void CAviFile::EmptyIndex()
-{
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- s->cs.RemoveAll();
- s->totalsize = 0;
- }
-}
-
-bool CAviFile::IsInterleaved(bool fKeepInfo)
-{
- if (m_strms.GetCount() < 2) {
- return true;
- }
- /*
- if (m_avih.dwFlags&AVIF_ISINTERLEAVED) // not reliable, nandub can write f*cked up files and still sets it
- return true;
- */
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- m_strms[i]->cs2.SetCount(m_strms[i]->cs.GetCount());
- }
-
- DWORD* curchunks = DEBUG_NEW DWORD[m_avih.dwStreams];
- UINT64* cursizes = DEBUG_NEW UINT64[m_avih.dwStreams];
-
- ZeroMemory(curchunks, sizeof(DWORD)*m_avih.dwStreams);
- ZeroMemory(cursizes, sizeof(UINT64)*m_avih.dwStreams);
-
- int end = 0;
-
- for (;;) {
- UINT64 fpmin = _I64_MAX;
-
- DWORD n = (DWORD) - 1;
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- DWORD curchunk = curchunks[i];
- CAtlArray<strm_t::chunk>& cs = m_strms[i]->cs;
- if (curchunk >= cs.GetCount()) {
- continue;
- }
- UINT64 fp = cs[curchunk].filepos;
- if (fp < fpmin) {
- fpmin = fp;
- n = i;
- }
- }
- if (n == -1) {
- break;
- }
-
- strm_t* s = m_strms[n];
- DWORD& curchunk = curchunks[n];
- UINT64& cursize = cursizes[n];
-
- if (!s->IsRawSubtitleStream()) {
- strm_t::chunk2& cs2 = s->cs2[curchunk];
- cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize) >> 13); // for comparing later it is just as good as /10000 to get a near [ms] accuracy
- //cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize)/10000);
- cs2.n = end++;
- }
-
- cursize = s->cs[curchunk].size;
- ++curchunk;
- }
-
- ZeroMemory(curchunks, sizeof(DWORD)*m_avih.dwStreams);
-
- strm_t::chunk2 cs2last = {(DWORD) - 1, 0};
-
- bool fInterleaved = true;
-
- while (fInterleaved) {
- strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
-
- DWORD n = (DWORD) - 1;
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- DWORD curchunk = curchunks[i];
- if (curchunk >= m_strms[i]->cs2.GetCount()) {
- continue;
- }
- strm_t::chunk2& cs2 = m_strms[i]->cs2[curchunk];
- if (cs2.t < cs2min.t) {
- cs2min = cs2;
- n = i;
- }
- }
- if (n == -1) {
- break;
- }
-
- ++curchunks[n];
-
- if (cs2last.t != (DWORD) - 1 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
- fInterleaved = false;
- }
-
- cs2last = cs2min;
- }
-
- delete [] curchunks;
- delete [] cursizes;
-
- if (fInterleaved && !fKeepInfo) {
- // this is not needed anymore, let's save a little memory then
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- m_strms[i]->cs2.RemoveAll();
- }
- }
-
- return fInterleaved;
-}
-
-REFERENCE_TIME CAviFile::strm_t::GetRefTime(DWORD frame, UINT64 size)
-{
- if (strh.dwRate == 0) {
- return 0;
- }
- if (strh.fccType == FCC('auds')) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
- if (wfe->nBlockAlign == 0) {
- return 0;
- }
- return (REFERENCE_TIME)ceil(10000000.0 * size * strh.dwScale / (unsigned __int64(strh.dwRate) * wfe->nBlockAlign));
- // need calculate in double, because the (10000000ui64 * size * strh.dwScale) can give overflow
- // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
- }
- return (REFERENCE_TIME)ceil(10000000.0 * frame * strh.dwScale / strh.dwRate);
- // need calculate in double, because the (10000000ui64 * frame * strh.dwScale) can give overflow (verified in practice)
- // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
-}
-
-DWORD CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
-{
- DWORD frame;
-
- if (strh.dwScale == 0 || rt <= 0 || cs.IsEmpty()) {
- frame = 0;
- } else if (strh.fccType == FCC('auds')) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
-
- UINT64 size = (UINT64)(double(rt) * wfe->nBlockAlign * strh.dwRate / (strh.dwScale * 10000000.0));
- // need calculate in double, because the (rt * wfe->nBlockAlign * strh.dwRate) can give overflow
- frame = 1;
- for (; frame < cs.GetCount(); ++frame) {
- if (cs[frame].size > size) {
- break;
- }
- }
- --frame;
- } else {
- frame = (DWORD)(double(rt) * strh.dwRate / (strh.dwScale * 10000000.0));
- // need calculate in double, because the (rt * strh.dwRate) can give overflow (verified in practice)
- if (frame >= cs.GetCount()) {
- frame = (DWORD)cs.GetCount() - 1;
- }
- }
-
- return frame;
-}
-
-DWORD CAviFile::strm_t::GetKeyFrame(REFERENCE_TIME rt)
-{
- DWORD i = GetFrame(rt);
- for (; i > 0; i--) {
- if (cs[i].fKeyFrame) {
- break;
- }
- }
- return i;
-}
-
-DWORD CAviFile::strm_t::GetChunkSize(DWORD size)
-{
- if (strh.fccType == FCC('auds')) {
- WORD nBlockAlign = ((WAVEFORMATEX*)strf.GetData())->nBlockAlign;
- size = nBlockAlign ? (size + (nBlockAlign - 1)) / nBlockAlign * nBlockAlign : 0; // round up for nando's vbr hack
- }
-
- return size;
-}
-
-bool CAviFile::strm_t::IsRawSubtitleStream()
-{
- return strn.Find("Subtitle") == 0 || strh.fccType == FCC('txts') && cs.GetCount() == 1;
-}
diff --git a/src/filters/parser/AviSplitter/AviFile.h b/src/filters/parser/AviSplitter/AviFile.h
deleted file mode 100644
index 14fba760e..000000000
--- a/src/filters/parser/AviSplitter/AviFile.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <aviriff.h> // conflicts with vfw.h...
-#include "../BaseSplitter/BaseSplitter.h"
-
-class CAviFile : public CBaseSplitterFile
-{
- HRESULT Init();
- HRESULT Parse(DWORD parentid, __int64 end);
- HRESULT BuildAMVIndex();
-
-public:
- CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- //using CBaseSplitterFile::Read;
- template<typename T>
- HRESULT Read(T& var, int offset = 0) {
- ZeroMemory(&var, sizeof(var));
- HRESULT hr = ByteRead((BYTE*)&var + offset, sizeof(var) - offset);
- return hr;
- }
-
- AVIMAINHEADER m_avih;
- struct ODMLExtendedAVIHeader {
- DWORD dwTotalFrames;
- } m_dmlh;
- //VideoPropHeader m_vprp;
- struct strm_t {
- AVISTREAMHEADER strh;
- CAtlArray<BYTE> strf;
- CStringA strn;
- CAutoPtr<AVISUPERINDEX> indx;
- struct chunk {
- UINT64 fKeyFrame: 1, fChunkHdr: 1, size: 62;
- UINT64 filepos;
- DWORD orgsize;
- };
- CAtlArray<chunk> cs;
- UINT64 totalsize;
- REFERENCE_TIME GetRefTime(DWORD frame, UINT64 size);
- int GetTime(DWORD frame, UINT64 size);
- DWORD GetFrame(REFERENCE_TIME rt);
- DWORD GetKeyFrame(REFERENCE_TIME rt);
- DWORD GetChunkSize(DWORD size);
- bool IsRawSubtitleStream();
-
- // tmp
- struct chunk2 {
- DWORD t;
- DWORD n;
- };
- CAtlArray<chunk2> cs2;
- };
- CAutoPtrArray<strm_t> m_strms;
- CAtlMap<DWORD, CStringA> m_info;
- CAutoPtr<AVIOLDINDEX> m_idx1;
-
- CAtlList<UINT64> m_movis;
- bool m_isamv;
-
- REFERENCE_TIME GetTotalTime();
- HRESULT BuildIndex();
- void EmptyIndex();
- bool IsInterleaved(bool fKeepInfo = false);
-};
-
-#define TRACKNUM(fcc) (10 * ((fcc & 0xff) - 0x30) + (((fcc >> 8) & 0xff) - 0x30))
-#define TRACKTYPE(fcc) ((WORD)((((DWORD)fcc >> 24) & 0xff) | ((fcc >> 8) & 0xff00)))
diff --git a/src/filters/parser/AviSplitter/AviSplitter.cpp b/src/filters/parser/AviSplitter/AviSplitter.cpp
deleted file mode 100644
index 37737ed68..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.cpp
+++ /dev/null
@@ -1,988 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "AviFile.h"
-#include "AviSplitter.h"
-
-#define MAXPACKETS_AVI 1000
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Avi},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CAviSplitterFilter), AviSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CAviSourceFilter), AviSourceName, MERIT_NORMAL + 1, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAviSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CAviSourceFilter>, nullptr, &sudFilter[1]},
- {L"CAviSplitterPropertyPage", &__uuidof(CAviSplitterSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CAviSplitterSettingsWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920")); // 'RIFF' ... 'AVI '
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958")); // 'RIFF' ... 'AVIX'
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,414D5620")); // 'RIFF' ... 'AMV '
-
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Avi,
- chkbytes,
- _T(".avi"), _T(".divx"), _T(".vp6"), _T(".amv"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- //UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
-
-class CAviSplitterApp : public CWinApp
-{
-public:
- CAviSplitterApp() {}
-
- BOOL InitInstance() {
- if (!__super::InitInstance()) {
- return FALSE;
- }
- DllEntryPoint(m_hInstance, DLL_PROCESS_ATTACH, 0);
- return TRUE;
- }
-
- BOOL ExitInstance() {
- DllEntryPoint(m_hInstance, DLL_PROCESS_DETACH, 0);
- return __super::ExitInstance();
- }
-
- void SetDefaultRegistryKey() {
- SetRegistryKey(_T("Gabest"));
- }
-
- DECLARE_MESSAGE_MAP()
-};
-
-BEGIN_MESSAGE_MAP(CAviSplitterApp, CWinApp)
-END_MESSAGE_MAP()
-
-CAviSplitterApp theApp;
-
-#endif
-
-//
-// CAviSplitterFilter
-//
-
-CAviSplitterFilter::CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CAviSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_AVI)
- , m_timeformat(TIME_FORMAT_MEDIA_TIME)
- , m_maxTimeStamp(Packet::INVALID_TIME)
- , m_bNonInterleavedFilesSupport(true)
-{
-#ifdef STANDALONE_FILTER
- /*CRegKey key;
-
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\AVI Splitter"), KEY_READ)) {
- DWORD dw;
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("NonInterleavedFilesSupport"), dw)) {
- m_bNonInterleavedFilesSupport = !!dw;
- }
- }*/
-#else
- //m_bNonInterleavedFilesSupport = !!AfxGetApp()->GetProfileInt(_T("Filters\\AVI Splitter"), _T("NonInterleavedFilesSupport"), m_bNonInterleavedFilesSupport);
-#endif
-}
-
-STDMETHODIMP CAviSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- *ppv = nullptr;
-
- return
- QI(IAviSplitterFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CAviSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, AviSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_tFrame.Free();
-
- m_pFile.Attach(DEBUG_NEW CAviFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
-
- if (SUCCEEDED(hr) && !m_bNonInterleavedFilesSupport && !m_pFile->IsInterleaved()) {
- hr = E_FAIL;
- }
-
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetTotalTime();
-
- bool fHasIndex = false;
-
- for (unsigned int i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); ++i) {
- if (!m_pFile->m_strms[i]->cs.IsEmpty()) {
- fHasIndex = true;
- }
- }
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
-
- if (fHasIndex && s->cs.IsEmpty()) {
- continue;
- }
-
- CMediaType mt;
- CAtlArray<CMediaType> mts;
-
- CStringW name, label;
-
- if (s->strh.fccType == FCC('vids')) {
- label = L"Video";
-
- ASSERT(s->strf.GetCount() >= sizeof(BITMAPINFOHEADER));
-
- BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)s->strf.GetData())->bmiHeader;
-
- mt.majortype = MEDIATYPE_Video;
- switch (pbmi->biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pbmi->biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pbmi->biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pbmi->biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pbmi->biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pbmi->biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pbmi->biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
- MEDIASUBTYPE_NULL;
- break;
- //case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
- //case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
- case FCC('AVRn')://uncommon fourcc
- case FCC('JPGL')://uncommon fourcc
- mt.subtype = MEDIASUBTYPE_MJPG;
- break;
- case FCC('MPG2'):
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- break;
- default:
- mt.subtype = FOURCCMap(pbmi->biCompression);
- }
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + (ULONG)s->strf.GetCount() - sizeof(BITMAPINFOHEADER));
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(&pvih->bmiHeader, s->strf.GetData(), s->strf.GetCount());
- if (s->strh.dwRate > 0) {
- pvih->AvgTimePerFrame = 10000000ui64 * s->strh.dwScale / s->strh.dwRate;
- }
-
- if (s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
- UINT64 size = 0;
- for (unsigned int j = 0; j < s->cs.GetCount(); ++j) {
- size += s->cs[j].orgsize;
- }
- pvih->dwBitRate = (DWORD)(10000000.0 * size * 8 / (s->cs.GetCount() * pvih->AvgTimePerFrame) + 0.5);
- // need calculate in double, because the (10000000ui64 * size * 8) can give overflow
- }
-
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (pvih->bmiHeader.biWidth * pvih->bmiHeader.biHeight * 4));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('auds') || s->strh.fccType == FCC('amva')) {
- label = L"Audio";
-
- ASSERT(s->strf.GetCount() >= sizeof(WAVEFORMATEX)
- || s->strf.GetCount() == sizeof(PCMWAVEFORMAT));
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
-
- if (pwfe->nBlockAlign == 0) {
- continue;
- }
-
- mt.majortype = MEDIATYPE_Audio;
- if (m_pFile->m_isamv) {
- mt.subtype = FOURCCMap(MAKEFOURCC('A', 'M', 'V', 'A'));
- } else {
- mt.subtype = FOURCCMap(pwfe->wFormatTag);
- }
- mt.formattype = FORMAT_WaveFormatEx;
- if (nullptr == mt.AllocFormatBuffer(max((ULONG)s->strf.GetCount(), sizeof(WAVEFORMATEX)))) {
- continue;
- }
- memcpy(mt.Format(), s->strf.GetData(), s->strf.GetCount());
- pwfe = (WAVEFORMATEX*)mt.Format();
- if (s->strf.GetCount() == sizeof(PCMWAVEFORMAT)) {
- pwfe->cbSize = 0;
- }
- if (pwfe->wFormatTag == WAVE_FORMAT_PCM) {
- pwfe->nBlockAlign = pwfe->nChannels * pwfe->wBitsPerSample >> 3;
- }
- if (pwfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
- mt.subtype = ((WAVEFORMATEXTENSIBLE*)pwfe)->SubFormat;
- }
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (pwfe->nChannels * pwfe->nSamplesPerSec * 32 >> 3));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('mids')) {
- label = L"Midi";
-
- mt.majortype = MEDIATYPE_Midi;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (1024 * 1024));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('txts')) {
- label = L"Text";
-
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (1024 * 1024));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('iavs')) {
- label = L"Interleaved";
-
- ASSERT(s->strh.fccHandler == FCC('dvsd'));
-
- mt.majortype = MEDIATYPE_Interleaved;
- mt.subtype = FOURCCMap(s->strh.fccHandler);
- mt.formattype = FORMAT_DvInfo;
- mt.SetFormat(s->strf.GetData(), max((ULONG)s->strf.GetCount(), sizeof(DVINFO)));
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (1024 * 1024));
- mts.Add(mt);
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("CAviSourceFilter: Unsupported stream (%d)\n"), i);
- continue;
- }
-
- //Put filename at front sometime(eg. ~temp.avi) will cause filter graph
- //stop check this pin. Not sure the reason exactly. but it happens.
- //If you know why, please emailto: tomasen@gmail.com
- if (s->strn.IsEmpty()) {
- name.Format(L"%s %u", label, i);
- } else {
- name.Format(L"%s (%s %u)", CStringW(s->strn), label, i);
- }
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CAviSplitterOutputPin(mts, name, this, this, &hr2));
- AddOutputPin(i, pPinOut);
- }
-
- POSITION pos = m_pFile->m_info.GetStartPosition();
- while (pos) {
- DWORD fcc;
- CStringA value;
- m_pFile->m_info.GetNextAssoc(pos, fcc, value);
-
- switch (fcc) {
- case FCC('INAM'):
- SetProperty(L"TITL", CStringW(value));
- break;
- case FCC('IART'):
- SetProperty(L"AUTH", CStringW(value));
- break;
- case FCC('ICOP'):
- SetProperty(L"CPYR", CStringW(value));
- break;
- case FCC('ISBJ'):
- SetProperty(L"DESC", CStringW(value));
- break;
- }
- }
-
- m_tFrame.Attach(DEBUG_NEW DWORD[m_pFile->m_avih.dwStreams]);
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CAviSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CAviSplitterFilter");
-
- if (!m_pFile) {
- return false;
- }
-
- // reindex if needed
-
- bool fReIndex = false;
-
- for (DWORD i = 0; i < m_pFile->m_avih.dwStreams && !fReIndex; ++i) {
- if (m_pFile->m_strms[i]->cs.IsEmpty() && GetOutputPin(i)) {
- fReIndex = true;
- }
- }
-
- if (fReIndex) {
- m_pFile->EmptyIndex();
-
- m_fAbort = false;
- m_nOpenProgress = 0;
-
- m_rtDuration = 0;
-
- CAutoVectorPtr<UINT64> pSize;
- pSize.Allocate(m_pFile->m_avih.dwStreams);
- ZeroMemory((UINT64*)pSize, sizeof(UINT64)*m_pFile->m_avih.dwStreams);
- m_pFile->Seek(0);
- ReIndex(m_pFile->GetLength(), pSize);
-
- if (m_fAbort) {
- m_pFile->EmptyIndex();
- }
-
- m_fAbort = false;
- m_nOpenProgress = 100;
- }
-
- return true;
-}
-
-HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize)
-{
- HRESULT hr = S_OK;
-
- while (S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort) {
- __int64 pos = m_pFile->GetPos();
-
- DWORD id = 0, size;
- if (S_OK != m_pFile->Read(id) || id == 0) {
- return E_FAIL;
- }
-
- if (id == FCC('RIFF') || id == FCC('LIST')) {
- if (S_OK != m_pFile->Read(size) || S_OK != m_pFile->Read(id)) {
- return E_FAIL;
- }
-
- size += (size & 1) + 8;
-
- if (id == FCC('AVI ') || id == FCC('AVIX') || id == FCC('movi') || id == FCC('rec ')) {
- hr = ReIndex(pos + size, pSize);
- }
- } else {
- if (S_OK != m_pFile->Read(size)) {
- return E_FAIL;
- }
-
- DWORD TrackNumber = TRACKNUM(id);
-
- if (TrackNumber < m_pFile->m_strms.GetCount()) {
- CAviFile::strm_t* s = m_pFile->m_strms[TrackNumber];
-
- WORD type = TRACKTYPE(id);
-
- if (type == 'db' || type == 'dc' || /*type == 'pc' ||*/ type == 'wb'
- || type == 'iv' || type == '__' || type == 'xx') {
- CAviFile::strm_t::chunk c;
- c.filepos = pos;
- c.size = pSize[TrackNumber];
- c.orgsize = size;
- c.fKeyFrame = size > 0; // TODO: find a better way...
- c.fChunkHdr = true;
- s->cs.Add(c);
-
- pSize[TrackNumber] += s->GetChunkSize(size);
-
- REFERENCE_TIME rt = s->GetRefTime((DWORD)s->cs.GetCount() - 1, pSize[TrackNumber]);
- m_rtDuration = max(rt, m_rtDuration);
- }
- }
-
- size += (size & 1) + 8;
- }
-
- m_pFile->Seek(pos + size);
-
- m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
-
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- }
-
- return hr;
-}
-
-void CAviSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- ZeroMemory((DWORD*)m_tFrame, m_pFile->m_avih.dwStreams * sizeof(DWORD));
- m_pFile->Seek(0);
-
- DbgLog((LOG_TRACE, 0, _T("Seek: %I64d"), rt / 10000));
-
- if (rt > 0) {
- for (DWORD track = 0; track < m_pFile->m_avih.dwStreams; track++) {
- CAviFile::strm_t* s = m_pFile->m_strms[track];
-
- if (s->IsRawSubtitleStream() || s->cs.IsEmpty()) {
- continue;
- }
-
- //ASSERT(s->GetFrame(rt) == s->GetKeyFrame(rt)); // fast seek test
- m_tFrame[track] = s->GetKeyFrame(rt);
- }
- }
-}
-
-bool CAviSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- CAtlArray<BOOL> fDiscontinuity;
- fDiscontinuity.SetCount(m_pFile->m_avih.dwStreams);
- ZeroMemory(fDiscontinuity.GetData(), m_pFile->m_avih.dwStreams * sizeof(BOOL));
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- DWORD curTrack = DWORD_MAX;
-
- REFERENCE_TIME minTime = INT64_MAX;
- UINT64 minpos = INT64_MAX;
- for (DWORD track = 0; track < m_pFile->m_avih.dwStreams; track++) {
- CAviFile::strm_t* s = m_pFile->m_strms[track];
- DWORD f = m_tFrame[track];
-
- if (f >= (DWORD)s->cs.GetCount()) {
- continue;
- }
-
- if (s->IsRawSubtitleStream()) {
- // TODO: get subtitle time from index
- minTime = 0;
- curTrack = track;
- break; // read all subtitles at once
- }
-
- REFERENCE_TIME start = s->GetRefTime(f, s->cs[f].size);
- if (start < minTime || (start == minTime && s->cs[f].filepos < minpos)) {
- minTime = start;
- curTrack = track;
- minpos = s->cs[f].filepos;
- }
- }
-
- if (minTime == INT64_MAX) {
- return true;
- }
-
- do {
- CAviFile::strm_t* s = m_pFile->m_strms[curTrack];
- DWORD f = m_tFrame[curTrack];
- //TRACE(_T("CAviFile::DemuxLoop(): track %d, time %I64d, pos %I64d\n"), curTrack, minTime, s->cs[f].filepos);
-
- m_pFile->Seek(s->cs[f].filepos);
- DWORD size = 0;
-
- if (s->cs[f].fChunkHdr) {
- DWORD id = 0;
- if (S_OK != m_pFile->Read(id) || id == 0 || curTrack != TRACKNUM(id) || S_OK != m_pFile->Read(size)) {
- fDiscontinuity[curTrack] = true;
- break;
- }
-
- if (size != s->cs[f].orgsize) {
- TRACE(_T("WARNING: CAviFile::DemuxLoop() incorrect chunk size. By index: %d, by header: %d\n"), s->cs[f].orgsize, size);
- fDiscontinuity[curTrack] = true;
- //ASSERT(0);
- break;
- }
- } else {
- size = s->cs[f].orgsize;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = (DWORD)curTrack;
- p->bSyncPoint = (BOOL)s->cs[f].fKeyFrame;
- p->bDiscontinuity = fDiscontinuity[curTrack];
- p->rtStart = s->GetRefTime(f, s->cs[f].size);
- p->rtStop = s->GetRefTime(f + 1, f + 1 < (DWORD)s->cs.GetCount() ? s->cs[f + 1].size : s->totalsize);
- p->SetCount(size);
- if (S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
- return true; // break;
- }
-#if defined(_DEBUG) && 0
- DbgLog((LOG_TRACE, 0,
- _T("%d (%d): %I64d - %I64d, %I64d - %I64d (size = %d)"),
- minTrack, (int)p->bSyncPoint,
- (p->rtStart) / 10000, (p->rtStop) / 10000,
- (p->rtStart - m_rtStart) / 10000, (p->rtStop - m_rtStart) / 10000,
- size));
-#endif
- m_maxTimeStamp = max(m_maxTimeStamp, p->rtStart);
-
- hr = DeliverPacket(p);
-
- fDiscontinuity[curTrack] = false;
- } while (0);
-
- m_tFrame[curTrack]++;
- }
-
- if (m_maxTimeStamp != Packet::INVALID_TIME) {
- m_rtCurrent = m_maxTimeStamp;
- }
- return true;
-}
-
-// IMediaSeeking
-
-STDMETHODIMP CAviSplitterFilter::GetDuration(LONGLONG* pDuration)
-{
- CheckPointer(pDuration, E_POINTER);
- CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
-
- if (m_timeformat == TIME_FORMAT_FRAME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- *pDuration = s->cs.GetCount();
- return S_OK;
- }
- }
-
- return E_UNEXPECTED;
- }
-
- return __super::GetDuration(pDuration);
-}
-
-//
-
-STDMETHODIMP CAviSplitterFilter::IsFormatSupported(const GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- HRESULT hr = __super::IsFormatSupported(pFormat);
- if (S_OK == hr) {
- return hr;
- }
- return *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetTimeFormat(GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- *pFormat = m_timeformat;
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- return *pFormat == m_timeformat ? S_OK : S_FALSE;
-}
-
-STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- if (S_OK != IsFormatSupported(pFormat)) {
- return E_FAIL;
- }
- m_timeformat = *pFormat;
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetStopPosition(LONGLONG* pStop)
-{
- CheckPointer(pStop, E_POINTER);
- if (FAILED(__super::GetStopPosition(pStop))) {
- return E_FAIL;
- }
- if (m_timeformat == TIME_FORMAT_MEDIA_TIME) {
- return S_OK;
- }
- LONGLONG rt = *pStop;
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
-{
- CheckPointer(pTarget, E_POINTER);
-
- const GUID& SourceFormat = pSourceFormat ? *pSourceFormat : m_timeformat;
- const GUID& TargetFormat = pTargetFormat ? *pTargetFormat : m_timeformat;
-
- if (TargetFormat == SourceFormat) {
- *pTarget = Source;
- return S_OK;
- } else if (TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- *pTarget = s->GetFrame(Source);
- return S_OK;
- }
- }
- } else if (TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- if (Source < 0 || Source >= (LONGLONG)s->cs.GetCount()) {
- return E_FAIL;
- }
- CAviFile::strm_t::chunk& c = s->cs[(size_t)Source];
- *pTarget = s->GetRefTime((DWORD)Source, c.size);
- return S_OK;
- }
- }
- }
-
- return E_FAIL;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
-{
- HRESULT hr;
- if (FAILED(hr = __super::GetPositions(pCurrent, pStop)) || m_timeformat != TIME_FORMAT_FRAME) {
- return hr;
- }
-
- if (pCurrent)
- if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_FRAME, *pCurrent, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- if (pStop)
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, *pStop, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
-
- return S_OK;
-}
-
-HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
-{
- if (m_timeformat != TIME_FORMAT_FRAME) {
- return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
- }
-
- if (!pCurrent && !pStop
- || (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
- && (dwStopFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
- return S_OK;
- }
-
- REFERENCE_TIME
- rtCurrent = m_rtCurrent,
- rtStop = m_rtStop;
-
- if ((dwCurrentFlags & AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtCurrent, &TIME_FORMAT_FRAME, rtCurrent, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- if ((dwStopFlags & AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtStop, &TIME_FORMAT_FRAME, rtStop, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
-
- if (pCurrent)
- switch (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtCurrent = *pCurrent;
- break;
- case AM_SEEKING_RelativePositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- }
-
- if (pStop)
- switch (dwStopFlags & AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtStop = *pStop;
- break;
- case AM_SEEKING_RelativePositioning:
- rtStop += *pStop;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtStop = rtCurrent + *pStop;
- break;
- }
-
- if ((dwCurrentFlags & AM_SEEKING_PositioningBitsMask)
- && pCurrent)
- if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_MEDIA_TIME, rtCurrent, &TIME_FORMAT_FRAME))) {
- return E_FAIL;
- }
- if ((dwStopFlags & AM_SEEKING_PositioningBitsMask)
- && pStop)
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
- return E_FAIL;
- }
-
- return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CAviSplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- HRESULT hr = S_OK;
-
- nKFs = 0;
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType != FCC('vids')) {
- continue;
- }
-
- for (unsigned int j = 0; j < s->cs.GetCount(); ++j) {
- CAviFile::strm_t::chunk& c = s->cs[j];
- if (c.fKeyFrame) {
- ++nKFs;
- }
- }
-
- if (nKFs == s->cs.GetCount()) {
- hr = S_FALSE;
- }
-
- break;
- }
-
- return hr;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
- return E_INVALIDARG;
- }
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType != FCC('vids')) {
- continue;
- }
- bool fConvertToRefTime = !!(*pFormat == TIME_FORMAT_MEDIA_TIME);
-
- UINT nKFsTmp = 0;
-
- for (unsigned int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; ++j) {
- if (s->cs[j].fKeyFrame) {
- pKFs[nKFsTmp++] = fConvertToRefTime ? s->GetRefTime(j, s->cs[j].size) : j;
- }
- }
- nKFs = nKFsTmp;
-
- return S_OK;
- }
-
- return E_FAIL;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CAviSplitterFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CAviSplitterSettingsWnd);
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CAviSplitterFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CAviSplitterSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CAviSplitterSettingsWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-// IAviSplitterFilter
-STDMETHODIMP CAviSplitterFilter::Apply()
-{
-#ifdef STANDALONE_FILTER
- /*CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\AVI Splitter"))) {
- key.SetDWORDValue(_T("NonInterleavedFilesSupport"), m_bNonInterleavedFilesSupport);
- }*/
-#else
- //AfxGetApp()->WriteProfileInt(_T("Filters\\AVI Splitter"), _T("NonInterleavedFilesSupport"), m_bNonInterleavedFilesSupport);
-#endif
-
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::SetNonInterleavedFilesSupport(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_bNonInterleavedFilesSupport = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CAviSplitterFilter::GetNonInterleavedFilesSupport()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_bNonInterleavedFilesSupport;
-}
-
-//
-// CAviSourceFilter
-//
-
-CAviSourceFilter::CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CAviSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CAviSplitterOutputPin
-//
-
-CAviSplitterOutputPin::CAviSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_AVI)
-{
-}
-
-HRESULT CAviSplitterOutputPin::CheckConnect(IPin* pPin)
-{
- int iPosition = 0;
- CMediaType mt;
- while (S_OK == GetMediaType(iPosition++, &mt)) {
- if (mt.majortype == MEDIATYPE_Video
- && (mt.subtype == FOURCCMap(FCC('IV32'))
- || mt.subtype == FOURCCMap(FCC('IV31'))
- || mt.subtype == FOURCCMap(FCC('IF09')))) {
- CLSID clsid = GetCLSID(GetFilterFromPin(pPin));
- if (clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
- return E_FAIL;
- }
- }
-
- mt.InitMediaType();
- }
-
- return __super::CheckConnect(pPin);
-}
diff --git a/src/filters/parser/AviSplitter/AviSplitter.def b/src/filters/parser/AviSplitter/AviSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/AviSplitter/AviSplitter.h b/src/filters/parser/AviSplitter/AviSplitter.h
deleted file mode 100644
index 8f2005fd2..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "AviSplitterSettingsWnd.h"
-
-#define AviSplitterName L"MPC AVI Splitter"
-#define AviSourceName L"MPC AVI Source"
-
-class CAviFile;
-
-class CAviSplitterOutputPin : public CBaseSplitterOutputPin
-{
-public:
- CAviSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT CheckConnect(IPin* pPin);
-};
-
-class __declspec(uuid("9736D831-9D6C-4E72-B6E7-560EF9181001"))
- CAviSplitterFilter
- : public CBaseSplitterFilter
- , public ISpecifyPropertyPages2
- , public IAviSplitterFilter
-{
- CCritSec m_csProps;
-
- CAutoVectorPtr<DWORD> m_tFrame;
-
- bool m_bNonInterleavedFilesSupport;
-
-protected:
- CAutoPtr<CAviFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
- HRESULT ReIndex(__int64 end, UINT64* pSize);
-
- REFERENCE_TIME m_maxTimeStamp;
-public:
- CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IMediaSeeking
-
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
-
- // TODO: this is too ugly, integrate this with the baseclass somehow
- GUID m_timeformat;
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat,
- LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
-
- HRESULT SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags,
- LONGLONG* pStop, DWORD dwStopFlags);
-
- // IKeyFrameInfo
-
- STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-
- // ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // IAviSplitterFilter
- STDMETHODIMP Apply();
-
- STDMETHODIMP SetNonInterleavedFilesSupport(BOOL nValue);
- STDMETHODIMP_(BOOL) GetNonInterleavedFilesSupport();
-};
-
-class __declspec(uuid("CEA8DEFF-0AF7-4DB9-9A38-FB3C3AEFC0DE"))
- CAviSourceFilter : public CAviSplitterFilter
-{
-public:
- CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/AviSplitter/AviSplitter.rc b/src/filters/parser/AviSplitter/AviSplitter.rc
deleted file mode 100644
index da78c7cbd..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.rc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "AVI Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "AVI Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "AviSplitter.ax"
- VALUE "ProductName", "AVI Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-STRINGTABLE
-BEGIN
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_AVISPLITTER_NON_INTERLEAVED "Non interleaved files support"
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/AviSplitter/AviSplitter.vcxproj b/src/filters/parser/AviSplitter/AviSplitter.vcxproj
deleted file mode 100644
index b07296a91..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.vcxproj
+++ /dev/null
@@ -1,258 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{9738B023-FC46-48A2-953A-0035FD897678}</ProjectGuid>
- <RootNamespace>AviSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>AviSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="AviFile.cpp" />
- <ClCompile Include="AviSplitter.cpp" />
- <ClCompile Include="AviSplitterSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="AviSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="AviFile.h" />
- <ClInclude Include="AviSplitter.h" />
- <ClInclude Include="AviSplitterSettingsWnd.h" />
- <ClInclude Include="IAviSplitterFilter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="AviSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters b/src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters
deleted file mode 100644
index 080f0fa1b..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{ec5fabec-814c-4ffb-8d23-25aec8708380}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{cc7db61d-a383-4ede-bcbb-8c23eff3cea6}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{0b124017-fe32-448f-a338-451dbd38ed75}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="AviFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="AviSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="AviSplitterSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="AviSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="AviFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="AviSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="AviSplitterSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="IAviSplitterFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="AviSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp b/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp
deleted file mode 100644
index 975823d58..000000000
--- a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "AviSplitterSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "resource.h"
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-
-
-CAviSplitterSettingsWnd::CAviSplitterSettingsWnd()
-{
-}
-
-bool CAviSplitterSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pASF);
-
- m_pASF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pASF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pASF) {
- return false;
- }
-
- return true;
-}
-
-void CAviSplitterSettingsWnd::OnDisconnect()
-{
- m_pASF.Release();
-}
-
-bool CAviSplitterSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
-
- m_cbNonInterleavedFilesSupport.Create(ResStr(IDS_AVISPLITTER_NON_INTERLEAVED), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(260), m_fontheight)), this, IDC_PP_NON_INTERLEAVED_FILES_SUPPORT);
- p.y += h20;
-
- if (m_pASF) {
- m_cbNonInterleavedFilesSupport.SetCheck(m_pASF->GetNonInterleavedFilesSupport());
- }
- m_cbNonInterleavedFilesSupport.EnableWindow(FALSE);
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CAviSplitterSettingsWnd::OnDeactivate()
-{
-}
-
-bool CAviSplitterSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pASF) {
- m_pASF->SetNonInterleavedFilesSupport(m_cbNonInterleavedFilesSupport.GetCheck());
-
- m_pASF->Apply();
- }
-
- return true;
-}
-
-BEGIN_MESSAGE_MAP(CAviSplitterSettingsWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
diff --git a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h b/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h
deleted file mode 100644
index b56e93c15..000000000
--- a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * (C) 2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "IAviSplitterFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("A008C72A-0D51-461D-9043-C823B3A7D4CC"))
- CAviSplitterSettingsWnd : public CInternalPropertyPageWnd
-{
-private:
- CComQIPtr<IAviSplitterFilter> m_pASF;
-
- CButton m_cbNonInterleavedFilesSupport;
-
- enum {
- IDC_PP_NON_INTERLEAVED_FILES_SUPPORT = 10000,
- };
-
-public:
- CAviSplitterSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(280, 33); }
-
- DECLARE_MESSAGE_MAP()
-};
diff --git a/src/filters/parser/AviSplitter/IAviSplitterFilter.h b/src/filters/parser/AviSplitter/IAviSplitterFilter.h
deleted file mode 100644
index a648d3b42..000000000
--- a/src/filters/parser/AviSplitter/IAviSplitterFilter.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-interface __declspec(uuid("1E41BBCB-F6E0-4A49-91F7-A2AD5B5C7113"))
-IAviSplitterFilter :
-public IUnknown {
- STDMETHOD(Apply()) PURE;
-
- STDMETHOD(SetNonInterleavedFilesSupport(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetNonInterleavedFilesSupport()) PURE;
-};
diff --git a/src/filters/parser/AviSplitter/resource.h b/src/filters/parser/AviSplitter/resource.h
deleted file mode 100644
index 6a2c6fabd..000000000
--- a/src/filters/parser/AviSplitter/resource.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by AviSplitter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_AVISPLITTER_NON_INTERLEAVED 7100
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/AviSplitter/stdafx.cpp b/src/filters/parser/AviSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/AviSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/AviSplitter/stdafx.h b/src/filters/parser/AviSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/AviSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.cpp b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
deleted file mode 100644
index 1b16e6c0c..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.cpp
+++ /dev/null
@@ -1,924 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "FLVSplitter.h"
-#include "../../../DSUtil/DSUtil.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include <MMReg.h>
-#include "moreuuids.h"
-
-#define FLV_AUDIODATA 8
-#define FLV_VIDEODATA 9
-#define FLV_SCRIPTDATA 18
-
-#define FLV_AUDIO_PCM 0 // Linear PCM, platform endian
-#define FLV_AUDIO_ADPCM 1 // ADPCM
-#define FLV_AUDIO_MP3 2 // MP3
-#define FLV_AUDIO_PCMLE 3 // Linear PCM, little endian
-#define FLV_AUDIO_NELLY16 4 // Nellymoser 16 kHz mono
-#define FLV_AUDIO_NELLY8 5 // Nellymoser 8 kHz mono
-#define FLV_AUDIO_NELLY 6 // Nellymoser
-// 7 = G.711 A-law logarithmic PCM (reserved)
-// 8 = G.711 mu-law logarithmic PCM (reserved)
-// 9 = reserved
-#define FLV_AUDIO_AAC 10 // AAC
-#define FLV_AUDIO_SPEEX 11 // Speex
-// 14 = MP3 8 kHz (reserved)
-// 15 = Device-specific sound (reserved)
-
-//#define FLV_VIDEO_JPEG 1 // non-standard? need samples
-#define FLV_VIDEO_H263 2 // Sorenson H.263
-#define FLV_VIDEO_SCREEN 3 // Screen video
-#define FLV_VIDEO_VP6 4 // On2 VP6
-#define FLV_VIDEO_VP6A 5 // On2 VP6 with alpha channel
-#define FLV_VIDEO_SCREEN2 6 // Screen video version 2
-#define FLV_VIDEO_AVC 7 // AVC
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_FLV},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CFLVSplitterFilter), FlvSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CFLVSourceFilter), FlvSourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLVSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CFLVSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".flv"));
-
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_FLV, _T("0,4,,464C5601"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_FLV);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CFLVSplitterFilter
-//
-
-CFLVSplitterFilter::CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CFLVSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-STDMETHODIMP CFLVSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, FlvSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-bool CFLVSplitterFilter::ReadTag(Tag& t)
-{
- if (m_pFile->GetRemaining() < 15) {
- return false;
- }
-
- t.PreviousTagSize = (UINT32)m_pFile->BitRead(32);
- t.TagType = (BYTE)m_pFile->BitRead(8);
- t.DataSize = (UINT32)m_pFile->BitRead(24);
- t.TimeStamp = (UINT32)m_pFile->BitRead(24);
- t.TimeStamp |= (UINT32)m_pFile->BitRead(8) << 24;
- t.StreamID = (UINT32)m_pFile->BitRead(24);
-
- return m_pFile->GetRemaining() >= t.DataSize;
-}
-
-bool CFLVSplitterFilter::ReadTag(AudioTag& at)
-{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
-
- at.SoundFormat = (BYTE)m_pFile->BitRead(4);
- at.SoundRate = (BYTE)m_pFile->BitRead(2);
- at.SoundSize = (BYTE)m_pFile->BitRead(1);
- at.SoundType = (BYTE)m_pFile->BitRead(1);
-
- return true;
-}
-
-bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
-{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
-
- vt.FrameType = (BYTE)m_pFile->BitRead(4);
- vt.CodecID = (BYTE)m_pFile->BitRead(4);
-
- return true;
-}
-
-#ifndef NOVIDEOTWEAK
-bool CFLVSplitterFilter::ReadTag(VideoTweak& vt)
-{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
-
- vt.x = (BYTE)m_pFile->BitRead(4);
- vt.y = (BYTE)m_pFile->BitRead(4);
-
- return true;
-}
-#endif
-
-bool CFLVSplitterFilter::Sync(__int64& pos)
-{
- m_pFile->Seek(pos);
-
- while (m_pFile->GetRemaining() >= 15) {
- __int64 limit = m_pFile->GetRemaining();
- while (true) {
- BYTE b = (BYTE)m_pFile->BitRead(8);
- if (b == FLV_AUDIODATA || b == FLV_VIDEODATA) {
- break;
- }
- if (--limit < 15) {
- return false;
- }
- }
-
- pos = m_pFile->GetPos() - 5;
- m_pFile->Seek(pos);
-
- Tag ct;
- if (ReadTag(ct)) {
- __int64 next = m_pFile->GetPos() + ct.DataSize;
- if (next == m_pFile->GetLength() - 4) {
- m_pFile->Seek(pos);
- return true;
- } else if (next <= m_pFile->GetLength() - 19) {
- m_pFile->Seek(next);
- Tag nt;
- if (ReadTag(nt) && (nt.TagType == FLV_AUDIODATA || nt.TagType == FLV_VIDEODATA || nt.TagType == FLV_SCRIPTDATA)) {
- if ((nt.PreviousTagSize == ct.DataSize + 11) ||
- (m_IgnorePrevSizes &&
- nt.TimeStamp >= ct.TimeStamp &&
- nt.TimeStamp - ct.TimeStamp <= 1000)) {
- m_pFile->Seek(pos);
- return true;
- }
- }
- }
- }
-
- m_pFile->Seek(pos + 5);
- }
-
- return false;
-}
-
-HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DEBUG_NEW CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- if (m_pFile->BitRead(24) != 'FLV' || m_pFile->BitRead(8) != 1) {
- return E_FAIL;
- }
-
- EXECUTE_ASSERT(m_pFile->BitRead(5) == 0); // TypeFlagsReserved
- bool fTypeFlagsAudio = !!m_pFile->BitRead(1);
- EXECUTE_ASSERT(m_pFile->BitRead(1) == 0); // TypeFlagsReserved
- bool fTypeFlagsVideo = !!m_pFile->BitRead(1);
- m_DataOffset = (UINT32)m_pFile->BitRead(32);
-
- // doh, these flags aren't always telling the truth
- fTypeFlagsAudio = fTypeFlagsVideo = true;
-
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- UINT32 prevTagSize = 0;
- m_IgnorePrevSizes = false;
-
- m_pFile->Seek(m_DataOffset);
-
- for (int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio); i++) {
- if (!t.DataSize) {
- continue; // skip empty Tag
- }
-
- UINT64 next = m_pFile->GetPos() + t.DataSize;
-
- CStringW name;
-
- CMediaType mt;
- CMediaType ff_mtype;
- mt.SetSampleSize(1);
- mt.subtype = GUID_NULL;
-
- if (i != 0 && t.PreviousTagSize != prevTagSize) {
- m_IgnorePrevSizes = true;
- }
- prevTagSize = t.DataSize + 11;
-
- if (t.TagType == FLV_AUDIODATA && t.DataSize != 0 && fTypeFlagsAudio) {
- UNREFERENCED_PARAMETER(at);
- AudioTag at;
- name = L"Audio";
-
- if (ReadTag(at)) {
- int dataSize = t.DataSize - 1;
-
- fTypeFlagsAudio = false;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, sizeof(WAVEFORMATEX));
- wfe->nSamplesPerSec = 44100 * (1 << at.SoundRate) / 8;
- wfe->wBitsPerSample = 8 * (at.SoundSize + 1);
- wfe->nChannels = at.SoundType + 1;
-
- switch (at.SoundFormat) {
- case FLV_AUDIO_PCM:
- case FLV_AUDIO_PCMLE:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
- name += L" PCM";
- wfe->nBlockAlign = wfe->wBitsPerSample * wfe->nChannels / 8;
- wfe->nAvgBytesPerSec = wfe->nBlockAlign * wfe->nSamplesPerSec;
- break;
- case FLV_AUDIO_ADPCM:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_ADPCM_SWF);
- name += L" ADPCM";
- break;
- case FLV_AUDIO_MP3:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
- name += L" MP3";
-
- {
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, 4, false, &mt2)) {
- mt = mt2;
- }
- }
- break;
- case FLV_AUDIO_NELLY16:
- mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
- wfe->nSamplesPerSec = 16000;
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_NELLY8:
- mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
- wfe->nSamplesPerSec = 8000;
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_NELLY:
- mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_AAC: {
- if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
- fTypeFlagsAudio = true;
- break;
- }
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- name += L" AAC";
-
- __int64 configOffset = m_pFile->GetPos();
- UINT32 configSize = dataSize - 1;
- if (configSize < 2) {
- break;
- }
-
- // Might break depending on the AAC profile, see ff_mpeg4audio_get_config in ffmpeg's mpeg4audio.c
- m_pFile->BitRead(5);
- int iSampleRate = (int)m_pFile->BitRead(4);
- int iChannels = (int)m_pFile->BitRead(4);
- if (iSampleRate > 12 || iChannels > 7) {
- break;
- }
-
- const int sampleRates[] = {
- 96000, 88200, 64000, 48000, 44100, 32000, 24000,
- 22050, 16000, 12000, 11025, 8000, 7350
- };
- const int channels[] = {
- 0, 1, 2, 3, 4, 5, 6, 8
- };
-
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + configSize);
- ZeroMemory(wfe, mt.FormatLength());
- wfe->nSamplesPerSec = sampleRates[iSampleRate];
- wfe->wBitsPerSample = 16;
- wfe->nChannels = channels[iChannels];
- wfe->cbSize = configSize;
-
- m_pFile->Seek(configOffset);
- m_pFile->ByteRead((BYTE*)(wfe + 1), configSize);
- }
-
- }
- }
- } else if (t.TagType == FLV_VIDEODATA && t.DataSize != 0 && fTypeFlagsVideo) {
- UNREFERENCED_PARAMETER(vt);
- VideoTag vt;
- if (ReadTag(vt) && vt.FrameType == 1) {
- int dataSize = t.DataSize - 1;
-
- fTypeFlagsVideo = false;
- name = L"Video";
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- ZeroMemory(vih, sizeof(VIDEOINFOHEADER));
-
- BITMAPINFOHEADER* bih = &vih->bmiHeader;
-
- int w, h, arx, ary;
-
- switch (vt.CodecID) {
- case FLV_VIDEO_H263: // H.263
- if (m_pFile->BitRead(17) != 1) {
- break;
- }
-
- m_pFile->BitRead(13); // Version (5), TemporalReference (8)
-
- switch (BYTE PictureSize = (BYTE)m_pFile->BitRead(3)) { // w00t
- case 0:
- case 1:
- vih->bmiHeader.biWidth = (WORD)m_pFile->BitRead(8 * (PictureSize + 1));
- vih->bmiHeader.biHeight = (WORD)m_pFile->BitRead(8 * (PictureSize + 1));
- break;
- case 2:
- case 3:
- case 4:
- vih->bmiHeader.biWidth = 704 / PictureSize;
- vih->bmiHeader.biHeight = 576 / PictureSize;
- break;
- case 5:
- case 6:
- PictureSize -= 3;
- vih->bmiHeader.biWidth = 640 / PictureSize;
- vih->bmiHeader.biHeight = 480 / PictureSize;
- break;
- }
-
- if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
- break;
- }
-
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
- name += L" H.263";
-
- break;
- case FLV_VIDEO_SCREEN: {
- m_pFile->BitRead(4);
- vih->bmiHeader.biWidth = (LONG)m_pFile->BitRead(12);
- m_pFile->BitRead(4);
- vih->bmiHeader.biHeight = (LONG)m_pFile->BitRead(12);
-
- if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
- break;
- }
-
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 24;
- vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth * vih->bmiHeader.biHeight * 3;
-
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VSF');
- name += L" Screen";
-
- break;
- }
- case FLV_VIDEO_VP6A: // VP6 with alpha
- m_pFile->BitRead(24);
- case FLV_VIDEO_VP6: { // VP6
-#ifdef NOVIDEOTWEAK
- m_pFile->BitRead(8);
-#else
- VideoTweak fudge;
- ReadTag(fudge);
-#endif
-
- if (m_pFile->BitRead(1)) {
- // Delta (inter) frame
- fTypeFlagsVideo = true;
- break;
- }
- m_pFile->BitRead(6);
- bool fSeparatedCoeff = !!m_pFile->BitRead(1);
- m_pFile->BitRead(5);
- int filterHeader = (int)m_pFile->BitRead(2);
- m_pFile->BitRead(1);
- if (fSeparatedCoeff || !filterHeader) {
- m_pFile->BitRead(16);
- }
-
- h = (int)m_pFile->BitRead(8) * 16;
- w = (int)m_pFile->BitRead(8) * 16;
-
- ary = (int)m_pFile->BitRead(8) * 16;
- arx = (int)m_pFile->BitRead(8) * 16;
-
- if (arx && arx != w || ary && ary != h) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- ZeroMemory(vih2, sizeof(VIDEOINFOHEADER2));
- vih2->dwPictAspectRatioX = arx;
- vih2->dwPictAspectRatioY = ary;
- bih = &vih2->bmiHeader;
- mt.formattype = FORMAT_VideoInfo2;
- vih = (VIDEOINFOHEADER*)vih2;
- }
-
- bih->biWidth = w;
- bih->biHeight = h;
-#ifndef NOVIDEOTWEAK
- SetRect(&vih->rcSource, 0, 0, w - fudge.x, h - fudge.y);
- SetRect(&vih->rcTarget, 0, 0, w - fudge.x, h - fudge.y);
-#endif
-
- mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
- name += L" VP6";
-
- break;
- }
- case FLV_VIDEO_AVC: { // H.264
- if (dataSize < 4 || m_pFile->BitRead(8) != 0) { // packet type 0 == avc header
- fTypeFlagsVideo = true;
- break;
- }
- m_pFile->BitRead(24); // composition time
-
- __int64 headerOffset = m_pFile->GetPos();
- UINT32 headerSize = dataSize - 4;
- BYTE* headerData = DEBUG_NEW BYTE[headerSize];
-
- m_pFile->ByteRead(headerData, headerSize);
-
- m_pFile->Seek(headerOffset + 9);
-
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + headerSize);
- ZeroMemory(vih, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- vih->dwFlags = (headerData[4] & 0x03) + 1; // nal length size
-
- vih->dwProfile = (BYTE)m_pFile->BitRead(8);
- m_pFile->BitRead(8);
- vih->dwLevel = (BYTE)m_pFile->BitRead(8);
- m_pFile->UExpGolombRead(); // seq_parameter_set_id
- UINT64 chroma_format_idc = 0;
- if (vih->dwProfile >= 100) { // high profile
- chroma_format_idc = m_pFile->UExpGolombRead();
- if (chroma_format_idc == 3) { // chroma_format_idc
- m_pFile->BitRead(1); // residue_transform_flag
- }
- m_pFile->UExpGolombRead(); // bit_depth_luma_minus8
- m_pFile->UExpGolombRead(); // bit_depth_chroma_minus8
- m_pFile->BitRead(1); // qpprime_y_zero_transform_bypass_flag
- if (m_pFile->BitRead(1)) { // seq_scaling_matrix_present_flag
- for (int k = 0; k < 8; k++) {
- if (m_pFile->BitRead(1)) { // seq_scaling_list_present_flag
- for (int j = 0, size = (k < 6) ? 16 : 64, next = 8; j < size && next != 0; ++j) {
- next = (next + m_pFile->SExpGolombRead() + 256) & 255;
- }
- }
- }
- }
- }
- m_pFile->UExpGolombRead(); // log2_max_frame_num_minus4
- UINT64 pic_order_cnt_type = m_pFile->UExpGolombRead();
- if (pic_order_cnt_type == 0) {
- m_pFile->UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- } else if (pic_order_cnt_type == 1) {
- m_pFile->BitRead(1); // delta_pic_order_always_zero_flag
- m_pFile->SExpGolombRead(); // offset_for_non_ref_pic
- m_pFile->SExpGolombRead(); // offset_for_top_to_bottom_field
- UINT64 num_ref_frames_in_pic_order_cnt_cycle = m_pFile->UExpGolombRead();
- for (int k = 0; k < num_ref_frames_in_pic_order_cnt_cycle; k++) {
- m_pFile->SExpGolombRead(); // offset_for_ref_frame[k]
- }
- }
- m_pFile->UExpGolombRead(); // num_ref_frames
- m_pFile->BitRead(1); // gaps_in_frame_num_value_allowed_flag
- UINT64 pic_width_in_mbs_minus1 = m_pFile->UExpGolombRead();
- UINT64 pic_height_in_map_units_minus1 = m_pFile->UExpGolombRead();
- BYTE frame_mbs_only_flag = (BYTE)m_pFile->BitRead(1);
- if (!frame_mbs_only_flag) {
- m_pFile->BitRead(1); // mb_adaptive_frame_field_flag
- }
- m_pFile->BitRead(1); // direct_8x8_inference_flag
- BYTE crop = (BYTE)m_pFile->BitRead(1); // frame_cropping_flag
- unsigned int crop_left = 0;
- unsigned int crop_right = 0;
- unsigned int crop_top = 0;
- unsigned int crop_bottom = 0;
-
- if (crop) {
- crop_left = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_left_offset
- crop_right = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_right_offset
- crop_top = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_top_offset
- crop_bottom = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_bottom_offset
- }
- struct sar {
- WORD num;
- WORD den;
- } sar;
-
- if (m_pFile->BitRead(1)) { // vui_parameters_present_flag
- if (m_pFile->BitRead(1)) { // aspect_ratio_info_present_flag
- BYTE aspect_ratio_idc = (BYTE)m_pFile->BitRead(8); // aspect_ratio_idc
- if (255 == aspect_ratio_idc) {
- sar.num = (WORD)m_pFile->BitRead(16); // sar_width
- sar.den = (WORD)m_pFile->BitRead(16); // sar_height
- } else if (aspect_ratio_idc < 17) {
- sar.num = pixel_aspect[aspect_ratio_idc][0];
- sar.den = pixel_aspect[aspect_ratio_idc][1];
- } else {
- return E_FAIL;
- }
- } else {
- sar.num = 1;
- sar.den = 1;
- }
- }
- unsigned int mb_Width = (unsigned int)pic_width_in_mbs_minus1 + 1;
- unsigned int mb_Height = ((unsigned int)pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag);
- BYTE CHROMA444 = (chroma_format_idc == 3);
-
- unsigned int Width, Height;
- Width = 16 * mb_Width - (2u >> CHROMA444) * min(crop_right, (8u << CHROMA444) - 1);
- if (frame_mbs_only_flag) {
- Height = 16 * mb_Height - (2u >> CHROMA444) * min(crop_bottom, (8u << CHROMA444) - 1);
- } else {
- Height = 16 * mb_Height - (4u >> CHROMA444) * min(crop_bottom, (8u << CHROMA444) - 1);
- }
- if (!sar.num) {
- sar.num = 1;
- }
- if (!sar.den) {
- sar.den = 1;
- }
- CSize aspect(Width * sar.num, Height * sar.den);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
-
- vih->hdr.dwPictAspectRatioX = aspect.cx;
- vih->hdr.dwPictAspectRatioY = aspect.cy;
- vih->hdr.bmiHeader.biWidth = Width;
- vih->hdr.bmiHeader.biHeight = Height;
-
- BYTE* src = (BYTE*)headerData + 5;
- BYTE* dst = (BYTE*)vih->dwSequenceHeader;
- BYTE* src_end = (BYTE*)headerData + headerSize;
- BYTE* dst_end = (BYTE*)vih->dwSequenceHeader + headerSize;
- int spsCount = *(src++) & 0x1F;
- int ppsCount = -1;
-
- vih->cbSequenceHeader = 0;
-
- while (src < src_end - 1) {
- if (spsCount == 0 && ppsCount == -1) {
- ppsCount = *(src++);
- continue;
- }
-
- if (spsCount > 0) {
- spsCount--;
- } else if (ppsCount > 0) {
- ppsCount--;
- } else {
- break;
- }
-
- int len = ((src[0] << 8) | src[1]) + 2;
- if (src + len > src_end || dst + len > dst_end) {
- ASSERT(0);
- break;
- }
- memcpy(dst, src, len);
- src += len;
- dst += len;
- vih->cbSequenceHeader += len;
- }
-
- delete [] headerData;
-
- mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
- name += L" H.264";
-
- break;
- }
- default:
- fTypeFlagsVideo = true;
- }
- }
- }
-
- if (mt.subtype != GUID_NULL) {
- CAtlArray<CMediaType> mts;
- if (mt.subtype == FOURCCMap(MAKEFOURCC('A', 'S', 'W', 'F'))) {
- mts.InsertAt(0, ff_mtype);
- }
- mts.Add(mt);
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CBaseSplitterOutputPin(mts, name, this, this, &hr));
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(t.TagType, pPinOut)));
- }
-
- m_pFile->Seek(next);
- }
-
- if (m_pFile->IsRandomAccess()) {
- __int64 pos = max(m_DataOffset, m_pFile->GetLength() - 256 * 1024);
-
- if (Sync(pos)) {
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t)) {
- UINT64 next = m_pFile->GetPos() + t.DataSize;
-
- if (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt)) {
- m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
- }
-
- m_pFile->Seek(next);
- }
- }
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CFLVSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CFLVSplitterFilter");
- return true;
-}
-
-void CFLVSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- if (!m_rtDuration || rt <= 0) {
- m_pFile->Seek(m_DataOffset);
- } else if (!m_IgnorePrevSizes) {
- NormalSeek(rt);
- } else {
- AlternateSeek(rt);
- }
-}
-
-void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
-{
- bool fAudio = !!GetOutputPin(FLV_AUDIODATA);
- bool fVideo = !!GetOutputPin(FLV_VIDEODATA);
-
- __int64 pos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
-
- if (!Sync(pos)) {
- ASSERT(0);
- m_pFile->Seek(m_DataOffset);
- return;
- }
-
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t)) {
- if (10000i64 * t.TimeStamp >= rt) {
- m_pFile->Seek(m_pFile->GetPos() - 15);
- break;
- }
-
- m_pFile->Seek(m_pFile->GetPos() + t.DataSize);
- }
-
- while (m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t)) {
- UINT64 prev = m_pFile->GetPos() - 15 - t.PreviousTagSize - 4;
-
- if (10000i64 * t.TimeStamp <= rt) {
- if (t.TagType == FLV_AUDIODATA && ReadTag(at)) {
- fAudio = false;
- } else if (t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
- fVideo = false;
- }
- }
-
- m_pFile->Seek(prev);
- }
-
- if (fAudio || fVideo) {
- ASSERT(0);
- m_pFile->Seek(m_DataOffset);
- }
-}
-
-void CFLVSplitterFilter::AlternateSeek(REFERENCE_TIME rt)
-{
- bool hasAudio = !!GetOutputPin(FLV_AUDIODATA);
- bool hasVideo = !!GetOutputPin(FLV_VIDEODATA);
-
- __int64 estimPos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
-
- while (true) {
- estimPos -= 256 * 1024;
- if (estimPos < m_DataOffset) {
- estimPos = m_DataOffset;
- }
-
- bool foundAudio = !hasAudio;
- bool foundVideo = !hasVideo;
- __int64 bestPos = estimPos;
-
- if (Sync(bestPos)) {
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t) && t.TimeStamp * 10000i64 < rt) {
- __int64 cur = m_pFile->GetPos() - 15;
- __int64 next = cur + 15 + t.DataSize;
-
- if (hasAudio && t.TagType == FLV_AUDIODATA && ReadTag(at)) {
- foundAudio = true;
- if (!hasVideo) {
- bestPos = cur;
- }
- } else if (hasVideo && t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
- foundVideo = true;
- bestPos = cur;
- }
-
- m_pFile->Seek(next);
- }
- }
-
- if (foundAudio && foundVideo) {
- m_pFile->Seek(bestPos);
- return;
- } else if (estimPos == m_DataOffset) {
- m_pFile->Seek(m_DataOffset);
- return;
- }
-
- }
-}
-
-bool CFLVSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- CAutoPtr<Packet> p;
-
- Tag t;
- AudioTag at = {};
- VideoTag vt = {};
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->GetRemaining()) {
- if (!ReadTag(t)) {
- break;
- }
-
- __int64 next = m_pFile->GetPos() + t.DataSize;
-
- if ((t.DataSize > 0) && (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt))) {
- UINT32 tsOffset = 0;
- if (t.TagType == FLV_VIDEODATA) {
- if (vt.FrameType == 5) {
- goto NextTag; // video info/command frame
- }
- if (vt.CodecID == FLV_VIDEO_VP6) {
- m_pFile->BitRead(8);
- } else if (vt.CodecID == FLV_VIDEO_VP6A) {
- m_pFile->BitRead(32);
- } else if (vt.CodecID == FLV_VIDEO_AVC) {
- if (m_pFile->BitRead(8) != 1) {
- goto NextTag;
- }
- // Tag timestamps specify decode time, this is the display time offset
- tsOffset = (UINT32)m_pFile->BitRead(24);
- tsOffset = (tsOffset + 0xff800000) ^ 0xff800000; // sign extension
- }
- }
- if (t.TagType == FLV_AUDIODATA && at.SoundFormat == FLV_AUDIO_AAC) {
- if (m_pFile->BitRead(8) != 1) {
- goto NextTag;
- }
- }
- __int64 dataSize = next - m_pFile->GetPos();
- if (dataSize <= 0) {
- goto NextTag;
- }
- p.Attach(DEBUG_NEW Packet());
- p->TrackNumber = t.TagType;
- p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
- p->rtStop = p->rtStart + 1;
- p->bSyncPoint = t.TagType == FLV_VIDEODATA ? vt.FrameType == 1 : true;
- p->SetCount((size_t)dataSize);
- m_pFile->ByteRead(p->GetData(), p->GetCount());
- hr = DeliverPacket(p);
- }
-
-NextTag:
- m_pFile->Seek(next);
- }
-
- return true;
-}
-
-//
-// CFLVSourceFilter
-//
-
-CFLVSourceFilter::CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CFLVSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.def b/src/filters/parser/FLVSplitter/FLVSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.h b/src/filters/parser/FLVSplitter/FLVSplitter.h
deleted file mode 100644
index 7401c297b..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "../../transform/BaseVideoFilter/BaseVideoFilter.h"
-
-#define FlvSplitterName L"MPC FLV Splitter"
-#define FlvSourceName L"MPC FLV Source"
-
-class __declspec(uuid("47E792CF-0BBE-4F7A-859C-194B0768650A"))
- CFLVSplitterFilter : public CBaseSplitterFilter
-{
- UINT32 m_DataOffset;
- bool m_IgnorePrevSizes;
-
- bool Sync(__int64& pos);
-
- struct VideoTweak {
- BYTE x;
- BYTE y;
- };
-
- bool ReadTag(VideoTweak& t);
-
- struct Tag {
- UINT32 PreviousTagSize;
- BYTE TagType;
- UINT32 DataSize;
- UINT32 TimeStamp;
- UINT32 StreamID;
- };
-
- bool ReadTag(Tag& t);
-
- struct AudioTag {
- BYTE SoundFormat;
- BYTE SoundRate;
- BYTE SoundSize;
- BYTE SoundType;
- };
-
- bool ReadTag(AudioTag& at);
-
- struct VideoTag {
- BYTE FrameType;
- BYTE CodecID;
- };
-
- bool ReadTag(VideoTag& vt);
-
- void NormalSeek(REFERENCE_TIME rt);
- void AlternateSeek(REFERENCE_TIME rt);
-
-protected:
- CAutoPtr<CBaseSplitterFileEx> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-
- // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
-};
-
-class __declspec(uuid("C9ECE7B3-1D8E-41F5-9F24-B255DF16C087"))
- CFLVSourceFilter : public CFLVSplitterFilter
-{
-public:
- CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.rc b/src/filters/parser/FLVSplitter/FLVSplitter.rc
deleted file mode 100644
index d0ebc17cb..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "FLV Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "FLV Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "FLVSplitter.ax"
- VALUE "ProductName", "FLV Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj b/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj
deleted file mode 100644
index 9987fd621..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj
+++ /dev/null
@@ -1,256 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{E62223EF-8263-41EB-8174-CD78BBEEF368}</ProjectGuid>
- <RootNamespace>FLVSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>FLVSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="FLVSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLVSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLVSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLVSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\transform\BaseVideoFilter\BaseVideoFilter.vcxproj">
- <Project>{54dda60f-e528-4d07-a152-960a1e818680}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters b/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters
deleted file mode 100644
index 6d767d024..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{97226fda-bc54-4e0c-aa74-af0bce156234}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{5c741c80-ab9b-4610-9718-d8f53ffa5718}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{a046237a-5cf9-45be-a5d4-c55690bd66c6}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="FLVSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLVSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLVSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLVSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/FLVSplitter/resource.h b/src/filters/parser/FLVSplitter/resource.h
deleted file mode 100644
index cf17d77a9..000000000
--- a/src/filters/parser/FLVSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by FLVSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/FLVSplitter/stdafx.cpp b/src/filters/parser/FLVSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/FLVSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/FLVSplitter/stdafx.h b/src/filters/parser/FLVSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/FLVSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
deleted file mode 100644
index afbb51d29..000000000
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "Ap4AsyncReaderStream.h"
-
-AP4_AsyncReaderStream::AP4_AsyncReaderStream(CBaseSplitterFile* pFile)
- : m_refs(1)
- , m_pFile(pFile)
-{
- ASSERT(pFile);
-}
-
-AP4_AsyncReaderStream::~AP4_AsyncReaderStream()
-{
- ASSERT(m_refs == 0);
-}
-
-void AP4_AsyncReaderStream::AddReference()
-{
- ASSERT(m_refs > 0);
- ++m_refs;
-}
-
-void AP4_AsyncReaderStream::Release()
-{
- ASSERT(m_refs > 0);
- if (--m_refs == 0) {
- delete this;
- }
-}
-
-AP4_Result AP4_AsyncReaderStream::Read(void* buffer, AP4_Size bytesToRead, AP4_Size* bytesRead)
-{
- __int64 bytesAvail = m_pFile->GetRemaining();
-
- if (bytesAvail < (__int64)bytesToRead) {
- if (bytesRead) {
- *bytesRead = bytesAvail;
- }
- bytesToRead = bytesAvail;
- }
-
- if (bytesAvail == 0) {
- return AP4_ERROR_EOS;
- }
-
- if (FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead))) {
- if (bytesRead) {
- *bytesRead = 0;
- }
- return AP4_ERROR_READ_FAILED;
- }
-
- if (bytesRead) {
- *bytesRead = bytesToRead;
- }
-
- return AP4_SUCCESS;
-}
-
-AP4_Result AP4_AsyncReaderStream::Write(const void* buffer, AP4_Size bytesToWrite, AP4_Size* bytesWritten)
-{
- return AP4_ERROR_WRITE_FAILED;
-}
-
-AP4_Result AP4_AsyncReaderStream::Seek(AP4_Offset offset)
-{
- m_pFile->Seek(offset);
- return m_pFile->GetPos() == offset ? AP4_SUCCESS : AP4_FAILURE;
-}
-
-AP4_Result AP4_AsyncReaderStream::Tell(AP4_Offset& offset)
-{
- offset = (AP4_Offset)m_pFile->GetPos();
- return AP4_SUCCESS;
-}
-
-AP4_Result AP4_AsyncReaderStream::GetSize(AP4_Size& size)
-{
- size = (AP4_Size)m_pFile->GetLength();
- return AP4_SUCCESS;
-}
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h
deleted file mode 100644
index 66c1835f7..000000000
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-
-#include "Ap4.h"
-#include "Ap4File.h"
-#include "Ap4ByteStream.h"
-
-class AP4_AsyncReaderStream : public AP4_ByteStream
-{
- int m_refs;
- CBaseSplitterFile* m_pFile;
-
-public:
- AP4_AsyncReaderStream(CBaseSplitterFile* pFile);
- virtual ~AP4_AsyncReaderStream();
-
- void AddReference();
- void Release();
-
- AP4_Result Read(void* buffer, AP4_Size bytesToRead, AP4_Size* bytesRead);
- AP4_Result Write(const void* buffer, AP4_Size bytesToWrite, AP4_Size* bytesWritten);
- AP4_Result Seek(AP4_Offset offset);
- AP4_Result Tell(AP4_Offset& offset);
- AP4_Result GetSize(AP4_Size& size);
-};
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.cpp b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
deleted file mode 100644
index dd1d7bb8f..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.cpp
+++ /dev/null
@@ -1,2114 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMreg.h>
-#include "MP4Splitter.h"
-#include "../../../DSUtil/GolombBuffer.h"
-#include "../../../DSUtil/AudioParser.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#include "Ap4.h"
-#include "Ap4File.h"
-#include "Ap4StssAtom.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4IsmaCryp.h"
-#include "Ap4AvcCAtom.h"
-#include "Ap4ChplAtom.h"
-#include "Ap4FtabAtom.h"
-#include "Ap4DataAtom.h"
-#include "Ap4PaspAtom.h"
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MP4},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMP4SplitterFilter), MP4SplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMP4SourceFilter), MP4SourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMPEG4VideoSplitterFilter), L"MPC MPEG4 Video Splitter", MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMPEG4VideoSourceFilter), L"MPC MPEG4 Video Source", MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMP4SplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMP4SourceFilter>, nullptr, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CMPEG4VideoSplitterFilter>, nullptr, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CMPEG4VideoSourceFilter>, nullptr, &sudFilter[3]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mp4"));
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mov"));
-
- CAtlList<CString> chkbytes;
-
- // mp4
- chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
- chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
- chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
- chkbytes.AddTail(_T("4,4,,736b6970")); // skip
- chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
-
- // mpeg4 video
- chkbytes.AddTail(_T("3,3,,000001"));
-
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MP4, chkbytes, nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_MP4);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-struct SSACharacter {
- CString pre, post;
- WCHAR c;
-};
-
-static CStringW ConvertTX3GToSSA(
- CStringW str,
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
- CStringW font,
- const AP4_Byte* mods,
- int size,
- CSize framesize,
- CPoint translation,
- int durationms,
- CRect& rbox)
-{
- int str_len = str.GetLength();
-
- SSACharacter* chars = DEBUG_NEW SSACharacter[str_len];
- for (int i = 0; i < str_len; ++i) {
- chars[i].c = str[i];
- }
- str.Empty();
-
- //
-
- rbox.SetRect(desc.TextBox.Left, desc.TextBox.Top, desc.TextBox.Right, desc.TextBox.Bottom);
-
- int align = 2;
- signed char h = (signed char)desc.HorizontalJustification;
- signed char v = (signed char)desc.VerticalJustification;
- if (h == 0 && v < 0) {
- align = 1;
- } else if (h > 0 && v < 0) {
- align = 2;
- } else if (h < 0 && v < 0) {
- align = 3;
- } else if (h == 0 && v > 0) {
- align = 4;
- } else if (h > 0 && v > 0) {
- align = 5;
- } else if (h < 0 && v > 0) {
- align = 6;
- } else if (h == 0 && v == 0) {
- align = 7;
- } else if (h > 0 && v == 0) {
- align = 8;
- } else if (h < 0 && v == 0) {
- align = 9;
- }
- str.Format(L"{\\an%d}%s", align, CStringW(str));
-
- if (!font.CompareNoCase(L"serif")) {
- font = L"Times New Roman";
- } else if (!font.CompareNoCase(L"sans-serif")) {
- font = L"Arial";
- } else if (!font.CompareNoCase(L"monospace")) {
- font = L"Courier New";
- }
- str.Format(L"{\\fn%s}%s", font, CStringW(str));
-
- const AP4_Byte* fclr = (const AP4_Byte*)&desc.Style.Font.Color;
-
- CStringW font_color;
- font_color.Format(L"{\\1c%02x%02x%02x\\1a%02x}", fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
- str = font_color + str;
-
- str.Format(L"%s{\\2c%02x%02x%02x\\2a%02x}", CString(str), fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
-
- CStringW font_size;
- font_size.Format(L"{\\fs%u}", desc.Style.Font.Size);
- str = font_size + str;
-
- CStringW font_flags;
- font_flags.Format(L"{\\b%d\\i%d\\u%d}",
- (desc.Style.Font.Face & 1) ? 1 : 0,
- (desc.Style.Font.Face & 2) ? 1 : 0,
- (desc.Style.Font.Face & 4) ? 1 : 0);
- str = font_flags + str;
-
- //
-
- const AP4_Byte* hclr = (const AP4_Byte*)&desc.BackgroundColor;
-
- while (size > 8) {
- DWORD tag_size = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
- DWORD tag = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
-
- size -= tag_size;
- tag_size -= 8;
- const AP4_Byte* next = mods + tag_size;
-
- if (tag == 'styl') {
- WORD styl_count = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- while (styl_count-- > 0) {
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD font_id = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD flags = mods[0];
- mods += 1;
- WORD size = mods[0];
- mods += 1;
- const AP4_Byte* color = mods;
- mods += 4;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", color[2], color[1], color[0], 255 - color[3]);
- chars[start].pre += s;
- chars[end - 1].post += font_color;
-
- s.Format(L"{\\fs%u}", size);
- chars[start].pre += s;
- chars[end - 1].post += font_size;
-
- s.Format(L"{\\b%d\\i%d\\u%d}", (flags & 1) ? 1 : 0, (flags & 2) ? 1 : 0, (flags & 4) ? 1 : 0);
- chars[start].pre += s;
- chars[end - 1].post += font_flags;
- }
- }
- } else if (tag == 'hclr') {
- hclr = mods;
- } else if (tag == 'hlit') {
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\3c%02x%02x%02x\\3a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- chars[start].pre += s;
- chars[end - 1].post += font_color;
-
- chars[start].pre += L"{\\bord0.1}";
- chars[end - 1].post += L"{\\bord}";
- }
- } else if (tag == 'blnk') {
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- // cheap...
-
- for (int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha) {
- CStringW s;
- s.Format(L"{\\t(%d, %d, \\alpha&H%02x&)}", i, i + 750, alpha);
- chars[start].pre += s;
- }
-
- chars[end - 1].post += L"{\\alpha}";
- }
- } else if (tag == 'tbox') {
- rbox.top = (mods[0] << 8) | (mods[1]);
- mods += 2;
- rbox.left = (mods[0] << 8) | (mods[1]);
- mods += 2;
- rbox.bottom = (mods[0] << 8) | (mods[1]);
- mods += 2;
- rbox.right = (mods[0] << 8) | (mods[1]);
- mods += 2;
- } else if (tag == 'krok' && !(desc.DisplayFlags & 0x800)) {
- DWORD start_time = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
- WORD krok_count = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- while (krok_count-- > 0) {
- DWORD end_time = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\kt%u\\kf%u}", start_time / 10, (end_time - start_time) / 10);
- chars[start].pre += s;
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- chars[start].pre += s;
- chars[end - 1].post += L"{\\kt}" + font_color;
- }
-
- start_time = end_time;
- }
- }
-
- mods = next;
- }
-
- // continous karaoke
-
- if (desc.DisplayFlags & 0x800) {
- CStringW s;
-
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- str += s;
-
- int breaks = 0;
-
- for (int i = 0, j = 0; i <= str_len; ++i) {
- if (chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
- ++breaks;
- }
- }
-
- if (str_len > breaks) {
- float dur = (float)max(durationms - 500, 0) / 10;
-
- for (int i = 0, j = 0; i <= str_len; ++i) {
- if (i == str_len || chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
- s.Format(L"{\\kf%d}", (int)(dur * (i - j) / (str_len - breaks)));
- chars[j].pre += s;
- j = i + 1;
- }
- }
- }
- }
-
- //
-
- for (int i = 0; i < str_len; ++i) {
- str += chars[i].pre;
- str += chars[i].c;
- if (desc.DisplayFlags & 0x20000) {
- str += L"\\N";
- }
- str += chars[i].post;
- }
-
- delete [] chars;
-
- //
-
- if (rbox.IsRectEmpty()) {
- rbox.SetRect(0, 0, framesize.cx, framesize.cy);
- }
- rbox.OffsetRect(translation);
-
- CRect rbox2 = rbox;
- rbox2.DeflateRect(2, 2);
-
- CRect r(0, 0, 0, 0);
- if (rbox2.Height() > 0) {
- r.top = rbox2.top;
- r.bottom = framesize.cy - rbox2.bottom;
- }
- if (rbox2.Width() > 0) {
- r.left = rbox2.left;
- r.right = framesize.cx - rbox2.right;
- }
-
- CStringW hdr;
- hdr.Format(L"0,0,Text,,%d,%d,%d,%d,,{\\clip(%d,%d,%d,%d)}",
- r.left, r.right, r.top, r.bottom,
- rbox.left, rbox.top, rbox.right, rbox.bottom);
-
- //
-
- return hdr + str;
-}
-
-//
-// CMP4SplitterFilter
-//
-
-CMP4SplitterFilter::CMP4SplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMP4SplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-CMP4SplitterFilter::~CMP4SplitterFilter()
-{
-}
-
-STDMETHODIMP CMP4SplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MP4SourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-void SetTrackName(CString* TrackName, CString Suffix)
-{
- if (TrackName->IsEmpty()) {
- *TrackName = Suffix;
- } else {
- *TrackName += _T(" - ");
- *TrackName += Suffix;
- }
-}
-
-HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- //bool b_HasVideo = false;
-
- m_trackpos.RemoveAll();
-
- m_pFile.Free();
- m_pFile.Attach(DEBUG_NEW CMP4SplitterFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
- REFERENCE_TIME rtVideoDuration = 0;
-
- m_framesize.SetSize(640, 480);
-
- if (AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
- // looking for main video track (skip tracks with motionless frames)
- AP4_UI32 mainvideoID = 0;
- for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext()) {
- AP4_Track* track = item->GetData();
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
- if (!mainvideoID) {
- mainvideoID = track->GetId();
- }
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- mainvideoID = track->GetId();
- break;
- }
- }
- }
- // process the tracks
- for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext()) {
- AP4_Track* track = item->GetData();
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO
- && track->GetType() != AP4_Track::TYPE_AUDIO
- && track->GetType() != AP4_Track::TYPE_TEXT
- && track->GetType() != AP4_Track::TYPE_SUBP) {
- continue;
- }
-
- //if (b_HasVideo && track->GetType() == AP4_Track::TYPE_VIDEO) {
- if (track->GetType() == AP4_Track::TYPE_VIDEO && track->GetId() != mainvideoID) {
- continue;
- }
-
- AP4_Sample sample;
-
- if (!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
- continue;
- }
-
- CStringW TrackName = UTF8ToStringW(track->GetTrackName().c_str());
- if (TrackName.IsEmpty()) {
- TrackName = LocalToStringW(track->GetTrackName().c_str()); //Trying Local...
- }
- if (TrackName.GetLength() && TrackName[0] < 0x20) {
- TrackName.Delete(0);
- }
- TrackName.Trim();
-
- CStringA TrackLanguage = track->GetTrackLanguage().c_str();
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(1);
-
- VIDEOINFOHEADER* vih = nullptr;
- WAVEFORMATEX* wfe = nullptr;
-
- AP4_DataBuffer empty;
-
- if (AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
- AP4_MpegSampleDescription* mpeg_desc = nullptr;
-
- if (desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
- mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(desc);
- } else if (desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
- AP4_IsmaCrypSampleDescription* isma_desc = dynamic_cast<AP4_IsmaCrypSampleDescription*>(desc);
- mpeg_desc = isma_desc->GetOriginalSampleDescription();
- }
-
- if (mpeg_desc) {
- CStringW TypeString = CStringW(mpeg_desc->GetObjectTypeString(mpeg_desc->GetObjectTypeId()));
- if ((TypeString.Find(_T("UNKNOWN")) == -1) && (TypeString.Find(_T("INVALID")) == -1)) {
- SetTrackName(&TrackName, TypeString);
- }
- }
-
- if (AP4_MpegVideoSampleDescription* video_desc =
- dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc)) {
- const AP4_DataBuffer* di = video_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
-
- LONG biWidth = (LONG)video_desc->GetWidth();
- LONG biHeight = (LONG)video_desc->GetHeight();
-
- if (!biWidth || !biHeight) {
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- biWidth = tkhd->GetWidth() >> 16;
- biHeight = tkhd->GetHeight() >> 16;
- }
- }
-
- if (!biWidth || !biHeight) {
- continue;
- }
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + di->GetDataSize());
- ZeroMemory(vih, mt.FormatLength());
- vih->dwBitRate = video_desc->GetAvgBitrate() / 8;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = biWidth;
- vih->bmiHeader.biHeight = biHeight;
- memcpy(vih + 1, di->GetData(), di->GetDataSize());
-
- switch (video_desc->GetObjectTypeId()) {
- case AP4_MPEG4_VISUAL_OTI:
- mt.subtype = FOURCCMap('v4pm');
- mt.formattype = FORMAT_MPEG2Video;
- {
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = biWidth;
- mvih->hdr.bmiHeader.biHeight = biHeight;
- mvih->hdr.bmiHeader.biCompression = 'v4pm';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
- mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
- mvih->cbSequenceHeader = di->GetDataSize();
- memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
- //b_HasVideo = true;
- }
- break;
- case AP4_JPEG_OTI:
- mt.subtype = FOURCCMap('gepj');
- mt.formattype = FORMAT_MPEG2Video;
- {
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = biWidth;
- mvih->hdr.bmiHeader.biHeight = biHeight;
- mvih->hdr.bmiHeader.biCompression = 'gepj';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
- mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
- mvih->cbSequenceHeader = di->GetDataSize();
- memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- //b_HasVideo = true;
- }
- break;
- case AP4_MPEG2_VISUAL_SIMPLE_OTI:
- case AP4_MPEG2_VISUAL_MAIN_OTI:
- case AP4_MPEG2_VISUAL_SNR_OTI:
- case AP4_MPEG2_VISUAL_SPATIAL_OTI:
- case AP4_MPEG2_VISUAL_HIGH_OTI:
- case AP4_MPEG2_VISUAL_422_OTI:
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::seqhdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- case AP4_MPEG1_VISUAL_OTI: // ???
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::seqhdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown video OBI: %02x\n"), video_desc->GetObjectTypeId());
- }
- } else if (AP4_MpegAudioSampleDescription* audio_desc =
- dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
- const AP4_DataBuffer* di = audio_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
- const BYTE* extdata = di->GetData();
- size_t extsize = di->GetDataSize();
- ASSERT(extsize <= WORD_MAX);
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
-
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + di->GetDataSize());
- ZeroMemory(wfe, mt.FormatLength());
- wfe->nSamplesPerSec = audio_desc->GetSampleRate();
- wfe->nAvgBytesPerSec = audio_desc->GetAvgBitrate() / 8;
- wfe->nChannels = audio_desc->GetChannelCount();
- wfe->wBitsPerSample = audio_desc->GetSampleSize();
- wfe->cbSize = (WORD)extsize;
- wfe->nBlockAlign = wfe->nChannels * wfe->wBitsPerSample / 8;
-
- memcpy(wfe + 1, extdata, extsize);
-
- switch (audio_desc->GetObjectTypeId()) {
- case AP4_MPEG4_AUDIO_OTI:
- case AP4_MPEG2_AAC_AUDIO_MAIN_OTI: // ???
- case AP4_MPEG2_AAC_AUDIO_LC_OTI: // ???
- case AP4_MPEG2_AAC_AUDIO_SSRP_OTI: // ???
- if (extsize > 10) {
- if (*(DWORD*)(extdata + 6) == 0x00534c41) { // 'ALS\0' sync word
- wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
- mt.subtype = FOURCCMap(MAKEFOURCC('A', 'L', 'S', ' ')); // create our own GUID - {20534C41-0000-0010-8000-00AA00389B71}
- mts.Add(mt);
- break;
- }
- }
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- if (extsize >= 2 && wfe->nChannels < 8) {
- WORD channels = (extdata[1] >> 3) & 0xf;
- if (channels) { // not the best solution
- wfe->nChannels = channels;
- wfe->nBlockAlign = channels * wfe->wBitsPerSample / 8;
- }
- }
- mts.Add(mt);
- break;
- case AP4_MPEG2_PART3_AUDIO_OTI: // ???
- case AP4_MPEG1_AUDIO_OTI:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), false, &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- case AP4_DTSC_AUDIO_OTI:
- case AP4_DTSH_AUDIO_OTI:
- case AP4_DTSL_AUDIO_OTI:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::dtshdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown audio OBI: %02x\n"), audio_desc->GetObjectTypeId());
- }
- } else if (AP4_MpegSystemSampleDescription* system_desc =
- dynamic_cast<AP4_MpegSystemSampleDescription*>(desc)) {
- const AP4_DataBuffer* di = system_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
-
- switch (system_desc->GetObjectTypeId()) {
- case AP4_NERO_VOBSUB:
- if (di->GetDataSize() >= 16 * 4) {
- CSize size(720, 576);
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- size.cx = tkhd->GetWidth() >> 16;
- size.cy = tkhd->GetHeight() >> 16;
- }
-
- const AP4_Byte* pal = di->GetData();
- CAtlList<CStringA> sl;
- for (int i = 0; i < 16 * 4; i += 4) {
- BYTE y = (pal[i + 1] - 16) * 255 / 219;
- BYTE u = pal[i + 2];
- BYTE v = pal[i + 3];
- BYTE r = (BYTE)min(max(1.0 * y + 1.4022 * (v - 128), 0), 255);
- BYTE g = (BYTE)min(max(1.0 * y - 0.3456 * (u - 128) - 0.7145 * (v - 128), 0), 255);
- BYTE b = (BYTE)min(max(1.0 * y + 1.7710 * (u - 128), 0) , 255);
- CStringA str;
- str.Format("%02x%02x%02x", r, g, b);
- sl.AddTail(str);
- }
-
- CStringA hdr;
- hdr.Format(
- "# VobSub index file, v7 (do not modify this line!)\n"
- "size: %dx%d\n"
- "palette: %s\n",
- size.cx, size.cy,
- Implode(sl, ','));
-
- mt.majortype = MEDIATYPE_Subtitle;
- mt.subtype = MEDIASUBTYPE_VOBSUB;
- mt.formattype = FORMAT_SubtitleInfo;
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
- ZeroMemory(si, mt.FormatLength());
- si->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
- wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
- memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
- mts.Add(mt);
- }
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown audio OBI: %02x\n"), system_desc->GetObjectTypeId());
- }
- } else if (AP4_UnknownSampleDescription* unknown_desc =
- dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
- AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
-
- if (dynamic_cast<AP4_TextSampleEntry*>(sample_entry)
- || dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
- mt.majortype = MEDIATYPE_Subtitle;
- mt.subtype = MEDIASUBTYPE_ASS2;
- mt.formattype = FORMAT_SubtitleInfo;
- CStringA hdr;
- hdr.Format(
- "[Script Info]\n"
- "ScriptType: v4.00++\n"
- "ScaledBorderAndShadow: yes\n"
- "PlayResX: %d\n"
- "PlayResY: %d\n"
- "[V4++ Styles]\n"
- "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,3,0,0,2,0,0,0,0,1,1\n",
- // "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,1,0,0,2,0,0,0,0,1,1\n",
- m_framesize.cx,
- m_framesize.cy);
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
- ZeroMemory(si, mt.FormatLength());
- si->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
- wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
- memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
- mts.Add(mt);
- }
- }
- } else if (AP4_Avc1SampleEntry* avc1 = dynamic_cast<AP4_Avc1SampleEntry*>(
- track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd/avc1"))) {
- if (AP4_AvcCAtom* avcC = dynamic_cast<AP4_AvcCAtom*>(avc1->GetChild(AP4_ATOM_TYPE_AVCC))) {
- SetTrackName(&TrackName, _T("MPEG4 Video (H264)"));
-
- const AP4_DataBuffer* di = avcC->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
- int num = 1;
- int den = 1;
- if (AP4_PaspAtom* pasp = dynamic_cast<AP4_PaspAtom*>(avc1->GetChild(AP4_ATOM_TYPE_PASP))) {
- num = pasp->GetNum();
- den = pasp->GetDen();
- }
- if (num <= 0 || den <= 0) { // if bad AR
- num = den = 1; // then reset AR
- }
-
- const AP4_Byte* data = di->GetData();
- AP4_Size size = di->GetDataSize();
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('1cva');
- mt.formattype = FORMAT_MPEG2Video;
-
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + size - 7);
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = (LONG)avc1->GetWidth();
- mvih->hdr.bmiHeader.biHeight = (LONG)avc1->GetHeight();
- mvih->hdr.bmiHeader.biCompression = '1cva';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
-
- CSize aspect(mvih->hdr.bmiHeader.biWidth * num, mvih->hdr.bmiHeader.biHeight * den);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- mvih->hdr.dwPictAspectRatioX = aspect.cx;
- mvih->hdr.dwPictAspectRatioY = aspect.cy;
- if (item->GetData()->GetSampleCount()) {
- mvih->hdr.AvgTimePerFrame = item->GetData()->GetDurationMs() * 10000 / (item->GetData()->GetSampleCount());
- }
- mvih->dwProfile = data[1];
- mvih->dwLevel = data[3];
- mvih->dwFlags = (data[4] & 3) + 1;
-
- mvih->cbSequenceHeader = 0;
-
- BYTE* src = (BYTE*)data + 5;
- BYTE* dst = (BYTE*)mvih->dwSequenceHeader;
-
- BYTE* src_end = (BYTE*)data + size;
- BYTE* dst_end = (BYTE*)mvih->dwSequenceHeader + size;
-
- for (int i = 0; i < 2; ++i) {
- for (int n = *src++ & 0x1f; n > 0; --n) {
- int len = ((src[0] << 8) | src[1]) + 2;
- if (src + len > src_end || dst + len > dst_end) {
- ASSERT(0);
- break;
- }
- memcpy(dst, src, len);
- src += len;
- dst += len;
- mvih->cbSequenceHeader += len;
- }
- }
-
- mts.Add(mt);
-
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = '1CVA');
- mts.Add(mt);
- //b_HasVideo = true;
- }
- } else if (AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd"))) {
- const AP4_DataBuffer& db = stsd->GetDataBuffer();
-
- int k = 0;
- for (AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
- item;
- item = item->GetNext(), ++k) {
-
- AP4_Atom* atom = item->GetData();
- AP4_Atom::Type type = atom->GetType();
-
- if (k == 0 && stsd->GetChildren().ItemCount() > 1 && type == AP4_ATOM_TYPE_JPEG) {
- continue; // Multiple fourcc, we skip first JPEG.
- }
-
- DWORD fourcc =
- ((type >> 24) & 0x000000ff) |
- ((type >> 8) & 0x0000ff00) |
- ((type << 8) & 0x00ff0000) |
- ((type << 24) & 0xff000000);
-
- if (AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
-
- if (type == AP4_ATOM_TYPE_MJPA || type == AP4_ATOM_TYPE_MJPB || type == AP4_ATOM_TYPE_MJPG) {
- SetTrackName(&TrackName, _T("M-Jpeg"));
- } else if (type == AP4_ATOM_TYPE_RAW) {
- fourcc = BI_RGB;
- }
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + db.GetDataSize());
- ZeroMemory(vih, mt.FormatLength());
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = (LONG)vse->GetWidth();
- vih->bmiHeader.biHeight = (LONG)vse->GetHeight();
- vih->bmiHeader.biCompression = fourcc;
- vih->bmiHeader.biBitCount = (LONG)vse->GetDepth();
- memcpy(vih + 1, db.GetData(), db.GetDataSize());
-
- if (fourcc == BI_RGB) {
- WORD& bitcount = vih->bmiHeader.biBitCount;
- if (bitcount == 16) {
- mt.subtype = MEDIASUBTYPE_RGB555;
- } else if (bitcount == 24) {
- mt.subtype = MEDIASUBTYPE_RGB24;
- } else if (bitcount == 32) {
- mt.subtype = MEDIASUBTYPE_ARGB32;
- } else {
- break;
- }
- mts.Add(mt);
- break;
- }
- mt.subtype = FOURCCMap(fourcc);
- mts.Add(mt);
-
- char buff[5];
- memcpy(buff, &fourcc, 4);
- buff[4] = 0;
-
- _strlwr_s(buff);
- AP4_Atom::Type typelwr = *(AP4_Atom::Type*)buff;
-
- if (typelwr != fourcc) {
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typelwr);
- mts.Add(mt);
- //b_HasVideo = true;
- }
-
- _strupr_s(buff);
- AP4_Atom::Type typeupr = *(AP4_Atom::Type*)buff;
-
- if (typeupr != fourcc) {
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typeupr);
- mts.Add(mt);
- //b_HasVideo = true;
- }
-
- break;
- } else if (AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
- DWORD samplerate = ase->GetSampleRate();
- WORD channels = ase->GetChannelCount();
- WORD bitspersample = ase->GetSampleSize();
-
- // overwrite audio fourc
- if ((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
- fourcc = type & 0xffff;
- } else if (type == AP4_ATOM_TYPE_ALAW) {
- fourcc = WAVE_FORMAT_ALAW;
- SetTrackName(&TrackName, _T("PCM A-law"));
- } else if (type == AP4_ATOM_TYPE_ULAW) {
- fourcc = WAVE_FORMAT_MULAW;
- SetTrackName(&TrackName, _T("PCM mu-law"));
- } else if (type == AP4_ATOM_TYPE__MP3) {
- SetTrackName(&TrackName, _T("MPEG Audio (MP3)"));
- fourcc = WAVE_FORMAT_MPEGLAYER3;
- } else if ((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3) || (type == AP4_ATOM_TYPE_EAC3)) {
- fourcc = 0x2000;
- if (type != AP4_ATOM_TYPE_EAC3) {
- SetTrackName(&TrackName, _T("AC-3 Audio"));
- } else {
- SetTrackName(&TrackName, _T("Enhanced AC-3 audio"));
- }
- } else if (type == AP4_ATOM_TYPE_MP4A) {
- fourcc = WAVE_FORMAT_AAC;
- SetTrackName(&TrackName, _T("MPEG-2 Audio AAC"));
- } else if (type == AP4_ATOM_TYPE_NMOS) {
- fourcc = MAKEFOURCC('N', 'E', 'L', 'L');
- SetTrackName(&TrackName, _T("NellyMoser Audio"));
- } else if (type == AP4_ATOM_TYPE_ALAC) {
- fourcc = MAKEFOURCC('a', 'l', 'a', 'c');
- SetTrackName(&TrackName, _T("ALAC Audio"));
- } else if ((type == AP4_ATOM_TYPE_NONE || type == AP4_ATOM_TYPE_RAW) && bitspersample == 8 ||
- type == AP4_ATOM_TYPE_SOWT && bitspersample == 16 ||
- (type == AP4_ATOM_TYPE_IN24 || type == AP4_ATOM_TYPE_IN32) && ase->GetEndian() == ENDIAN_LITTLE) {
- fourcc = type = WAVE_FORMAT_PCM;
- } else if ((type == AP4_ATOM_TYPE_FL32 || type == AP4_ATOM_TYPE_FL64) && ase->GetEndian() == ENDIAN_LITTLE) {
- fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
- } else if (type == AP4_ATOM_TYPE_LPCM) {
- DWORD flags = ase->GetFormatSpecificFlags();
- if (flags & 2) { // big endian
- if (flags & 1) { // floating point
- if (bitspersample == 32) {
- type = AP4_ATOM_TYPE_FL32;
- } else if (bitspersample == 64) {
- type = AP4_ATOM_TYPE_FL64;
- }
- } else {
- if (bitspersample == 16) {
- type = AP4_ATOM_TYPE_TWOS;
- } else if (bitspersample == 24) {
- type = AP4_ATOM_TYPE_IN24;
- } else if (bitspersample == 32) {
- type = AP4_ATOM_TYPE_IN32;
- }
- }
- fourcc = ((type >> 24) & 0x000000ff) |
- ((type >> 8) & 0x0000ff00) |
- ((type << 8) & 0x00ff0000) |
- ((type << 24) & 0xff000000);
- } else { // little endian
- if (flags & 1) { // floating point
- fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- fourcc = type = WAVE_FORMAT_PCM;
- }
- }
- }
-
- DWORD nAvgBytesPerSec = 0;
- if (type == AP4_ATOM_TYPE_EAC3) {
-
- AP4_Sample sample;
- AP4_DataBuffer sample_data;
-
- AP4_Cardinal SampleCount = track->GetSampleCount();
- if (SampleCount) {
- track->ReadSample(1, sample, sample_data);
- const AP4_Byte* data = sample_data.GetData();
- AP4_Size size = sample_data.GetDataSize();
-
- CGolombBuffer gb((BYTE*)data, size);
- for (; size >= 7 && gb.BitRead(16, true) != 0x0b77; --size) {
- gb.BitRead(8);
- }
- WORD sync = (WORD)gb.BitRead(16);
- if ((size >= 7) && (sync == 0x0b77)) {
- static DWORD freq[] = {48000, 44100, 32000, 0};
- gb.BitRead(2);
- gb.BitRead(3);
- WORD frame_size = ((WORD)gb.BitRead(11) + 1) << 1;
- BYTE sr_code = (BYTE)gb.BitRead(2);
- if (sr_code == 3) {
- BYTE sr_code2 = (BYTE)gb.BitRead(2);
- samplerate = freq[sr_code2] / 2;
- } else {
- static BYTE eac3_blocks[4] = {1, 2, 3, 6};
- BYTE num_blocks = eac3_blocks[gb.BitRead(2)];
- samplerate = freq[sr_code];
- nAvgBytesPerSec = frame_size * samplerate / (num_blocks * 256);
- }
- BYTE acmod = (BYTE)gb.BitRead(3);
- BYTE lfeon = (BYTE)gb.BitRead(1);
- static WORD channels_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5};
- channels = channels_tbl[acmod] + lfeon;
- }
- }
- }
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, mt.FormatLength());
- if (!(fourcc & 0xffff0000)) {
- wfe->wFormatTag = (WORD)fourcc;
- }
- wfe->nSamplesPerSec = samplerate;
- wfe->nChannels = channels;
- wfe->wBitsPerSample = bitspersample;
- wfe->nBlockAlign = ase->GetBytesPerFrame();
- if (nAvgBytesPerSec == 0 && ase->GetSamplesPerPacket() > 0) {
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign / ase->GetSamplesPerPacket();
- }
-
- mt.subtype = FOURCCMap(fourcc);
-
-
- if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x02)) {
- const WORD numcoef = 7;
- static ADPCMCOEFSET coef[] = { {256, 0}, {512, -256}, {0, 0}, {192, 64}, {240, 0}, {460, -208}, {392, -232} };
- const ULONG size = sizeof(ADPCMWAVEFORMAT) + (numcoef * sizeof(ADPCMCOEFSET));
- ADPCMWAVEFORMAT* format = (ADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(size);
- if (format != nullptr) {
- format->wfx.wFormatTag = WAVE_FORMAT_ADPCM;
- format->wfx.wBitsPerSample = 4;
- format->wfx.cbSize = (WORD)(size - sizeof(WAVEFORMATEX));
- format->wSamplesPerBlock = format->wfx.nBlockAlign * 2 / format->wfx.nChannels - 12;
- format->wNumCoef = numcoef;
- memcpy(format->aCoef, coef, sizeof(coef));
- }
- } else if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x11)) {
- IMAADPCMWAVEFORMAT* format = (IMAADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(sizeof(IMAADPCMWAVEFORMAT));
- if (format != nullptr) {
- format->wfx.wFormatTag = WAVE_FORMAT_IMA_ADPCM;
- format->wfx.wBitsPerSample = 4;
- format->wfx.cbSize = (WORD)(sizeof(IMAADPCMWAVEFORMAT) - sizeof(WAVEFORMATEX));
- int X = (format->wfx.nBlockAlign - (4 * format->wfx.nChannels)) * 8;
- int Y = format->wfx.wBitsPerSample * format->wfx.nChannels;
- format->wSamplesPerBlock = (X / Y) + 1;
- }
- } else if (type == AP4_ATOM_TYPE_ALAC) {
- const AP4_Byte* data = db.GetData();
- AP4_Size size = db.GetDataSize();
-
- while (size >= 36) {
- if ((*(DWORD*)(data) == 0x24000000) && (*(DWORD*)(data + 4) == 0x63616c61)) {
- break;
- }
- size--;
- data++;
- }
-
- if (size >= 36) {
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 36);
- wfe->cbSize = 36;
- memcpy(wfe + 1, data, 36);
- }
- } else if (type == WAVE_FORMAT_PCM) {
- mt.SetSampleSize(wfe->nBlockAlign);
- if (channels > 2 || bitspersample > 16) {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (wfex != nullptr) {
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = bitspersample;
- wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
- wfex->SubFormat = MEDIASUBTYPE_PCM;
- }
- }
- } else if (type == WAVE_FORMAT_IEEE_FLOAT) {
- mt.SetSampleSize(wfe->nBlockAlign);
- if (channels > 2) {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (wfex != nullptr) {
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = bitspersample;
- wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
- wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
- }
- }
- } else if (type == AP4_ATOM_TYPE_MP4A ||
- type == AP4_ATOM_TYPE_ALAW ||
- type == AP4_ATOM_TYPE_ULAW) {
- // not need any extra data for ALAW, ULAW
- // also extra data is not required for IMA4, MAC3, MAC6
- } else if (db.GetDataSize() > 0) {
- //always needed extra data for QDM2
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + db.GetDataSize());
- wfe->cbSize = db.GetDataSize();
- memcpy(wfe + 1, db.GetData(), db.GetDataSize());
- }
-
- mts.Add(mt);
- break;
- } else {
- TRACE(_T("Unknow MP4 Stream %x\n") , fourcc);
- }
- }
- }
-
- if (mts.IsEmpty()) {
- continue;
- }
-
- REFERENCE_TIME rtDuration = 10000i64 * track->GetDurationMs();
- if (m_rtDuration < rtDuration) {
- m_rtDuration = rtDuration;
- }
- if (rtVideoDuration < rtDuration && AP4_Track::TYPE_VIDEO == track->GetType()) {
- rtVideoDuration = rtDuration; // get the max video duration
- }
-
- DWORD id = track->GetId();
-
- CStringW name, lang;
- name.Format(L"Output %u", id);
-
- if (!TrackName.IsEmpty()) {
- name = TrackName;
- }
-
- if (!TrackLanguage.IsEmpty()) {
- if (TrackLanguage != L"und") {
- name += " (" + TrackLanguage + ")";
- }
- }
-
- for (size_t i = 0, j = mts.GetCount(); i < j; ++i) {
- BITMAPINFOHEADER bih;
- if (ExtractBIH(&mts[i], &bih)) {
- m_framesize.cx = bih.biWidth;
- m_framesize.cy = abs(bih.biHeight);
- }
- }
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMP4SplitterOutputPin(mts, name, this, this, &hr));
-
- if (!TrackName.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", TrackName);
- }
- if (!TrackLanguage.IsEmpty()) {
- pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
- }
-
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
-
- m_trackpos[id] = trackpos();
-
- if (mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
- LPCWSTR postfix = L" (plain text)";
-
- mts[0].subtype = MEDIASUBTYPE_UTF8;
-
- SUBTITLEINFO* si = (SUBTITLEINFO*)mts[0].ReallocFormatBuffer(sizeof(SUBTITLEINFO));
- wcscat_s(si->TrackName, postfix);
-
- id ^= 0x80402010; // FIXME: until fixing, let's hope there won't be another track like this...
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMP4SplitterOutputPin(mts, name + postfix, this, this, &hr));
-
- if (!TrackName.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", TrackName + postfix);
- }
- if (!TrackLanguage.IsEmpty()) {
- pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
- }
-
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
- }
- }
-
- if (AP4_ChplAtom* chpl = dynamic_cast<AP4_ChplAtom*>(movie->GetMoovAtom()->FindChild("udta/chpl"))) {
- AP4_Array<AP4_ChplAtom::AP4_Chapter>& chapters = chpl->GetChapters();
-
- for (AP4_Cardinal i = 0; i < chapters.ItemCount(); ++i) {
- AP4_ChplAtom::AP4_Chapter& chapter = chapters[i];
- ChapAppend(chapter.Time, UTF8To16(ConvertMBCS(chapter.Name.c_str(), ANSI_CHARSET, CP_UTF8))); // this is b0rked, thx to nero :P
- }
-
- ChapSort();
- }
-
- if (AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst"))) {
- CStringW title, artist, writer, album, year, appl, desc, gen, track;
-
- for (AP4_List<AP4_Atom>::Item* item = ilst->GetChildren().FirstItem();
- item;
- item = item->GetNext()) {
- if (AP4_ContainerAtom* atom = dynamic_cast<AP4_ContainerAtom*>(item->GetData())) {
- if (AP4_DataAtom* data = dynamic_cast<AP4_DataAtom*>(atom->GetChild(AP4_ATOM_TYPE_DATA))) {
- const AP4_DataBuffer* db = data->GetData();
-
- if (atom->GetType() == AP4_ATOM_TYPE_TRKN) {
- if (db->GetDataSize() >= 4) {
- unsigned short n = (db->GetData()[2] << 8) | db->GetData()[3];
- if (n > 0 && n < 100) {
- track.Format(L"%02u", n);
- } else if (n >= 100) {
- track.Format(L"%u", n);
- }
- }
- } else {
- CStringW str = UTF8To16(CStringA((LPCSTR)db->GetData(), db->GetDataSize()));
-
- switch (atom->GetType()) {
- case AP4_ATOM_TYPE_NAM:
- title = str;
- break;
- case AP4_ATOM_TYPE_ART:
- artist = str;
- break;
- case AP4_ATOM_TYPE_WRT:
- writer = str;
- break;
- case AP4_ATOM_TYPE_ALB:
- album = str;
- break;
- case AP4_ATOM_TYPE_DAY:
- year = str;
- break;
- case AP4_ATOM_TYPE_TOO:
- appl = str;
- break;
- case AP4_ATOM_TYPE_CMT:
- desc = str;
- break;
- case AP4_ATOM_TYPE_GEN:
- gen = str;
- break;
- }
- }
- }
- }
- }
-
- if (!title.IsEmpty()) {
- if (!track.IsEmpty()) {
- title = track + L" - " + title;
- }
- if (!album.IsEmpty()) {
- title = album + L" - " + title;
- }
- if (!year.IsEmpty()) {
- title += L" - " + year;
- }
- if (!gen.IsEmpty()) {
- title += L" - " + gen;
- }
- SetProperty(L"TITL", title);
- }
-
- if (!artist.IsEmpty()) {
- SetProperty(L"AUTH", artist);
- } else if (!writer.IsEmpty()) {
- SetProperty(L"AUTH", writer);
- }
-
- if (!appl.IsEmpty()) {
- SetProperty(L"APPL", appl);
- }
-
- if (!desc.IsEmpty()) {
- SetProperty(L"DESC", desc);
- }
- }
- }
-
- if (rtVideoDuration > 0 && rtVideoDuration < m_rtDuration / 2) {
- m_rtDuration = rtVideoDuration; // fix incorrect duration
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- TRACE(_T("CMP4SplitterFilter m_pOutputs.GetCount() = %d\n") , m_pOutputs.GetCount());
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CMP4SplitterFilter::DemuxInit()
-{
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- pPair->m_value.index = 0;
- pPair->m_value.ts = 0;
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(0, sample))) {
- pPair->m_value.ts = sample.GetCts();
- }
- }
-
- return true;
-}
-
-void CMP4SplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- if (AP4_FAILED(track->GetSampleIndexForRefTime(rt, pPair->m_value.index))) {
- continue;
- }
-
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, sample))) {
- pPair->m_value.ts = sample.GetCts();
- }
-
- // FIXME: slow search & stss->m_Entries is private
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- AP4_Cardinal i = 1;
- while (i < stss->m_Entries.ItemCount()) {
- if (stss->m_Entries[i] - 1 > pPair->m_value.index) {
- break;
- }
- ++i;
- }
- //ASSERT(pPair->m_value.index == stss->m_Entries[i-1] - 1); // fast seek test
- pPair->m_value.index = stss->m_Entries[i - 1] - 1;
- }
- }
- }
-}
-
-bool CMP4SplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- CAtlMap<DWORD, trackpos>::CPair* pPairNext = nullptr;
- REFERENCE_TIME rtNext = 0;
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
- if (!pPin->IsConnected()) {
- continue;
- }
-
- REFERENCE_TIME rt = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * pPair->m_value.ts);
-
- if (pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
- pPairNext = pPair;
- rtNext = rt;
- }
- }
-
- if (!pPairNext) {
- break;
- }
-
- AP4_Track* track = movie->GetTrack(pPairNext->m_key);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
-
- AP4_Sample sample;
- AP4_DataBuffer data;
-
- if (pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
- const CMediaType& mt = pPin->CurrentMediaType();
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
- p->TrackNumber = (DWORD)track->GetId();
- p->rtStart = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
- p->rtStop = p->rtStart + (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
- p->bSyncPoint = TRUE;
-
- // FIXME: slow search & stss->m_Entries is private
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- p->bSyncPoint = FALSE;
- for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); ++i) {
- if (stss->m_Entries[i] - 1 < pPairNext->m_value.index) {
- continue;
- }
- if (stss->m_Entries[i] - 1 == pPairNext->m_value.index) {
- p->bSyncPoint = TRUE;
- }
- break;
- }
- }
- }
-
- //
- if (track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() >= 1 && data.GetDataSize() <= 16) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
-
- int nBlockAlign;
- if (wfe->nBlockAlign == 0) {
- nBlockAlign = 1200;
- } else if (wfe->nBlockAlign <= 16) { // for PCM (from 8bit mono to 64bit stereo), A-Law, u-Law
- nBlockAlign = wfe->nBlockAlign * (wfe->nSamplesPerSec >> 4); // 1/16s=62.5ms
- } else {
- nBlockAlign = wfe->nBlockAlign;
- pPairNext->m_value.index -= pPairNext->m_value.index % wfe->nBlockAlign;
- }
-
- p->rtStop = p->rtStart;
- TRACE(_T("track->GetSampleCount() %d %d\n"), track->GetSampleCount(), pPairNext->m_value.index);
- int fFirst = true;
-
- while (AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
- AP4_Size size = data.GetDataSize();
- const AP4_Byte* ptr = data.GetData();
-
- if (fFirst) {
- p->SetData(ptr, size);
- p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
- fFirst = false;
- } else {
- for (int i = 0; i < size; ++i) {
- p->Add(ptr[i]);
- }
- }
-
- p->rtStop += (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
-
- if (pPairNext->m_value.index + 1 >= track->GetSampleCount() || (int)p->GetCount() >= nBlockAlign) {
- break;
- }
-
- pPairNext->m_value.index++;
- }
- } else if (track->GetType() == AP4_Track::TYPE_TEXT) {
- CStringA dlgln_bkg, dlgln_plaintext;
-
- const AP4_Byte* ptr = data.GetData();
- AP4_Size avail = data.GetDataSize();
-
- if (avail > 2) {
- AP4_UI16 size = (ptr[0] << 8) | ptr[1];
-
- if (size <= avail - 2) {
- CStringA str;
-
- if (size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff) {
- CStringW wstr = CStringW((LPCWSTR)&ptr[2], size / 2);
- for (int i = 0; i < wstr.GetLength(); ++i) {
- wstr.SetAt(i, ((WORD)wstr[i] >> 8) | ((WORD)wstr[i] << 8));
- }
- str = UTF16To8(wstr);
- } else {
- str = CStringA((LPCSTR)&ptr[2], size);
- }
-
- CStringA dlgln = str;
-
- if (mt.subtype == MEDIASUBTYPE_ASS2) {
- AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex());
-
- dlgln = "0,0,Text,,0000,0000,0000,0000,," + str;
- dlgln_plaintext = str;
-
- CPoint translation(0, 0);
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- AP4_Float x, y;
- tkhd->GetTranslation(x, y);
- translation.SetPoint((int)x, (int)y);
- }
-
- if (AP4_UnknownSampleDescription* unknown_desc = dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
- AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
-
- if (AP4_TextSampleEntry* text = dynamic_cast<AP4_TextSampleEntry*>(sample_entry)) {
- const AP4_TextSampleEntry::AP4_TextDescription& d = text->GetDescription();
-
- // TODO
- } else if (AP4_Tx3gSampleEntry* tx3g = dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc = tx3g->GetDescription();
-
- CStringW font = L"Arial";
-
- if (AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(tx3g->GetChild(AP4_ATOM_TYPE_FTAB))) {
- AP4_String Name;
- if (AP4_SUCCEEDED(ftab->LookupFont(desc.Style.Font.Id, Name))) {
- font = Name.c_str();
- }
- }
-
- CRect rbox;
- CStringW ssa = ConvertTX3GToSSA(
- UTF8To16(str), desc, font,
- ptr + (2 + size), avail - (2 + size),
- m_framesize, translation,
- (p->rtStop - p->rtStart) / 10000,
- rbox);
- dlgln = UTF16To8(ssa);
-
- const AP4_Byte* bclr = (const AP4_Byte*)&desc.BackgroundColor;
-
- if (bclr[3]) {
- CPoint tl = rbox.TopLeft();
- rbox.OffsetRect(-tl.x, -tl.y);
-
- dlgln_bkg.Format(
- "0,-1,Text,,0,0,0,0,,{\\an7\\pos(%d,%d)\\1c%02x%02x%02x\\1a%02x\\bord0\\shad0}{\\p1}m %d %d l %d %d l %d %d l %d %d {\\p0}",
- tl.x, tl.y,
- bclr[2], bclr[1], bclr[0],
- 255 - bclr[3],
- rbox.left, rbox.top,
- rbox.right, rbox.top,
- rbox.right, rbox.bottom,
- rbox.left, rbox.bottom);
- }
- }
- }
- }
-
- dlgln.Replace("\r", "");
- dlgln.Replace("\n", "\\N");
-
- p->SetData((LPCSTR)dlgln, dlgln.GetLength());
- }
- }
-
- if (!dlgln_bkg.IsEmpty()) {
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
- p2->TrackNumber = p->TrackNumber;
- p2->rtStart = p->rtStart;
- p2->rtStop = p->rtStop;
- p2->bSyncPoint = p->bSyncPoint;
- p2->SetData((LPCSTR)dlgln_bkg, dlgln_bkg.GetLength());
- hr = DeliverPacket(p2);
- }
-
- if (!dlgln_plaintext.IsEmpty()) {
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
- p2->TrackNumber = p->TrackNumber ^ 0x80402010;
- p2->rtStart = p->rtStart;
- p2->rtStop = p->rtStop;
- p2->bSyncPoint = p->bSyncPoint;
- p2->SetData((LPCSTR)dlgln_plaintext, dlgln_plaintext.GetLength());
- hr = DeliverPacket(p2);
- }
- } else {
- p->SetData(data.GetData(), data.GetDataSize());
- }
- hr = DeliverPacket(p);
- }
-
- {
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
- pPairNext->m_value.ts = sample.GetCts();
- }
- }
-
- }
-
- return true;
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CMP4SplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- CheckPointer(m_pFile, E_UNEXPECTED);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
-
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- nKFs = stss->m_Entries.ItemCount();
- return S_OK;
- }
- }
-
- return E_FAIL;
-}
-
-STDMETHODIMP CMP4SplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
- CheckPointer(m_pFile, E_UNEXPECTED);
-
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
-
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- UINT nKFsTmp = 0;
- AP4_UI32 mts = track->GetMediaTimeScale();
-
- for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount() && nKFsTmp < nKFs; ++i) {
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i] - 1, sample))) {
- pKFs[nKFsTmp++] = REFERENCE_TIME((10000000ui64 * sample.GetCts() + mts / 2) / mts);
- //pKFs[nKFsTmp++] = REFERENCE_TIME(10000000.0 * sample.GetCts() / track->GetMediaTimeScale() + 0.5);
- }
- }
- nKFs = nKFsTmp;
-
- return S_OK;
- }
- }
-
- return E_FAIL;
-}
-
-//
-// CMP4SourceFilter
-//
-
-CMP4SourceFilter::CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMP4SplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CMPEG4VideoSplitterFilter
-//
-
-CMPEG4VideoSplitterFilter::CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMPEG4VideoSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-void CMPEG4VideoSplitterFilter::SkipUserData()
-{
- m_pFile->BitByteAlign();
- while (m_pFile->BitRead(32, true) == 0x000001b2)
- while (m_pFile->BitRead(24, true) != 0x000001) {
- m_pFile->BitRead(8);
- }
-}
-
-HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DEBUG_NEW CBaseSplitterFileEx(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- // TODO
-
- DWORD width = 0;
- DWORD height = 0;
- BYTE parx = 1;
- BYTE pary = 1;
- REFERENCE_TIME atpf = 400000;
-
- if (m_pFile->BitRead(24, true) != 0x000001) {
- return E_FAIL;
- }
-
- BYTE id;
- while (m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos())) {
- if (id == 0xb5) {
- BYTE is_visual_object_identifier = (BYTE)m_pFile->BitRead(1);
-
- if (is_visual_object_identifier) {
- BYTE visual_object_verid = (BYTE)m_pFile->BitRead(4);
- BYTE visual_object_priority = (BYTE)m_pFile->BitRead(3);
- }
-
- BYTE visual_object_type = (BYTE)m_pFile->BitRead(4);
-
- if (visual_object_type == 1 || visual_object_type == 2) {
- BYTE video_signal_type = (BYTE)m_pFile->BitRead(1);
-
- if (video_signal_type) {
- BYTE video_format = (BYTE)m_pFile->BitRead(3);
- BYTE video_range = (BYTE)m_pFile->BitRead(1);
- BYTE colour_description = (BYTE)m_pFile->BitRead(1);
-
- if (colour_description) {
- BYTE colour_primaries = (BYTE)m_pFile->BitRead(8);
- BYTE transfer_characteristics = (BYTE)m_pFile->BitRead(8);
- BYTE matrix_coefficients = (BYTE)m_pFile->BitRead(8);
- }
- }
- }
-
- SkipUserData();
-
- if (visual_object_type == 1) {
- if (m_pFile->BitRead(24) != 0x000001) {
- break;
- }
-
- BYTE video_object_start_code = (BYTE)m_pFile->BitRead(8);
- if (video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
- break;
- }
-
- if (m_pFile->BitRead(24) != 0x000001) {
- break;
- }
-
- BYTE video_object_layer_start_code = (DWORD)m_pFile->BitRead(8);
- if (video_object_layer_start_code < 0x20 || video_object_layer_start_code > 0x2f) {
- break;
- }
-
- BYTE random_accessible_vol = (BYTE)m_pFile->BitRead(1);
- BYTE video_object_type_indication = (BYTE)m_pFile->BitRead(8);
-
- if (video_object_type_indication == 0x12) { // Fine Granularity Scalable
- break; // huh
- }
-
- BYTE is_object_layer_identifier = (BYTE)m_pFile->BitRead(1);
-
- BYTE video_object_layer_verid = 0;
-
- if (is_object_layer_identifier) {
- video_object_layer_verid = (BYTE)m_pFile->BitRead(4);
- BYTE video_object_layer_priority = (BYTE)m_pFile->BitRead(3);
- }
-
- BYTE aspect_ratio_info = (BYTE)m_pFile->BitRead(4);
-
- switch (aspect_ratio_info) {
- default:
- ASSERT(0);
- break;
- case 1:
- parx = 1;
- pary = 1;
- break;
- case 2:
- parx = 12;
- pary = 11;
- break;
- case 3:
- parx = 10;
- pary = 11;
- break;
- case 4:
- parx = 16;
- pary = 11;
- break;
- case 5:
- parx = 40;
- pary = 33;
- break;
- case 15:
- parx = (BYTE)m_pFile->BitRead(8);
- pary = (BYTE)m_pFile->BitRead(8);
- break;
- }
-
- BYTE vol_control_parameters = (BYTE)m_pFile->BitRead(1);
-
- if (vol_control_parameters) {
- BYTE chroma_format = (BYTE)m_pFile->BitRead(2);
- BYTE low_delay = (BYTE)m_pFile->BitRead(1);
- BYTE vbv_parameters = (BYTE)m_pFile->BitRead(1);
-
- if (vbv_parameters) {
- WORD first_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD latter_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD first_half_vbv_buffer_size = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
-
- BYTE latter_half_vbv_buffer_size = (BYTE)m_pFile->BitRead(3);
- WORD first_half_vbv_occupancy = (WORD)m_pFile->BitRead(11);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD latter_half_vbv_occupancy = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- }
- }
-
- BYTE video_object_layer_shape = (BYTE)m_pFile->BitRead(2);
-
- if (video_object_layer_shape == 3 && video_object_layer_verid != 1) {
- BYTE video_object_layer_shape_extension = (BYTE)m_pFile->BitRead(4);
- }
-
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD vop_time_increment_resolution = (WORD)m_pFile->BitRead(16);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- BYTE fixed_vop_rate = (BYTE)m_pFile->BitRead(1);
-
- if (fixed_vop_rate) {
- int bits = 0;
- for (WORD i = vop_time_increment_resolution; i; i /= 2) {
- ++bits;
- }
-
- WORD fixed_vop_time_increment = m_pFile->BitRead(bits);
-
- if (fixed_vop_time_increment) {
- atpf = 10000000i64 * fixed_vop_time_increment / vop_time_increment_resolution;
- }
- }
-
- if (video_object_layer_shape != 2) {
- if (video_object_layer_shape == 0) {
- if (!m_pFile->BitRead(1)) {
- break;
- }
- width = (WORD)m_pFile->BitRead(13);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- height = (WORD)m_pFile->BitRead(13);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- }
-
- BYTE interlaced = (BYTE)m_pFile->BitRead(1);
- BYTE obmc_disable = (BYTE)m_pFile->BitRead(1);
-
- // ...
- }
- }
- } else if (id == 0xb6) {
- m_seqhdrsize = m_pFile->GetPos() - 4;
- }
- }
-
- if (!width || !height) {
- return E_FAIL;
- }
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(1);
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('v4pm');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + m_seqhdrsize);
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = width;
- mvih->hdr.bmiHeader.biHeight = height;
- mvih->hdr.bmiHeader.biCompression = 'v4pm';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.AvgTimePerFrame = atpf;
- mvih->hdr.dwPictAspectRatioX = width * parx;
- mvih->hdr.dwPictAspectRatioY = height * pary;
- mvih->cbSequenceHeader = m_seqhdrsize;
- m_pFile->Seek(0);
- m_pFile->ByteRead((BYTE*)mvih->dwSequenceHeader, m_seqhdrsize);
- mts.Add(mt);
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(0, pPinOut)));
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CMPEG4VideoSplitterFilter::DemuxInit()
-{
- return true;
-}
-
-void CMPEG4VideoSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- ASSERT(rt == 0);
-
- m_pFile->Seek(m_seqhdrsize);
-}
-
-bool CMPEG4VideoSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- CAutoPtr<Packet> p;
-
- REFERENCE_TIME rt = 0;
- REFERENCE_TIME atpf = ((MPEG2VIDEOINFO*)GetOutputPin(0)->CurrentMediaType().Format())->hdr.AvgTimePerFrame;
-
- DWORD sync = ~0;
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->GetRemaining()) {
- for (int i = 0; i < 65536; ++i) { // don't call CheckRequest so often
- bool eof = !m_pFile->GetRemaining();
-
- if (p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
- hr = DeliverPacket(p);
- }
-
- if (eof) {
- break;
- }
-
- if (!p) {
- p.Attach(DEBUG_NEW Packet());
- p->SetCount(0, 1024);
- p->TrackNumber = 0;
- p->rtStart = rt;
- p->rtStop = rt + atpf;
- p->bSyncPoint = FALSE;
- rt += atpf;
- // rt = Packet::INVALID_TIME;
- }
-
- BYTE b;
- m_pFile->ByteRead(&b, 1);
- p->Add(b);
- }
- }
-
- return true;
-}
-
-//
-// CMPEG4VideoSourceFilter
-//
-
-CMPEG4VideoSourceFilter::CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMPEG4VideoSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CMP4SplitterOutputPin
-//
-
-CMP4SplitterOutputPin::CMP4SplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
-{
-}
-
-CMP4SplitterOutputPin::~CMP4SplitterOutputPin()
-{
-}
-
-HRESULT CMP4SplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(this);
- return __super::DeliverNewSegment(tStart, tStop, dRate);
-}
-
-HRESULT CMP4SplitterOutputPin::DeliverEndFlush()
-{
- CAutoLock cAutoLock(this);
- return __super::DeliverEndFlush();
-}
-
-HRESULT CMP4SplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- CAutoLock cAutoLock(this);
- return __super::DeliverPacket(p);
-}
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.def b/src/filters/parser/MP4Splitter/MP4Splitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.h b/src/filters/parser/MP4Splitter/MP4Splitter.h
deleted file mode 100644
index 10b58e3a2..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "MP4SplitterFile.h"
-#include "../BaseSplitter/BaseSplitter.h"
-
-#define MP4SplitterName L"MPC MP4/MOV Splitter"
-#define MP4SourceName L"MPC MP4/MOV Source"
-
-class __declspec(uuid("61F47056-E400-43d3-AF1E-AB7DFFD4C4AD"))
- CMP4SplitterFilter : public CBaseSplitterFilter
-{
- struct trackpos {
- DWORD /*AP4_Ordinal*/ index;
- unsigned __int64 /*AP4_TimeStamp*/ ts;
- };
- CAtlMap<DWORD, trackpos> m_trackpos;
- CSize m_framesize;
-
-protected:
- CAutoPtr<CMP4SplitterFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMP4SplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CMP4SplitterFilter();
-
- // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IKeyFrameInfo
-
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-};
-
-class __declspec(uuid("3CCC052E-BDEE-408a-BEA7-90914EF2964B"))
- CMP4SourceFilter : public CMP4SplitterFilter
-{
-public:
- CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-// for raw mpeg4 elementary streams:
-
-class __declspec(uuid("D3D9D58B-45B5-48AB-B199-B8C40560AEC7"))
- CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
-{
- __int64 m_seqhdrsize;
- int NextStartCode();
- void SkipUserData();
-
-protected:
- CAutoPtr<CBaseSplitterFileEx> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-class __declspec(uuid("E2B98EEA-EE55-4E9B-A8C1-6E5288DF785A"))
- CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
-{
-public:
- CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-class CMP4SplitterOutputPin : public CBaseSplitterOutputPin, protected CCritSec
-{
-public:
- CMP4SplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMP4SplitterOutputPin();
-
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
- HRESULT DeliverEndFlush();
-};
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.rc b/src/filters/parser/MP4Splitter/MP4Splitter.rc
deleted file mode 100644
index b45dd9a87..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.rc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "MP4 Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "MP4 Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MP4Splitter.ax"
- VALUE "ProductName", "MP4 Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj
deleted file mode 100644
index 907d49cec..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj
+++ /dev/null
@@ -1,263 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{9ED4B036-7399-4128-868D-6E71188E0277}</ProjectGuid>
- <RootNamespace>MP4Splitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MP4Splitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="Ap4AsyncReaderStream.cpp" />
- <ClCompile Include="MP4Splitter.cpp" />
- <ClCompile Include="MP4SplitterFile.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="Ap4AsyncReaderStream.h" />
- <ClInclude Include="MP4Splitter.h" />
- <ClInclude Include="MP4SplitterFile.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <None Include="MP4Splitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MP4Splitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\zlib\zlib.vcxproj">
- <Project>{2fcd4b66-9cf9-4c8f-bc70-37cd20002d49}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\Bento4\Bento4.vcxproj">
- <Project>{40177920-a66c-4647-b119-332a10224c83}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters
deleted file mode 100644
index bd8470503..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{811a4da3-b120-496c-98a0-7016078458cd}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{4ae0033a-41e4-43a5-ac05-966c1d9184fe}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{2471c705-e3fc-48d6-9877-e6ece4604e13}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="Ap4AsyncReaderStream.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MP4Splitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MP4SplitterFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="Ap4AsyncReaderStream.h">
- <Filter>Source Files</Filter>
- </ClInclude>
- <ClInclude Include="MP4Splitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MP4SplitterFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <None Include="MP4Splitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MP4Splitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
deleted file mode 100644
index e4881f63b..000000000
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MP4SplitterFile.h"
-#include "Ap4AsyncReaderStream.h"
-
-CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr)
- : CBaseSplitterFileEx(pReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_pAp4File(nullptr)
-{
- if (FAILED(hr)) {
- return;
- }
-
- hr = Init();
-}
-
-CMP4SplitterFile::~CMP4SplitterFile()
-{
- delete(AP4_File*)m_pAp4File;
-}
-
-void* /* AP4_Movie* */ CMP4SplitterFile::GetMovie()
-{
- ASSERT(m_pAp4File);
- return m_pAp4File ? ((AP4_File*)m_pAp4File)->GetMovie() : nullptr;
-}
-
-HRESULT CMP4SplitterFile::Init()
-{
- Seek(0);
-
- delete(AP4_File*)m_pAp4File;
-
- AP4_ByteStream* stream = DEBUG_NEW AP4_AsyncReaderStream(this);
-
- m_pAp4File = DEBUG_NEW AP4_File(*stream);
-
- AP4_Movie* movie = ((AP4_File*)m_pAp4File)->GetMovie();
-
- stream->Release();
-
- return movie ? S_OK : E_FAIL;
-}
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.h b/src/filters/parser/MP4Splitter/MP4SplitterFile.h
deleted file mode 100644
index df41f8803..000000000
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-// #include "Ap4AsyncReaderStream.h" // FIXME
-
-class CMP4SplitterFile : public CBaseSplitterFileEx
-{
- void* /* AP4_File* */ m_pAp4File;
-
- HRESULT Init();
-
-public:
- CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr);
- virtual ~CMP4SplitterFile();
-
- void* /* AP4_Movie* */ GetMovie();
-};
diff --git a/src/filters/parser/MP4Splitter/resource.h b/src/filters/parser/MP4Splitter/resource.h
deleted file mode 100644
index f9afd652d..000000000
--- a/src/filters/parser/MP4Splitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MP4Splitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MP4Splitter/stdafx.cpp b/src/filters/parser/MP4Splitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MP4Splitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MP4Splitter/stdafx.h b/src/filters/parser/MP4Splitter/stdafx.h
deleted file mode 100644
index b0e6277c8..000000000
--- a/src/filters/parser/MP4Splitter/stdafx.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-
-#include <crtdefs.h>
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
deleted file mode 100644
index 396d6a449..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
+++ /dev/null
@@ -1,1595 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MatroskaFile.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "zlib/zlib.h"
-
-#define DOCTYPE _T("matroska")
-#define DOCTYPE_WEBM _T("webm")
-#define DOCTYPEVERSION 2
-
-using namespace MatroskaReader;
-
-
-#define BeginChunk \
- CheckPointer(pMN0, E_POINTER); \
- CAutoPtr<CMatroskaNode> pMN = pMN0->Child(); \
- \
- if (!pMN) \
- return S_FALSE; \
- do { \
- switch (pMN->m_id) {
-
-
-#define EndChunk \
- } \
- } while (pMN->Next()); \
- \
- return S_OK;
-
-
-static void bswap(BYTE* s, int len)
-{
- for (BYTE* d = s + len - 1; s < d; s++, d--) {
- *s ^= *d, *d ^= *s, *s ^= *d;
- }
-}
-
-//
-// CMatroskaFile
-//
-
-CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_rtOffset(0)
-{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
-}
-
-HRESULT CMatroskaFile::Init()
-{
- DWORD dw;
- if (FAILED(Read(dw)) || dw != 0x1A45DFA3) {
- return E_FAIL;
- }
-
- CMatroskaNode Root(this);
- if (FAILED(Parse(&Root))) {
- return E_FAIL;
- }
-
- CAutoPtr<CMatroskaNode> pSegment, pCluster;
- if ((pSegment = Root.Child(0x18538067))
- && (pCluster = pSegment->Child(0x1F43B675))) {
- Cluster c0;
- c0.ParseTimeCode(pCluster);
- m_rtOffset = m_segment.GetRefTime(c0.TimeCode);
- }
-
- return S_OK;
-}
-
-template <class T>
-HRESULT CMatroskaFile::Read(T& var)
-{
- HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- if (S_OK == hr) {
- bswap((BYTE*)&var, sizeof(var));
- }
- return hr;
-}
-
-HRESULT CMatroskaFile::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x1A45DFA3:
- m_ebml.Parse(pMN);
- if ((m_ebml.DocType != DOCTYPE || m_ebml.DocTypeReadVersion > DOCTYPEVERSION) && m_ebml.DocType != DOCTYPE_WEBM) {
- return E_FAIL;
- }
- break;
-case 0x18538067:
- if (m_segment.SegmentInfo.SegmentUID.IsEmpty()) {
- m_segment.ParseMinimal(pMN);
- }
- break;
- EndChunk;
-}
-
-//
-
-HRESULT EBML::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x4286:
- EBMLVersion.Parse(pMN);
- break;
-case 0x42F7:
- EBMLReadVersion.Parse(pMN);
- break;
-case 0x42F2:
- EBMLMaxIDLength.Parse(pMN);
- break;
-case 0x42F3:
- EBMLMaxSizeLength.Parse(pMN);
- break;
-case 0x4282:
- DocType.Parse(pMN);
- break;
-case 0x4287:
- DocTypeVersion.Parse(pMN);
- break;
-case 0x4285:
- DocTypeReadVersion.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Segment::Parse(CMatroskaNode* pMN0)
-{
- pos = pMN0->GetPos();
-
- BeginChunk;
-case 0x1549A966:
- SegmentInfo.Parse(pMN);
- break;
-case 0x114D9B74:
- MetaSeekInfo.Parse(pMN);
- break;
-case 0x1654AE6B:
- Tracks.Parse(pMN);
- break;
-case 0x1F43B675:
- Clusters.Parse(pMN);
- break;
-case 0x1C53BB6B:
- Cues.Parse(pMN);
- break;
-case 0x1941A469:
- Attachments.Parse(pMN);
- break;
-case 0x1043A770:
- Chapters.Parse(pMN);
- break;
- // case 0x1254C367: Tags.Parse(pMN); break;
- EndChunk;
-}
-
-HRESULT Segment::ParseMinimal(CMatroskaNode* pMN0)
-{
- CheckPointer(pMN0, E_POINTER);
-
- pos = pMN0->GetPos();
- len = pMN0->m_len;
-
- CAutoPtr<CMatroskaNode> pMN = pMN0->Child();
- if (!pMN) {
- return S_FALSE;
- }
-
- unsigned int k = 0;
-
- do {
- switch (pMN->m_id) {
- case 0x1549A966:
- SegmentInfo.Parse(pMN);
- k |= (1 << 0);
- break;
- case 0x114D9B74:
- MetaSeekInfo.Parse(pMN);
- k |= (1 << 1);
- break;
- case 0x1654AE6B:
- Tracks.Parse(pMN);
- k |= (1 << 2);
- break;
- case 0x1C53BB6B:
- k |= (1 << 3);
- Cues.Parse(pMN);
- break;
- }
- } while (k != 15 && pMN->m_id != 0x1F43B675 && pMN->Next());
-
- if (!pMN->IsRandomAccess()) {
- return S_OK;
- }
-
- while (QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
- pMN->SeekTo(pos);
- if (FAILED(pMN->Parse())) {
- break; // a broken file
- }
- MetaSeekInfo.Parse(pMN);
- }
-
- if (k != 15) {
- if (Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false))) {
- do {
- Cues.Parse(pMN);
- } while (pMN->Next(true));
- }
-
- if (Chapters.IsEmpty() && (pMN = pMN0->Child(0x1043A770, false))) {
- do {
- Chapters.Parse(pMN); /*BIG UGLY HACK:*/
- break;
- } while (pMN->Next(true));
- }
-
- if (Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
- do {
- Attachments.Parse(pMN); /*BIG UGLY HACK:*/
- break;
- } while (pMN->Next(true));
- }
- }
-
- return S_OK;
-}
-
-UINT64 Segment::GetMasterTrack()
-{
- UINT64 TrackNumber = 0, AltTrackNumber = 0;
-
- POSITION pos1 = Tracks.GetHeadPosition();
- while (pos1 && TrackNumber == 0) {
- Track* pT = Tracks.GetNext(pos1);
-
- POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while (pos2 && TrackNumber == 0) {
- TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- TrackNumber = pTE->TrackNumber;
- break;
- } else if (pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0) {
- AltTrackNumber = pTE->TrackNumber;
- }
- }
- }
-
- if (TrackNumber == 0) {
- TrackNumber = AltTrackNumber;
- }
- if (TrackNumber == 0) {
- TrackNumber = 1;
- }
-
- return TrackNumber;
-}
-
-ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
-{
- if (ChapterUID == id) {
- return this;
- }
-
- POSITION pos = ChapterAtoms.GetHeadPosition();
- while (pos) {
- ChapterAtom* ca = ChapterAtoms.GetNext(pos)->FindChapterAtom(id);
- if (ca) {
- return ca;
- }
- }
-
- return nullptr;
-}
-
-ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
-{
- POSITION pos1 = Chapters.GetHeadPosition();
- while (pos1) {
- Chapter* c = Chapters.GetNext(pos1);
-
- POSITION pos2 = c->EditionEntries.GetHeadPosition();
- while (pos2) {
- EditionEntry* ee = c->EditionEntries.GetNext(pos2);
-
- if (nEditionEntry-- == 0) {
- return id == 0 ? ee : ee->FindChapterAtom(id);
- }
- }
- }
-
- return nullptr;
-}
-
-HRESULT Info::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x73A4:
- SegmentUID.Parse(pMN);
- break;
-case 0x7384:
- SegmentFilename.Parse(pMN);
- break;
-case 0x3CB923:
- PrevUID.Parse(pMN);
- break;
-case 0x3C83AB:
- PrevFilename.Parse(pMN);
- break;
-case 0x3EB923:
- NextUID.Parse(pMN);
- break;
-case 0x3E83BB:
- NextFilename.Parse(pMN);
- break;
-case 0x2AD7B1:
- TimeCodeScale.Parse(pMN);
- break;
-case 0x4489:
- Duration.Parse(pMN);
- break;
-case 0x4461:
- DateUTC.Parse(pMN);
- break;
-case 0x7BA9:
- Title.Parse(pMN);
- break;
-case 0x4D80:
- MuxingApp.Parse(pMN);
- break;
-case 0x5741:
- WritingApp.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Seek::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x4DBB:
- SeekHeads.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT SeekHead::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x53AB:
- SeekID.Parse(pMN);
- break;
-case 0x53AC:
- SeekPosition.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Track::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xAE:
- TrackEntries.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT TrackEntry::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xD7:
- TrackNumber.Parse(pMN);
- break;
-case 0x73C5:
- TrackUID.Parse(pMN);
- break;
-case 0x83:
- TrackType.Parse(pMN);
- break;
-case 0xB9:
- FlagEnabled.Parse(pMN);
- break;
-case 0x88:
- FlagDefault.Parse(pMN);
- break;
-case 0x9C:
- FlagLacing.Parse(pMN);
- break;
-case 0x55AA:
- FlagForced.Parse(pMN);
- break;
-case 0x6DE7:
- MinCache.Parse(pMN);
- break;
-case 0x6DF8:
- MaxCache.Parse(pMN);
- break;
-case 0x536E:
- Name.Parse(pMN);
- break;
-case 0x22B59C:
- Language.Parse(pMN);
- break;
-case 0x86:
- CodecID.Parse(pMN);
- break;
-case 0x63A2:
- CodecPrivate.Parse(pMN);
- break;
-case 0x258688:
- CodecName.Parse(pMN);
- break;
-case 0x3A9697:
- CodecSettings.Parse(pMN);
- break;
-case 0x3B4040:
- CodecInfoURL.Parse(pMN);
- break;
-case 0x26B240:
- CodecDownloadURL.Parse(pMN);
- break;
-case 0xAA:
- CodecDecodeAll.Parse(pMN);
- break;
-case 0x6FAB:
- TrackOverlay.Parse(pMN);
- break;
-case 0x23E383:
-case 0x2383E3:
- DefaultDuration.Parse(pMN);
- break;
-case 0x23314F:
- TrackTimecodeScale.Parse(pMN);
- break;
-case 0xE0:
- if (S_OK == v.Parse(pMN)) {
- DescType |= DescVideo;
- }
- break;
-case 0xE1:
- if (S_OK == a.Parse(pMN)) {
- DescType |= DescAudio;
- }
- break;
-case 0x6D80:
- ces.Parse(pMN);
- break;
- EndChunk;
-}
-
-static int cesort(const void* a, const void* b)
-{
- UINT64 ce1 = (static_cast<ContentEncoding*>(const_cast<void*>(a)))->ContentEncodingOrder;
- UINT64 ce2 = (static_cast<ContentEncoding*>(const_cast<void*>(b)))->ContentEncodingOrder;
-
- return (int)ce1 - (int)ce2;
-}
-
-bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
-{
- if (ces.ce.IsEmpty()) {
- return true;
- }
-
- CAtlArray<ContentEncoding*> cearray;
- POSITION pos = ces.ce.GetHeadPosition();
- while (pos) {
- cearray.Add(ces.ce.GetNext(pos));
- }
- qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);
-
- for (int i = (int)cearray.GetCount() - 1; i >= 0; i--) {
- ContentEncoding* ce = cearray[i];
-
- if (!(ce->ContentEncodingScope & Scope)) {
- continue;
- }
-
- if (ce->ContentEncodingType == ContentEncoding::Compression) {
- if (!data.Decompress(ce->cc)) {
- return false;
- }
- } else if (ce->ContentEncodingType == ContentEncoding::Encryption) {
- // TODO
- return false;
- }
- }
-
- return true;
-}
-
-HRESULT Video::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x9A:
- FlagInterlaced.Parse(pMN);
- break;
-case 0x53B8:
- StereoMode.Parse(pMN);
- break;
-case 0xB0:
- PixelWidth.Parse(pMN);
- if (!DisplayWidth) {
- DisplayWidth.Set(PixelWidth);
- }
- break;
-case 0xBA:
- PixelHeight.Parse(pMN);
- if (!DisplayHeight) {
- DisplayHeight.Set(PixelHeight);
- }
- break;
-case 0x54B0:
- DisplayWidth.Parse(pMN);
- break;
-case 0x54BA:
- DisplayHeight.Parse(pMN);
- break;
-case 0x54B2:
- DisplayUnit.Parse(pMN);
- break;
-case 0x54B3:
- AspectRatioType.Parse(pMN);
- break;
-case 0x54AA:
- VideoPixelCropBottom.Parse(pMN);
- if ((INT64)VideoPixelCropBottom < 0) {
- VideoPixelCropBottom.Set(0); // fix bad value
- }
- break;
-case 0x54BB:
- VideoPixelCropTop.Parse(pMN);
- if ((INT64)VideoPixelCropTop < 0) {
- VideoPixelCropTop.Set(0); // fix bad value
- }
- break;
-case 0x54CC:
- VideoPixelCropLeft.Parse(pMN);
- if ((INT64)VideoPixelCropLeft < 0) {
- VideoPixelCropLeft.Set(0); // fix bad value
- }
- break;
-case 0x54DD:
- VideoPixelCropRight.Parse(pMN);
- if ((INT64)VideoPixelCropRight < 0) {
- VideoPixelCropRight.Set(0); // fix bad value
- }
- break;
-case 0x2EB524:
- ColourSpace.Parse(pMN);
- break;
-case 0x2FB523:
- GammaValue.Parse(pMN);
- break;
-case 0x2383E3:
- FramePerSec.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Audio::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xB5:
- SamplingFrequency.Parse(pMN);
- if (!OutputSamplingFrequency) {
- OutputSamplingFrequency.Set(SamplingFrequency);
- }
- break;
-case 0x78B5:
- OutputSamplingFrequency.Parse(pMN);
- break;
-case 0x9F:
- Channels.Parse(pMN);
- break;
-case 0x7D7B:
- ChannelPositions.Parse(pMN);
- break;
-case 0x6264:
- BitDepth.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentEncodings::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x6240:
- ce.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentEncoding::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x5031:
- ContentEncodingOrder.Parse(pMN);
- break;
-case 0x5032:
- ContentEncodingScope.Parse(pMN);
- break;
-case 0x5033:
- ContentEncodingType.Parse(pMN);
- break;
-case 0x5034:
- cc.Parse(pMN);
- break;
-case 0x5035:
- ce.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentCompression::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x4254:
- ContentCompAlgo.Parse(pMN);
- break;
-case 0x4255:
- ContentCompSettings.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentEncryption::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x47e1:
- ContentEncAlgo.Parse(pMN);
- break;
-case 0x47e2:
- ContentEncKeyID.Parse(pMN);
- break;
-case 0x47e3:
- ContentSignature.Parse(pMN);
- break;
-case 0x47e4:
- ContentSigKeyID.Parse(pMN);
- break;
-case 0x47e5:
- ContentSigAlgo.Parse(pMN);
- break;
-case 0x47e6:
- ContentSigHashAlgo.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Cluster::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xE7:
- TimeCode.Parse(pMN);
- break;
-case 0xA7:
- Position.Parse(pMN);
- break;
-case 0xAB:
- PrevSize.Parse(pMN);
- break;
-case 0xA0:
- BlockGroups.Parse(pMN, true);
- break;
-case 0xA3:
- SimpleBlocks.Parse(pMN, true);
- break;
- EndChunk;
-}
-
-HRESULT Cluster::ParseTimeCode(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xE7:
- TimeCode.Parse(pMN);
- return S_OK;
- EndChunk;
-}
-
-HRESULT BlockGroup::Parse(CMatroskaNode* pMN0, bool fFull)
-{
- BeginChunk;
-case 0xA1:
- Block.Parse(pMN, fFull);
- break;
-case 0xA2: /* TODO: multiple virt blocks? */
- ;
- break;
-case 0x9B:
- BlockDuration.Parse(pMN);
- break;
-case 0xFA:
- ReferencePriority.Parse(pMN);
- break;
-case 0xFB:
- ReferenceBlock.Parse(pMN);
- break;
-case 0xFD:
- ReferenceVirtual.Parse(pMN);
- break;
-case 0xA4:
- CodecState.Parse(pMN);
- break;
-case 0xE8:
- TimeSlices.Parse(pMN);
- break;
-case 0x75A1:
- if (fFull) {
- ba.Parse(pMN);
- }
- break;
- EndChunk;
-}
-
-HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull)
-{
- pMN->SeekTo(pMN->m_start);
-
- TrackNumber.Parse(pMN);
- CShort s;
- s.Parse(pMN);
- TimeCode.Set(s);
- Lacing.Parse(pMN);
-
- if (!fFull) {
- return S_OK;
- }
-
- CAtlList<QWORD> lens;
- QWORD tlen = 0;
- QWORD FrameSize;
- BYTE FramesInLaceLessOne;
-
- switch ((Lacing & 0x06) >> 1) {
- case 0:
- // No lacing
- lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
- break;
- case 1:
- // Xiph lacing
- BYTE n;
- pMN->Read(n);
- while (n-- > 0) {
- BYTE b;
- QWORD len = 0;
- do {
- pMN->Read(b);
- len += b;
- } while (b == 0xff);
- lens.AddTail(len);
- tlen += len;
- }
- lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
- break;
- case 2:
- // Fixed-size lacing
- pMN->Read(FramesInLaceLessOne);
- FramesInLaceLessOne++;
- FrameSize = ((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen)) / FramesInLaceLessOne;
- while (FramesInLaceLessOne-- > 0) {
- lens.AddTail(FrameSize);
- }
- break;
- case 3:
- // EBML lacing
- pMN->Read(FramesInLaceLessOne);
-
- CLength FirstFrameSize;
- FirstFrameSize.Parse(pMN);
- lens.AddTail(FirstFrameSize);
- FramesInLaceLessOne--;
- tlen = FirstFrameSize;
-
- CSignedLength DiffSize;
- FrameSize = FirstFrameSize;
- while (FramesInLaceLessOne--) {
- DiffSize.Parse(pMN);
- FrameSize += DiffSize;
- lens.AddTail(FrameSize);
- tlen += FrameSize;
- }
- lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
- break;
- }
-
- POSITION pos = lens.GetHeadPosition();
- while (pos) {
- QWORD len = lens.GetNext(pos);
- CAutoPtr<CBinary> p(DEBUG_NEW CBinary());
- p->SetCount((INT_PTR)len);
- pMN->Read(p->GetData(), len);
- BlockData.AddTail(p);
- }
-
- return S_OK;
-}
-
-HRESULT BlockAdditions::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xA6:
- bm.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT BlockMore::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xEE:
- BlockAddID.Parse(pMN);
- break;
-case 0xA5:
- BlockAdditional.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT TimeSlice::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xCC:
- LaceNumber.Parse(pMN);
- break;
-case 0xCD:
- FrameNumber.Parse(pMN);
- break;
-case 0xCE:
- Delay.Parse(pMN);
- break;
-case 0xCF:
- Duration.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Cue::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xBB:
- CuePoints.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT CuePoint::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xB3:
- CueTime.Parse(pMN);
- break;
-case 0xB7:
- CueTrackPositions.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT CueTrackPosition::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xF7:
- CueTrack.Parse(pMN);
- break;
-case 0xF1:
- CueClusterPosition.Parse(pMN);
- break;
-case 0x5387:
- CueBlockNumber.Parse(pMN);
- break;
-case 0xEA:
- CueCodecState.Parse(pMN);
- break;
-case 0xDB:
- CueReferences.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT CueReference::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x96:
- CueRefTime.Parse(pMN);
- break;
-case 0x97:
- CueRefCluster.Parse(pMN);
- break;
-case 0x535F:
- CueRefNumber.Parse(pMN);
- break;
-case 0xEB:
- CueRefCodecState.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Attachment::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x61A7:
- AttachedFiles.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT AttachedFile::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x467E:
- FileDescription.Parse(pMN);
- break;
-case 0x466E:
- FileName.Parse(pMN);
- break;
-case 0x4660:
- FileMimeType.Parse(pMN);
- break;
-case 0x465C: // binary
- FileDataLen = (INT_PTR)pMN->m_len;
- FileDataPos = pMN->m_start;
- break;
-case 0x46AE:
- FileUID.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Chapter::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x45B9:
- EditionEntries.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT EditionEntry::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xB6:
- ChapterAtoms.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ChapterAtom::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x73C4:
- ChapterUID.Parse(pMN);
- break;
-case 0x91:
- ChapterTimeStart.Parse(pMN);
- break;
-case 0x92:
- ChapterTimeEnd.Parse(pMN);
- break;
- // case 0x8F: // TODO
-case 0x80:
- ChapterDisplays.Parse(pMN);
- break;
-case 0xB6:
- ChapterAtoms.Parse(pMN);
- break;
-case 0x98:
- ChapterFlagHidden.Parse(pMN);
- break;
-case 0x4598:
- ChapterFlagEnabled.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ChapterDisplay::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x85:
- ChapString.Parse(pMN);
- break;
-case 0x437C:
- ChapLanguage.Parse(pMN);
- break;
-case 0x437E:
- ChapCountry.Parse(pMN);
- break;
- EndChunk;
-}
-
-//
-
-HRESULT CBinary::Parse(CMatroskaNode* pMN)
-{
- ASSERT(pMN->m_len <= INT_MAX);
- SetCount((INT_PTR)pMN->m_len);
- return pMN->Read(GetData(), pMN->m_len);
-}
-
-bool CBinary::Compress(ContentCompression& cc)
-{
- if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
- int res;
- z_stream c_stream;
-
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
-
- if (Z_OK != (res = deflateInit(&c_stream, 9))) {
- return false;
- }
-
- c_stream.next_in = GetData();
- c_stream.avail_in = (uInt)GetCount();
-
- BYTE* dst = nullptr;
- BYTE* newDst = nullptr;
- int n = 0;
- do {
- newDst = (BYTE*)realloc(dst, ++n * 10);
- if (newDst) {
- dst = newDst;
- c_stream.next_out = &dst[(n - 1) * 10];
- c_stream.avail_out = 10;
- }
- if (!newDst || (Z_OK != (res = deflate(&c_stream, Z_FINISH)) && Z_STREAM_END != res)) {
- free(dst);
- return false;
- }
- } while (0 == c_stream.avail_out && Z_STREAM_END != res);
-
- deflateEnd(&c_stream);
-
- SetCount(c_stream.total_out);
- memcpy(GetData(), dst, GetCount());
-
- free(dst);
-
- return true;
- }
-
- return false;
-}
-
-bool CBinary::Decompress(ContentCompression& cc)
-{
- if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
- int res;
- z_stream d_stream;
-
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- if (Z_OK != (res = inflateInit(&d_stream))) {
- return false;
- }
-
- d_stream.next_in = GetData();
- d_stream.avail_in = (uInt)GetCount();
-
- BYTE* dst = nullptr;
- BYTE* newDst = nullptr;
- int n = 0;
- do {
- newDst = (BYTE*)realloc(dst, ++n * 1000);
- if (newDst) {
- dst = newDst;
- d_stream.next_out = &dst[(n - 1) * 1000];
- d_stream.avail_out = 1000;
- }
- if (!newDst || (Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res)) {
- free(dst);
- return false;
- }
- } while (0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
-
- inflateEnd(&d_stream);
-
- SetCount(d_stream.total_out);
- memcpy(GetData(), dst, GetCount());
-
- free(dst);
-
- return true;
- } else if (cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
- InsertArrayAt(0, &cc.ContentCompSettings);
- }
-
- return false;
-}
-
-HRESULT CANSI::Parse(CMatroskaNode* pMN)
-{
- Empty();
-
- QWORD len = pMN->m_len;
- CHAR c;
- while (len-- > 0 && SUCCEEDED(pMN->Read(c))) {
- *this += c;
- }
-
- return (len == -1 ? S_OK : E_FAIL);
-}
-
-HRESULT CUTF8::Parse(CMatroskaNode* pMN)
-{
- Empty();
- CAutoVectorPtr<BYTE> buff;
- if (!buff.Allocate((UINT)pMN->m_len + 1) || S_OK != pMN->Read(buff, pMN->m_len)) {
- return E_FAIL;
- }
- buff[pMN->m_len] = 0;
- CStringW::operator = (UTF8To16((LPCSTR)(BYTE*)buff));
- return S_OK;
-}
-
-HRESULT CUInt::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
- for (int i = 0; i < (int)pMN->m_len; i++) {
- m_val <<= 8;
- HRESULT hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
- m_fValid = true;
- return S_OK;
-}
-
-HRESULT CInt::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
- for (int i = 0; i < (int)pMN->m_len; i++) {
- HRESULT hr = pMN->Read(*((BYTE*)&m_val + 7 - i));
- if (FAILED(hr)) {
- return hr;
- }
- }
- m_val >>= (8 - pMN->m_len) * 8;
- m_fValid = true;
- return S_OK;
-}
-
-HRESULT CFloat::Parse(CMatroskaNode* pMN)
-{
- HRESULT hr = E_FAIL;
- m_val = 0;
-
- if (pMN->m_len == 4) {
- float val = 0;
- hr = pMN->Read(val);
- m_val = val;
- } else if (pMN->m_len == 8) {
- hr = pMN->Read(m_val);
- }
- if (SUCCEEDED(hr)) {
- m_fValid = true;
- }
- return hr;
-}
-
-
-template<class T, class BASE>
-HRESULT CSimpleVar<T, BASE>::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
- m_fValid = true;
- return pMN->Read(m_val);
-}
-
-HRESULT CID::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) {
- return hr;
- }
-
- int nMoreBytes = 0;
-
- if ((b & 0x80) == 0x80) {
- m_val = b & 0xff;
- nMoreBytes = 0;
- } else if ((b & 0xc0) == 0x40) {
- m_val = b & 0x7f;
- nMoreBytes = 1;
- } else if ((b & 0xe0) == 0x20) {
- m_val = b & 0x3f;
- nMoreBytes = 2;
- } else if ((b & 0xf0) == 0x10) {
- m_val = b & 0x1f;
- nMoreBytes = 3;
- } else {
- return E_FAIL;
- }
-
- while (nMoreBytes-- > 0) {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- m_fValid = true;
-
- return S_OK;
-}
-
-HRESULT CLength::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) {
- return hr;
- }
-
- int nMoreBytes = 0;
-
- if ((b & 0x80) == 0x80) {
- m_val = b & 0x7f;
- nMoreBytes = 0;
- } else if ((b & 0xc0) == 0x40) {
- m_val = b & 0x3f;
- nMoreBytes = 1;
- } else if ((b & 0xe0) == 0x20) {
- m_val = b & 0x1f;
- nMoreBytes = 2;
- } else if ((b & 0xf0) == 0x10) {
- m_val = b & 0x0f;
- nMoreBytes = 3;
- } else if ((b & 0xf8) == 0x08) {
- m_val = b & 0x07;
- nMoreBytes = 4;
- } else if ((b & 0xfc) == 0x04) {
- m_val = b & 0x03;
- nMoreBytes = 5;
- } else if ((b & 0xfe) == 0x02) {
- m_val = b & 0x01;
- nMoreBytes = 6;
- } else if ((b & 0xff) == 0x01) {
- m_val = b & 0x00;
- nMoreBytes = 7;
- } else {
- return E_FAIL;
- }
-
- //int nMoreBytesTmp = nMoreBytes;
-
- QWORD UnknownSize = (1i64 << (7 * (nMoreBytes + 1))) - 1;
-
- while (nMoreBytes-- > 0) {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- if (m_val == UnknownSize) {
- m_val = pMN->GetLength() - pMN->GetPos();
- TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
- }
-
- if (m_fSigned) {
- m_val -= (UnknownSize >> 1);
- }
-
- m_fValid = true;
-
- return S_OK;
-}
-/*
-HRESULT CSignedLength::Parse(CMatroskaNode* pMN)
-{
-// HRESULT hr = __super::Parse(pMN);
-// if (FAILED(hr)) return hr;
-
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) return hr;
-
- int nMoreBytes = 0;
-
- if ((b&0x80) == 0x80) {m_val = b&0x7f; nMoreBytes = 0;}
- else if ((b&0xc0) == 0x40) {m_val = b&0x3f; nMoreBytes = 1;}
- else if ((b&0xe0) == 0x20) {m_val = b&0x1f; nMoreBytes = 2;}
- else if ((b&0xf0) == 0x10) {m_val = b&0x0f; nMoreBytes = 3;}
- else if ((b&0xf8) == 0x08) {m_val = b&0x07; nMoreBytes = 4;}
- else if ((b&0xfc) == 0x04) {m_val = b&0x03; nMoreBytes = 5;}
- else if ((b&0xfe) == 0x02) {m_val = b&0x01; nMoreBytes = 6;}
- else if ((b&0xff) == 0x01) {m_val = b&0x00; nMoreBytes = 7;}
- else return E_FAIL;
-
- //int nMoreBytesTmp = nMoreBytes;
-
- QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
-
- while (nMoreBytes-- > 0)
- {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) return hr;
- }
-
- if (m_val == UnknownSize)
- {
- m_val = pMN->GetLength() - pMN->GetPos();
- TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
- }
-
- m_val -= (UnknownSize >> 1);
-
- m_fValid = true;
-
- return S_OK;
-}
-*/
-template<class T>
-HRESULT CNode<T>::Parse(CMatroskaNode* pMN)
-{
- CAutoPtr<T> p(DEBUG_NEW T());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
-}
-
-HRESULT CBlockGroupNode::Parse(CMatroskaNode* pMN, bool fFull)
-{
- CAutoPtr<BlockGroup> p(DEBUG_NEW BlockGroup());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
-}
-
-HRESULT CSimpleBlockNode::Parse(CMatroskaNode* pMN, bool fFull)
-{
- CAutoPtr<SimpleBlock> p(DEBUG_NEW SimpleBlock());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
-}
-
-///////////////////////////////
-
-CMatroskaNode::CMatroskaNode(CMatroskaFile* pMF)
- : m_pMF(pMF)
- , m_pParent(nullptr)
-{
- ASSERT(m_pMF);
- m_start = m_filepos = 0;
- m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
-}
-
-CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent)
- : m_pMF(pParent->m_pMF)
- , m_pParent(pParent)
-{
- Parse();
-}
-
-HRESULT CMatroskaNode::Parse()
-{
- m_filepos = GetPos();
- if (FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this))) {
- return E_FAIL;
- }
- m_start = GetPos();
- return S_OK;
-}
-
-CAutoPtr<CMatroskaNode> CMatroskaNode::Child(DWORD id, bool fSearch)
-{
- if (m_len == 0) {
- return CAutoPtr<CMatroskaNode>();
- }
- SeekTo(m_start);
- CAutoPtr<CMatroskaNode> pMN(DEBUG_NEW CMatroskaNode(this));
- if (id && !pMN->Find(id, fSearch)) {
- pMN.Free();
- }
- return pMN;
-}
-
-bool CMatroskaNode::Next(bool fSame)
-{
- if (!m_pParent) {
- return false;
- }
-
- CID id = m_id;
-
- while (m_start + m_len < m_pParent->m_start + m_pParent->m_len) {
- SeekTo(m_start + m_len);
-
- if (FAILED(Parse())) {
- if (!Resync()) {
- return false;
- }
- }
-
- if (!fSame || m_id == id) {
- return true;
- }
- }
-
- return false;
-}
-
-bool CMatroskaNode::Find(DWORD id, bool fSearch)
-{
- QWORD pos = m_pParent && m_pParent->m_id == 0x18538067 /*segment?*/
- ? FindPos(id)
- : 0;
-
- if (pos) {
- SeekTo(pos);
- Parse();
- } else if (fSearch) {
- while (m_id != id && Next()) {
- ;
- }
- }
-
- return (m_id == id);
-}
-
-void CMatroskaNode::SeekTo(QWORD pos)
-{
- m_pMF->Seek(pos);
-}
-
-QWORD CMatroskaNode::GetPos()
-{
- return m_pMF->GetPos();
-}
-
-QWORD CMatroskaNode::GetLength()
-{
- return m_pMF->GetLength();
-}
-
-template <class T>
-HRESULT CMatroskaNode::Read(T& var)
-{
- return m_pMF->Read(var);
-}
-
-HRESULT CMatroskaNode::Read(BYTE* pData, QWORD len)
-{
- return m_pMF->ByteRead(pData, len);
-}
-
-QWORD CMatroskaNode::FindPos(DWORD id, QWORD start)
-{
- Segment& sm = m_pMF->m_segment;
-
- POSITION pos = sm.MetaSeekInfo.GetHeadPosition();
- while (pos) {
- Seek* s = sm.MetaSeekInfo.GetNext(pos);
-
- POSITION pos2 = s->SeekHeads.GetHeadPosition();
- while (pos2) {
- SeekHead* sh = s->SeekHeads.GetNext(pos2);
- if (sh->SeekID == id && sh->SeekPosition + sm.pos >= start) {
- return sh->SeekPosition + sm.pos;
- }
- }
- }
-
- return 0;
-}
-
-CAutoPtr<CMatroskaNode> CMatroskaNode::Copy()
-{
- CAutoPtr<CMatroskaNode> pNewNode(DEBUG_NEW CMatroskaNode(m_pMF));
- pNewNode->m_pParent = m_pParent;
- pNewNode->m_id.Set(m_id);
- pNewNode->m_len.Set(m_len);
- pNewNode->m_filepos = m_filepos;
- pNewNode->m_start = m_start;
- return pNewNode;
-}
-
-CAutoPtr<CMatroskaNode> CMatroskaNode::GetFirstBlock()
-{
- CAutoPtr<CMatroskaNode> pNode = Child();
- do {
- if (pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
- return pNode;
- }
- } while (pNode->Next());
- return CAutoPtr<CMatroskaNode>();
-}
-
-bool CMatroskaNode::NextBlock()
-{
- if (!m_pParent) {
- return false;
- }
-
- CID id = m_id;
-
- while (m_start + m_len < m_pParent->m_start + m_pParent->m_len) {
- SeekTo(m_start + m_len);
-
- if (FAILED(Parse())) {
- if (!Resync()) {
- return false;
- }
- }
-
- if (m_id == 0xA0 || m_id == 0xA3) {
- return true;
- }
- }
-
- return false;
-}
-
-bool CMatroskaNode::Resync()
-{
- if (m_pParent->m_id == 0x18538067) { /*segment?*/
- SeekTo(m_filepos);
-
- for (BYTE b = 0; S_OK == Read(b); b = 0) {
- if ((b & 0xf0) != 0x10) {
- continue;
- }
-
- DWORD dw = b;
- Read((BYTE*)&dw + 1, 3);
- bswap((BYTE*)&dw, 4);
-
- switch (dw) {
- case 0x1549A966: // SegmentInfo
- case 0x114D9B74: // MetaSeekInfo
- case 0x1654AE6B: // Tracks
- case 0x1F43B675: // Clusters
- case 0x1C53BB6B: // Cues
- case 0x1941A469: // Attachments
- case 0x1043A770: // Chapters
- case 0x1254C367: // Tags
- SeekTo(GetPos() - 4);
- return SUCCEEDED(Parse());
- default:
- SeekTo(GetPos() - 3);
- break;
- }
- }
- }
-
- return false;
-}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.h b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
deleted file mode 100644
index 9ef8995ca..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.h
+++ /dev/null
@@ -1,593 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-
-namespace MatroskaReader
-{
- class CMatroskaNode;
-
- class CANSI : public CStringA
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CUTF8 : public CStringW
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- template<class T, class BASE>
- class CSimpleVar
- {
- protected:
- T m_val;
- bool m_fValid;
- public:
- CSimpleVar(T val = 0) : m_val(val), m_fValid(false) {}
- BASE& operator = (const BASE& v) {
- m_val = v.m_val;
- m_fValid = true;
- return *this;
- }
- BASE& operator = (T val) {
- m_val = val;
- m_fValid = true;
- return *this;
- }
- operator T() const {
- return m_val;
- }
- BASE& Set(T val) {
- m_val = val;
- m_fValid = true;
- return (*(BASE*)this);
- }
- bool IsValid() const {
- return m_fValid;
- }
- virtual HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CUInt : public CSimpleVar<UINT64, CUInt>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CInt : public CSimpleVar<INT64, CInt>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CByte : public CSimpleVar<BYTE, CByte> {};
- class CShort : public CSimpleVar<short, CShort> {};
- class CFloat : public CSimpleVar<double, CFloat>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CID : public CSimpleVar<DWORD, CID>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CLength : public CSimpleVar<UINT64, CLength>
- {
- bool m_fSigned;
- public:
- CLength(bool fSigned = false) : m_fSigned(fSigned) {} HRESULT Parse(CMatroskaNode* pMN);
- };
- class CSignedLength : public CLength
- {
- public:
- CSignedLength() : CLength(true) {}
- };
-
- class ContentCompression;
-
- class CBinary : public CAtlArray<BYTE>
- {
- public:
- CBinary& operator = (const CBinary& b) {
- Copy(b);
- return *this;
- }
- CStringA ToString() {
- return CStringA((LPCSTR)GetData(), (int)GetCount());
- }
- bool Compress(ContentCompression& cc), Decompress(ContentCompression& cc);
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- template<class T>
- class CNode : public CAutoPtrList<T>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class EBML
- {
- public:
- CUInt EBMLVersion, EBMLReadVersion;
- CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
- CANSI DocType;
- CUInt DocTypeVersion, DocTypeReadVersion;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Info
- {
- public:
- CBinary SegmentUID, PrevUID, NextUID;
- CUTF8 SegmentFilename, PrevFilename, NextFilename;
- CUInt TimeCodeScale; // [ns], default: 1.000.000
- CFloat Duration;
- CInt DateUTC;
- CUTF8 Title, MuxingApp, WritingApp;
-
- Info() { TimeCodeScale.Set(1000000ui64); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class SeekHead
- {
- public:
- CID SeekID;
- CUInt SeekPosition;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Seek
- {
- public:
- CNode<SeekHead> SeekHeads;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class TimeSlice
- {
- public:
- CUInt LaceNumber, FrameNumber;
- CUInt Delay, Duration;
-
- TimeSlice() {
- LaceNumber.Set(0);
- FrameNumber.Set(0);
- Delay.Set(0);
- Duration.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class SimpleBlock
- {
- public:
- CLength TrackNumber;
- CInt TimeCode;
- CByte Lacing;
- CAutoPtrList<CBinary> BlockData;
-
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class BlockMore
- {
- public:
- CInt BlockAddID;
- CBinary BlockAdditional;
-
- BlockMore() { BlockAddID.Set(1); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class BlockAdditions
- {
- public:
- CNode<BlockMore> bm;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class BlockGroup
- {
- public:
- SimpleBlock Block;
- //BlockVirtual
- CUInt BlockDuration;
- CUInt ReferencePriority;
- CInt ReferenceBlock;
- CInt ReferenceVirtual;
- CBinary CodecState;
- CNode<TimeSlice> TimeSlices;
- BlockAdditions ba;
-
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class CBlockGroupNode : public CNode<BlockGroup>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class CSimpleBlockNode : public CNode<SimpleBlock>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class Cluster
- {
- public:
- CUInt TimeCode, Position, PrevSize;
- CBlockGroupNode BlockGroups;
- CSimpleBlockNode SimpleBlocks;
-
- HRESULT Parse(CMatroskaNode* pMN);
- HRESULT ParseTimeCode(CMatroskaNode* pMN);
- };
-
- class Video
- {
- public:
- CUInt FlagInterlaced, StereoMode;
- CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
- CUInt VideoPixelCropBottom, VideoPixelCropTop, VideoPixelCropLeft, VideoPixelCropRight;
- CUInt AspectRatioType;
- CUInt ColourSpace;
- CFloat GammaValue;
- CFloat FramePerSec;
-
- Video() {
- FlagInterlaced.Set(0);
- StereoMode.Set(0);
- DisplayUnit.Set(0);
- AspectRatioType.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Audio
- {
- public:
- CFloat SamplingFrequency;
- CFloat OutputSamplingFrequency;
- CUInt Channels;
- CBinary ChannelPositions;
- CUInt BitDepth;
-
- Audio() {
- SamplingFrequency.Set(8000.0);
- Channels.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentCompression
- {
- public:
- CUInt ContentCompAlgo;
- enum { ZLIB, BZLIB, LZO1X, HDRSTRIP };
- CBinary ContentCompSettings;
-
- ContentCompression() { ContentCompAlgo.Set(ZLIB); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncryption
- {
- public:
- CUInt ContentEncAlgo;
- enum { UNKE, DES, THREEDES, TWOFISH, BLOWFISH, AES };
- CBinary ContentEncKeyID, ContentSignature, ContentSigKeyID;
- CUInt ContentSigAlgo;
- enum { UNKS, RSA };
- CUInt ContentSigHashAlgo;
- enum { UNKSH, SHA1_160, MD5 };
-
- ContentEncryption() {
- ContentEncAlgo.Set(0);
- ContentSigAlgo.Set(0);
- ContentSigHashAlgo.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncoding
- {
- public:
- CUInt ContentEncodingOrder;
- CUInt ContentEncodingScope;
- enum { AllFrameContents = 1, TracksPrivateData = 2 };
- CUInt ContentEncodingType;
- enum { Compression, Encryption };
- ContentCompression cc;
- ContentEncryption ce;
-
- ContentEncoding() {
- ContentEncodingOrder.Set(0);
- ContentEncodingScope.Set(AllFrameContents);
- ContentEncodingType.Set(Compression);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncodings
- {
- public:
- CNode<ContentEncoding> ce;
-
- ContentEncodings() {}
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class TrackEntry
- {
- public:
- enum { TypeVideo = 1,
- TypeAudio = 2,
- TypeComplex = 3,
- TypeLogo = 0x10,
- TypeSubtitle = 0x11,
- TypeControl = 0x20
- };
- CUInt TrackNumber, TrackUID, TrackType;
- CUInt FlagEnabled, FlagDefault, FlagLacing, FlagForced;
- CUInt MinCache, MaxCache;
- CUTF8 Name;
- CANSI Language;
- CBinary CodecID;
- CBinary CodecPrivate;
- CUTF8 CodecName;
- CUTF8 CodecSettings;
- CANSI CodecInfoURL;
- CANSI CodecDownloadURL;
- CUInt CodecDecodeAll;
- CUInt TrackOverlay;
- CUInt DefaultDuration;
- CUInt MaxBlockAdditionID;
- CFloat TrackTimecodeScale;
- enum { NoDesc = 0, DescVideo = 1, DescAudio = 2 };
- unsigned int DescType;
- Video v;
- Audio a;
- ContentEncodings ces;
- TrackEntry() {
- DescType = NoDesc;
- FlagEnabled.Set(1);
- FlagDefault.Set(1);
- FlagLacing.Set(1);
- FlagForced.Set(0);
- MinCache.Set(0);
- TrackTimecodeScale.Set(1.0f);
- Language.CStringA::operator = ("eng");
- MaxBlockAdditionID.Set(0);
- CodecDecodeAll.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
-
- bool Expand(CBinary& data, UINT64 Scope);
- };
-
- class Track
- {
- public:
- CNode<TrackEntry> TrackEntries;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CueReference
- {
- public:
- CUInt CueRefTime, CueRefCluster, CueRefNumber, CueRefCodecState;
-
- CueReference() {
- CueRefNumber.Set(1);
- CueRefCodecState.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CueTrackPosition
- {
- public:
- CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
- CNode<CueReference> CueReferences;
-
- CueTrackPosition() {
- CueBlockNumber.Set(1);
- CueCodecState.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CuePoint
- {
- public:
- CUInt CueTime;
- CNode<CueTrackPosition> CueTrackPositions;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Cue
- {
- public:
- CNode<CuePoint> CuePoints;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class AttachedFile
- {
- public:
- CUTF8 FileDescription;
- CUTF8 FileName;
- CANSI FileMimeType;
- QWORD FileDataPos, FileDataLen; // BYTE* FileData
- CUInt FileUID;
-
- AttachedFile() { FileDataPos = FileDataLen = 0; }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Attachment
- {
- public:
- CNode<AttachedFile> AttachedFiles;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ChapterDisplay
- {
- public:
- CUTF8 ChapString;
- CANSI ChapLanguage;
- CANSI ChapCountry;
-
- ChapterDisplay() { ChapLanguage.CStringA::operator = ("eng"); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ChapterAtom
- {
- public:
- CUInt ChapterUID;
- CUInt ChapterTimeStart, ChapterTimeEnd, ChapterFlagHidden, ChapterFlagEnabled;
- //CNode<CUInt> ChapterTracks; // TODO
- CNode<ChapterDisplay> ChapterDisplays;
- CNode<ChapterAtom> ChapterAtoms;
-
- ChapterAtom() {
- ChapterUID.Set(0);// 0 = not set (ChapUID zero not allow by Matroska specs)
- ChapterFlagHidden.Set(0);
- ChapterFlagEnabled.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- ChapterAtom* FindChapterAtom(UINT64 id);
- };
-
- class EditionEntry : public ChapterAtom
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Chapter
- {
- public:
- CNode<EditionEntry> EditionEntries;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Segment
- {
- public:
- QWORD pos, len;
- Info SegmentInfo;
- CNode<Seek> MetaSeekInfo;
- CNode<Cluster> Clusters;
- CNode<Track> Tracks;
- CNode<Cue> Cues;
- CNode<Attachment> Attachments;
- CNode<Chapter> Chapters;
- // TODO: Chapters
- // TODO: Tags
-
- HRESULT Parse(CMatroskaNode* pMN);
- HRESULT ParseMinimal(CMatroskaNode* pMN);
-
- UINT64 GetMasterTrack();
-
- REFERENCE_TIME GetRefTime(INT64 t) const {
- return t * (REFERENCE_TIME)(SegmentInfo.TimeCodeScale) / 100;
- }
- ChapterAtom* FindChapterAtom(UINT64 id, int nEditionEntry = 0);
- };
-
- class CMatroskaFile : public CBaseSplitterFile
- {
- public:
- CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- virtual ~CMatroskaFile() {}
-
- HRESULT Init();
-
- //using CBaseSplitterFile::Read;
- template <class T> HRESULT Read(T& var);
-
- EBML m_ebml;
- Segment m_segment;
- REFERENCE_TIME m_rtOffset;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CMatroskaNode
- {
- CMatroskaNode* m_pParent;
- CMatroskaFile* m_pMF;
-
- bool Resync();
-
- public:
- CID m_id;
- CLength m_len;
- QWORD m_filepos, m_start;
-
- HRESULT Parse();
-
- public:
- CMatroskaNode(CMatroskaFile* pMF); // creates the root
- CMatroskaNode(CMatroskaNode* pParent);
-
- CMatroskaNode* Parent() { return m_pParent; }
- CAutoPtr<CMatroskaNode> Child(DWORD id = 0, bool fSearch = true);
- bool Next(bool fSame = false);
- bool Find(DWORD id, bool fSearch = true);
-
- QWORD FindPos(DWORD id, QWORD start = 0);
-
- void SeekTo(QWORD pos);
- QWORD GetPos(), GetLength();
- template <class T> HRESULT Read(T& var);
- HRESULT Read(BYTE* pData, QWORD len);
-
- CAutoPtr<CMatroskaNode> Copy();
-
- CAutoPtr<CMatroskaNode> GetFirstBlock();
- bool NextBlock();
-
- bool IsRandomAccess() { return m_pMF->IsRandomAccess(); }
- };
-}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
deleted file mode 100644
index 9909ac57f..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
+++ /dev/null
@@ -1,1687 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "MatroskaSplitter.h"
-#include "../../../DSUtil/AudioParser.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-#include <vector>
-
-using namespace MatroskaReader;
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMatroskaSplitterFilter), MatroskaSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMatroskaSourceFilter), MatroskaSourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMatroskaSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- RegisterSourceFilter(
- __uuidof(CMatroskaSourceFilter),
- MEDIASUBTYPE_Matroska,
- _T("0,4,,1A45DFA3"),
- _T(".mkv"), _T(".mka"), _T(".mks"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_Matroska);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CMatroskaSplitterFilter
-//
-
-CMatroskaSplitterFilter::CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMatroskaSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-CMatroskaSplitterFilter::~CMatroskaSplitterFilter()
-{
-}
-
-STDMETHODIMP CMatroskaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(ITrackInfo)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CMatroskaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MatroskaSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pTrackEntryMap.RemoveAll();
- m_pOrderedTrackArray.RemoveAll();
-
- CAtlArray<CMatroskaSplitterOutputPin*> pinOut;
- CAtlArray<TrackEntry*> pinOutTE;
-
- m_pFile.Attach(DEBUG_NEW CMatroskaFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- int iVideo = 1, iAudio = 1, iSubtitle = 1;
- bool bHasVideo = 0;
-
- POSITION pos = m_pFile->m_segment.Tracks.GetHeadPosition();
- while (pos) {
- Track* pT = m_pFile->m_segment.Tracks.GetNext(pos);
-
- POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while (pos2) {
- TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
-
- bool isSub = false;
-
- if (!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
- continue;
- }
-
- CStringA CodecID = pTE->CodecID.ToString();
-
- CStringW Name;
- Name.Format(L"Output %I64u", (UINT64)pTE->TrackNumber);
-
- CMediaType mt;
- CAtlArray<CMediaType> mts;
-
- mt.SetSampleSize(1);
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- Name.Format(L"Video %d", iVideo++);
-
- mt.majortype = MEDIATYPE_Video;
-
- if (CodecID == "V_MS/VFW/FOURCC") {
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount() - sizeof(BITMAPINFOHEADER));
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(&pvih->bmiHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mt.subtype = FOURCCMap(pvih->bmiHeader.biCompression);
- switch (pvih->bmiHeader.biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
- MEDIASUBTYPE_NULL;
- break;
- // case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
- // case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
- }
- if (!bHasVideo) {
- mts.Add(mt);
- if (mt.subtype == MEDIASUBTYPE_WVC1) {
- mt.subtype = MEDIASUBTYPE_WVC1_CYBERLINK;
- mts.Add(mt);
- }
- }
- bHasVideo = true;
- } else if (CodecID == "V_UNCOMPRESSED") {
- } else if (CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6) {
- BYTE sps = pTE->CodecPrivate[5] & 0x1f;
-
- std::vector<BYTE> avcC;
- for (size_t i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
- avcC.push_back(pTE->CodecPrivate[i]);
- }
-
- std::vector<BYTE> sh;
-
- unsigned jj = 6;
-
- while (sps--) {
- if (jj + 2 > avcC.size()) {
- goto avcfail;
- }
- unsigned spslen = ((unsigned)avcC[jj] << 8) | avcC[jj + 1];
- if (jj + 2 + spslen > avcC.size()) {
- goto avcfail;
- }
- unsigned cur = sh.size();
- sh.resize(cur + spslen + 2, 0);
- std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + spslen, sh.begin() + cur);
- jj += 2 + spslen;
- }
-
- if (jj + 1 > avcC.size()) {
- continue;
- }
-
- unsigned pps = avcC[jj++];
-
- while (pps--) {
- if (jj + 2 > avcC.size()) {
- goto avcfail;
- }
- unsigned ppslen = ((unsigned)avcC[jj] << 8) | avcC[jj + 1];
- if (jj + 2 + ppslen > avcC.size()) {
- goto avcfail;
- }
- unsigned cur = sh.size();
- sh.resize(cur + ppslen + 2, 0);
- std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + ppslen, sh.begin() + cur);
- jj += 2 + ppslen;
- }
-
- goto avcsuccess;
-avcfail:
- continue;
-avcsuccess:
-
- CAtlArray<BYTE> data;
- data.SetCount(sh.size());
- std::copy(sh.begin(), sh.end(), data.GetData());
-
- mt.subtype = FOURCCMap('1CVA');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + data.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
- pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm2vi->hdr.bmiHeader.biCompression = '1CVA';
- pm2vi->hdr.bmiHeader.biPlanes = 1;
- pm2vi->hdr.bmiHeader.biBitCount = 24;
- pm2vi->dwProfile = pTE->CodecPrivate[1];
- pm2vi->dwLevel = pTE->CodecPrivate[3];
- pm2vi->dwFlags = (pTE->CodecPrivate[4] & 3) + 1;
- BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
- memcpy(pSequenceHeader, data.GetData(), data.GetCount());
- pm2vi->cbSequenceHeader = (DWORD)data.GetCount();
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID.Find("V_MPEG4/") == 0) {
- mt.subtype = FOURCCMap('V4PM');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
- pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm2vi->hdr.bmiHeader.biCompression = 'V4PM';
- pm2vi->hdr.bmiHeader.biPlanes = 1;
- pm2vi->hdr.bmiHeader.biBitCount = 24;
- BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
- memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pm2vi->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID.Find("V_REAL/RV") == 0) {
- mt.subtype = FOURCCMap('00VR' + ((CodecID[9] - 0x30) << 16));
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID == "V_DIRAC") {
- mt.subtype = MEDIASUBTYPE_DiracVideo;
- mt.formattype = FORMAT_DiracVideoInfo;
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
- dvih->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- dvih->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
- dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
-
- BYTE* pSequenceHeader = (BYTE*)dvih->dwSequenceHeader;
- memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- dvih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
-
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID == "V_MPEG2") {
- BYTE* seqhdr = pTE->CodecPrivate.GetData();
- DWORD len = (DWORD)pTE->CodecPrivate.GetCount();
- int w = (int)pTE->v.PixelWidth;
- int h = (int)pTE->v.PixelHeight;
-
- if (MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- }
- } else if (CodecID == "V_THEORA") {
- BYTE* thdr = pTE->CodecPrivate.GetData() + 3;
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('OEHT');
- mt.formattype = FORMAT_MPEG2_VIDEO;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = *(WORD*)&thdr[10] >> 4;
- vih->hdr.bmiHeader.biHeight = *(WORD*)&thdr[12] >> 4;
- vih->hdr.bmiHeader.biCompression = 'OEHT';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- int nFpsNum = (thdr[22] << 24) | (thdr[23] << 16) | (thdr[24] << 8) | thdr[25];
- int nFpsDenum = (thdr[26] << 24) | (thdr[27] << 16) | (thdr[28] << 8) | thdr[29];
- if (nFpsNum) {
- vih->hdr.AvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * nFpsDenum / nFpsNum);
- }
- vih->hdr.dwPictAspectRatioX = (thdr[14] << 16) | (thdr[15] << 8) | thdr[16];
- vih->hdr.dwPictAspectRatioY = (thdr[17] << 16) | (thdr[18] << 8) | thdr[19];
- mt.bFixedSizeSamples = 0;
-
- vih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
- memcpy(&vih->dwSequenceHeader, pTE->CodecPrivate.GetData(), vih->cbSequenceHeader);
-
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID.Find("V_VP8") == 0) {
- mt.subtype = FOURCCMap('08PV');
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID == "V_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
- DWORD* type;
- if (m_pFile->m_ebml.DocTypeReadVersion == 1) {
- type = (DWORD*)(pTE->CodecPrivate.GetData());
- } else {
- type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
- }
- if (*type == MAKEFOURCC('S', 'V', 'Q', '3') || *type == MAKEFOURCC('S', 'V', 'Q', '1') || *type == MAKEFOURCC('c', 'v', 'i', 'd')) {
- mt.subtype = FOURCCMap(*type);
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- }
- } else if (CodecID == "V_DSHOW/MPEG1VIDEO" || CodecID == "V_MPEG1") {
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- mt.formattype = FORMAT_MPEGVideo;
-
- MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG1VIDEOINFO) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(MPEG1VIDEOINFO), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- pm1vi->hdr.bmiHeader.biSize = sizeof(pm1vi->hdr.bmiHeader);
- pm1vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm1vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm1vi->hdr.bmiHeader.biBitCount = 12;
- pm1vi->hdr.bmiHeader.biSizeImage = DIBSIZE(pm1vi->hdr.bmiHeader);
-
- mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth * pm1vi->hdr.bmiHeader.biHeight * 4);
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- }
- REFERENCE_TIME AvgTimePerFrame = 0;
-
- if (pTE->v.FramePerSec > 0) {
- AvgTimePerFrame = (REFERENCE_TIME)(10000000i64 / pTE->v.FramePerSec);
- } else if (pTE->DefaultDuration > 0 && pTE->DefaultDuration != 1000000) {
- AvgTimePerFrame = (REFERENCE_TIME)pTE->DefaultDuration / 100;
- } else { // pTE->DefaultDuration == 1000000 or < 0
- CMatroskaNode Root(m_pFile);
- m_pSegment = Root.Child(0x18538067);
- m_pCluster = m_pSegment->Child(0x1F43B675);
-
- QWORD lastCueClusterPosition = (QWORD) - 1;
- UINT64 timecode1 = 0;
- UINT64 timecode2 = 0;
- unsigned int framecount = 0;
- bool readmore = true;
-
- POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while (readmore && pos1) {
- Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
- POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while (readmore && pos2) {
- CuePoint* pCuePoint = pCue->CuePoints.GetNext(pos2);
- POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while (readmore && pos3) {
- CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
- if (pCueTrackPositions->CueTrack != pTE->TrackNumber) {
- continue;
- }
-
- if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
- continue;
- }
- lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
-
- m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
- m_pCluster->Parse();
-
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
- do {
- CBlockGroupNode bgn;
-
- if (pBlock->m_id == 0xA0) {
- bgn.Parse(pBlock, true);
- } else if (pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DEBUG_NEW BlockGroup());
- bg->Block.Parse(pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- POSITION pos4 = bgn.GetHeadPosition();
- while (pos4) {
- BlockGroup* bg = bgn.GetNext(pos4);
- if (bg->Block.TrackNumber != pTE->TrackNumber) {
- continue;
- }
- UINT64 tc = c.TimeCode + bg->Block.TimeCode;
- TRACE(_T("Frame: %d, TimeCode %I64d\n"), framecount, tc);
-
- if (framecount == 0) {
- timecode1 = tc;
- timecode2 = tc;
- } else if (tc == timecode2) { // hmm
- continue;
- } else if (tc > timecode2) { // I and P frames
- if (framecount > 24) {
- // good for 23.976, 24, 25, 30, 50, 60 fps.
- // for 29.97 and 59,94 can give a small inaccuracy
- readmore = false;
- break;
- }
- timecode2 = tc;
- } //else if (tc < timecode2) {} // B-Frames
-
- framecount++;
- }
- } while (readmore && pBlock->NextBlock());
- }
- }
- }
- }
- if (framecount > 1) {
- AvgTimePerFrame = m_pFile->m_segment.SegmentInfo.TimeCodeScale * (timecode2 - timecode1) / (100 * (framecount - 1));
- }
-
- m_pCluster.Free();
- }
- //if (AvgTimePerFrame < 0) AvgTimePerFrame = 0;
-
- for (size_t i = 0; i < mts.GetCount(); i++) {
- if (mts[i].formattype == FORMAT_VideoInfo
- || mts[i].formattype == FORMAT_VideoInfo2
- || mts[i].formattype == FORMAT_MPEG2Video
- || mts[i].formattype == FORMAT_MPEGVideo) {
- if (pTE->v.PixelWidth && pTE->v.PixelHeight) {
- RECT rect = {(LONG)pTE->v.VideoPixelCropLeft,
- (LONG)pTE->v.VideoPixelCropTop,
- (LONG)(pTE->v.PixelWidth - pTE->v.VideoPixelCropRight),
- (LONG)(pTE->v.PixelHeight - pTE->v.VideoPixelCropBottom)
- };
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mts[i].Format();
- vih->rcSource = vih->rcTarget = rect;
- }
-
- if (AvgTimePerFrame) {
- if (mts[i].subtype == MEDIASUBTYPE_MPEG1Payload) {
- AvgTimePerFrame *= 2; // Need more testing, but work on all sample that i have :)
- }
- ((VIDEOINFOHEADER*)mts[i].Format())->AvgTimePerFrame = AvgTimePerFrame;
- }
- }
- }
-
- if (pTE->v.DisplayWidth && pTE->v.DisplayHeight) {
- for (size_t i = 0; i < mts.GetCount(); i++) {
- if (mts[i].formattype == FORMAT_VideoInfo) {
- mt = mts[i];
- DWORD vih1 = FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
- DWORD vih2 = FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader);
- DWORD bmi = mts[i].FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
- mt.formattype = FORMAT_VideoInfo2;
- mt.AllocFormatBuffer(vih2 + bmi);
- memcpy(mt.Format(), mts[i].Format(), vih1);
- ZeroMemory(mt.Format() + vih1, vih2 - vih1);
- memcpy(mt.Format() + vih2, mts[i].Format() + vih1, bmi);
-
- CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioX = aspect.cx;
- ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioY = aspect.cy;
- mts.InsertAt(i++, mt);
- } else if (mts[i].formattype == FORMAT_MPEG2Video) {
- CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioX = aspect.cx;
- ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioY = aspect.cy;
- }
- }
- }
- } else if (pTE->TrackType == TrackEntry::TypeAudio) {
- Name.Format(L"Audio %d", iAudio++);
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, mt.FormatLength());
- wfe->nChannels = (WORD)pTE->a.Channels;
- wfe->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- wfe->wBitsPerSample = (WORD)pTE->a.BitDepth;
- wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;
- mt.SetSampleSize(256000);
-
- if (CodecID == "A_MPEG/L3") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
- mts.Add(mt);
- } else if (CodecID == "A_MPEG/L2" ||
- CodecID == "A_MPEG/L1") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEG);
- mts.Add(mt);
- } else if (CodecID == "A_AC3" ||
- CodecID == "A_EAC3") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
- mts.Add(mt);
- } else if (CodecID == "A_TRUEHD" ||
- CodecID == "A_MLP") {
- wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- mt.subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
- mts.Add(mt);
- } else if (CodecID == "A_DTS") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
- mts.Add(mt);
- } else if (CodecID == "A_TTA1") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_TTA1);
- wfe->cbSize = 30;
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 30);
- BYTE* p = (BYTE*)(wfe + 1);
- memcpy(p, (const unsigned char*)"TTA1\x01\x00", 6);
- memcpy(p + 6, &wfe->nChannels, 2);
- memcpy(p + 8, &wfe->wBitsPerSample, 2);
- memcpy(p + 10, &wfe->nSamplesPerSec, 4);
- ZeroMemory(p + 14, 30 - 14);
- mts.Add(mt);
- } else if (CodecID == "A_AAC") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- } else if (CodecID == "A_WAVPACK4") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_WAVPACK4);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- } else if (CodecID == "A_FLAC") {
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
- mts.Add(mt);
- mt.subtype = MEDIASUBTYPE_FLAC;
- mts.Add(mt);
- } else if (CodecID == "A_PCM/INT/LIT") {
- mt.subtype = MEDIASUBTYPE_PCM;
- mt.SetSampleSize(wfe->nBlockAlign);
- if (pTE->a.Channels <= 2 && pTE->a.BitDepth <= 16) {
- wfe->wFormatTag = WAVE_FORMAT_PCM;
- } else {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (pTE->a.BitDepth & 7) {
- wfex->Format.wBitsPerSample = (WORD)(pTE->a.BitDepth + 7) & 0xFFF8;
- wfex->Format.nBlockAlign = wfex->Format.nChannels * wfex->Format.wBitsPerSample / 8;
- wfex->Format.nAvgBytesPerSec = wfex->Format.nSamplesPerSec * wfex->Format.nBlockAlign;
- mt.SetSampleSize(wfex->Format.nBlockAlign);
- }
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
- wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
- wfex->SubFormat = MEDIASUBTYPE_PCM;
- }
- mts.Add(mt);
- } else if (CodecID == "A_PCM/FLOAT/IEEE") {
- mt.subtype = MEDIASUBTYPE_IEEE_FLOAT;
- mt.SetSampleSize(wfe->nBlockAlign);
- if (pTE->a.Channels <= 2) {
- wfe->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
- wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
- wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
- }
- mts.Add(mt);
- } else if (CodecID == "A_MS/ACM") {
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
- memcpy(wfe, (WAVEFORMATEX*)pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe->cbSize == 22) {
- mt.subtype = ((WAVEFORMATEXTENSIBLE*)wfe)->SubFormat;
- } else {
- mt.subtype = FOURCCMap(wfe->wFormatTag);
- }
- mts.Add(mt);
- } else if (CodecID == "A_VORBIS") {
- BYTE* p = pTE->CodecPrivate.GetData();
- CAtlArray<int> sizes;
- int totalsize = 0;
- for (BYTE n = *p++; n > 0; n--) {
- int size = 0;
- do {
- size += *p;
- } while (*p++ == 0xff);
- sizes.Add(size);
- totalsize += size;
- }
- sizes.Add((int)(pTE->CodecPrivate.GetData() + pTE->CodecPrivate.GetCount() - p) - totalsize);
- totalsize += sizes[sizes.GetCount() - 1];
-
- if (sizes.GetCount() == 3) {
- mt.subtype = MEDIASUBTYPE_Vorbis2;
- mt.formattype = FORMAT_VorbisFormat2;
- VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + (ULONG)totalsize);
- ZeroMemory(pvf2, mt.FormatLength());
- pvf2->Channels = (WORD)pTE->a.Channels;
- pvf2->SamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- pvf2->BitsPerSample = (DWORD)pTE->a.BitDepth;
- BYTE* p2 = mt.Format() + sizeof(VORBISFORMAT2);
- for (size_t i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
- memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);
- }
-
- mts.Add(mt);
- }
-
- mt.subtype = MEDIASUBTYPE_Vorbis;
- mt.formattype = FORMAT_VorbisFormat;
- VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
- ZeroMemory(vf, mt.FormatLength());
- vf->nChannels = (WORD)pTE->a.Channels;
- vf->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- vf->nMinBitsPerSec = vf->nMaxBitsPerSec = vf->nAvgBitsPerSec = (DWORD) - 1;
- mts.Add(mt);
- } else if (CodecID.Find("A_AAC/") == 0) {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
- wfe->cbSize = 2;
-
- int profile;
-
- if (CodecID.Find("/MAIN") > 0) {
- profile = 0;
- } else if (CodecID.Find("/SBR") > 0) {
- profile = -1;
- } else if (CodecID.Find("/LC") > 0) {
- profile = 1;
- } else if (CodecID.Find("/SSR") > 0) {
- profile = 2;
- } else if (CodecID.Find("/LTP") > 0) {
- profile = 3;
- } else {
- continue;
- }
-
- WORD cbSize = MakeAACInitData((BYTE*)(wfe + 1), profile, wfe->nSamplesPerSec, (int)pTE->a.Channels);
-
- mts.Add(mt);
-
- if (profile < 0) {
- wfe->cbSize = cbSize;
- wfe->nSamplesPerSec *= 2;
- wfe->nAvgBytesPerSec *= 2;
-
- mts.InsertAt(0, mt);
- }
- } else if (CodecID.Find("A_REAL/") == 0 && CodecID.GetLength() >= 11) {
- mt.subtype = FOURCCMap((DWORD)CodecID[7] | ((DWORD)CodecID[8] << 8) | ((DWORD)CodecID[9] << 16) | ((DWORD)CodecID[10] << 24));
- mt.bTemporalCompression = TRUE;
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- wfe->cbSize = 0; // IMPORTANT: this is screwed, but cbSize has to be 0 and the extra data from codec priv must be after WAVEFORMATEX
- mts.Add(mt);
- } else if (CodecID == "A_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
- DWORD* type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
- if (*type == MAKEFOURCC('Q', 'D', 'M', '2') || *type == MAKEFOURCC('Q', 'D', 'M', 'C')) {
- mt.subtype = FOURCCMap(*type);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- }
- } else if (CodecID == "A_ALAC") {
- mt.subtype = MEDIASUBTYPE_ALAC;
- WORD cbSize = (WORD)pTE->CodecPrivate.GetCount() + 12;
- wfe->cbSize = cbSize;
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + cbSize);
- BYTE* p = (BYTE*)(wfe + 1);
-
- ZeroMemory(p, cbSize);
- memcpy(p + 3, &cbSize, 1);
- memcpy(p + 4, (const unsigned char*)"alac", 4);
- memcpy(p + 12, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- }
- } else if (pTE->TrackType == TrackEntry::TypeSubtitle) {
- if (iSubtitle == 1) {
- InstallFonts();
- }
-
- Name.Format(L"Subtitle %d", iSubtitle++);
-
- mt.SetSampleSize(1);
-
- if (CodecID == "S_TEXT/ASCII") {
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mts.Add(mt);
- isSub = true;
- } else {
- mt.majortype = MEDIATYPE_Subtitle;
- mt.formattype = FORMAT_SubtitleInfo;
- SUBTITLEINFO* psi = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + pTE->CodecPrivate.GetCount());
- ZeroMemory(psi, mt.FormatLength());
- strncpy_s(psi->IsoLang, pTE->Language, _countof(psi->IsoLang) - 1);
- CString subtitle_Name = pTE->Name;
- if (pTE->FlagForced) { // "Forced" overrides "Default"
- subtitle_Name += L" [Forced]";
- } else if (pTE->FlagDefault) {
- subtitle_Name += L" [Default]";
- }
- subtitle_Name = subtitle_Name.Trim();
-
- wcsncpy_s(psi->TrackName, subtitle_Name, _countof(psi->TrackName) - 1);
- memcpy(mt.pbFormat + (psi->dwOffset = sizeof(SUBTITLEINFO)), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- mt.subtype =
- CodecID == "S_TEXT/UTF8" ? MEDIASUBTYPE_UTF8 :
- CodecID == "S_TEXT/SSA" || CodecID == "S_SSA" ? MEDIASUBTYPE_SSA :
- CodecID == "S_TEXT/ASS" || CodecID == "S_ASS" ? MEDIASUBTYPE_ASS :
- CodecID == "S_TEXT/USF" || CodecID == "S_USF" ? MEDIASUBTYPE_USF :
- CodecID == "S_HDMV/PGS" ? MEDIASUBTYPE_HDMVSUB :
- //CodecID == "S_DVBSUB" ? MEDIASUBTYPE_DVB_SUBTITLES : // does not work
- CodecID == "S_VOBSUB" ? MEDIASUBTYPE_VOBSUB :
- MEDIASUBTYPE_NULL;
-
- if (mt.subtype != MEDIASUBTYPE_NULL) {
- mts.Add(mt);
- isSub = true;
- }
- }
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("CMatroskaSourceFilter: Unsupported TrackType %s (%I64d)\n"), CString(CodecID), (UINT64)pTE->TrackType);
- continue;
- }
-
- Name = CStringW(pTE->Language.IsEmpty() ? L"English" : CStringW(ISO6392ToLanguage(pTE->Language)))
- + (pTE->Name.IsEmpty() ? L"" : L", " + pTE->Name)
- + (L" (" + Name + L")");
-
- if (pTE->FlagForced) { // "Forced" overrides "Default"
- Name = Name + L" [Forced]";
- } else if (pTE->FlagDefault) {
- Name = Name + L" [Default]";
- }
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr2));
- if (!pTE->Name.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", pTE->Name);
- }
- if (pTE->Language.GetLength() == 3) {
- pPinOut->SetProperty(L"LANG", CStringW(CString(pTE->Language)));
- }
-
- if (!isSub) {
- pinOut.InsertAt((iVideo + iAudio - 3), DEBUG_NEW CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr2), 1);
- pinOutTE.InsertAt((iVideo + iAudio - 3), pTE, 1);
- } else {
- pinOut.Add(DEBUG_NEW CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr2));
- pinOutTE.Add(pTE);
- }
-
- }
- }
-
- for (size_t i = 0; i < pinOut.GetCount(); i++) {
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- pPinOut.Attach(pinOut[i]);
- TrackEntry* pTE = pinOutTE[i];
-
- if (pTE != nullptr) {
- AddOutputPin((DWORD)pTE->TrackNumber, pPinOut);
- m_pTrackEntryMap[(DWORD)pTE->TrackNumber] = pTE;
- m_pOrderedTrackArray.Add(pTE);
- }
- }
-
-
- Info& info = m_pFile->m_segment.SegmentInfo;
-
- if (m_pFile->IsRandomAccess()) {
- m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- /*#ifdef _DEBUG
- for (int i = 1, j = GetChapterCount(CHAPTER_ROOT_ID); i <= j; i++)
- {
- UINT id = GetChapterId(CHAPTER_ROOT_ID, i);
- struct ChapterElement ce;
- BOOL b = GetChapterInfo(id, &ce);
- BSTR bstr = GetChapterStringInfo(id, "eng", "");
- if (bstr) ::SysFreeString(bstr);
- }
- #endif*/
-
- SetProperty(L"TITL", info.Title);
- // TODO
-
- // resources
-
- {
- POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while (pos) {
- Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
-
- POSITION pos = pA->AttachedFiles.GetHeadPosition();
- while (pos) {
- AttachedFile* pF = pA->AttachedFiles.GetNext(pos);
-
- CAtlArray<BYTE> pData;
- pData.SetCount((size_t)pF->FileDataLen);
- m_pFile->Seek(pF->FileDataPos);
- if (SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
- ResAppend(pF->FileName, pF->FileDescription, CStringW(pF->FileMimeType), pData.GetData(), (DWORD)pData.GetCount());
- }
- }
- }
- }
-
- // chapters
-
- if (ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0)) {
- CStringA str;
- str.ReleaseBufferSetLength(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, str.GetBuffer(3), 3));
- CStringA ChapLanguage = CStringA(ISO6391To6392(str));
- if (ChapLanguage.GetLength() < 3) {
- ChapLanguage = "eng";
- }
-
- SetupChapters(ChapLanguage, caroot);
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int level)
-{
- CStringW tabs('+', level);
-
- if (!tabs.IsEmpty()) {
- tabs += ' ';
- }
-
- POSITION pos = parent->ChapterAtoms.GetHeadPosition();
- while (pos) {
- // ChapUID zero not allow by Matroska specs
- UINT64 ChapUID = parent->ChapterAtoms.GetNext(pos)->ChapterUID;
- ChapterAtom* ca = (ChapUID == 0) ? nullptr : m_pFile->m_segment.FindChapterAtom(ChapUID);
-
- if (ca) {
- CStringW name, first;
-
- POSITION pos = ca->ChapterDisplays.GetHeadPosition();
- while (pos) {
- ChapterDisplay* cd = ca->ChapterDisplays.GetNext(pos);
- if (first.IsEmpty()) {
- first = cd->ChapString;
- }
- if (cd->ChapLanguage == lng) {
- name = cd->ChapString;
- }
- }
-
- name = tabs + (!name.IsEmpty() ? name : first);
-
- ChapAppend(ca->ChapterTimeStart / 100 - m_pFile->m_rtOffset, name);
-
- if (!ca->ChapterAtoms.IsEmpty() && level < 5) {
- // level < 5 - hard limit for the number of levels
- SetupChapters(lng, ca, level + 1);
- }
- }
- }
-
-}
-
-void CMatroskaSplitterFilter::InstallFonts()
-{
- POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while (pos) {
- Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
-
- POSITION p2 = pA->AttachedFiles.GetHeadPosition();
- while (p2) {
- AttachedFile* pF = pA->AttachedFiles.GetNext(p2);
-
- if (pF->FileMimeType == "application/x-truetype-font" ||
- pF->FileMimeType == "application/x-font-ttf" ||
- pF->FileMimeType == "application/vnd.ms-opentype") {
- // assume this is a font resource
-
- if (BYTE* pData = DEBUG_NEW BYTE[(UINT)pF->FileDataLen]) {
- m_pFile->Seek(pF->FileDataPos);
-
- if (SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
- //m_fontinst.InstallFont(pData, (UINT)pF->FileDataLen);
- m_fontinst.InstallFontMemory(pData, (UINT)pF->FileDataLen);
- }
-
- delete [] pData;
- }
- }
- }
- }
-}
-
-void CMatroskaSplitterFilter::SendVorbisHeaderSample()
-{
- HRESULT hr;
-
- POSITION pos = m_pTrackEntryMap.GetStartPosition();
- while (pos) {
- DWORD TrackNumber = 0;
- TrackEntry* pTE = nullptr;
- m_pTrackEntryMap.GetNextAssoc(pos, TrackNumber, pTE);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNumber);
-
- if (!(pTE && pPin && pPin->IsConnected())) {
- continue;
- }
-
- if (pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
- && !pTE->CodecPrivate.IsEmpty()) {
- BYTE* ptr = pTE->CodecPrivate.GetData();
-
- CAtlList<int> sizes;
- int last = 0;
- for (BYTE n = *ptr++; n > 0; n--) {
- int size = 0;
- do {
- size += *ptr;
- } while (*ptr++ == 0xff);
- sizes.AddTail(size);
- last += size;
- }
- sizes.AddTail((int)(pTE->CodecPrivate.GetData() + pTE->CodecPrivate.GetCount() - ptr) - last);
-
- hr = S_OK;
-
- POSITION pos = sizes.GetHeadPosition();
- while (pos && SUCCEEDED(hr)) {
- long len = sizes.GetNext(pos);
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
- p->TrackNumber = (DWORD)pTE->TrackNumber;
- p->rtStart = 0;
- p->rtStop = 1;
- p->bSyncPoint = FALSE;
-
- p->SetData(ptr, len);
- ptr += len;
-
- hr = DeliverPacket(p);
- }
-
- if (FAILED(hr)) {
- TRACE(_T("ERROR: Vorbis initialization failed for stream %I64d\n"), TrackNumber);
- }
- }
- }
-}
-
-bool CMatroskaSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CMatroskaSplitterFilter");
-
- CMatroskaNode Root(m_pFile);
- if (!m_pFile
- || !(m_pSegment = Root.Child(0x18538067))
- || !(m_pCluster = m_pSegment->Child(0x1F43B675))) {
- return false;
- }
-
- // reindex if needed
-
- if (m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.IsEmpty()) {
- m_nOpenProgress = 0;
- m_pFile->m_segment.SegmentInfo.Duration.Set(0);
-
- UINT64 TrackNumber = m_pFile->m_segment.GetMasterTrack();
-
- CAutoPtr<Cue> pCue(DEBUG_NEW Cue());
-
- do {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- m_pFile->m_segment.SegmentInfo.Duration.Set((float)c.TimeCode - m_pFile->m_rtOffset / 10000);
-
- CAutoPtr<CuePoint> pCuePoint(DEBUG_NEW CuePoint());
- CAutoPtr<CueTrackPosition> pCueTrackPosition(DEBUG_NEW CueTrackPosition());
- pCuePoint->CueTime.Set(c.TimeCode);
- pCueTrackPosition->CueTrack.Set(TrackNumber);
- pCueTrackPosition->CueClusterPosition.Set(m_pCluster->m_filepos - m_pSegment->m_start);
- pCuePoint->CueTrackPositions.AddTail(pCueTrackPosition);
- pCue->CuePoints.AddTail(pCuePoint);
-
- m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
-
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- } while (!m_fAbort && m_pCluster->Next(true));
-
- m_nOpenProgress = 100;
-
- if (!m_fAbort) {
- m_pFile->m_segment.Cues.AddTail(pCue);
- }
-
- m_fAbort = false;
-
- if (m_pFile->m_segment.Cues.GetCount()) {
- Info& info = m_pFile->m_segment.SegmentInfo;
- m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
- m_rtNewStop = m_rtStop = m_rtDuration;
- }
- }
-
- m_pCluster.Free();
- m_pBlock.Free();
-
- return true;
-}
-
-void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- m_pCluster = m_pSegment->Child(0x1F43B675);
- m_pBlock.Free();
-
- if (rt > 0) {
- rt += m_pFile->m_rtOffset;
-
- QWORD lastCueClusterPosition = (QWORD) - 1;
-
- Segment& s = m_pFile->m_segment;
-
- UINT64 TrackNumber = s.GetMasterTrack();
-
- POSITION pos1 = s.Cues.GetHeadPosition();
- while (pos1) {
- Cue* pCue = s.Cues.GetNext(pos1);
-
- POSITION pos2 = pCue->CuePoints.GetTailPosition();
- while (pos2) {
- CuePoint* pCuePoint = pCue->CuePoints.GetPrev(pos2);
-
- if (rt < s.GetRefTime(pCuePoint->CueTime)) {
- continue;
- }
-
- POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while (pos3) {
- CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
-
- if (TrackNumber != pCueTrackPositions->CueTrack) {
- continue;
- }
-
- if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
- continue;
- }
-
- lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
-
- m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
- m_pCluster->Parse();
-
- bool fFoundKeyFrame = false;
- /*
- if (pCueTrackPositions->CueBlockNumber > 0)
- {
- // TODO: CueBlockNumber only tells the block num of the track and not for all mixed in the cluster
- m_nLastBlock = (int)pCueTrackPositions->CueBlockNumber;
- fFoundKeyFrame = true;
- }
- else
- */
- {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
- bool fPassedCueTime = false;
-
- do {
- CBlockGroupNode bgn;
-
- if (pBlock->m_id == 0xA0) {
- bgn.Parse(pBlock, true);
- } else if (pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DEBUG_NEW BlockGroup());
- bg->Block.Parse(pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- POSITION pos4 = bgn.GetHeadPosition();
- while (!fPassedCueTime && pos4) {
- BlockGroup* bg = bgn.GetNext(pos4);
-
- if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && rt < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)
- || rt + 5000000i64 < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)) { // allow 500ms difference between tracks, just in case intreleaving wasn't that much precise
- fPassedCueTime = true;
- } else if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
- fFoundKeyFrame = true;
- m_pBlock = pBlock->Copy();
- }
- }
- } while (!fPassedCueTime && pBlock->NextBlock());
- }
- }
-
- if (fFoundKeyFrame) {
- pos1 = pos2 = pos3 = nullptr;
- }
- }
- }
- }
-
- if (!m_pBlock) {
- m_pCluster = m_pSegment->Child(0x1F43B675);
- }
- }
-}
-
-bool CMatroskaSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- SendVorbisHeaderSample(); // HACK: init vorbis decoder with the headers
-
- do {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (!m_pBlock) {
- m_pBlock = m_pCluster->GetFirstBlock();
- }
- if (!m_pBlock) {
- continue;
- }
-
- do {
- CBlockGroupNode bgn;
-
- if (m_pBlock->m_id == 0xA0) {
- bgn.Parse(m_pBlock, true);
- } else if (m_pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DEBUG_NEW BlockGroup());
- bg->Block.Parse(m_pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- while (bgn.GetCount() && SUCCEEDED(hr)) {
- CAutoPtr<MatroskaPacket> p(DEBUG_NEW MatroskaPacket());
- p->bg = bgn.RemoveHead();
-
- p->bSyncPoint = !p->bg->ReferenceBlock.IsValid();
- p->TrackNumber = (DWORD)p->bg->Block.TrackNumber;
-
- TrackEntry* pTE = nullptr;
-
- if (!m_pTrackEntryMap.Lookup(p->TrackNumber, pTE) || !pTE) {
- continue;
- }
-
- p->rtStart = m_pFile->m_segment.GetRefTime((REFERENCE_TIME)c.TimeCode + p->bg->Block.TimeCode);
- p->rtStop = p->rtStart + (p->bg->BlockDuration.IsValid() ? m_pFile->m_segment.GetRefTime(p->bg->BlockDuration) : 1);
-
- // Fix subtitle with duration = 0
- if (pTE->TrackType == TrackEntry::TypeSubtitle && !p->bg->BlockDuration.IsValid()) {
- p->bg->BlockDuration.Set(1); // just setting it to be valid
- p->rtStop = p->rtStart;
- }
-
- POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- CBinary* pb = p->bg->Block.BlockData.GetNext(pos);
- pTE->Expand(*pb, ContentEncoding::AllFrameContents);
- }
-
- // HACK
- p->rtStart -= m_pFile->m_rtOffset;
- p->rtStop -= m_pFile->m_rtOffset;
-
- hr = DeliverPacket(p);
- }
- } while (m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(nullptr));
-
- m_pBlock.Free();
- } while (m_pFile->GetPos() < (__int64)(m_pFile->m_segment.pos + m_pFile->m_segment.len)
- && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(nullptr));
-
- m_pCluster.Free();
-
- return true;
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- HRESULT hr = S_OK;
-
- nKFs = 0;
-
- POSITION pos = m_pFile->m_segment.Cues.GetHeadPosition();
- while (pos) {
- nKFs += (UINT)m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
- }
-
- return hr;
-}
-
-STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
-
- UINT nKFsTmp = 0;
-
- POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while (pos1 && nKFsTmp < nKFs) {
- Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
-
- POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while (pos2 && nKFsTmp < nKFs) {
- pKFs[nKFsTmp++] = m_pFile->m_segment.GetRefTime(pCue->CuePoints.GetNext(pos2)->CueTime);
- }
- }
-
- nKFs = nKFsTmp;
-
- return S_OK;
-}
-
-//
-// CMatroskaSourceFilter
-//
-
-CMatroskaSourceFilter::CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMatroskaSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CMatroskaSplitterOutputPin
-//
-
-CMatroskaSplitterOutputPin::CMatroskaSplitterOutputPin(
- unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
- , m_nMinCache(nMinCache), m_rtDefaultDuration(rtDefaultDuration)
-{
- m_nMinCache = 1;//max(m_nMinCache, 1);
-}
-
-CMatroskaSplitterOutputPin::~CMatroskaSplitterOutputPin()
-{
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverEndFlush()
-{
- {
- CAutoLock cAutoLock(&m_csQueue);
- m_packets.RemoveAll();
- m_rob.RemoveAll();
- m_tos.RemoveAll();
- }
-
- return __super::DeliverEndFlush();
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream()
-{
- CAutoLock cAutoLock(&m_csQueue);
-
- // send out the last remaining packets from the queue
-
- while (m_rob.GetCount()) {
- MatroskaPacket* mp = m_rob.RemoveHead();
- if (m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
- mp->rtStop = m_rob.GetHead()->rtStart;
- } else if (m_rob.IsEmpty() && m_rtDefaultDuration > 0) {
- mp->rtStop = mp->rtStart + m_rtDefaultDuration;
- }
-
- timeoverride to = {mp->rtStart, mp->rtStop};
- m_tos.AddTail(to);
- }
-
- while (m_packets.GetCount()) {
- HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if (hr != S_OK) {
- return hr;
- }
- }
-
- return __super::DeliverEndOfStream();
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- MatroskaPacket* mp = dynamic_cast<MatroskaPacket*>(p.m_p);
- if (!mp) {
- return __super::DeliverPacket(p);
- }
-
- // don't try to understand what's happening here, it's magic
-
- CAutoLock cAutoLock(&m_csQueue);
-
- CAutoPtr<MatroskaPacket> p2;
- p.Detach();
- p2.Attach(mp);
- m_packets.AddTail(p2);
-
- POSITION pos = m_rob.GetTailPosition();
- ASSERT(m_nMinCache > 0);
- for (int i = m_nMinCache - 1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; --i) {
- m_rob.GetPrev(pos);
- }
-
- if (!pos) {
- m_rob.AddHead(mp);
- } else {
- m_rob.InsertAfter(pos, mp);
- }
-
- mp = nullptr;
-
- if (m_rob.GetCount() == m_nMinCache + 1) {
- ASSERT(m_nMinCache > 0);
- pos = m_rob.GetHeadPosition();
- MatroskaPacket* mp1 = m_rob.GetNext(pos);
- MatroskaPacket* mp2 = m_rob.GetNext(pos);
- if (!mp1->bg->BlockDuration.IsValid()) {
- mp1->bg->BlockDuration.Set(1); // just to set it valid
-
- if (mp1->rtStart >= mp2->rtStart) {
- /* CString str;
- str.Format(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
- AfxMessageBox(str);
- */
- // TRACE(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
- } else {
- mp1->rtStop = mp2->rtStart;
- }
- }
- }
-
- while (m_packets.GetCount()) {
- mp = m_packets.GetHead();
- if (!mp->bg->BlockDuration.IsValid()) {
- break;
- }
-
- mp = m_rob.RemoveHead();
- timeoverride to = {mp->rtStart, mp->rtStop};
- m_tos.AddTail(to);
-
- HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if (hr != S_OK) {
- return hr;
- }
- }
-
- return S_OK;
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
-{
- HRESULT hr = S_FALSE;
-
- if (m_tos.GetCount()) {
- timeoverride to = m_tos.RemoveHead();
-
-#if defined(_DEBUG) && 0
- TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
- p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
- QueueCount());
-#endif
-
- p->rtStart = to.rtStart;
- p->rtStop = to.rtStop;
- }
-
- REFERENCE_TIME
- rtStart = p->rtStart,
- rtDelta = (p->rtStop - p->rtStart) / p->bg->Block.BlockData.GetCount(),
- rtStop = p->rtStart + rtDelta;
-
- POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- CAutoPtr<Packet> tmp(DEBUG_NEW Packet());
- tmp->TrackNumber = p->TrackNumber;
- tmp->bDiscontinuity = p->bDiscontinuity;
- tmp->bSyncPoint = p->bSyncPoint;
- tmp->rtStart = rtStart;
- tmp->rtStop = rtStop;
- tmp->Copy(*p->bg->Block.BlockData.GetNext(pos));
- if (S_OK != (hr = DeliverPacket(tmp))) {
- break;
- }
-
- rtStart += rtDelta;
- rtStop += rtDelta;
-
- p->bSyncPoint = false;
- p->bDiscontinuity = false;
- }
-
- if (m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
- POSITION pos = p->bg->ba.bm.GetHeadPosition();
- while (pos) {
- const BlockMore* bm = p->bg->ba.bm.GetNext(pos);
- CAutoPtr<Packet> tmp(DEBUG_NEW Packet());
- tmp->TrackNumber = p->TrackNumber;
- tmp->bDiscontinuity = false;
- tmp->bSyncPoint = false;
- tmp->rtStart = p->rtStart;
- tmp->rtStop = p->rtStop;
- tmp->Copy(bm->BlockAdditional);
- if (S_OK != (hr = DeliverPacket(tmp))) {
- break;
- }
- }
- }
-
- return hr;
-}
-
-// ITrackInfo
-
-TrackEntry* CMatroskaSplitterFilter::GetTrackEntryAt(UINT aTrackIdx)
-{
- if (aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
- return nullptr;
- }
- return m_pOrderedTrackArray[aTrackIdx];
-}
-
-STDMETHODIMP_(UINT) CMatroskaSplitterFilter::GetTrackCount()
-{
- return (UINT)m_pTrackEntryMap.GetCount();
-}
-
-STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return FALSE;
- }
-
- pStructureToFill->FlagDefault = !!pTE->FlagDefault;
- pStructureToFill->FlagForced = !!pTE->FlagForced;
- pStructureToFill->FlagLacing = !!pTE->FlagLacing;
- strncpy_s(pStructureToFill->Language, pTE->Language, 3);
- if (pStructureToFill->Language[0] == '\0') {
- strncpy_s(pStructureToFill->Language, "eng", 3);
- }
- pStructureToFill->Language[3] = '\0';
- pStructureToFill->MaxCache = (UINT)pTE->MaxCache;
- pStructureToFill->MinCache = (UINT)pTE->MinCache;
- pStructureToFill->Type = (BYTE)pTE->TrackType;
- return TRUE;
-}
-
-STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return FALSE;
- }
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
- pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
- pTEIV->DisplayUnit = (BYTE)pTE->v.DisplayUnit;
- pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
- pTEIV->DisplayHeight = (UINT)pTE->v.DisplayHeight;
- pTEIV->Interlaced = !!pTE->v.FlagInterlaced;
- pTEIV->PixelWidth = (UINT)pTE->v.PixelWidth;
- pTEIV->PixelHeight = (UINT)pTE->v.PixelHeight;
- } else if (pTE->TrackType == TrackEntry::TypeAudio) {
- TrackExtendedInfoAudio* pTEIA = (TrackExtendedInfoAudio*)pStructureToFill;
- pTEIA->BitDepth = (UINT)pTE->a.BitDepth;
- pTEIA->Channels = (UINT)pTE->a.Channels;
- pTEIA->OutputSamplingFrequency = (float)pTE->a.OutputSamplingFrequency;
- pTEIA->SamplingFreq = (float)pTE->a.SamplingFrequency;
- } else {
- return FALSE;
- }
-
- return TRUE;
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackName(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->Name.AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecID(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecID.ToString().AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecName(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecName.AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecInfoURL(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecInfoURL.AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecDownloadURL(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecDownloadURL.AllocSysString();
-}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.def b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
deleted file mode 100644
index 774443f12..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "MatroskaFile.h"
-#include "../BaseSplitter/BaseSplitter.h"
-#include "ITrackInfo.h"
-
-#define MatroskaSplitterName L"MPC Matroska Splitter"
-#define MatroskaSourceName L"MPC Matroska Source"
-
-class MatroskaPacket : public Packet
-{
-protected:
- int GetDataSize() {
- size_t size = 0;
- POSITION pos = bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- size += bg->Block.BlockData.GetNext(pos)->GetCount();
- }
- return (int)size;
- }
-public:
- CAutoPtr<MatroskaReader::BlockGroup> bg;
-};
-
-class CMatroskaSplitterOutputPin : public CBaseSplitterOutputPin
-{
- HRESULT DeliverBlock(MatroskaPacket* p);
-
- unsigned int m_nMinCache;
- REFERENCE_TIME m_rtDefaultDuration;
-
- CCritSec m_csQueue;
- CAutoPtrList<MatroskaPacket> m_packets;
- CAtlList<MatroskaPacket*> m_rob;
-
- typedef struct {
- REFERENCE_TIME rtStart, rtStop;
- } timeoverride;
- CAtlList<timeoverride> m_tos;
-
-protected:
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
-
-public:
- CMatroskaSplitterOutputPin(
- unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMatroskaSplitterOutputPin();
-
- HRESULT DeliverEndFlush();
- HRESULT DeliverEndOfStream();
-};
-
-class __declspec(uuid("149D2E01-C32E-4939-80F6-C07B81015A7A"))
- CMatroskaSplitterFilter : public CBaseSplitterFilter, public ITrackInfo
-{
- void SetupChapters(LPCSTR lng, MatroskaReader::ChapterAtom* parent, int level = 0);
- void InstallFonts();
- void SendVorbisHeaderSample();
-
- CAutoPtr<MatroskaReader::CMatroskaNode> m_pSegment, m_pCluster, m_pBlock;
-
-protected:
- CAutoPtr<MatroskaReader::CMatroskaFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- CAtlMap<DWORD, MatroskaReader::TrackEntry*> m_pTrackEntryMap;
- CAtlArray<MatroskaReader::TrackEntry*> m_pOrderedTrackArray;
- MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CMatroskaSplitterFilter();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IKeyFrameInfo
-
- STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-
- // ITrackInfo
-
- STDMETHODIMP_(UINT) GetTrackCount();
- STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
- STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill);
- STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx);
-};
-
-class __declspec(uuid("0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4"))
- CMatroskaSourceFilter : public CMatroskaSplitterFilter
-{
-public:
- CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc
deleted file mode 100644
index 3e5208af5..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "Matroska Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "Matroska Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MatroskaSplitter.ax"
- VALUE "ProductName", "Matroska Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj
deleted file mode 100644
index 19c06c397..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj
+++ /dev/null
@@ -1,258 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{3F5EA225-F4B7-4413-AEB3-4E4E5751E438}</ProjectGuid>
- <RootNamespace>MatroskaSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MatroskaSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MatroskaFile.cpp" />
- <ClCompile Include="MatroskaSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MatroskaSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MatroskaFile.h" />
- <ClInclude Include="MatroskaSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MatroskaSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\zlib\zlib.vcxproj">
- <Project>{2fcd4b66-9cf9-4c8f-bc70-37cd20002d49}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters
deleted file mode 100644
index f06730c57..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{9ef31dfd-95ec-4218-a840-f6c00ca6a2f4}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{387f16df-2821-49ac-b2e0-3e0c454021dc}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{482333a1-25da-4a3f-a09b-495e204e4b32}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="MatroskaFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MatroskaSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MatroskaSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MatroskaFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MatroskaSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MatroskaSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MatroskaSplitter/resource.h b/src/filters/parser/MatroskaSplitter/resource.h
deleted file mode 100644
index 1cd7111d9..000000000
--- a/src/filters/parser/MatroskaSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MatroskaSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.cpp b/src/filters/parser/MatroskaSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MatroskaSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.h b/src/filters/parser/MatroskaSplitter/stdafx.h
deleted file mode 100644
index 4b7a0b4bc..000000000
--- a/src/filters/parser/MatroskaSplitter/stdafx.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-#include "../../../DSUtil/DSUtil.h"
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.cpp b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
deleted file mode 100644
index 3cdc5f1d7..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "MpaSplitter.h"
-#include "moreuuids.h"
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpaSplitterFilter), MpaSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMpaSourceFilter), MpaSourceName, MERIT_NORMAL + 1, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpaSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpaSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
- chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1Audio, chkbytes, nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CMpaSplitterFilter
-//
-
-CMpaSplitterFilter::CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMpaSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-STDMETHODIMP CMpaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CMpaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MpaSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DEBUG_NEW CMpaSplitterFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- CAtlArray<CMediaType> mts;
- mts.Add(m_pFile->GetMediaType());
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
- AddOutputPin(0, pPinOut);
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
-
- CStringW str, title;
- if (m_pFile->m_tags.Lookup('TIT2', str)) {
- title = str;
- }
- if (m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) {
- title += L" (" + str + L")";
- }
- if (!title.IsEmpty()) {
- SetProperty(L"TITL", title);
- }
- if (m_pFile->m_tags.Lookup('TPE1', str)) {
- SetProperty(L"AUTH", str);
- }
- if (m_pFile->m_tags.Lookup('TCOP', str)) {
- SetProperty(L"CPYR", str);
- }
- if (m_pFile->m_tags.Lookup('COMM', str)) {
- SetProperty(L"DESC", str);
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-STDMETHODIMP CMpaSplitterFilter::GetDuration(LONGLONG* pDuration)
-{
- CheckPointer(pDuration, E_POINTER);
- CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
-
- *pDuration = m_pFile->GetDuration();
-
- return S_OK;
-}
-
-bool CMpaSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CMpaSplitterFilter");
- if (!m_pFile) {
- return false;
- }
-
- // TODO
-
- return true;
-}
-
-void CMpaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- __int64 startpos = m_pFile->GetStartPos();
- __int64 endpos = m_pFile->GetEndPos();
-
- if (rt <= 0 || m_pFile->GetDuration() <= 0) {
- m_pFile->Seek(startpos);
- m_rtStart = 0;
- } else {
- m_pFile->Seek(startpos + (__int64)((1.0 * rt / m_pFile->GetDuration()) * (endpos - startpos)));
- m_rtStart = rt;
- }
-
-}
-
-bool CMpaSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- int FrameSize;
- REFERENCE_TIME rtDuration;
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9) {
- if (!m_pFile->Sync(FrameSize, rtDuration)) {
- Sleep(1);
- continue;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
- p->SetCount(FrameSize);
- m_pFile->ByteRead(p->GetData(), FrameSize);
-
- p->TrackNumber = 0;
- p->rtStart = m_rtStart;
- p->rtStop = m_rtStart + rtDuration;
- p->bSyncPoint = TRUE;
-
- hr = DeliverPacket(p);
-
- m_rtStart += rtDuration;
- }
-
- return true;
-}
-
-//
-// CMpaSourceFilter
-//
-
-CMpaSourceFilter::CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMpaSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.def b/src/filters/parser/MpaSplitter/MpaSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.h b/src/filters/parser/MpaSplitter/MpaSplitter.h
deleted file mode 100644
index 676d9d8d0..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-#include "MpaSplitterFile.h"
-
-#define MpaSplitterName L"MPC Mpa Splitter"
-#define MpaSourceName L"MPC Mpa Source"
-
-class __declspec(uuid("0E9D4BF7-CBCB-46C7-BD80-4EF223A3DC2B"))
- CMpaSplitterFilter : public CBaseSplitterFilter
-{
- REFERENCE_TIME m_rtStart;
-
-protected:
- CAutoPtr<CMpaSplitterFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
-};
-
-class __declspec(uuid("59A0DB73-0287-4C9A-9D3C-8CFF39F8E5DB"))
- CMpaSourceFilter : public CMpaSplitterFilter
-{
-public:
- CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.rc b/src/filters/parser/MpaSplitter/MpaSplitter.rc
deleted file mode 100644
index 6fd827bc0..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "Mpa Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "Mpa Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MpaSplitter.ax"
- VALUE "ProductName", "Mpa Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj b/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj
deleted file mode 100644
index d88344341..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj
+++ /dev/null
@@ -1,255 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{C0F7A036-FC2D-40DF-9852-C37518DB6B3E}</ProjectGuid>
- <RootNamespace>MpaSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MpaSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MpaSplitter.cpp" />
- <ClCompile Include="MpaSplitterFile.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpaSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MpaSplitter.h" />
- <ClInclude Include="MpaSplitterFile.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpaSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters b/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters
deleted file mode 100644
index 370f5a9d5..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{83fa794a-e93b-4f78-92a0-3af952b1b16c}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{ff3aa9c3-cd89-4cdd-a526-fb6c03d372b7}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{ce0a230d-519f-43e0-bb7d-cd56d97cc3de}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="MpaSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MpaSplitterFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpaSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MpaSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpaSplitterFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpaSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
deleted file mode 100644
index 27317e18e..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "MpaSplitterFile.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#define FRAMES_FLAG 0x0001
-#define MPA_HEADER_SIZE 4 // MPEG-Audio Header Size
-
-//
-
-static const LPCTSTR s_genre[] = {
- _T("Blues"), _T("Classic Rock"), _T("Country"), _T("Dance"),
- _T("Disco"), _T("Funk"), _T("Grunge"), _T("Hip-Hop"),
- _T("Jazz"), _T("Metal"), _T("New Age"), _T("Oldies"),
- _T("Other"), _T("Pop"), _T("R&B"), _T("Rap"),
- _T("Reggae"), _T("Rock"), _T("Techno"), _T("Industrial"),
- _T("Alternative"), _T("Ska"), _T("Death Metal"), _T("Pranks"),
- _T("Soundtrack"), _T("Euro-Techno"), _T("Ambient"), _T("Trip-Hop"),
- _T("Vocal"), _T("Jazz+Funk"), _T("Fusion"), _T("Trance"),
- _T("Classical"), _T("Instrumental"), _T("Acid"), _T("House"),
- _T("Game"), _T("Sound Clip"), _T("Gospel"), _T("Noise"),
- _T("Alternative Rock"), _T("Bass"), _T("Soul"), _T("Punk"),
- _T("Space"), _T("Meditative"), _T("Instrumental Pop"), _T("Instrumental Rock"),
- _T("Ethnic"), _T("Gothic"), _T("Darkwave"), _T("Techno-Industrial"),
- _T("Electronic"), _T("Pop-Folk"), _T("Eurodance"), _T("Dream"),
- _T("Southern Rock"), _T("Comedy"), _T("Cult"), _T("Gangsta"),
- _T("Top 40"), _T("Christian Rap"), _T("Pop/Funk"), _T("Jungle"),
- _T("Native US"), _T("Cabaret"), _T("New Wave"), _T("Psychadelic"),
- _T("Rave"), _T("Showtunes"), _T("Trailer"), _T("Lo-Fi"),
- _T("Tribal"), _T("Acid Punk"), _T("Acid Jazz"), _T("Polka"),
- _T("Retro"), _T("Musical"), _T("Rock & Roll"), _T("Hard Rock"),
- _T("Folk"), _T("Folk-Rock"), _T("National Folk"), _T("Swing"),
- _T("Fast Fusion"), _T("Bebob"), _T("Latin"), _T("Revival"),
- _T("Celtic"), _T("Bluegrass"), _T("Avantgarde"), _T("Gothic Rock"),
- _T("Progressive Rock"), _T("Psychedelic Rock"), _T("Symphonic Rock"), _T("Slow Rock"),
- _T("Big Band"), _T("Chorus"), _T("Easy Listening"), _T("Acoustic"),
- _T("Humour"), _T("Speech"), _T("Chanson"), _T("Opera"),
- _T("Chamber Music"), _T("Sonata"), _T("Symphony"), _T("Booty Bass"),
- _T("Primus"), _T("Porn Groove"), _T("Satire"), _T("Slow Jam"),
- _T("Club"), _T("Tango"), _T("Samba"), _T("Folklore"),
- _T("Ballad"), _T("Power Ballad"), _T("Rhytmic Soul"), _T("Freestyle"),
- _T("Duet"), _T("Punk Rock"), _T("Drum Solo"), _T("Acapella"),
- _T("Euro-House"), _T("Dance Hall"), _T("Goa"), _T("Drum & Bass"),
- _T("Club-House"), _T("Hardcore"), _T("Terror"), _T("Indie"),
- _T("BritPop"), _T("Negerpunk"), _T("Polsk Punk"), _T("Beat"),
- _T("Christian Gangsta"), _T("Heavy Metal"), _T("Black Metal"),
- _T("Crossover"), _T("Contemporary C"), _T("Christian Rock"), _T("Merengue"), _T("Salsa"),
- _T("Thrash Metal"), _T("Anime"), _T("JPop"), _T("SynthPop"),
-};
-
-//
-
-CMpaSplitterFile::CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_mode(none)
- , m_rtDuration(0)
- , m_startpos(0)
- , m_endpos(0)
- , m_totalbps(0)
- , m_bIsVBR(false)
-{
- if (SUCCEEDED(hr)) {
- hr = Init();
- }
-}
-
-HRESULT CMpaSplitterFile::Init()
-{
- m_startpos = 0;
- m_endpos = GetLength();
-
- Seek(0);
-
- // some files can be determined as Mpeg Audio
- if ((BitRead(24, true) == 0x000001) || // ?
- (BitRead(32, true) == 'RIFF') || // skip AVI and WAV files
- (BitRead(24, true) == 'AMV')) { // skip MTV files (.amv .mtv)
- return E_FAIL;
- }
-
- if (m_endpos > 128 && IsRandomAccess()) {
- Seek(m_endpos - 128);
-
- if (BitRead(24) == 'TAG') {
- m_endpos -= 128;
-
- CStringA str;
-
- // title
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TIT2'] = CStringW(str).Trim();
-
- // artist
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TPE1'] = CStringW(str).Trim();
-
- // album
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TALB'] = CStringW(str).Trim();
-
- // year
- ByteRead((BYTE*)str.GetBufferSetLength(4), 4);
- m_tags['TYER'] = CStringW(str).Trim();
-
- // comment
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['COMM'] = CStringW(str).Trim();
-
- // track
- LPCSTR s = str;
- if (s[28] == 0 && s[29] != 0) {
- m_tags['TRCK'].Format(L"%d", s[29]);
- }
-
- // genre
- BYTE genre = (BYTE)BitRead(8);
- if (genre < _countof(s_genre)) {
- m_tags['TCON'] = CStringW(s_genre[genre]);
- }
- }
- }
-
- Seek(0);
-
- bool MP3_find = false;
-
- while (BitRead(24, true) == 'ID3') {
- MP3_find = true;
-
- BitRead(24);
-
- BYTE major = (BYTE)BitRead(8);
- BYTE revision = (BYTE)BitRead(8);
- UNREFERENCED_PARAMETER(revision);
-
- BYTE flags = (BYTE)BitRead(8);
- UNREFERENCED_PARAMETER(flags);
- DWORD size = 0;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 21;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 14;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 7;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7);
-
- m_startpos = GetPos() + size;
-
- // TODO: read extended header
-
- if (major <= 4) {
- __int64 pos = GetPos();
-
- while (pos < m_startpos) {
- Seek(pos);
-
- DWORD tag = (DWORD)BitRead(32);
- DWORD size = 0;
- size |= BitRead(8) << 24;
- size |= BitRead(8) << 16;
- size |= BitRead(8) << 8;
- size |= BitRead(8);
- WORD flags = (WORD)BitRead(16);
- UNREFERENCED_PARAMETER(flags);
-
- pos += 4 + 4 + 2 + size;
-
- if (!size || pos >= m_startpos) {
- break;
- }
-
- if (tag == 'TIT2'
- || tag == 'TPE1'
- || tag == 'TALB'
- || tag == 'TYER'
- || tag == 'COMM'
- || tag == 'TRCK') {
- BYTE encoding = (BYTE)BitRead(8);
- size--;
-
- WORD bom = (WORD)BitRead(16, true);
-
- CStringA str;
- CStringW wstr;
-
- if (encoding > 0 && size >= 2 && bom == 0xfffe) {
- BitRead(16);
- size = (size - 2) / 2;
- ByteRead((BYTE*)wstr.GetBufferSetLength(size), size * 2);
- m_tags[tag] = wstr.Trim();
- } else if (encoding > 0 && size >= 2 && bom == 0xfeff) {
- BitRead(16);
- size = (size - 2) / 2;
- ByteRead((BYTE*)wstr.GetBufferSetLength(size), size * 2);
- for (int i = 0, j = wstr.GetLength(); i < j; i++) {
- wstr.SetAt(i, (wstr[i] << 8) | (wstr[i] >> 8));
- }
- m_tags[tag] = wstr.Trim();
- } else {
- ByteRead((BYTE*)str.GetBufferSetLength(size), size);
- m_tags[tag] = (encoding > 0 ? UTF8To16(str) : CStringW(str)).Trim();
- }
- }
- }
- }
-
- Seek(m_startpos);
-
- for (int i = 0; i < (1 << 20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
- BitRead(8), m_startpos++;
- }
- }
-
- int searchlen = 0;
- __int64 startpos = 0;
- __int64 syncpos = 0;
-
- __int64 startpos_mp3 = m_startpos;
- while (m_mode == none) {
- if (!MP3_find && GetPos() >= 2048) {
- break;
- }
- searchlen = (int)min(m_endpos - startpos_mp3, 512);
- Seek(startpos_mp3);
-
- // If we fail to see sync bytes, we reposition here and search again
- syncpos = startpos_mp3 + searchlen;
-
- // Check for a valid MPA header
- if (Read(m_mpahdr, searchlen, true, &m_mt)) {
- m_mode = mpa;
-
- syncpos = GetPos();
- startpos = syncpos - 4;
-
- // make sure the first frame is followed by another of the same kind (validates m_mpahdr basically)
- Seek(startpos + m_mpahdr.FrameSize);
- if (!Sync(4)) {
- m_mode = none;
- } else {
- break;
- }
- }
-
- // If we have enough room to search for a valid header, then skip ahead and try again
- if (m_endpos - syncpos >= 8) {
- startpos_mp3 = syncpos;
- } else {
- break;
- }
- }
-
- searchlen = (int)min(m_endpos - m_startpos, m_startpos > 0 ? 512 : 7);
- Seek(m_startpos);
-
- if (m_mode == none && Read(m_aachdr, searchlen, &m_mt)) {
- m_mode = mp4a;
-
- startpos = GetPos() - (m_aachdr.fcrc ? 7 : 9);
-
- // make sure the first frame is followed by another of the same kind (validates m_aachdr basically)
- Seek(startpos + m_aachdr.aac_frame_length);
- if (!Sync(9)) {
- m_mode = none;
- }
- }
-
- if (m_mode == none) {
- return E_FAIL;
- }
-
- m_startpos = startpos;
-
- if (m_mode == mpa) {
- DWORD m_dwFrames = 0; // total number of frames
- Seek(m_startpos + MPA_HEADER_SIZE + 32);
- if (BitRead(32, true) == 'Xing' || BitRead(32, true) == 'Info') {
- BitRead(32); // Skip ID tag
- DWORD dwFlags = (DWORD)BitRead(32);
- // extract total number of frames in file
- if (dwFlags & FRAMES_FLAG) {
- m_dwFrames = (DWORD)BitRead(32);
- }
-
- } else if (BitRead(32, true) == 'VBRI') {
- BitRead(32); // Skip ID tag
- // extract all fields from header (all mandatory)
- BitRead(16); // version
- BitRead(16); // delay
- BitRead(16); // quality
- BitRead(32); // bytes
- m_dwFrames = (DWORD)BitRead(32); // extract total number of frames in file
- }
-
- if (m_dwFrames) {
-
- bool l3ext = m_mpahdr.layer == 3 && !(m_mpahdr.version & 1);
- DWORD m_dwSamplesPerFrame = m_mpahdr.layer == 1 ? 384 : l3ext ? 576 : 1152;
-
- m_bIsVBR = true;
- m_rtDuration = 10000000i64 * (m_dwFrames * m_dwSamplesPerFrame / m_mpahdr.nSamplesPerSec);
- }
- }
-
- Seek(m_startpos);
-
- int FrameSize;
- REFERENCE_TIME rtFrameDur, rtPrevDur = -1;
- clock_t start = clock();
- int i = 0;
- while (Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC) {
- TRACE(_T("%I64d\n"), m_rtDuration);
- Seek(GetPos() + FrameSize);
- i = rtPrevDur == m_rtDuration ? i + 1 : 0;
- if (i == 10) {
- break;
- }
- rtPrevDur = m_rtDuration;
- }
-
- return S_OK;
-}
-
-bool CMpaSplitterFile::Sync(int limit)
-{
- int FrameSize;
- REFERENCE_TIME rtDuration;
- return Sync(FrameSize, rtDuration, limit);
-}
-
-bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limit)
-{
- __int64 endpos = min(m_endpos, GetPos() + limit);
-
- if (m_mode == mpa) {
- while (GetPos() <= endpos - 4) {
- mpahdr h;
-
- if (Read(h, (int)(endpos - GetPos()), true)) {
- if (m_mpahdr.version == h.version
- && m_mpahdr.layer == h.layer
- && m_mpahdr.channels == h.channels) {
- Seek(GetPos() - 4);
- AdjustDuration(h.nBytesPerSec);
-
- FrameSize = h.FrameSize;
- rtDuration = h.rtDuration;
-
- return true;
- }
- } else {
- break;
- }
- }
- } else if (m_mode == mp4a) {
- while (GetPos() <= endpos - 9) {
- aachdr h;
-
- if (Read(h, (int)(endpos - GetPos()))) {
- if (m_aachdr.version == h.version
- && m_aachdr.layer == h.layer
- && m_aachdr.channels == h.channels) {
- Seek(GetPos() - (h.fcrc ? 7 : 9));
- AdjustDuration(h.nBytesPerSec);
- Seek(GetPos() + (h.fcrc ? 7 : 9));
-
- FrameSize = h.FrameSize;
- rtDuration = h.rtDuration;
-
- return true;
- }
- } else {
- break;
- }
- }
- }
-
- return false;
-}
-
-void CMpaSplitterFile::AdjustDuration(int nBytesPerSec)
-{
- ASSERT(nBytesPerSec);
-
- if (!m_bIsVBR) {
- int rValue;
- if (!m_pos2bps.Lookup(GetPos(), rValue)) {
- m_totalbps += nBytesPerSec;
- if (!m_totalbps) {
- return;
- }
- m_pos2bps.SetAt(GetPos(), nBytesPerSec);
- __int64 avgbps = m_totalbps / m_pos2bps.GetCount();
- m_rtDuration = 10000000i64 * (m_endpos - m_startpos) / avgbps;
- }
- }
-}
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.h b/src/filters/parser/MpaSplitter/MpaSplitterFile.h
deleted file mode 100644
index 41c5a09c8..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-
-class CMpaSplitterFile : public CBaseSplitterFileEx
-{
- CMediaType m_mt;
- REFERENCE_TIME m_rtDuration;
-
- enum { none, mpa, mp4a } m_mode;
-
- mpahdr m_mpahdr;
- aachdr m_aachdr;
- __int64 m_startpos, m_endpos;
-
- __int64 m_totalbps;
- CRBMap<__int64, int> m_pos2bps;
-
- HRESULT Init();
- void AdjustDuration(int nBytesPerSec);
-
- bool m_bIsVBR;
-
-public:
- CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- CAtlMap<DWORD, CStringW> m_tags;
-
- const CMediaType& GetMediaType() { return m_mt; }
- REFERENCE_TIME GetDuration() { return IsRandomAccess() ? m_rtDuration : 0; }
-
- __int64 GetStartPos() { return m_startpos; }
- __int64 GetEndPos() { return m_endpos; }
-
- bool Sync(int limit = 0x2000);
- bool Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limit = 0x2000);
-};
diff --git a/src/filters/parser/MpaSplitter/resource.h b/src/filters/parser/MpaSplitter/resource.h
deleted file mode 100644
index c2fcfb22b..000000000
--- a/src/filters/parser/MpaSplitter/resource.h
+++ /dev/null
@@ -1,15 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MpaSplitter.rc
-//
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MpaSplitter/stdafx.cpp b/src/filters/parser/MpaSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MpaSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MpaSplitter/stdafx.h b/src/filters/parser/MpaSplitter/stdafx.h
deleted file mode 100644
index a29dc1481..000000000
--- a/src/filters/parser/MpaSplitter/stdafx.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-
-#include <atlcoll.h>
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/MediaTypes.h"
diff --git a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h b/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h
deleted file mode 100644
index e0ad52cb0..000000000
--- a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * (C) 2011-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-interface __declspec(uuid("1DC9C085-04AC-4BB8-B2BD-C49A4D30B104"))
-IMpegSplitterFilter :
-public IUnknown {
- STDMETHOD(Apply()) PURE;
-
- STDMETHOD(SetFastStreamChange(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetFastStreamChange()) PURE;
-
- STDMETHOD(SetForcedSub(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetForcedSub()) PURE;
-
- STDMETHOD(SetAudioLanguageOrder(WCHAR * nValue)) PURE;
- STDMETHOD_(WCHAR*, GetAudioLanguageOrder()) PURE;
-
- STDMETHOD(SetSubtitlesLanguageOrder(WCHAR * nValue)) PURE;
- STDMETHOD_(WCHAR*, GetSubtitlesLanguageOrder()) PURE;
-
- STDMETHOD(SetVC1_GuidFlag(int nValue)) PURE;
- STDMETHOD_(int, GetVC1_GuidFlag()) PURE;
-
- STDMETHOD(SetTrueHD(int nValue)) PURE;
- STDMETHOD_(int, GetTrueHD()) PURE;
-
- STDMETHOD(SetAlternativeDuration(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetAlternativeDuration()) PURE;
-
- STDMETHOD_(int, GetMPEGType()) PURE;
-};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
deleted file mode 100644
index 136c663e0..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp
+++ /dev/null
@@ -1,2087 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include <dmodshow.h>
-#include "MpegSplitter.h"
-#include "moreuuids.h"
-#include "../../../DSUtil/AudioParser.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../mpc-hc/SettingsDefines.h"
-
-TCHAR* MPEG2_Profile[] = {
- L"0",
- L"High Profile",
- L"Spatially Scalable Profile",
- L"SNR Scalable Profile",
- L"Main Profile",
- L"Simple Profile",
- L"6",
- L"7",
-};
-
-TCHAR* MPEG2_Level[] = {
- L"0",
- L"1",
- L"2",
- L"3",
- L"High Level",
- L"4",
- L"High1440 Level",
- L"5",
- L"Main Level",
- L"6",
- L"Low Level",
- L"7",
- L"8",
- L"9",
- L"10",
- L"11",
-};
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_TRANSPORT},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PVA},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr},
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpegSplitterFilter), MpegSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMpegSourceFilter), MpegSourceName, MERIT_UNLIKELY, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpegSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpegSourceFilter>, nullptr, &sudFilter[1]},
- {L"CMpegSplitterPropertyPage", &__uuidof(CMpegSplitterSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpegSplitterSettingsWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".ts"));
-
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1System, _T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"), nullptr);
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PROGRAM, _T("0,5,FFFFFFFFC0,000001BA40"), nullptr);
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PVA, _T("0,8,fffffc00ffe00000,4156000055000000"), nullptr);
-
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
- chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
- chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47")); // TFrc
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_TRANSPORT, chkbytes, nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-template <typename t_CType>
-t_CType GetFormatHelper(t_CType& _pInfo, const CMediaType* _pFormat)
-{
- ASSERT(_pFormat->cbFormat >= sizeof(*_pInfo));
- _pInfo = (t_CType)_pFormat->pbFormat;
- return _pInfo;
-}
-
-static int GetHighestBitSet32(unsigned long _Value)
-{
- unsigned long Ret;
- unsigned char bNonZero = _BitScanReverse(&Ret, _Value);
- if (bNonZero) {
- return Ret;
- } else {
- return -1;
- }
-}
-
-CString FormatBitrate(double _Bitrate)
-{
- CString Temp;
- if (_Bitrate > 20000000) { // More than 2 mbit
- Temp.Format(L"%.2f mbit/s", double(_Bitrate) / 1000000.0);
- } else {
- Temp.Format(L"%.1f kbit/s", double(_Bitrate) / 1000.0);
- }
-
- return Temp;
-}
-
-CString FormatString(const wchar_t* pszFormat, ...)
-{
- CString Temp;
- ATLASSERT(AtlIsValidString(pszFormat));
-
- va_list argList;
- va_start(argList, pszFormat);
- Temp.FormatV(pszFormat, argList);
- va_end(argList);
-
- return Temp;
-}
-
-CString GetMediaTypeDesc(const CMediaType* _pMediaType, const CHdmvClipInfo::Stream* pClipInfo, int _PresentationType, CString lang)
-{
- const WCHAR* pPresentationDesc = nullptr;
-
- if (pClipInfo) {
- pPresentationDesc = StreamTypeToName(pClipInfo->m_Type);
- } else {
- pPresentationDesc = StreamTypeToName((PES_STREAM_TYPE)_PresentationType);
- }
-
- CString MajorType;
- CAtlList<CString> Infos;
-
- if (_pMediaType->majortype == MEDIATYPE_Video) {
- MajorType = "Video";
-
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
-
- if (!name.IsEmpty()) {
- Infos.AddTail(name);
- }
- } else {
- if (!lang.IsEmpty()) {
- Infos.AddTail(lang);
- }
- }
-
- const VIDEOINFOHEADER* pVideoInfo = nullptr;
- const VIDEOINFOHEADER2* pVideoInfo2 = nullptr;
-
- if (_pMediaType->formattype == FORMAT_MPEGVideo) {
- Infos.AddTail(L"MPEG");
-
- const MPEG1VIDEOINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo = &pInfo->hdr;
-
- } else if (_pMediaType->formattype == FORMAT_MPEG2_VIDEO) {
- const MPEG2VIDEOINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo2 = &pInfo->hdr;
-
- bool bIsAVC = false;
- bool bIsMPEG2 = false;
-
- if (pInfo->hdr.bmiHeader.biCompression == '1CVA') {
- bIsAVC = true;
- Infos.AddTail(L"AVC (H.264)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 'CVMA') {
- bIsAVC = true;
- Infos.AddTail(L"MVC (Full)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 'CVME') {
- bIsAVC = true;
- Infos.AddTail(L"MVC (Subset)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 0) {
- Infos.AddTail(L"MPEG2");
- bIsMPEG2 = true;
- } else {
- WCHAR Temp[5];
- ZeroMemory(Temp, sizeof(Temp));
- Temp[0] = (pInfo->hdr.bmiHeader.biCompression >> 0) & 0xFF;
- Temp[1] = (pInfo->hdr.bmiHeader.biCompression >> 8) & 0xFF;
- Temp[2] = (pInfo->hdr.bmiHeader.biCompression >> 16) & 0xFF;
- Temp[3] = (pInfo->hdr.bmiHeader.biCompression >> 24) & 0xFF;
- Infos.AddTail(Temp);
- }
-
- if (bIsMPEG2) {
- Infos.AddTail(MPEG2_Profile[pInfo->dwProfile]);
- } else if (pInfo->dwProfile) {
- if (bIsAVC) {
- switch (pInfo->dwProfile) {
- case 44:
- Infos.AddTail(L"CAVLC Profile");
- break;
- case 66:
- Infos.AddTail(L"Baseline Profile");
- break;
- case 77:
- Infos.AddTail(L"Main Profile");
- break;
- case 88:
- Infos.AddTail(L"Extended Profile");
- break;
- case 100:
- Infos.AddTail(L"High Profile");
- break;
- case 110:
- Infos.AddTail(L"High 10 Profile");
- break;
- case 118:
- Infos.AddTail(L"Multiview High Profile");
- break;
- case 122:
- Infos.AddTail(L"High 4:2:2 Profile");
- break;
- case 244:
- Infos.AddTail(L"High 4:4:4 Profile");
- break;
- case 128:
- Infos.AddTail(L"Stereo High Profile");
- break;
- default:
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- break;
- }
- } else {
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- }
- }
-
- if (bIsMPEG2) {
- Infos.AddTail(MPEG2_Level[pInfo->dwLevel]);
- } else if (pInfo->dwLevel) {
- if (bIsAVC) {
- Infos.AddTail(FormatString(L"Level %1.1f", double(pInfo->dwLevel) / 10.0));
- } else {
- Infos.AddTail(FormatString(L"Level %d", pInfo->dwLevel));
- }
- }
- } else if (_pMediaType->formattype == FORMAT_VIDEOINFO2) {
- const VIDEOINFOHEADER2* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo2 = pInfo;
- bool bIsVC1 = false;
-
- DWORD CodecType = pInfo->bmiHeader.biCompression;
- if (CodecType == '1CVW') {
- bIsVC1 = true;
- Infos.AddTail(L"VC-1");
- } else if (CodecType) {
- WCHAR Temp[5];
- ZeroMemory(Temp, sizeof(Temp));
- Temp[0] = (CodecType >> 0) & 0xFF;
- Temp[1] = (CodecType >> 8) & 0xFF;
- Temp[2] = (CodecType >> 16) & 0xFF;
- Temp[3] = (CodecType >> 24) & 0xFF;
- Infos.AddTail(Temp);
- }
- } else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
- Infos.AddTail(L"DVD Sub Picture");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
- Infos.AddTail(L"SVCD Sub Picture");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
- Infos.AddTail(L"CVD Sub Picture");
- }
-
- if (pVideoInfo2) {
- if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) {
- Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight));
- }
- if (pVideoInfo2->AvgTimePerFrame) {
- Infos.AddTail(FormatString(L"%.3f fps", 10000000.0 / double(pVideoInfo2->AvgTimePerFrame)));
- }
- if (pVideoInfo2->dwBitRate) {
- Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate));
- }
- } else if (pVideoInfo) {
- if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight) {
- Infos.AddTail(FormatString(L"%dx%d", pVideoInfo->bmiHeader.biWidth, pVideoInfo->bmiHeader.biHeight));
- }
- if (pVideoInfo->AvgTimePerFrame) {
- Infos.AddTail(FormatString(L"%.3f fps", 10000000.0 / double(pVideoInfo->AvgTimePerFrame)));
- }
- if (pVideoInfo->dwBitRate) {
- Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate));
- }
- }
-
- } else if (_pMediaType->majortype == MEDIATYPE_Audio) {
- MajorType = "Audio";
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty()) {
- Infos.AddTail(name);
- }
- } else {
- if (!lang.IsEmpty()) {
- Infos.AddTail(lang);
- }
- }
- if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
- const WAVEFORMATEX* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- Infos.AddTail(L"DVD LPCM");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- const WAVEFORMATEX_HDMV_LPCM* pInfoHDMV = GetFormatHelper(pInfoHDMV, _pMediaType);
- UNREFERENCED_PARAMETER(pInfoHDMV);
- Infos.AddTail(L"HDMV LPCM");
- }
- if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
- Infos.AddTail(L"Dolby Digital Plus");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- Infos.AddTail(L"TrueHD");
- } else {
- switch (pInfo->wFormatTag) {
- case WAVE_FORMAT_PS2_PCM: {
- Infos.AddTail(L"PS2 PCM");
- }
- break;
- case WAVE_FORMAT_PS2_ADPCM: {
- Infos.AddTail(L"PS2 ADPCM");
- }
- break;
- case WAVE_FORMAT_DVD_DTS: {
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- } else {
- Infos.AddTail(L"DTS");
- }
- }
- break;
- case WAVE_FORMAT_DOLBY_AC3: {
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- } else {
- Infos.AddTail(L"Dolby Digital");
- }
- }
- break;
- case WAVE_FORMAT_AAC: {
- Infos.AddTail(L"AAC");
- }
- break;
- case WAVE_FORMAT_MPEGLAYER3: {
- Infos.AddTail(L"MP3");
- }
- break;
- case WAVE_FORMAT_MPEG: {
- const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, _pMediaType);
-
- int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
- Infos.AddTail(FormatString(L"MPEG1 - Layer %d", layer));
- }
- break;
- }
- }
-
- if (pClipInfo && (pClipInfo->m_SampleRate == BDVM_SampleRate_48_192 || pClipInfo->m_SampleRate == BDVM_SampleRate_48_96)) {
- switch (pClipInfo->m_SampleRate) {
- case BDVM_SampleRate_48_192:
- Infos.AddTail(FormatString(L"192(48) kHz"));
- break;
- case BDVM_SampleRate_48_96:
- Infos.AddTail(FormatString(L"96(48) kHz"));
- break;
- }
- } else if (pInfo->nSamplesPerSec) {
- Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec) / 1000.0));
- }
- if (pInfo->nChannels) {
- Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
- }
- if (pInfo->wBitsPerSample) {
- Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
- }
- if (pInfo->nAvgBytesPerSec) {
- Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
- }
-
- }
- } else if (_pMediaType->majortype == MEDIATYPE_Subtitle) {
- MajorType = "Subtitle";
-
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- }
-
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty()) {
- Infos.AddHead(name);
- } else if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- }
- } else if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO)) {
- const SUBTITLEINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
- CString name = ISO6392ToLanguage(pInfo->IsoLang);
-
- if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- } else if (!name.IsEmpty()) {
- Infos.AddHead(name);
- }
- if (pInfo->TrackName[0]) {
- Infos.AddTail(pInfo->TrackName);
- }
- } else if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- }
- }
-
- if (!Infos.IsEmpty()) {
- CString Ret;
-
- Ret += MajorType;
- Ret += " - ";
-
- bool bFirst = true;
-
- for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
- CString& String = Infos.GetAt(pos);
-
- if (bFirst) {
- Ret += String;
- } else {
- Ret += L", " + String;
- }
-
- bFirst = false;
- }
-
- return Ret;
- }
- return CString();
-}
-
-//
-// CMpegSplitterFilter
-//
-
-CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid)
- : CBaseSplitterFilter(NAME("CMpegSplitterFilter"), pUnk, phr, clsid)
- , m_pPipoBimbo(false)
- , m_rtPlaylistDuration(0)
- , m_csAudioLanguageOrder(_T(""))
- , m_csSubtitlesLanguageOrder(_T(""))
- , m_useFastStreamChange(true)
- , m_ForcedSub(false)
- , m_AC3CoreOnly(0)
- , m_nVC1_GuidFlag(1)
- , m_AlternativeDuration(false)
-{
-#ifdef STANDALONE_FILTER
- CRegKey key;
- TCHAR buff[256];
- ULONG len;
-
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"), KEY_READ)) {
- DWORD dw;
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseFastStreamChange"), dw)) {
- m_useFastStreamChange = !!dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSub"), dw)) {
- m_ForcedSub = !!dw;
- }
-
- len = _countof(buff);
- ZeroMemory(buff, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(_T("AudioLanguageOrder"), buff, &len)) {
- m_csAudioLanguageOrder = CString(buff);
- }
-
- len = _countof(buff);
- ZeroMemory(buff, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(_T("SubtitlesLanguageOrder"), buff, &len)) {
- m_csSubtitlesLanguageOrder = CString(buff);
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("VC1_Decoder_Output"), dw)) {
- m_nVC1_GuidFlag = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AC3CoreOnly"), dw)) {
- m_AC3CoreOnly = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AlternativeDuration"), dw)) {
- m_AlternativeDuration = !!dw;
- }
- }
-#else
- m_useFastStreamChange = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
- m_ForcedSub = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
- m_csSubtitlesLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
- m_csAudioLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
- m_nVC1_GuidFlag = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- if (m_nVC1_GuidFlag < 1 || m_nVC1_GuidFlag > 3) {
- m_nVC1_GuidFlag = 1;
- }
- m_AC3CoreOnly = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
- m_AlternativeDuration = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
-#endif
-}
-
-bool CMpegSplitterFilter::StreamIsTrueHD(const WORD pid)
-{
- int iProgram = -1;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(pid, iProgram, pClipInfo);
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- return (StreamType == AUDIO_STREAM_AC3_TRUE_HD);
-}
-
-STDMETHODIMP CMpegSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IMpegSplitterFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- QI(IAMStreamSelect)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CMpegSplitterFilter::GetClassID(CLSID* pClsID)
-{
- CheckPointer(pClsID, E_POINTER);
-
- if (m_pPipoBimbo) {
- memcpy(pClsID, &CLSID_WMAsfReader, sizeof(GUID));
- return S_OK;
- } else {
- return __super::GetClassID(pClsID);
- }
-}
-
-STDMETHODIMP CMpegSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MpegSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-void CMpegSplitterFilter::ReadClipInfo(LPCOLESTR pszFileName)
-{
- if (wcslen(pszFileName) > 0) {
- WCHAR Drive[_MAX_DRIVE];
- WCHAR Dir[MAX_PATH];
- WCHAR Filename[MAX_PATH];
- WCHAR Ext[_MAX_EXT];
-
- if (_wsplitpath_s(pszFileName, Drive, _countof(Drive), Dir, _countof(Dir), Filename, _countof(Filename), Ext, _countof(Ext)) == 0) {
- CString strClipInfo;
-
- _wcslwr_s(Ext, _countof(Ext));
-
- if (wcscmp(Ext, L".ssif") == 0) {
- if (Drive[0]) {
- strClipInfo.Format(_T("%s\\%s\\..\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- } else {
- strClipInfo.Format(_T("%s\\..\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
- }
- } else {
- if (Drive[0]) {
- strClipInfo.Format(_T("%s\\%s\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- } else {
- strClipInfo.Format(_T("%s\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
- }
- }
-
- m_ClipInfo.ReadInfo(strClipInfo);
- }
- }
-}
-
-STDMETHODIMP CMpegSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
-{
- return __super::Load(pszFileName, pmt);
-}
-
-HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
-{
- HRESULT hr;
- BYTE b;
-
- if (m_pFile->m_type == mpeg_ps || m_pFile->m_type == mpeg_es) {
- if (!m_pFile->NextMpegStartCode(b)) {
- return S_FALSE;
- }
-
- if (b == 0xba) { // program stream header
- CMpegSplitterFile::pshdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
- } else if (b == 0xbb) { // program stream system header
- CMpegSplitterFile::pssyshdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
- } else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
- CMpegSplitterFile::peshdr h;
-
- if (!m_pFile->Read(h, b) || !h.len) {
- return S_FALSE;
- }
-
- if (h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- __int64 pos = m_pFile->GetPos();
-
- DWORD TrackNumber = m_pFile->AddStream(0, b, h.id_ext, h.len);
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h.fpts;
- p->bAppendable = !h.fpts;
- p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart + 1;
- p->SetCount(h.len - (size_t)(m_pFile->GetPos() - pos));
-
- m_pFile->ByteRead(p->GetData(), h.len - (m_pFile->GetPos() - pos));
-
- hr = DeliverPacket(p);
- }
- m_pFile->Seek(pos + h.len);
- }
- } else if (m_pFile->m_type == mpeg_ts) {
- CMpegSplitterFile::tshdr h;
-
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
-
-
- __int64 pos = m_pFile->GetPos();
-
- m_pFile->UpdatePrograms(h, false);
-
- if (h.payload && ISVALIDPID(h.pid)) {
- DWORD TrackNumber = h.pid;
-
- CMpegSplitterFile::peshdr h2;
-
- if (h.payloadstart && m_pFile->NextMpegStartCode(b, 4) && m_pFile->Read(h2, b)) { // pes packet
- if (h2.type == CMpegSplitterFile::mpeg2 && h2.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
- TrackNumber = m_pFile->AddStream(h.pid, b, 0, h.bytes - (DWORD)(m_pFile->GetPos() - pos));
- }
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h2.fpts;
- p->bAppendable = !h2.fpts;
-
- if (h.fPCR) {
- CRefTime rtNow;
- StreamTime(rtNow);
- //TRACE(_T("Now=%s PCR=%s\n"), ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
- }
-
- p->rtStart = h2.fpts ? (h2.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart + 1;
- p->SetCount(h.bytes - (size_t)(m_pFile->GetPos() - pos));
-
- int nBytes = int(h.bytes - (m_pFile->GetPos() - pos));
- m_pFile->ByteRead(p->GetData(), nBytes);
-
- hr = DeliverPacket(p);
- }
- }
-
- m_pFile->Seek(h.next);
- } else if (m_pFile->m_type == mpeg_pva) {
- CMpegSplitterFile::pvahdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
-
- DWORD TrackNumber = h.streamid;
-
- __int64 pos = m_pFile->GetPos();
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h.fpts;
- p->bAppendable = !h.fpts;
- p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart + 1;
- p->SetCount(h.length);
-
- m_pFile->ByteRead(p->GetData(), h.length);
- hr = DeliverPacket(p);
- }
-
- m_pFile->Seek(pos + h.length);
- }
-
- return S_OK;
-}
-
-//
-
-HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- ReadClipInfo(GetPartFilename(pAsyncReader));
- m_pFile.Attach(DEBUG_NEW CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo, m_nVC1_GuidFlag, m_ForcedSub, m_AC3CoreOnly, m_AlternativeDuration));
-
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
-
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- if (m_pFile->m_type == mpeg_ps) {
- if (m_pInput && m_pInput->IsConnected() && (GetCLSID(m_pInput->GetConnected()) == GUIDFromCString(_T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}")))) { // MPC VTS Reader
- pTI = GetFilterFromPin(m_pInput->GetConnected());
- }
- }
-
- CString cs_audioProgram = _T("");
- CString cs_subpicProgram = _T("");
-
- // Create
- if (m_ClipInfo.IsHdmv()) {
- for (size_t i = 0; i < m_ClipInfo.GetStreamNumber(); i++) {
- const CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex(i);
- if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM) {
- m_pFile->AddHdmvPGStream(stream->m_PID, stream->m_LanguageCode);
- }
- }
- }
-
- CString lang = _T("");
- 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.Add(lang);
- }
- lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
- }
- }
-
- if (!m_csSubtitlesLanguageOrder.IsEmpty()) {
- int tPos = 0;
- lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
- while (tPos != -1) {
- if (!lang.IsEmpty()) {
- lang_list_subpic.Add(lang);
- }
- lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
- }
- }
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
- CAtlArray<CMediaType> mts;
- mts.Add(s.mt);
-
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- continue;
- } else {
- int iProgram = -1;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t* pStreamName = nullptr;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
- if (i == CMpegSplitterFile::audio) {
- CString str_tmp = str.Mid(8).MakeLower();
- 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]) {
- continue; // not matched
- }
- }
- cs_audioProgram = str;
- break;
- }
- }
- if (i == CMpegSplitterFile::subpic) {
- CString str_tmp = str.Mid(11).MakeLower();
- 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]) {
- continue; // not matched
- }
- }
- cs_subpicProgram = str;
- break;
- }
- }
- }
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
- CAtlArray<CMediaType> mts;
- mts.Add(s.mt);
-
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- } else {
- int iProgram = -1;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t* pStreamName = nullptr;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMpegSplitterOutputPin(mts, str, this, this, &hr, m_pFile->m_type));
- if (i == CMpegSplitterFile::subpic) {
- (static_cast<CMpegSplitterOutputPin*>(pPinOut.m_p))->SetMaxShift(_I64_MAX);
- }
-
- if (i == CMpegSplitterFile::audio) {
- if (!cs_audioProgram.IsEmpty()) {
- if (!cs_audioProgram.Compare(str) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- } else {
- if (S_OK == AddOutputPin(s, pPinOut)) {
- break;
- }
- }
- } else if (i == CMpegSplitterFile::subpic) {
- if (!cs_subpicProgram.IsEmpty()) {
- if (!cs_subpicProgram.Compare(str) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- } else {
- if ((m_pFile->m_streams[CMpegSplitterFile::subpic].GetCount() == 1) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- } else if ((s.pid != NO_SUBTITLE_PID) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- }
- } else {
- if (S_OK == AddOutputPin(s, pPinOut)) {
- break;
- }
- }
- }
- }
-
- if (m_rtPlaylistDuration) {
- m_rtNewStop = m_rtStop = m_rtDuration = m_rtPlaylistDuration;
- } else if (m_pFile->IsRandomAccess() && m_pFile->m_rate) {
- m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_pFile->GetLength() / m_pFile->m_rate;
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CMpegSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CMpegSplitterFilter");
- if (!m_pFile) {
- return false;
- }
-
- m_rtStartOffset = 0;
-
- return true;
-}
-
-void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- CAtlList<CMpegSplitterFile::stream>* pMasterStream = m_pFile->GetMasterStream();
-
- if (!pMasterStream) {
- ASSERT(0);
- return;
- }
-
- if (m_pFile->IsStreaming()) {
- m_pFile->Seek(max(0, m_pFile->GetLength() - 100 * 1024));
- m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead());
- return;
- }
-
- REFERENCE_TIME rtPreroll = 10000000;
-
- if (rt <= rtPreroll || m_rtDuration <= 0) {
- m_pFile->Seek(0);
- } else {
- __int64 len = m_pFile->GetLength();
- __int64 seekpos = (__int64)(1.0 * rt / m_rtDuration * len);
- __int64 minseekpos = _I64_MAX;
-
- REFERENCE_TIME rtmax = rt - rtPreroll;
- REFERENCE_TIME rtmin = rtmax - 5000000;
-
- if (m_rtStartOffset == 0) {
- for (int i = 0; i < _countof(m_pFile->m_streams) - 1; i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- DWORD TrackNum = m_pFile->m_streams[i].GetNext(pos);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNum);
- if (pPin && pPin->IsConnected()) {
- m_pFile->Seek(seekpos);
-
- __int64 curpos = seekpos;
- REFERENCE_TIME pdt = _I64_MIN;
-
- for (int j = 0; j < 10; j++) {
- REFERENCE_TIME rt2 = m_pFile->NextPTS(TrackNum);
-
- if (rt2 < 0) {
- break;
- }
-
- REFERENCE_TIME dt = rt2 - rtmax;
- if (dt > 0 && dt == pdt) {
- dt = 10000000i64;
- }
-
-
- if (rtmin <= rt2 && rt2 <= rtmax || pdt > 0 && dt < 0) {
- minseekpos = min(minseekpos, curpos);
- break;
- }
-
- curpos -= (__int64)(1.0 * dt / m_rtDuration * len);
- m_pFile->Seek(curpos);
-
- //pdt = dt;
- }
- }
- }
- }
- }
-
- if (minseekpos != _I64_MAX) {
- seekpos = minseekpos;
- } else {
- // this file is probably screwed up, try plan B, seek simply by bitrate
-
- rt -= rtPreroll;
- seekpos = (__int64)(1.0 * rt / m_rtDuration * len);
- m_pFile->Seek(seekpos);
- m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead()) - rt;
- }
-
- m_pFile->Seek(seekpos);
- }
-}
-
-bool CMpegSplitterFilter::DemuxLoop()
-{
- REFERENCE_TIME rtStartOffset = m_rtStartOffset ? m_rtStartOffset : m_pFile->m_rtMin;
-
- HRESULT hr = S_OK;
- while (SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- if ((hr = m_pFile->HasMoreData(1024 * 500)) == S_OK)
- if ((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
- Sleep(1);
- }
- }
-
- return true;
-}
-
-bool CMpegSplitterFilter::BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items)
-{
- m_rtPlaylistDuration = 0;
- return SUCCEEDED(m_ClipInfo.ReadPlaylist(pszFileName, m_rtPlaylistDuration, Items)) ? true : false;
-}
-
-bool CMpegSplitterFilter::BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items)
-{
- return SUCCEEDED(m_ClipInfo.ReadChapters(pszFileName, PlaylistItems, Items)) ? true : false;
-}
-
-// IAMStreamSelect
-
-STDMETHODIMP CMpegSplitterFilter::Count(DWORD* pcStreams)
-{
- CheckPointer(pcStreams, E_POINTER);
-
- *pcStreams = 0;
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- (*pcStreams) += m_pFile->m_streams[i].GetCount();
- }
-
- return S_OK;
-}
-
-STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags)
-{
- if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
- return E_NOTIMPL;
- }
-
- for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
- int cnt = (int)m_pFile->m_streams[i].GetCount();
-
- if (lIndex >= j && lIndex < j + cnt) {
- lIndex -= j;
-
- POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if (!pos) {
- return E_UNEXPECTED;
- }
-
- CMpegSplitterFile::stream& to = m_pFile->m_streams[i].GetAt(pos);
-
- pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& from = m_pFile->m_streams[i].GetNext(pos);
- if (!GetOutputPin(from)) {
- continue;
- }
-
- if (m_useFastStreamChange) {
- PauseGraph;
- ResumeGraph;
- }
-
- HRESULT hr;
- if (FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
- return hr;
- }
-
-#if 0
- // Don't rename other pin for Hdmv!
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* p = m_pFile->FindProgram(to.pid, iProgram, pClipInfo);
-
- if (p != nullptr && !m_ClipInfo.IsHdmv() && !m_pFile->IsHdmv()) {
- for (int k = 0; k < _countof(m_pFile->m_streams); k++) {
- if (k == i) {
- continue;
- }
-
- pos = m_pFile->m_streams[k].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& from = m_pFile->m_streams[k].GetNext(pos);
- if (!GetOutputPin(from)) {
- continue;
- }
-
- for (int l = 0; l < _countof(p->streams); l++) {
- if (const CMpegSplitterFile::stream* s = m_pFile->m_streams[k].FindStream(p->streams[l].pid)) {
- if (from != *s) {
- hr = RenameOutputPin(from, *s, &s->mt);
- }
- break;
- }
- }
- }
- }
- }
-#endif
-
- return S_OK;
- }
- }
-
- j += cnt;
- }
-
- return S_FALSE;
-}
-
-LONGLONG GetMediaTypeQuality(const CMediaType* _pMediaType, int _PresentationFormat)
-{
- if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
- __int64 Ret = 0;
-
- const WAVEFORMATEX* pInfo = GetFormatHelper(pInfo, _pMediaType);
- int TypePriority = 0;
-
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- TypePriority = 12;
- } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- TypePriority = 12;
- } else {
- if (_PresentationFormat == AUDIO_STREAM_DTS_HD_MASTER_AUDIO) {
- TypePriority = 12;
- } else if (_PresentationFormat == AUDIO_STREAM_DTS_HD) {
- TypePriority = 11;
- } else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD) {
- TypePriority = 12;
- } else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS) {
- TypePriority = 10;
- } else {
- switch (pInfo->wFormatTag) {
- case WAVE_FORMAT_PS2_PCM: {
- TypePriority = 12;
- }
- break;
- case WAVE_FORMAT_PS2_ADPCM: {
- TypePriority = 4;
- }
- break;
- case WAVE_FORMAT_DVD_DTS: {
- TypePriority = 9;
- }
- break;
- case WAVE_FORMAT_DOLBY_AC3: {
- TypePriority = 8;
- }
- break;
- case WAVE_FORMAT_AAC: {
- TypePriority = 7;
- }
- break;
- case WAVE_FORMAT_MPEGLAYER3: {
- TypePriority = 6;
- }
- break;
- case WAVE_FORMAT_MPEG: {
- TypePriority = 5;
- }
- break;
- }
- }
- }
-
- Ret += __int64(TypePriority) * 100000000i64 * 1000000000i64;
-
- Ret += __int64(pInfo->nChannels) * 1000000i64 * 1000000000i64;
- Ret += __int64(pInfo->nSamplesPerSec) * 10i64 * 1000000000i64;
- Ret += __int64(pInfo->wBitsPerSample) * 10000000i64;
- Ret += __int64(pInfo->nAvgBytesPerSec);
-
- return Ret;
- }
-
- return 0;
-}
-
-STDMETHODIMP CMpegSplitterFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
-{
- for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
- int cnt = (int)m_pFile->m_streams[i].GetCount();
-
- if (lIndex >= j && lIndex < j + cnt) {
- lIndex -= j;
-
- POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if (!pos) {
- return E_UNEXPECTED;
- }
-
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetAt(pos);
- const CHdmvClipInfo::Stream* pStream = m_ClipInfo.FindStream(s.pid);
-
- if (ppmt) {
- *ppmt = CreateMediaType(&s.mt);
- }
- if (pdwFlags) {
- *pdwFlags = GetOutputPin(s) ? (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE) : 0;
- }
- if (plcid) {
- *plcid = pStream ? pStream->m_LCID : 0;
- }
- if (pdwGroup) {
- *pdwGroup = i;
- }
- if (ppObject) {
- *ppObject = nullptr;
- }
- if (ppUnk) {
- *ppUnk = nullptr;
- }
-
- if (ppszName) {
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
-
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- if (plcid) {
- *plcid = (LCID)LCID_NOSUBTITLES;
- }
- } else {
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t* pStreamName = nullptr;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
-
- *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength() + 1) * sizeof(WCHAR));
- if (*ppszName == nullptr) {
- return E_OUTOFMEMORY;
- }
-
- wcscpy_s(*ppszName, str.GetLength() + 1, str);
- }
- }
-
- j += cnt;
- }
-
- return S_OK;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CMpegSplitterFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CMpegSplitterSettingsWnd);
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CMpegSplitterFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CMpegSplitterSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMpegSplitterSettingsWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-// IMpegSplitterFilter
-STDMETHODIMP CMpegSplitterFilter::Apply()
-{
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"))) {
- key.SetDWORDValue(_T("UseFastStreamChange"), m_useFastStreamChange);
- key.SetDWORDValue(_T("ForcedSub"), m_ForcedSub);
- key.SetStringValue(_T("AudioLanguageOrder"), m_csAudioLanguageOrder);
- key.SetStringValue(_T("SubtitlesLanguageOrder"), m_csSubtitlesLanguageOrder);
- key.SetDWORDValue(_T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- key.SetDWORDValue(_T("AC3CoreOnly"), m_AC3CoreOnly);
- key.SetDWORDValue(_T("AlternativeDuration"), m_AlternativeDuration);
- }
-#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
-#endif
-
- return S_OK;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetFastStreamChange(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_useFastStreamChange = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetFastStreamChange()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_useFastStreamChange;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetForcedSub(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_ForcedSub = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetForcedSub()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_ForcedSub;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetAudioLanguageOrder(WCHAR* nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_csAudioLanguageOrder = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(WCHAR*) CMpegSplitterFilter::GetAudioLanguageOrder()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_csAudioLanguageOrder.GetBuffer();
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetSubtitlesLanguageOrder(WCHAR* nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_csSubtitlesLanguageOrder = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(WCHAR*) CMpegSplitterFilter::GetSubtitlesLanguageOrder()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_csSubtitlesLanguageOrder.GetBuffer();
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetVC1_GuidFlag(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nVC1_GuidFlag = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMpegSplitterFilter::GetVC1_GuidFlag()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nVC1_GuidFlag;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetTrueHD(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_AC3CoreOnly = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMpegSplitterFilter::GetTrueHD()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_AC3CoreOnly;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetAlternativeDuration(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_AlternativeDuration = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetAlternativeDuration()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_AlternativeDuration;
-}
-
-STDMETHODIMP_(int) CMpegSplitterFilter::GetMPEGType()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_pFile->m_type;
-}
-//
-// CMpegSourceFilter
-//
-
-CMpegSourceFilter::CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid)
- : CMpegSplitterFilter(pUnk, phr, clsid)
-{
- m_pInput.Free();
-}
-
-//
-// CMpegSplitterOutputPin
-//
-
-CMpegSplitterOutputPin::CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int type)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
- , m_fHasAccessUnitDelimiters(false)
- , m_rtMaxShift(50000000)
- , m_bFilterDTSMA(false)
- , m_type(type)
- , DD_reset(false)
- , m_bFlushed(false)
-{
-}
-
-CMpegSplitterOutputPin::~CMpegSplitterOutputPin()
-{
-}
-
-HRESULT CMpegSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- {
- CAutoLock cAutoLock(this);
-
- m_rtPrev = Packet::INVALID_TIME;
- m_rtOffset = 0;
- }
-
- return __super::DeliverNewSegment(tStart, tStop, dRate);
-}
-
-HRESULT CMpegSplitterOutputPin::DeliverEndFlush()
-{
- {
- CAutoLock cAutoLock(this);
-
- m_p.Free();
- m_pl.RemoveAll();
- DD_reset = true;
- m_bFlushed = true;
- }
-
- return __super::DeliverEndFlush();
-}
-
-#define MOVE_TO_H264_START_CODE(b, e) \
- while (b <= e-4 && !((*(DWORD *)b == 0x01000000) || ((*(DWORD *)b & 0x00FFFFFF) == 0x00010000))) { \
- b++; \
- } \
- if ((b <= e-4) && *(DWORD *)b == 0x01000000) \
- b++;
-
-HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- CAutoLock cAutoLock(this);
-
- if (p->rtStart != Packet::INVALID_TIME) {
- REFERENCE_TIME rt = p->rtStart + m_rtOffset;
-
- // Filter invalid PTS (if too different from previous packet)
- if (m_rtPrev != Packet::INVALID_TIME)
- if (_abs64(rt - m_rtPrev) > m_rtMaxShift) {
- m_rtOffset += m_rtPrev - rt;
- }
-
- p->rtStart += m_rtOffset;
- p->rtStop += m_rtOffset;
-
- m_rtPrev = p->rtStart;
- }
-
- if (p->pmt) {
- if (*((CMediaType*)p->pmt) != m_mt) {
- SetMediaType((CMediaType*)p->pmt);
- }
- }
-
- if (m_mt.subtype == MEDIASUBTYPE_AAC) { // special code for aac, the currently available decoders only like whole frame samples
- if (m_p && m_p->GetCount() == 1 && m_p->GetAt(0) == 0xff && !(!p->IsEmpty() && (p->GetAt(0) & 0xf6) == 0xf0)) {
- m_p.Free();
- }
-
- if (!m_p) {
- BYTE* base = p->GetData();
- BYTE* s = base;
- BYTE* e = s + p->GetCount();
-
- for (; s < e; s++) {
- if (*s != 0xff) {
- continue;
- }
-
- if (s == e - 1 || (s[1] & 0xf6) == 0xf0) {
- memmove(base, s, e - s);
- p->SetCount(e - s);
- m_p = p;
- break;
- }
- }
- } else {
- m_p->Append(*p);
- }
-
- while (m_p && m_p->GetCount() > 9) {
- BYTE* base = m_p->GetData();
- BYTE* s = base;
- BYTE* e = s + m_p->GetCount();
- int len = ((s[3] & 3) << 11) | (s[4] << 3) | (s[5] >> 5);
- bool crc = !(s[1] & 1);
- s += 7;
- len -= 7;
- if (crc) {
- s += 2, len -= 2;
- }
-
- if (e - s < len) {
- break;
- }
-
- if (len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len + 1] & 0xf6) != 0xf0)) {
- m_p.Free();
- break;
- }
-
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
-
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity |= m_p->bDiscontinuity;
- m_p->bDiscontinuity = false;
-
- p2->bSyncPoint = m_p->rtStart != Packet::INVALID_TIME;
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
-
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
- p2->pmt = m_p->pmt;
- m_p->pmt = nullptr;
- p2->SetData(s, len);
-
- s += len;
- memmove(base, s, e - s);
- m_p->SetCount(e - s);
-
- HRESULT hr = __super::DeliverPacket(p2);
- if (hr != S_OK) {
- return hr;
- }
- }
-
- if (m_p && p) {
- if (!m_p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- }
- if (!m_p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- }
- if (m_p->rtStart == Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStart, m_p->rtStop = p->rtStop;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = nullptr;
- }
-
- return S_OK;
- } else if (m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva') || m_mt.subtype == FOURCCMap('CVMA') || m_mt.subtype == FOURCCMap('CVME')) {
- if (!m_p) {
- m_p.Attach(DEBUG_NEW Packet());
- m_p->TrackNumber = p->TrackNumber;
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
-
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
-
- m_p->rtStart = p->rtStart;
- p->rtStart = Packet::INVALID_TIME;
-
- m_p->rtStop = p->rtStop;
- p->rtStop = Packet::INVALID_TIME;
- }
-
- m_p->Append(*p);
-
- BYTE* start = m_p->GetData();
- BYTE* end = start + m_p->GetCount();
-
- MOVE_TO_H264_START_CODE(start, end);
-
- while (start <= end - 4) {
- BYTE* next = start + 1;
-
- MOVE_TO_H264_START_CODE(next, end);
-
- if (next >= end - 4) {
- break;
- }
-
- int size = next - start;
-
- CH264Nalu Nalu;
- Nalu.SetBuffer(start, size, 0);
-
- CAutoPtr<Packet> p2;
-
- while (Nalu.ReadNext()) {
- DWORD dwNalLength =
- ((Nalu.GetDataLength() >> 24) & 0x000000ff) |
- ((Nalu.GetDataLength() >> 8) & 0x0000ff00) |
- ((Nalu.GetDataLength() << 8) & 0x00ff0000) |
- ((Nalu.GetDataLength() << 24) & 0xff000000);
-
- CAutoPtr<Packet> p3(DEBUG_NEW Packet());
-
- p3->SetCount(Nalu.GetDataLength() + sizeof(dwNalLength));
- memcpy(p3->GetData(), &dwNalLength, sizeof(dwNalLength));
- memcpy(p3->GetData() + sizeof(dwNalLength), Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- if (p2 == nullptr) {
- p2 = p3;
- } else {
- p2->Append(*p3);
- }
- }
- start = next;
-
- if (!p2) {
- continue;
- }
-
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity = m_p->bDiscontinuity;
- m_p->bDiscontinuity = FALSE;
-
- p2->bSyncPoint = m_p->bSyncPoint;
- m_p->bSyncPoint = FALSE;
-
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
-
- p2->pmt = m_p->pmt;
- m_p->pmt = nullptr;
-
- m_pl.AddTail(p2);
-
- if (p->rtStart != Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStart;
- m_p->rtStop = p->rtStop;
- p->rtStart = Packet::INVALID_TIME;
- }
- if (p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
- }
- if (p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = nullptr;
- }
- if (start > m_p->GetData()) {
- m_p->RemoveAt(0, start - m_p->GetData());
- }
-
- REFERENCE_TIME rtStart = Packet::INVALID_TIME, rtStop = Packet::INVALID_TIME;
-
- for (POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos)) {
- if (pos == m_pl.GetHeadPosition()) {
- continue;
- }
-
- Packet* pPacket = m_pl.GetAt(pos);
- BYTE* pData = pPacket->GetData();
-
- if ((pData[4] & 0x1f) == 0x09) {
- m_fHasAccessUnitDelimiters = true;
- }
-
- if ((pData[4] & 0x1f) == 0x09 || (!m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)) {
- if (pPacket->rtStart == Packet::INVALID_TIME && rtStart != Packet::INVALID_TIME) {
- pPacket->rtStart = rtStart;
- pPacket->rtStop = rtStop;
- }
-
- p = m_pl.RemoveHead();
-
- while (pos != m_pl.GetHeadPosition()) {
- CAutoPtr<Packet> p2 = m_pl.RemoveHead();
- p->Append(*p2);
- }
-
- HRESULT hr = __super::DeliverPacket(p);
- if (hr != S_OK) {
- return hr;
- }
- } else if (rtStart == Packet::INVALID_TIME) {
- rtStart = pPacket->rtStart;
- rtStop = pPacket->rtStop;
- }
- }
-
- return S_OK;
- } else if (m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw') ||
- m_mt.subtype == MEDIASUBTYPE_WVC1_CYBERLINK || m_mt.subtype == MEDIASUBTYPE_WVC1_ARCSOFT) { // just like aac, this has to be starting nalus, more can be packed together
- if (!m_p) {
- m_p.Attach(DEBUG_NEW Packet());
- m_p->TrackNumber = p->TrackNumber;
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
-
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
-
- m_p->rtStart = p->rtStart;
- p->rtStart = Packet::INVALID_TIME;
-
- m_p->rtStop = p->rtStop;
- p->rtStop = Packet::INVALID_TIME;
- }
-
- m_p->Append(*p);
-
- BYTE* start = m_p->GetData();
- BYTE* end = start + m_p->GetCount();
-
- bool bSeqFound = false;
- while (start <= end - 4) {
- if (*(DWORD*)start == 0x0D010000) {
- bSeqFound = true;
- break;
- } else if (*(DWORD*)start == 0x0F010000) {
- break;
- }
- start++;
- }
-
- while (start <= end - 4) {
- BYTE* next = start + 1;
-
- while (next <= end - 4) {
- if (*(DWORD*)next == 0x0D010000) {
- if (bSeqFound) {
- break;
- }
- bSeqFound = true;
- } else if (*(DWORD*)next == 0x0F010000) {
- break;
- }
- next++;
- }
-
- if (next >= end - 4) {
- break;
- }
-
- int size = next - start - 4;
- UNREFERENCED_PARAMETER(size);
-
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity = m_p->bDiscontinuity;
- m_p->bDiscontinuity = FALSE;
-
- p2->bSyncPoint = m_p->bSyncPoint;
- m_p->bSyncPoint = FALSE;
-
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
-
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
-
- p2->pmt = m_p->pmt;
- m_p->pmt = nullptr;
-
- p2->SetData(start, next - start);
-
- HRESULT hr = __super::DeliverPacket(p2);
- if (hr != S_OK) {
- return hr;
- }
-
- if (p->rtStart != Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStop; //p->rtStart; //Sebastiii for enable VC1 decoding in FFDshow (no more shutter)
- m_p->rtStop = p->rtStop;
- p->rtStart = Packet::INVALID_TIME;
- }
- if (p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
- }
- if (p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = nullptr;
-
- start = next;
- bSeqFound = (*(DWORD*)start == 0x0D010000);
- }
-
- if (start > m_p->GetData()) {
- m_p->RemoveAt(0, start - m_p->GetData());
- }
-
- return S_OK;
- }
- // DTS HD MA data is causing trouble with some filters, lets just remove it
- else if (m_bFilterDTSMA && ((m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS))) {
- if (p->GetCount() < 4 && !p->pmt) {
- return S_OK; // Should be invalid packet
- }
- BYTE* hdr = p->GetData();
-
- int Type;
- // 16 bits big endian bitstream
- if (hdr[0] == 0x7f && hdr[1] == 0xfe &&
- hdr[2] == 0x80 && hdr[3] == 0x01) {
- Type = 16 + 32;
- }
-
- // 16 bits low endian bitstream
- else if (hdr[0] == 0xfe && hdr[1] == 0x7f &&
- hdr[2] == 0x01 && hdr[3] == 0x80) {
- Type = 16;
- }
-
- // 14 bits big endian bitstream
- else if (hdr[0] == 0x1f && hdr[1] == 0xff &&
- hdr[2] == 0xe8 && hdr[3] == 0x00 &&
- hdr[4] == 0x07 && (hdr[5] & 0xf0) == 0xf0) {
- Type = 14 + 32;
- }
-
- // 14 bits low endian bitstream
- else if (hdr[0] == 0xff && hdr[1] == 0x1f &&
- hdr[2] == 0x00 && hdr[3] == 0xe8 &&
- (hdr[4] & 0xf0) == 0xf0 && hdr[5] == 0x07) {
- Type = 14;
- }
-
- // no sync
- else if (!p->pmt) {
- return S_OK;
- }
- // HDMV LPCM
- } else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- if (!m_p) {
- m_p.Attach(DEBUG_NEW Packet());
- }
- m_p->Append(*p);
-
- if (m_p->GetCount() < 4) {
- m_p.Free();
- return S_OK; // Should be invalid packet
- }
-
- BYTE* start = m_p->GetData();
- int samplerate, channels;
- size_t header_size = ParseHdmvLPCMHeader(start, &samplerate, &channels);
- if (!header_size || header_size > m_p->GetCount()) {
- if (!header_size) {
- m_p.Free();
- }
- return S_OK;
- }
-
- if (!p->pmt && m_bFlushed) {
- p->pmt = CreateMediaType(&m_mt);
- m_bFlushed = false;
- }
- p->SetData(start + 4, m_p->GetCount() - 4);
- m_p.Free();
- // Dolby_AC3
- } else if ((m_type == mpeg_ts) &&
- (m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->StreamIsTrueHD(p->TrackNumber) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
- if (p->GetCount() < 8) {
- return S_OK; // Should be invalid packet
- }
- BYTE* start = p->GetData();
- if (*(WORD*)start != 0x770b) { // skip none AC3
- return S_OK;
- }
- // TrueHD
- } else if (m_mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD && (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
- if (p->GetCount() < 8) {
- return S_OK; // Should be invalid packet
- }
- BYTE* start = p->GetData();
- if (*(WORD*)start == 0x770b) { // skip AC3
- return S_OK;
- }
- if (DD_reset || p->rtStart == 0) {
- p->bDiscontinuity = true;
- DD_reset = false;
- }
- } else {
- m_p.Free();
- m_pl.RemoveAll();
- }
-
- return __super::DeliverPacket(p);
-}
-
-STDMETHODIMP CMpegSplitterOutputPin::Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt)
-{
- HRESULT hr;
- PIN_INFO PinInfo;
- GUID FilterClsid;
-
- if (SUCCEEDED(pReceivePin->QueryPinInfo(&PinInfo))) {
- if (SUCCEEDED(PinInfo.pFilter->GetClassID(&FilterClsid))) {
- if (FilterClsid == CLSID_DMOWrapperFilter) {
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(true);
- }
- // AC3 Filter did not support DTS-MA
- else if (FilterClsid == CLSID_AC3Filter) {
- m_bFilterDTSMA = true;
- }
- }
- PinInfo.pFilter->Release();
- }
-
- hr = __super::Connect(pReceivePin, pmt);
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(false);
- return hr;
-}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.def b/src/filters/parser/MpegSplitter/MpegSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.h b/src/filters/parser/MpegSplitter/MpegSplitter.h
deleted file mode 100644
index 2a6eb97cc..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-#include "MpegSplitterFile.h"
-#include "MpegSplitterSettingsWnd.h"
-#include "ITrackInfo.h"
-
-#define MpegSplitterName L"MPC MPEG Splitter"
-#define MpegSourceName L"MPC MPEG Source"
-
-class __declspec(uuid("DC257063-045F-4BE2-BD5B-E12279C464F0"))
- CMpegSplitterFilter
- : public CBaseSplitterFilter
- , public IAMStreamSelect
- , public ISpecifyPropertyPages2
- , public IMpegSplitterFilter
-{
- REFERENCE_TIME m_rtStartOffset;
- bool m_pPipoBimbo;
- CHdmvClipInfo m_ClipInfo;
-
-protected:
- CAutoPtr<CMpegSplitterFile> m_pFile;
- CComQIPtr<ITrackInfo> pTI;
-
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- void ReadClipInfo(LPCOLESTR pszFileName);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
- bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& files);
- bool BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items);
-
- HRESULT DemuxNextPacket(REFERENCE_TIME rtStartOffset);
-
- REFERENCE_TIME m_rtPlaylistDuration;
-
-private:
- CString m_csAudioLanguageOrder, m_csSubtitlesLanguageOrder;
- bool m_useFastStreamChange, m_ForcedSub, m_AlternativeDuration;
- int m_nVC1_GuidFlag, m_AC3CoreOnly;
- CCritSec m_csProps;
-
-public:
- CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSplitterFilter));
- void SetPipo(bool bPipo) { m_pPipoBimbo = bPipo; };
-
- bool StreamIsTrueHD(const WORD pid);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- STDMETHODIMP GetClassID(CLSID* pClsID);
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IAMStreamSelect
-
- STDMETHODIMP Count(DWORD* pcStreams);
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
- STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid,
- DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
-
- // ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // IMpegSplitterFilter
- STDMETHODIMP Apply();
-
- STDMETHODIMP SetFastStreamChange(BOOL nValue);
- STDMETHODIMP_(BOOL) GetFastStreamChange();
-
- STDMETHODIMP SetForcedSub(BOOL nValue);
- STDMETHODIMP_(BOOL) GetForcedSub();
-
- STDMETHODIMP SetAudioLanguageOrder(WCHAR* nValue);
- STDMETHODIMP_(WCHAR*) GetAudioLanguageOrder();
-
- STDMETHODIMP SetSubtitlesLanguageOrder(WCHAR* nValue);
- STDMETHODIMP_(WCHAR*) GetSubtitlesLanguageOrder();
-
- STDMETHODIMP SetVC1_GuidFlag(int nValue);
- STDMETHODIMP_(int) GetVC1_GuidFlag();
-
- STDMETHODIMP SetTrueHD(int nValue);
- STDMETHODIMP_(int) GetTrueHD();
-
- STDMETHODIMP SetAlternativeDuration(BOOL nValue);
- STDMETHODIMP_(BOOL) GetAlternativeDuration();
-
- STDMETHODIMP_(int) GetMPEGType();
-};
-
-class __declspec(uuid("1365BE7A-C86A-473C-9A41-C0A6E82C9FA3"))
- CMpegSourceFilter : public CMpegSplitterFilter
-{
-public:
- CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSourceFilter));
-};
-
-class CMpegSplitterOutputPin : public CBaseSplitterOutputPin, protected CCritSec
-{
- CAutoPtr<Packet> m_p;
- CAutoPtrList<Packet> m_pl;
- REFERENCE_TIME m_rtPrev, m_rtOffset, m_rtMaxShift;
- bool m_fHasAccessUnitDelimiters;
- bool m_bFilterDTSMA;
- bool DD_reset;
- bool m_bFlushed;
- int m_type;
-
-protected:
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
- HRESULT DeliverEndFlush();
-
-public:
- CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int type);
- virtual ~CMpegSplitterOutputPin();
- STDMETHODIMP Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt);
- void SetMaxShift(REFERENCE_TIME rtMaxShift) { m_rtMaxShift = rtMaxShift; };
-};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.rc b/src/filters/parser/MpegSplitter/MpegSplitter.rc
deleted file mode 100644
index 50eefbf5a..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.rc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "MPEG Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "MPEG Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MpegSplitter.ax"
- VALUE "ProductName", "MPEG Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-STRINGTABLE
-BEGIN
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_MPEGSPLITTER_FSTREAM_CHANGE "Fast stream change"
- IDS_MPEGSPLITTER_LANG_ORDER "Audio language order:"
- IDS_MPEGSPLITTER_SUB_ORDER "Subtitles language order:"
- IDS_MPEGSPLITTER_VC1_GUIDFLAG "VC-1 Output compatibility:"
- IDS_MPEGSPLITTER_SUB_FORCING "Force load all subtitles"
- IDS_MPEGSPLITTER_TRUEHD_OUTPUT "TrueHD+AC3 streams output"
- IDS_MPEGSPLITTER_THD_NOSPLIT "As is"
- IDS_MPEGSPLITTER_ALT_DUR_CALC "Alternative method calculation of duration"
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj b/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj
deleted file mode 100644
index e7f6c485e..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj
+++ /dev/null
@@ -1,258 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{4628C665-EDE4-40D2-B525-32BE8B8551C8}</ProjectGuid>
- <RootNamespace>MpegSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MpegSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MpegSplitter.cpp" />
- <ClCompile Include="MpegSplitterFile.cpp" />
- <ClCompile Include="MpegSplitterSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpegSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="IMpegSplitterFilter.h" />
- <ClInclude Include="MpegSplitter.h" />
- <ClInclude Include="MpegSplitterFile.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="MpegSplitterSettingsWnd.h" />
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpegSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters b/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters
deleted file mode 100644
index 1866e3db9..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{70db579e-c2ed-4846-a0d6-b454d5fb8edb}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{433ed245-8fc9-40ee-963b-755c136edc4f}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{967ace11-b9ea-4595-b490-e262f148595f}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="MpegSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MpegSplitterFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MpegSplitterSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpegSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="IMpegSplitterFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpegSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpegSplitterFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpegSplitterSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpegSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
deleted file mode 100644
index 777fc0169..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
+++ /dev/null
@@ -1,1134 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "MpegSplitterFile.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#define MEGABYTE 1024*1024
-#define PTS_MAX_BEFORE_WRAP (((1i64 << 33) - 1) * 10000 / 90)
-
-
-CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo& ClipInfo, int guid_flag, bool ForcedSub, int AC3CoreOnly, bool AlternativeDuration)
- : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false, true)
- , m_type(mpeg_us)
- , m_rate(0)
- , m_rtMin(0), m_rtMax(0)
- , m_posMin(0), m_posMax(0)
- , m_rtPrec(_I64_MIN)
- , m_bPTSWrap(false)
- , m_bIsHdmv(bIsHdmv)
- , m_ClipInfo(ClipInfo)
- , m_nVC1_GuidFlag(guid_flag)
- , m_ForcedSub(ForcedSub)
- , m_AC3CoreOnly(AC3CoreOnly)
- , m_AlternativeDuration(AlternativeDuration)
- , m_init(false)
-{
- if (SUCCEEDED(hr)) {
- hr = Init(pAsyncReader);
- }
-}
-
-HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader)
-{
- HRESULT hr;
-
- // get the type first
-
- m_type = mpeg_us;
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- if (BitRead(32, true) == 'TFrc') {
- Seek(0x67c);
- }
- int cnt = 0, limit = 4;
- for (tshdr h; cnt < limit && Read(h); cnt++) {
- Seek(h.next);
- }
- if (cnt >= limit) {
- m_type = mpeg_ts;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- if (BitRead(32, true) == 'TFrc') {
- Seek(0xE80);
- }
- int cnt = 0, limit = 4;
- for (tshdr h; cnt < limit && Read(h); cnt++) {
- Seek(h.next);
- }
- if (cnt >= limit) {
- m_type = mpeg_ts;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- int cnt = 0, limit = 4;
- for (pvahdr h; cnt < limit && Read(h); cnt++) {
- Seek(GetPos() + h.length);
- }
- if (cnt >= limit) {
- m_type = mpeg_pva;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- BYTE b;
- for (int i = 0; (i < 4 || GetPos() < MAX_PROBE_SIZE) && m_type == mpeg_us && NextMpegStartCode(b); i++) {
- if (b == 0xba) {
- pshdr h;
- if (Read(h)) {
- m_type = mpeg_ps;
- m_rate = int(h.bitrate / 8);
- break;
- }
- } else if ((b & 0xe0) == 0xc0 // audio, 110xxxxx, mpeg1/2/3
- || (b & 0xf0) == 0xe0 // video, 1110xxxx, mpeg1/2
- // || (b&0xbd) == 0xbd) // private stream 1, 0xbd, ac3/dts/lpcm/subpic
- || b == 0xbd) { // private stream 1, 0xbd, ac3/dts/lpcm/subpic
- peshdr h;
- if (Read(h, b) && BitRead(24, true) == 0x000001) {
- m_type = mpeg_es;
- }
- }
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- return E_FAIL;
- }
-
- // min/max pts & bitrate
- m_rtMin = m_posMin = _I64_MAX;
- m_rtMax = m_posMax = 0;
- m_rtPrec = _I64_MIN;
- m_bPTSWrap = false;
-
- m_init = true;
-
- if (IsRandomAccess() || IsStreaming()) {
- if (IsStreaming()) {
- for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(MEGABYTE, 100); i++) {
- ;
- }
- }
-
- SearchPrograms(0, min(GetLength(), MEGABYTE * 5)); // max 5Mb for search a valid Program Map Table
-
- __int64 pfp = 0;
- const int k = 5;
- for (int i = 0; i <= k; i++) {
- __int64 fp = i * GetLength() / k;
- fp = min(GetLength() - MEGABYTE / 8, fp);
- fp = max(pfp, fp);
- __int64 nfp = fp + (pfp == 0 ? 10 * MEGABYTE : MEGABYTE / 8);
- if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
- return hr;
- }
- pfp = nfp;
- }
- } else {
- if (FAILED(hr = SearchStreams(0, MEGABYTE / 8, pAsyncReader))) {
- return hr;
- }
- }
-
- if (m_type == mpeg_ts) {
- if (IsRandomAccess() || IsStreaming()) {
- if (IsStreaming()) {
- for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024 * 100, 100); i++) {
- ;
- }
- }
-
- __int64 pfp = 0;
- const int k = 5;
- for (int i = 0; i <= k; i++) {
- __int64 fp = i * GetLength() / k;
- fp = min(GetLength() - MEGABYTE / 8, fp);
- fp = max(pfp, fp);
- __int64 nfp = fp + (pfp == 0 ? 10 * MEGABYTE : MEGABYTE / 8);
- if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader, TRUE))) {
- return hr;
- }
- pfp = nfp;
- }
- } else {
- if (FAILED(hr = SearchStreams(0, MEGABYTE / 8, pAsyncReader, TRUE))) {
- return hr;
- }
- }
- }
-
- if (m_posMax - m_posMin <= 0 || (m_rtMax - m_rtMin <= 0 && !m_bPTSWrap)) {
- return E_FAIL;
- }
-
- m_init = false;
-
- int indicated_rate = m_rate;
- REFERENCE_TIME dur = !m_bPTSWrap ? (m_rtMax - m_rtMin) : (PTS_MAX_BEFORE_WRAP - m_rtMin + m_rtMax);
- int detected_rate = int(10000000i64 * (m_posMax - m_posMin) / dur);
-
- m_rate = detected_rate ? detected_rate : m_rate;
-#if (0)
- // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
- // (update: also allowing +/-50k/s)
- if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50 * 1024) {
- m_rate = detected_rate;
- } else {
- ; // TODO: in this case disable seeking, or try doing something less drastical...
- }
-#endif
-
- // Add fake subtitle stream...
- if (m_streams[video].GetCount() && m_streams[subpic].GetCount()) {
- if (m_type == mpeg_ts && m_bIsHdmv) {
- AddHdmvPGStream(NO_SUBTITLE_PID, "---");
- } else {
- stream s;
- s.pid = NO_SUBTITLE_PID;
- s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
- s.mt.subtype = m_streams[subpic].GetHead().mt.subtype;
- s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
- m_streams[subpic].Insert(s, this);
- }
- }
-
- Seek(0);
-
- return S_OK;
-}
-
-void CMpegSplitterFile::OnComplete(IAsyncReader* pAsyncReader)
-{
- __int64 pos = GetPos();
-
- if (SUCCEEDED(SearchStreams(GetLength() - 500 * 1024, GetLength(), pAsyncReader, TRUE))) {
- int indicated_rate = m_rate;
- REFERENCE_TIME dur = !m_bPTSWrap ? (m_rtMax - m_rtMin) : (PTS_MAX_BEFORE_WRAP - m_rtMin + m_rtMax);
- int detected_rate = int(10000000i64 * (m_posMax - m_posMin) / dur);
-
- m_rate = detected_rate ? detected_rate : m_rate;
-#if (0)
- // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
- // (update: also allowing +/-50k/s)
- if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50 * 1024) {
- m_rate = detected_rate;
- } else {
- ; // TODO: in this case disable seeking, or try doing something less drastical...
- }
-#endif
- }
-
- Seek(pos);
-}
-
-REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
-{
- REFERENCE_TIME rt = -1;
- __int64 rtpos = -1;
-
- BYTE b;
-
- while (GetRemaining()) {
- if (m_type == mpeg_ps || m_type == mpeg_es) {
- if (!NextMpegStartCode(b)) { // continue;
- ASSERT(0);
- break;
- }
-
- rtpos = GetPos() - 4;
-
- if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) {
- peshdr h;
- if (!Read(h, b) || !h.len) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- if (h.fpts && AddStream(0, b, h.id_ext, h.len) == TrackNum) {
- //ASSERT(h.pts >= m_rtMin && h.pts <= m_rtMax);
- rt = h.pts;
- break;
- }
-
- Seek(pos + h.len);
- }
- } else if (m_type == mpeg_ts) {
- tshdr h;
- if (!Read(h)) {
- continue;
- }
-
- rtpos = GetPos() - 4;
-
- if (h.payload && h.payloadstart && ISVALIDPID(h.pid)) {
- peshdr h2;
- if (NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if (h2.fpts && AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
- //ASSERT(h2.pts >= m_rtMin && h2.pts <= m_rtMax);
- rt = h2.pts;
- break;
- }
- }
- }
-
- Seek(h.next);
- } else if (m_type == mpeg_pva) {
- pvahdr h;
- if (!Read(h)) {
- continue;
- }
-
- if (h.fpts) {
- rt = h.pts;
- break;
- }
- }
- }
-
- if (rtpos >= 0) {
- Seek(rtpos);
- }
- if (rt >= 0) {
- rt -= m_rtMin;
- }
-
- return rt;
-}
-
-void CMpegSplitterFile::SearchPrograms(__int64 start, __int64 stop)
-{
- if (m_type != mpeg_ts) {
- return;
- }
-
- Seek(start);
- stop = min(stop, GetLength());
-
- while (GetPos() < stop) {
- tshdr h;
- if (!Read(h)) {
- continue;
- }
-
- UpdatePrograms(h);
- Seek(h.next);
- }
-}
-
-HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader, BOOL CalcDuration)
-{
- Seek(start);
- stop = min(stop, GetLength());
-
- while (GetPos() < stop) {
- BYTE b;
-
- if (m_type == mpeg_ps || m_type == mpeg_es) {
- if (!NextMpegStartCode(b)) {
- continue;
- }
-
- if (b == 0xba) { // program stream header
- pshdr h;
- if (!Read(h)) {
- continue;
- }
- m_rate = int(h.bitrate / 8);
- } else if (b == 0xbb) { // program stream system header
- pssyshdr h;
- if (!Read(h)) {
- continue;
- }
- } else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
- peshdr h;
- if (!Read(h, b) || !h.len) {
- continue;
- }
-
- if (h.type == mpeg2 && h.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- if (h.fpts) {
- if (m_rtMin == _I64_MAX) {
- m_rtMin = h.pts;
- m_posMin = GetPos();
- TRACE(_T("m_rtMin(SearchStreams)=%s\n"), ReftimeToString(m_rtMin));
- }
- if (m_rtMin < h.pts && m_rtMax < h.pts) {
- m_rtMax = h.pts;
- m_posMax = GetPos();
- TRACE(_T("m_rtMax(SearchStreams)=%s\n"), ReftimeToString(m_rtMax));
- }
- }
-
- __int64 pos = GetPos();
- AddStream(0, b, h.id_ext, h.len);
- if (h.len) {
- Seek(pos + h.len);
- }
- }
- } else if (m_type == mpeg_ts) {
- tshdr h;
- if (!Read(h)) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- //UpdatePrograms(h);
-
- if (h.payload && ISVALIDPID(h.pid)) {
- peshdr h2;
- if (h.payloadstart && NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if (h2.type == mpeg2 && h2.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- if (h2.fpts && CalcDuration && (m_AlternativeDuration || (GetMasterStream() && GetMasterStream()->GetHead() == h.pid))) {
- if (m_rtPrec != _I64_MIN && abs(h2.pts - m_rtPrec) >= PTS_MAX_BEFORE_WRAP / 2) {
- m_bPTSWrap = true;
- m_rtMax = h2.pts;
- m_posMax = GetPos();
- TRACE(_T("PTS Wrap detected --> m_rtMax(SearchStreams)=%s\n"), ReftimeToString(m_rtMax));
- }
- m_rtPrec = h2.pts;
-
- if ((m_rtMin == _I64_MAX) || (m_rtMin > h2.pts && m_rtMax > h2.pts && !m_bPTSWrap)) {
- m_rtMin = h2.pts;
- m_posMin = GetPos();
- TRACE(_T("m_rtMin(SearchStreams)=%s, PID=%d\n"), ReftimeToString(m_rtMin), h.pid);
- }
-
- if (m_rtMax < h2.pts && (m_rtMin < h2.pts || m_bPTSWrap)) {
- m_rtMax = h2.pts;
- m_posMax = GetPos();
- TRACE(_T("m_rtMax(SearchStreams)=%s, PID=%d\n"), ReftimeToString(m_rtMax), h.pid);
- // Ugly code : to support BRD H264 seamless playback, CMultiFiles need to update m_rtPTSOffset variable
- // each time a new part is open...
- // use this code only if Blu-ray is detected
- if (m_ClipInfo.IsHdmv()) {
- for (size_t i = 0; i < m_ClipInfo.GetStreamNumber(); i++) {
- const CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex(i);
- if (stream->m_Type == VIDEO_STREAM_H264 && m_rtMin == 116506666) {
- CComQIPtr<ISyncReader> pReader = pAsyncReader;
- if (pReader) {
- pReader->SetPTSOffset(&m_rtPTSOffset);
- }
- //TRACE(_T("UPDATE m_rtPTSOffset(SearchStreams)=%s\n"), ReftimeToString(m_rtPTSOffset));
- //TRACE(_T("m_rtMin(Boucle)=%s\n"), ReftimeToString(m_rtMin));
- //TRACE(_T("stream=%d\n"), stream->m_Type);
- //TRACE(_T("m_rtMax(Boucle)=%s\n"), ReftimeToString(m_rtMax));
- //TRACE(_T("m_rtMax - m_rtMin(Boucle)=%s\n"), ReftimeToString(m_rtMax - m_rtMin));
- }
- }
- }
- }
- }
- } else {
- b = 0;
- }
-
- if (!CalcDuration) {
- AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - pos)));
- }
- }
-
- Seek(h.next);
- } else if (m_type == mpeg_pva) {
- pvahdr h;
- if (!Read(h)) {
- continue;
- }
-
- if (h.fpts) {
- if (m_rtMin == _I64_MAX) {
- m_rtMin = h.pts;
- m_posMin = GetPos();
- }
-
- if (m_rtMin < h.pts && m_rtMax < h.pts) {
- m_rtMax = h.pts;
- m_posMax = GetPos();
- }
- }
-
- __int64 pos = GetPos();
-
- if (h.streamid == 1) {
- AddStream(h.streamid, 0xe0, 0, h.length);
- } else if (h.streamid == 2) {
- AddStream(h.streamid, 0xc0, 0, h.length);
- }
-
- if (h.length) {
- Seek(pos + h.length);
- }
- }
- }
-
- return S_OK;
-}
-
-#define IsMpegAudio(stream_type) (stream_type == AUDIO_STREAM_MPEG1 || stream_type == AUDIO_STREAM_MPEG2)
-#define IsAACAudio(stream_type) (stream_type == AUDIO_STREAM_AAC)
-#define IsAACLATMAudio(stream_type) (stream_type == AUDIO_STREAM_AAC_LATM)
-#define IsAC3Audio(stream_type) ( \
- stream_type == AUDIO_STREAM_AC3 || stream_type == AUDIO_STREAM_AC3_PLUS || \
- stream_type == AUDIO_STREAM_AC3_TRUE_HD || stream_type == SECONDARY_AUDIO_AC3_PLUS || \
- stream_type == PES_PRIVATE)
-#define IsMPEG2Video(stream_type) (stream_type == VIDEO_STREAM_MPEG2)
-#define IsH264Video(stream_type) (stream_type == VIDEO_STREAM_H264)
-#define IsVC1Video(stream_type) (stream_type == VIDEO_STREAM_VC1)
-
-DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, BYTE ps1id, DWORD len)
-{
- if (pid) {
- if (pesid) {
- m_pid2pes[pid] = pesid;
- } else {
- m_pid2pes.Lookup(pid, pesid);
- }
- }
-
- stream s;
- s.pid = pid;
- s.pesid = pesid;
- s.ps1id = ps1id;
-
- const __int64 start = GetPos();
- int type = unknown;
-
- if (pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
-
- // MPEG2
- if (type == unknown) {
- CMpegSplitterFile::seqhdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsMPEG2Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
- }
-
- // H.264
- if (type == unknown) {
- Seek(start);
- // PPS and SPS can be present on differents packets
- // and can also be split into multiple packets
- if (!avch.Lookup(pid)) {
- ZeroMemory(&avch[pid], sizeof(CMpegSplitterFile::avchdr));
- }
-#if defined(MVC_SUPPORT)
- if (!m_streams[video].Find(s) && !m_streams[stereo].Find(s) && Read(avch[pid], len, &s.mt)) {
- if (avch[pid].spspps[index_subsetsps].complete) {
- type = stereo;
- } else {
- type = video;
- }
- }
-#else
- if (!m_streams[video].Find(s) && Read(avch[pid], len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsH264Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
-#endif
- }
- } else if (pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
-
- // AAC
- if (type == unknown) {
- CMpegSplitterFile::aachdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, m_type)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAACAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // AAC LATM
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::latm_aachdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAACLATMAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // MPEG Audio
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::mpahdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsMpegAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
- } else if (pesid == 0xbd || pesid == 0xfd) { // private stream 1
- if (s.pid) {
- if (!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
-
- // AC3, E-AC3, TrueHD
- if (type == unknown) {
- CMpegSplitterFile::ac3hdr h;
- if (Read(h, len, &s.mt, true, (m_AC3CoreOnly == 1))) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAC3Audio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // DTS, DTS HD, DTS HD MA
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::dtshdr h;
- if (Read(h, len, &s.mt, false)) {
- type = audio;
- }
- }
-
- // VC1
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::vc1hdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsVC1Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
- }
-
- // DVB subtitles
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::dvbsub h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
- type = subpic;
- }
- }
-
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const program* pProgram = FindProgram(s.pid, iProgram, pClipInfo);
- if ((type == unknown) && (pProgram != nullptr)) {
- PES_STREAM_TYPE StreamType = INVALID;
-
- Seek(start);
- StreamType = pProgram->streams[iProgram].type;
-
- switch (StreamType) {
- case AUDIO_STREAM_LPCM: {
- CMpegSplitterFile::hdmvlpcmhdr h;
- if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
- type = audio;
- }
- }
- break;
- case PRESENTATION_GRAPHICS_STREAM: {
- CMpegSplitterFile::hdmvsubhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : nullptr)) {
- m_bIsHdmv = true;
- type = subpic;
- }
- }
- break;
- }
- }
- } else if ((m_AC3CoreOnly != 1) && m_init) {
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const program* pProgram = FindProgram(s.pid, iProgram, pClipInfo);
- if ((type == unknown) && (pProgram != nullptr) && AUDIO_STREAM_AC3_TRUE_HD == pProgram->streams[iProgram].type) {
- const stream* source = m_streams[audio].FindStream(s.pid);
- if (source && source->mt.subtype == MEDIASUBTYPE_DOLBY_AC3) {
- CMpegSplitterFile::ac3hdr h;
- if (Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1)) && s.mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- m_streams[audio].Replace((stream&)*source, s, this);
- }
- }
- }
- }
- } else if (pesid == 0xfd) {
- CMpegSplitterFile::vc1hdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
- type = video;
- }
- } else {
- BYTE b = (BYTE)BitRead(8, true);
- WORD w = (WORD)BitRead(16, true);
- DWORD dw = (DWORD)BitRead(32, true);
-
- if (b >= 0x80 && b < 0x88 || w == 0x0b77) { // ac3
- s.ps1id = (b >= 0x80 && b < 0x88) ? (BYTE)(BitRead(32) >> 24) : 0x80;
-
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) { // dts
- s.ps1id = (b >= 0x88 && b < 0x90) ? (BYTE)(BitRead(32) >> 24) : 0x88;
-
- CMpegSplitterFile::dtshdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0xa0 && b < 0xa8) { // lpcm
- s.ps1id = (BYTE)BitRead(8);
-
- do {
- // DVD-Audio LPCM
- if (b == 0xa0) {
- BitRead(8); // Continuity Counter - counts from 0x00 to 0x1f and then wraps to 0x00.
- DWORD headersize = (DWORD)BitRead(16); // LPCM_header_length
- if (headersize >= 8 && headersize + 4 < len) {
- CMpegSplitterFile::dvdalpcmhdr h;
- if (Read(h, len - 4, &s.mt)) {
- Seek(start + 4 + headersize);
- type = audio;
- break;
- }
- }
- }
- // DVD-Audio MLP
- else if (b == 0xa1 && len > 10) {
- BYTE counter = (BYTE)BitRead(8); // Continuity Counter: 0x00..0x1f or 0x20..0x3f or 0x40..0x5f
- BitRead(8); // some unknown data
- DWORD headersize = (DWORD)BitRead(8); // MLP_header_length (always equal 6?)
- BitRead(32); // some unknown data
- WORD unknown1 = (WORD)BitRead(16); // 0x0000 or 0x0400
- if (counter <= 0x5f && headersize == 6 && (unknown1 == 0x0000 || unknown1 == 0x0400)) { // Maybe it's MLP?
- // MLP header may be missing in the first package
- CMpegSplitterFile::mlphdr h;
- if (!m_streams[audio].Find(s) && Read(h, len - 10, &s.mt, true)) {
- // This is exactly the MLP.
- Seek(start + 10);
- type = audio;
- }
- Seek(start + 10);
- break;
- }
- }
-
- // DVD LPCM
- if (m_streams[audio].Find(s)) {
- Seek(start + 7);
- } else {
- Seek(start + 4);
- CMpegSplitterFile::lpcmhdr h;
- if (Read(h, &s.mt)) {
- type = audio;
- }
- }
- } while (false);
- } else if (b >= 0x20 && b < 0x40) { // DVD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::dvdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (b >= 0x70 && b < 0x80) { // SVCD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::svcdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (b >= 0x00 && b < 0x10) { // CVD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::cvdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (w == 0xffa0 || w == 0xffa1) { // ps2-mpg audio
- s.ps1id = (BYTE)BitRead(8);
- s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0xa000 | track id
-
- CMpegSplitterFile::ps2audhdr h;
- if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
- type = audio;
- }
- } else if (w == 0xff90) { // ps2-mpg ac3 or subtitles
- s.ps1id = (BYTE)BitRead(8);
- s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0x9000 | track id
-
- w = (WORD)BitRead(16, true);
-
- if (w == 0x0b77) {
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (w == 0x0000) { // usually zero...
- CMpegSplitterFile::ps2subhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- }
- } else if (b >= 0xc0 && b < 0xcf) { // dolby digital/dolby digital +
- s.ps1id = (BYTE)BitRead(8);
- // skip audio header - 3-byte
- BitRead(8);
- BitRead(8);
- BitRead(8);
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0xb0 && b < 0xbf) { // truehd
- s.ps1id = (BYTE)BitRead(8);
- // skip audio header - 3-byte
- BitRead(8);
- BitRead(8);
- BitRead(8);
- // TrueHD audio has a 4-byte header
- BitRead(8);
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, false, false)) {
- type = audio;
- }
- }
- }
- } else if (pesid == 0xbe) { // padding
- } else if (pesid == 0xbf) { // private stream 2
- }
-
- if (type != unknown && !m_streams[type].Find(s)) {
- if (s.pid) {
- for (int i = 0; i < unknown; i++) {
- if (m_streams[i].Find(s)) {
- return s;
- }
- }
- }
-
- m_streams[type].Insert(s, this);
- }
-
- return s;
-}
-
-void CMpegSplitterFile::AddHdmvPGStream(WORD pid, const char* language_code)
-{
- stream s;
-
- s.pid = pid;
- s.pesid = 0xbd;
-
- CMpegSplitterFile::hdmvsubhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
- m_streams[subpic].Insert(s, this);
- }
-}
-
-CAtlList<CMpegSplitterFile::stream>* CMpegSplitterFile::GetMasterStream()
-{
- return
- !m_streams[video].IsEmpty() ? &m_streams[video] :
- !m_streams[audio].IsEmpty() ? &m_streams[audio] :
- !m_streams[subpic].IsEmpty() ? &m_streams[subpic] :
-#if defined(MVC_SUPPORT)
- !m_streams[stereo].IsEmpty() ? &m_streams[stereo] :
-#endif
- nullptr;
-}
-
-void CMpegSplitterFile::UpdatePrograms(const tshdr& h, bool UpdateLang)
-{
- CAutoLock cAutoLock(&m_csProps);
-
- if (h.payload && h.payloadstart && h.pid == 0) {
- trsechdr h2;
- if (Read(h2) && h2.table_id == 0) {
- CAtlMap<WORD, bool> newprograms;
-
- int len = h2.section_length;
- len -= 5 + 4;
-
- for (int i = len / 4; i > 0; i--) {
- WORD program_number = (WORD)BitRead(16);
- BYTE reserved = (BYTE)BitRead(3);
- WORD pid = (WORD)BitRead(13);
- UNREFERENCED_PARAMETER(reserved);
- if (program_number != 0) {
- m_programs[pid].program_number = program_number;
- newprograms[program_number] = true;
- }
- }
-
- POSITION pos = m_programs.GetStartPosition();
- while (pos) {
- const CAtlMap<WORD, program>::CPair* pPair = m_programs.GetNext(pos);
-
- if (!newprograms.Lookup(pPair->m_value.program_number)) {
- m_programs.RemoveKey(pPair->m_key);
- }
- }
- }
- } else if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
- if (h.payload && h.payloadstart) {
- trsechdr h2;
- if (Read(h2) && h2.table_id == 2) {
- int len = h2.section_length;
- len -= 5 + 4;
-
- BYTE buffer[1024];
- ByteRead(buffer, len);
-
- int max_len = h.bytes - 9;
-
- if (len > max_len) {
- ZeroMemory(pPair->m_value.ts_buffer, sizeof(pPair->m_value.ts_buffer));
- pPair->m_value.ts_len_cur = max_len;
- pPair->m_value.ts_len_packet = len;
- memcpy(pPair->m_value.ts_buffer, buffer, max_len);
- } else {
- CGolombBuffer gb(buffer, len);
- UpdatePrograms(gb, h.pid, UpdateLang);
- }
- }
- } else {
- if (pPair->m_value.ts_len_cur > 0) {
- int len = pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur;
- if (len > h.bytes) {
- ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, h.bytes);
- pPair->m_value.ts_len_cur += h.bytes;
- } else {
- ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
- CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
- UpdatePrograms(gb, h.pid, UpdateLang);
- }
- }
- }
- }
-}
-
-void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang)
-{
- if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(pid)) {
- ZeroMemory(pPair->m_value.streams, sizeof(pPair->m_value.streams));
-
- int len = gb.GetSize();
-
- BYTE reserved1 = (BYTE)gb.BitRead(3);
- WORD PCR_PID = (WORD)gb.BitRead(13);
- BYTE reserved2 = (BYTE)gb.BitRead(4);
- WORD program_info_length = (WORD)gb.BitRead(12);
- UNREFERENCED_PARAMETER(reserved1);
- UNREFERENCED_PARAMETER(PCR_PID);
- UNREFERENCED_PARAMETER(reserved2);
-
- len -= (4 + program_info_length);
- if (len <= 0) {
- return;
- }
-
- while (program_info_length-- > 0) {
- gb.BitRead(8);
- }
-
- for (int i = 0; i < _countof(pPair->m_value.streams) && len >= 5; i++) {
- BYTE stream_type = (BYTE)gb.BitRead(8);
- BYTE nreserved1 = (BYTE)gb.BitRead(3);
- WORD pid = (WORD)gb.BitRead(13);
- BYTE nreserved2 = (BYTE)gb.BitRead(4);
- WORD ES_info_length = (WORD)gb.BitRead(12);
- UNREFERENCED_PARAMETER(nreserved1);
- UNREFERENCED_PARAMETER(nreserved2);
-
- pPair->m_value.streams[i].pid = pid;
- pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
-
- if (m_ForcedSub) {
- if (stream_type == PRESENTATION_GRAPHICS_STREAM) {
- stream s;
- s.pid = pid;
- CMpegSplitterFile::hdmvsubhdr hdr;
- if (Read(hdr, &s.mt, nullptr)) {
- if (!m_streams[subpic].Find(s)) {
- m_streams[subpic].Insert(s, this);
- }
- }
- }
- }
-
- len -= (5 + ES_info_length);
- if (len < 0) {
- break;
- }
- if (ES_info_length <= 2) {
- continue;
- }
-
- if (UpdateLang) {
- int info_length = ES_info_length;
- for (;;) {
- BYTE descriptor_tag = (BYTE)gb.BitRead(8);
- BYTE descriptor_length = (BYTE)gb.BitRead(8);
- info_length -= (2 + descriptor_length);
- if (info_length < 0) {
- break;
- }
- char ch[4];
- switch (descriptor_tag) {
- case 0x0a: // ISO 639 language descriptor
- case 0x56: // Teletext descriptor
- case 0x59: // Subtitling descriptor
- gb.ReadBuffer((BYTE*)ch, 3);
- ch[3] = 0;
- for (int j = 3; j < descriptor_length; j++) {
- gb.BitRead(8);
- }
- if (!(ch[0] == 'u' && ch[1] == 'n' && ch[2] == 'd')) {
- m_pPMT_Lang[pid] = ISO6392ToLanguage(ch);
- }
- break;
- default:
- for (int j = 0; j < descriptor_length; j++) {
- gb.BitRead(8);
- }
- break;
- }
- if (info_length <= 2) {
- break;
- }
- }
- } else {
- while (ES_info_length-- > 0) {
- gb.BitRead(8);
- }
- }
- }
- pPair->m_value.ts_len_cur = 0;
- pPair->m_value.ts_len_packet = 0;
- }
-}
-
-UINT32 SwapLE(const UINT32& _Value)
-{
- return (_Value & 0xFF) << 24 | ((_Value >> 8) & 0xFF) << 16 | ((_Value >> 16) & 0xFF) << 8 | ((_Value >> 24) & 0xFF) << 0;
-}
-
-UINT16 SwapLE(const UINT16& _Value)
-{
- return (_Value & 0xFF) << 8 | ((_Value >> 8) & 0xFF) << 0;
-}
-
-const CMpegSplitterFile::program* CMpegSplitterFile::FindProgram(WORD pid, int& iStream, const CHdmvClipInfo::Stream*& _pClipInfo)
-{
- _pClipInfo = m_ClipInfo.FindStream(pid);
-
- iStream = -1;
-
- POSITION pos = m_programs.GetStartPosition();
-
- while (pos) {
- program* p = &m_programs.GetNextValue(pos);
-
- for (int i = 0; i < _countof(p->streams); i++) {
- if (p->streams[i].pid == pid) {
- iStream = i;
- return p;
- }
- }
- }
-
- return nullptr;
-}
-
-bool CMpegSplitterFile::GetStreamType(WORD pid, PES_STREAM_TYPE& stream_type)
-{
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const program* pProgram = FindProgram(pid, iProgram, pClipInfo);
- if (pProgram) {
- stream_type = pProgram->streams[iProgram].type;
-
- if (stream_type != INVALID) {
- return true;
- }
- }
-
- return false;
-}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
deleted file mode 100644
index 38a7c813e..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "../../../DSUtil/GolombBuffer.h"
-
-#define NO_SUBTITLE_PID 1 // Fake PID use for the "No subtitle" entry
-#define NO_SUBTITLE_NAME _T("No subtitle")
-
-#define ISVALIDPID(pid) (pid >= 0x10 && pid < 0x1fff)
-
-//#define MVC_SUPPORT
-
-class CMpegSplitterFile : public CBaseSplitterFileEx
-{
- CAtlMap<WORD, BYTE> m_pid2pes;
- CAtlMap<WORD, CMpegSplitterFile::avchdr> avch;
- bool m_bIsHdmv;
- bool m_init;
-
- HRESULT Init(IAsyncReader* pAsyncReader);
-
- void OnComplete(IAsyncReader* pAsyncReader);
-
-public:
- CHdmvClipInfo& m_ClipInfo;
- CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv,
- CHdmvClipInfo& ClipInfo, int guid_flag, bool ForcedSub,
- int AC3CoreOnly, bool m_AlternativeDuration);
-
- REFERENCE_TIME NextPTS(DWORD TrackNum);
-
- CCritSec m_csProps;
-
- MPEG_TYPES m_type;
-
- REFERENCE_TIME m_rtMin, m_rtMax;
- __int64 m_posMin, m_posMax;
- REFERENCE_TIME m_rtPrec;
- bool m_bPTSWrap;
- int m_rate; // byte/sec
-
- int m_nVC1_GuidFlag, m_AC3CoreOnly;
- bool m_ForcedSub, m_AlternativeDuration;
-
- struct stream {
- CMpegSplitterFile* m_pFile;
- CMediaType mt;
- WORD pid;
- BYTE pesid, ps1id;
- struct stream()
- : m_pFile(0) {
- pid = pesid = ps1id = 0;
- }
- operator DWORD() const {
- return pid ? pid : ((pesid << 8) | ps1id);
- }
- bool operator == (const struct stream& s) const {
- return (DWORD) * this == (DWORD)s;
- }
- };
-
- enum {
- video,
- audio,
- subpic,
-#if defined(MVC_SUPPORT)
- stereo,
-#endif
- unknown
- };
-
- class CStreamList : public CAtlList<stream>
- {
- public:
- void Insert(stream& s, CMpegSplitterFile* _pFile) {
- s.m_pFile = _pFile;
- AddTail(s);
- if (GetCount() > 1) {
- for (size_t j = 0; j < GetCount(); j++) {
- for (size_t i = 0; i < GetCount() - 1; i++) {
- if (GetAt(FindIndex(i)) > GetAt(FindIndex(i + 1))) {
- SwapElements(FindIndex(i), FindIndex(i + 1));
- }
- }
- }
- }
- }
-
- void Replace(stream& source, stream& dest, CMpegSplitterFile* _pFile) {
- source.m_pFile = _pFile;
- dest.m_pFile = _pFile;
- for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
- stream& s = GetAt(pos);
- if (source == s) {
- SetAt(pos, dest);
- return;
- }
- }
- }
-
- static CStringW ToString(int type) {
- return
- type == video ? L"Video" :
- type == audio ? L"Audio" :
- type == subpic ? L"Subtitle" :
-#if defined(MVC_SUPPORT)
- type == stereo ? L"Stereo" :
-#endif
- L"Unknown";
- }
-
- const stream* FindStream(int pid) {
- for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
- const stream& s = GetAt(pos);
- if (s.pid == pid) {
- return &s;
- }
- }
-
- return nullptr;
- }
-
- } m_streams[unknown];
-
- HRESULT SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader, BOOL CalcDuration = FALSE);
- DWORD AddStream(WORD pid, BYTE pesid, BYTE ps1id, DWORD len);
- void AddHdmvPGStream(WORD pid, const char* language_code);
- CAtlList<stream>* GetMasterStream();
- bool IsHdmv() { return m_bIsHdmv; };
-
- struct program {
- WORD program_number;
- struct stream {
- WORD pid;
- PES_STREAM_TYPE type;
-
- };
- stream streams[64];
- struct program() {
- ZeroMemory(this, sizeof(*this));
- }
-
- BYTE ts_buffer[1024];
- WORD ts_len_cur, ts_len_packet;
- };
-
- CAtlMap<WORD, program> m_programs;
-
- void SearchPrograms(__int64 start, __int64 stop);
- void UpdatePrograms(const tshdr& h, bool UpdateLang = true);
- void UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang = true);
- const program* FindProgram(WORD pid, int& iStream, const CHdmvClipInfo::Stream*& _pClipInfo);
-
- CAtlMap<DWORD, CString> m_pPMT_Lang;
-
- bool GetStreamType(WORD pid, PES_STREAM_TYPE& stream_type);
-};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp
deleted file mode 100644
index dbdd7c0b9..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MpegSplitterSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "resource.h"
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-
-
-CMpegSplitterSettingsWnd::CMpegSplitterSettingsWnd()
-{
-}
-
-bool CMpegSplitterSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pMSF);
-
- m_pMSF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMSF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pMSF) {
- return false;
- }
-
- return true;
-}
-
-void CMpegSplitterSettingsWnd::OnDisconnect()
-{
- m_pMSF.Release();
-}
-
-bool CMpegSplitterSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- const int h25 = IPP_SCALE(25);
- const int h30 = IPP_SCALE(30);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
-
- m_cbFastStreamChange.Create(ResStr(IDS_MPEGSPLITTER_FSTREAM_CHANGE), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(305), m_fontheight)), this, IDC_PP_FAST_STREAM_SELECT);
- p.y += h20;
-
- m_cbForcedSub.Create(ResStr(IDS_MPEGSPLITTER_SUB_FORCING), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(305), m_fontheight)), this, IDC_PP_SUBTITLE_FORCED);
- p.y += h20;
-
- m_cbAlternativeDuration.Create(ResStr(IDS_MPEGSPLITTER_ALT_DUR_CALC), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(305), m_fontheight)), this, IDC_PP_ALTERNATIVE_DURATION);
- p.y += h20;
-
- m_txtAudioLanguageOrder.Create(ResStr(IDS_MPEGSPLITTER_LANG_ORDER), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(200), m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_edtAudioLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(p, CSize(IPP_SCALE(305), m_fontheight + 6)), this, IDC_PP_AUDIO_LANGUAGE_ORDER);
- p.y += h25;
-
- m_txtSubtitlesLanguageOrder.Create(ResStr(IDS_MPEGSPLITTER_SUB_ORDER), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(200), m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_edtSubtitlesLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(p, CSize(IPP_SCALE(305), m_fontheight + 6)), this, IDC_PP_SUBTITLES_LANGUAGE_ORDER);
- p.y += h25;
-
- m_txtVC1_GuidFlag.Create(ResStr(IDS_MPEGSPLITTER_VC1_GUIDFLAG), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(200), m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_cbVC1_GuidFlag.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p, CSize(IPP_SCALE(305), 200)), this, IDC_PP_VC1_GUIDFLAG);
- m_cbVC1_GuidFlag.AddString(_T("Default"));
- m_cbVC1_GuidFlag.AddString(_T("Cyberlink VC-1 Decoder"));
- m_cbVC1_GuidFlag.AddString(_T("ArcSoft VC-1 Decoder"));
- SetClassLongPtr(GetDlgItem(IDC_PP_VC1_GUIDFLAG)->m_hWnd, GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
- p.y += h30;
-
- m_grpTrueHD.Create(ResStr(IDS_MPEGSPLITTER_TRUEHD_OUTPUT), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(305), h20 + h20)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_cbTrueHD.Create(_T("TrueHD"), dwStyle | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE | WS_GROUP, CRect(p, CSize(IPP_SCALE(60), m_fontheight + 2)), this, IDC_PP_TRUEHD);
- m_cbAC3Core.Create(_T("AC-3"), dwStyle | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE, CRect(p + CPoint(IPP_SCALE(100), 0), CSize(IPP_SCALE(60), m_fontheight + 2)), this, IDC_PP_AC3CORE);
- m_cbAsIs.Create(ResStr(IDS_MPEGSPLITTER_THD_NOSPLIT), dwStyle | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE, CRect(p + CPoint(IPP_SCALE(200), 0), CSize(IPP_SCALE(95), m_fontheight + 2)), this, IDC_PP_ASIS);
-
- if (m_pMSF) {
- m_cbFastStreamChange.SetCheck(m_pMSF->GetFastStreamChange());
- m_cbForcedSub.SetCheck(m_pMSF->GetForcedSub());
- m_edtAudioLanguageOrder.SetWindowText(m_pMSF->GetAudioLanguageOrder());
- m_edtSubtitlesLanguageOrder.SetWindowText(m_pMSF->GetSubtitlesLanguageOrder());
- m_cbVC1_GuidFlag.SetCurSel(m_pMSF->GetVC1_GuidFlag() - 1);
- m_cbTrueHD.SetCheck(m_pMSF->GetTrueHD() == 0);
- m_cbAC3Core.SetCheck(m_pMSF->GetTrueHD() == 1);
- m_cbAsIs.SetCheck(!m_cbTrueHD.GetCheck() && !m_cbAC3Core.GetCheck());
- m_cbAlternativeDuration.SetCheck(m_pMSF->GetAlternativeDuration());
- }
-
-#ifndef STANDALONE_FILTER
- m_edtAudioLanguageOrder.EnableWindow(FALSE);
- m_edtSubtitlesLanguageOrder.EnableWindow(FALSE);
-#endif
-
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CMpegSplitterSettingsWnd::OnDeactivate()
-{
-}
-
-bool CMpegSplitterSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pMSF) {
- m_pMSF->SetFastStreamChange(m_cbFastStreamChange.GetCheck());
- m_pMSF->SetForcedSub(m_cbForcedSub.GetCheck());
- m_pMSF->SetVC1_GuidFlag(m_cbVC1_GuidFlag.GetCurSel() + 1);
- m_pMSF->SetTrueHD(m_cbTrueHD.GetCheck() ? 0 : m_cbAC3Core.GetCheck() ? 1 : 2);
- m_pMSF->SetAlternativeDuration(m_cbAlternativeDuration.GetCheck());
-
-#ifdef STANDALONE_FILTER
- CString str = _T("");
- m_edtAudioLanguageOrder.GetWindowText(str);
- m_pMSF->SetAudioLanguageOrder(str.GetBuffer());
- m_edtSubtitlesLanguageOrder.GetWindowText(str);
- m_pMSF->SetSubtitlesLanguageOrder(str.GetBuffer());
-#endif
- m_pMSF->Apply();
- }
-
- return true;
-}
-
-BEGIN_MESSAGE_MAP(CMpegSplitterSettingsWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h
deleted file mode 100644
index cff9f9479..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "IMpegSplitterFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("44FCB62D-3AEB-401C-A7E1-8A984C017923"))
- CMpegSplitterSettingsWnd : public CInternalPropertyPageWnd
-{
-private:
- CComQIPtr<IMpegSplitterFilter> m_pMSF;
-
- CButton m_cbFastStreamChange;
- CButton m_cbForcedSub;
- CButton m_cbAlternativeDuration;
- CStatic m_txtAudioLanguageOrder;
- CEdit m_edtAudioLanguageOrder;
- CStatic m_txtSubtitlesLanguageOrder;
- CEdit m_edtSubtitlesLanguageOrder;
- CStatic m_txtVC1_GuidFlag;
- CComboBox m_cbVC1_GuidFlag;
-
- CButton m_grpTrueHD;
- CButton m_cbTrueHD;
- CButton m_cbAC3Core;
- CButton m_cbAsIs;
-
- enum {
- IDC_PP_FAST_STREAM_SELECT = 10000,
- IDC_PP_SUBTITLE_FORCED,
- IDC_PP_AUDIO_LANGUAGE_ORDER,
- IDC_PP_SUBTITLES_LANGUAGE_ORDER,
- IDC_PP_VC1_GUIDFLAG,
- IDC_PP_TRUEHD,
- IDC_PP_AC3CORE,
- IDC_PP_ASIS,
- IDC_PP_ALTERNATIVE_DURATION
- };
-
-public:
- CMpegSplitterSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(320, 260); }
-
- DECLARE_MESSAGE_MAP()
-};
diff --git a/src/filters/parser/MpegSplitter/resource.h b/src/filters/parser/MpegSplitter/resource.h
deleted file mode 100644
index cbb3855c0..000000000
--- a/src/filters/parser/MpegSplitter/resource.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MpegSplitter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_MPEGSPLITTER_FSTREAM_CHANGE 7200
-#define IDS_MPEGSPLITTER_SUB_FORCING 7201
-#define IDS_MPEGSPLITTER_ALT_DUR_CALC 7202
-#define IDS_MPEGSPLITTER_LANG_ORDER 7203
-#define IDS_MPEGSPLITTER_SUB_ORDER 7205
-#define IDS_MPEGSPLITTER_VC1_GUIDFLAG 7206
-#define IDS_MPEGSPLITTER_TRUEHD_OUTPUT 7207
-#define IDS_MPEGSPLITTER_THD_NOSPLIT 7208
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MpegSplitter/stdafx.cpp b/src/filters/parser/MpegSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MpegSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MpegSplitter/stdafx.h b/src/filters/parser/MpegSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/MpegSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/OggSplitter/OggFile.cpp b/src/filters/parser/OggSplitter/OggFile.cpp
deleted file mode 100644
index eebab48a1..000000000
--- a/src/filters/parser/OggSplitter/OggFile.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "OggFile.h"
-
-COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
-{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
-}
-
-HRESULT COggFile::Init()
-{
- Seek(0);
- if (!Sync()) {
- return E_FAIL;
- }
-
- return S_OK;
-}
-
-bool COggFile::Sync(HANDLE hBreak)
-{
- __int64 start = GetPos();
-
- DWORD dw;
- for (__int64 i = 0, j = hBreak ? GetLength() - start : MAX_PROBE_SIZE;
- i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw))
- && ((i & 0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0);
- i++, Seek(start + i)) {
- if (dw == 'SggO') {
- Seek(start + i);
- return true;
- }
- }
-
- Seek(start);
-
- return false;
-}
-
-bool COggFile::Read(OggPageHeader& hdr, HANDLE hBreak)
-{
- return Sync(hBreak) && S_OK == ByteRead((BYTE*)&hdr, sizeof(hdr)) && hdr.capture_pattern == 'SggO';
-}
-
-bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak)
-{
- ZeroMemory(&page.m_hdr, sizeof(page.m_hdr));
- page.m_lens.RemoveAll();
- page.SetCount(0);
-
- if (!Read(page.m_hdr, hBreak)) {
- return false;
- }
-
- int pagelen = 0, packetlen = 0;
- for (BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
- BYTE b;
- if (S_OK != ByteRead(&b, 1)) {
- return false;
- }
- packetlen += b;
- if (1/*b < 0xff*/) {
- page.m_lens.AddTail(packetlen);
- pagelen += packetlen;
- packetlen = 0;
- }
- }
-
- if (fFull) {
- page.SetCount(pagelen);
- if (S_OK != ByteRead(page.GetData(), page.GetCount())) {
- return false;
- }
- } else {
- Seek(GetPos() + pagelen);
- page.m_lens.RemoveAll();
- }
-
- return true;
-}
diff --git a/src/filters/parser/OggSplitter/OggFile.h b/src/filters/parser/OggSplitter/OggFile.h
deleted file mode 100644
index 4c7cff2c4..000000000
--- a/src/filters/parser/OggSplitter/OggFile.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-
-#pragma pack(push, 1)
-
-struct OggPageHeader {
- DWORD capture_pattern;
- BYTE stream_structure_version;
- BYTE header_type_flag;
- enum { continued = 1, first = 2, last = 4 };
- __int64 granule_position;
- DWORD bitstream_serial_number;
- DWORD page_sequence_number;
- DWORD CRC_checksum;
- BYTE number_page_segments;
-};
-
-struct OggVorbisIdHeader {
- DWORD vorbis_version;
- BYTE audio_channels;
- DWORD audio_sample_rate;
- DWORD bitrate_maximum;
- DWORD bitrate_nominal;
- DWORD bitrate_minimum;
- BYTE blocksize_0: 4;
- BYTE blocksize_1: 4;
- BYTE framing_flag;
-};
-
-struct OggVideoHeader {
- DWORD w, h;
-};
-
-struct OggAudioHeader {
- WORD nChannels, nBlockAlign;
- DWORD nAvgBytesPerSec;
-};
-
-struct OggStreamHeader {
- char streamtype[8], subtype[4];
- DWORD size;
- __int64 time_unit, samples_per_unit;
- DWORD default_len;
- DWORD buffersize;
- WORD bps;
- WORD alignmentfix1;
- union {
- OggVideoHeader v;
- OggAudioHeader a;
- };
- DWORD alignmentfix2;
-};
-#pragma pack(pop)
-
-class OggPage : public CAtlArray<BYTE>
-{
-public:
- OggPageHeader m_hdr;
- CAtlList<int> m_lens;
- OggPage() {
- ZeroMemory(&m_hdr, sizeof(m_hdr));
- }
-};
-
-class COggFile : public CBaseSplitterFile
-{
- HRESULT Init();
-
-public:
- COggFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- bool Sync(HANDLE hBreak = nullptr);
- bool Read(OggPageHeader& hdr, HANDLE hBreak = nullptr);
- bool Read(OggPage& page, bool fFull = true, HANDLE hBreak = nullptr);
-};
diff --git a/src/filters/parser/OggSplitter/OggSplitter.cpp b/src/filters/parser/OggSplitter/OggSplitter.cpp
deleted file mode 100644
index 39ed7ee1b..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.cpp
+++ /dev/null
@@ -1,1318 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "OggSplitter.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/GolombBuffer.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-# define TH_VERSION_CHECK(version_major,version_minor,version_subminor,_maj,_min,_sub) \
- (version_major>(_maj)||version_major==(_maj)&& \
- (version_minor>(_min)||version_minor==(_min)&& \
- version_subminor>=(_sub)))
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(COggSplitterFilter), OggSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(COggSourceFilter), OggSourceName, MERIT_NORMAL + 1, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<COggSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<COggSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Ogg,
- _T("0,4,,4F676753"), // OggS
- _T(".ogg"), _T(".ogm"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_Ogg);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// bitstream
-//
-
-class bitstream
-{
- BYTE* m_p;
- int m_len, m_pos;
-public:
- bitstream(BYTE* p, int len, bool rev = false) : m_p(p), m_len(len * 8) {
- m_pos = !rev ? 0 : len * 8;
- }
- bool hasbits(int cnt) {
- int pos = m_pos + cnt;
- return (pos >= 0 && pos < m_len);
- }
- unsigned int showbits(int cnt) { // a bit unclean, but works and can read backwards too! :P
- if (!hasbits(cnt)) {
- ASSERT(0);
- return 0;
- }
- unsigned int ret = 0, off = 0;
- BYTE* p = m_p;
- if (cnt < 0) {
- p += (m_pos + cnt) >> 3;
- off = (m_pos + cnt) & 7;
- cnt = abs(cnt);
- ret = (*p++ & (~0 << off)) >> off;
- off = 8 - off;
- cnt -= off;
- } else {
- p += m_pos >> 3;
- off = m_pos & 7;
- ret = (*p++ >> off) & ((1 << min(cnt, 8)) - 1);
- off = 0;
- cnt -= 8 - off;
- }
- while (cnt > 0) {
- ret |= (*p++ & ((1 << min(cnt, 8)) - 1)) << off;
- off += 8;
- cnt -= 8;
- }
- return ret;
- }
- unsigned int getbits(int cnt) {
- unsigned int ret = showbits(cnt);
- m_pos += cnt;
- return ret;
- }
-};
-
-//
-// COggSplitterFilter
-//
-
-COggSplitterFilter::COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("COggSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-COggSplitterFilter::~COggSplitterFilter()
-{
-}
-
-STDMETHODIMP COggSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, OggSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DEBUG_NEW COggFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = 0;
-
- m_rtDuration = 0;
-
- m_pFile->Seek(0);
- OggPage page;
- for (int i = 0, nWaitForMore = 0; m_pFile->Read(page), i < 100; i++) {
- BYTE* p = page.GetData();
- if (!p) {
- break;
- }
-
- if (!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
- if (!memcmp(p, "fishead", 7) || !memcmp(p, "fisbone", 7)) {
- continue;
- }
-
- BYTE type = *p++;
-
- CStringW name;
- name.Format(L"Stream %d", i);
-
- HRESULT hr2;
-
- if (type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
- if (type == 0x80) {
- name.Format(L"Theora %d", i);
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- pPinOut.Attach(DEBUG_NEW COggTheoraOutputPin(page.GetData(), name, this, this, &hr2));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- nWaitForMore++;
- }
- } else if (type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
-
- if (!memcmp(p, "vorbis", 6)) {
- if ((*(OggVorbisIdHeader*)(p + 6)).audio_sample_rate == 0) {
- return E_FAIL; // fix crash on broken files
- }
- name.Format(L"Vorbis %d", i);
- pPinOut.Attach(DEBUG_NEW COggVorbisOutputPin((OggVorbisIdHeader*)(p + 6), name, this, this, &hr2));
- nWaitForMore++;
- } else if (!memcmp(p, "video", 5)) {
- name.Format(L"Video %d", i);
- pPinOut.Attach(DEBUG_NEW COggVideoOutputPin((OggStreamHeader*)p, name, this, this, &hr2));
- } else if (!memcmp(p, "audio", 5)) {
- name.Format(L"Audio %d", i);
- pPinOut.Attach(DEBUG_NEW COggAudioOutputPin((OggStreamHeader*)p, name, this, this, &hr2));
- } else if (!memcmp(p, "text", 4)) {
- name.Format(L"Text %d", i);
- pPinOut.Attach(DEBUG_NEW COggTextOutputPin((OggStreamHeader*)p, name, this, this, &hr2));
- } else if (!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
- name.Format(L"DirectShow %d", i);
- pPinOut.Attach(DEBUG_NEW COggDirectShowOutputPin((AM_MEDIA_TYPE*)(p + 35 + sizeof(GUID)), name, this, this, &hr2));
- }
-
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- } else if (type == 3 && !memcmp(p, "vorbis", 6)) {
- if (COggSplitterOutputPin* pOggPin =
- dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- pOggPin->AddComment(p + 6, (int)page.GetCount() - 6 - 1);
- }
- } else if (type == 0x7F && page.GetCount() > 12 && *(long*)(p + 8) == 0x43614C66) { // Flac
- // Ogg Flac : method 1
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- name.Format(L"FLAC %d", i);
- pPinOut.Attach(DEBUG_NEW COggFlacOutputPin(p + 12, (int)page.GetCount() - 14, name, this, this, &hr2));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- } else if (*(long*)(p - 1) == 0x43614C66) {
- //bFlac = true;
- //nWaitForMore++;
- if (m_pFile->Read(page)) {
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- name.Format(L"FLAC %d", i);
- p = page.GetData();
- pPinOut.Attach(DEBUG_NEW COggFlacOutputPin(p, (int)page.GetCount(), name, this, this, &hr2));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- }
- } else if (!(type & 1) && nWaitForMore == 0) {
- break;
- }
- }
-
- if (COggTheoraOutputPin* ptr = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- ptr->UnpackInitPage(page);
- if (ptr->IsInitialized()) {
- nWaitForMore--;
- }
- }
-
- if (COggVorbisOutputPin* ptr = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- ptr->UnpackInitPage(page);
- if (ptr->IsInitialized()) {
- nWaitForMore--;
- }
- }
- }
-
- if (m_pOutputs.IsEmpty()) {
- return E_FAIL;
- }
-
- if (m_pFile->IsRandomAccess()) {
- m_pFile->Seek(max(m_pFile->GetLength() - MAX_PROBE_SIZE, 0));
-
- OggPage ppage;
- while (m_pFile->Read(ppage)) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(ppage.m_hdr.bitstream_serial_number));
- if (!pOggPin || ppage.m_hdr.granule_position == -1) {
- continue;
- }
- REFERENCE_TIME rt = pOggPin->GetRefTime(ppage.m_hdr.granule_position);
- m_rtDuration = max(rt, m_rtDuration);
- }
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- // comments
-
- {
- CAtlMap<CStringW, CStringW, CStringElementTraits<CStringW>> tagmap;
- tagmap[L"TITLE"] = L"TITL";
- tagmap[L"ARTIST"] = L"AUTH"; // not quite
- tagmap[L"COPYRIGHT"] = L"CPYR";
- tagmap[L"DESCRIPTION"] = L"DESC";
-
- POSITION pos2 = tagmap.GetStartPosition();
- while (pos2) {
- CStringW oggtag, dsmtag;
- tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if (!pOggPin) {
- continue;
- }
-
- CStringW value = pOggPin->GetComment(oggtag);
- if (!value.IsEmpty()) {
- SetProperty(dsmtag, value);
- break;
- }
- }
- }
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos && !ChapGetCount()) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if (!pOggPin) {
- continue;
- }
-
- for (int i = 1; pOggPin; i++) {
- CStringW key;
- key.Format(L"CHAPTER%02d", i);
- CStringW time = pOggPin->GetComment(key);
- if (time.IsEmpty()) {
- break;
- }
- key.Format(L"CHAPTER%02dNAME", i);
- CStringW name = pOggPin->GetComment(key);
- if (name.IsEmpty()) {
- name.Format(L"Chapter %d", i);
- }
- int h, m, s, ms;
- WCHAR c;
- if (7 != swscanf_s(time, L"%d%c%d%c%d%c%d", &h, &c, 1, &m, &c, 1, &s, &c, 1, &ms)) {
- break;
- }
- REFERENCE_TIME rt = ((((REFERENCE_TIME)h * 60 + m) * 60 + s) * 1000 + ms) * 10000;
- ChapAppend(rt, name);
- }
- }
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool COggSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "COggSplitterFilter");
- if (!m_pFile) {
- return false;
- }
-
- return true;
-}
-
-void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- if (rt <= 0) {
- m_pFile->Seek(0);
- } else if (m_rtDuration > 0) {
- // oh, the horror...
-
- __int64 len = m_pFile->GetLength();
- __int64 startpos = len * rt / m_rtDuration;
- //__int64 diff = 0;
-
- REFERENCE_TIME rtMinDiff = _I64_MAX;
-
- for (;;) {
- __int64 endpos = startpos;
- REFERENCE_TIME rtPos = -1;
-
- OggPage page;
- m_pFile->Seek(startpos);
- while (m_pFile->Read(page, false)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if (!pOggPin) {
- ASSERT(0);
- continue;
- }
-
- rtPos = pOggPin->GetRefTime(page.m_hdr.granule_position);
- endpos = m_pFile->GetPos();
-
- break;
- }
-
- __int64 rtDiff = rtPos - rt;
-
- if (rtDiff < 0) {
- rtDiff = -rtDiff;
-
- if (rtDiff < 1000000 || rtDiff >= rtMinDiff) {
- m_pFile->Seek(startpos);
- break;
- }
-
- rtMinDiff = rtDiff;
- }
-
- __int64 newpos = startpos;
-
- if (rtPos < rt && rtPos < m_rtDuration) {
- newpos = startpos + (__int64)((1.0 * (rt - rtPos) / (m_rtDuration - rtPos)) * (len - startpos)) + 1024;
- if (newpos < endpos) {
- newpos = endpos + 1024;
- }
- } else if (rtPos > rt && rtPos > 0) {
- newpos = startpos - (__int64)((1.0 * (rtPos - rt) / (rtPos - 0)) * (startpos - 0)) - 1024;
- if (newpos >= startpos) {
- newpos = startpos - 1024;
- }
- } else if (rtPos == rt) {
- m_pFile->Seek(startpos);
- break;
- } else {
- ASSERT(0);
- m_pFile->Seek(0);
- break;
- }
-
- //diff = newpos - startpos;
-
- startpos = max(min(newpos, len), 0);
- }
-
- m_pFile->Seek(startpos);
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
-
- if (!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
- continue;
- }
-
- bool fKeyFrameFound = false, fSkipKeyFrame = true;
- __int64 endpos = _I64_MAX;
-
- while (!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0) {
- OggPage page;
- while (!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- continue;
- }
-
- if (pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
- break;
- }
-
- if (!fKeyFrameFound) {
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (p->bSyncPoint) {
- fKeyFrameFound = true;
- fSkipKeyFrame = p->fSkip;
- }
- }
-
- if (fKeyFrameFound) {
- break;
- }
- } else {
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (!p->fSkip) {
- fSkipKeyFrame = false;
- break;
- }
- }
- }
- }
-
- if (!(fKeyFrameFound && !fSkipKeyFrame)) {
- endpos = startpos;
- startpos = max(startpos - 10 * MAX_PROBE_SIZE, 0);
- }
-
- m_pFile->Seek(startpos);
- }
-
-#ifdef _DEBUG
- // verify kf
-
- {
- fKeyFrameFound = false;
-
- OggPage page;
- while (!fKeyFrameFound && m_pFile->Read(page)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- continue;
- }
-
- REFERENCE_TIME rtPos = pPin->GetRefTime(page.m_hdr.granule_position);
- if (rtPos > rt) {
- break;
- }
-
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (p->bSyncPoint) {
- fKeyFrameFound = true;
- break;
- }
- }
- }
-
- ASSERT(fKeyFrameFound);
-
- m_pFile->Seek(startpos);
- }
-#endif
- break;
- }
- }
-}
-
-bool COggSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- OggPage page;
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->Read(page, true, GetRequestHandle())) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if (!pOggPin) {
- ASSERT(0);
- continue;
- }
- if (!pOggPin->IsConnected()) {
- continue;
- }
- if (FAILED(hr = pOggPin->UnpackPage(page))) {
- ASSERT(0);
- break;
- }
- CAutoPtr<OggPacket> p;
- while (!CheckRequest(nullptr) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
- if (!p->fSkip) {
- hr = DeliverPacket(p);
- }
- }
- }
-
- return true;
-}
-
-//
-// COggSourceFilter
-//
-
-COggSourceFilter::COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : COggSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// COggSplitterOutputPin
-//
-
-COggSplitterOutputPin::COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- ResetState((DWORD) - 1);
-}
-
-void COggSplitterOutputPin::AddComment(BYTE* p, int len)
-{
- bitstream bs(p, len);
- bs.getbits(bs.getbits(32) * 8);
- for (int n = bs.getbits(32); n-- > 0;) {
- CStringA str;
- for (int len2 = bs.getbits(32); len2-- > 0;) {
- str += (CHAR)bs.getbits(8);
- }
-
- CAtlList<CStringA> sl;
- Explode(str, sl, '=', 2);
- if (sl.GetCount() == 2) {
- CAutoPtr<CComment> ptr(DEBUG_NEW CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
-
- if (ptr->m_key == L"LANGUAGE") {
- CString lang = ISO6392ToLanguage(sl.GetTail()), iso6392 = LanguageToISO6392(CString(ptr->m_value));
-
- if (ptr->m_value.GetLength() == 3 && !lang.IsEmpty()) {
- SetName(CStringW(lang));
- SetProperty(L"LANG", ptr->m_value);
- } else if (!iso6392.IsEmpty()) {
- SetName(ptr->m_value);
- SetProperty(L"LANG", CStringW(iso6392));
- } else {
- SetName(ptr->m_value);
- SetProperty(L"NAME", ptr->m_value);
- }
- }
-
- m_pComments.AddTail(ptr);
- }
- }
- ASSERT(bs.getbits(1) == 1);
-}
-
-CStringW COggSplitterOutputPin::GetComment(CStringW key)
-{
- key.MakeUpper();
- CAtlList<CStringW> sl;
- POSITION pos = m_pComments.GetHeadPosition();
- while (pos) {
- CComment* p = m_pComments.GetNext(pos);
- if (key == p->m_key) {
- sl.AddTail(p->m_value);
- }
- }
- return Implode(sl, ';');
-}
-
-void COggSplitterOutputPin::ResetState(DWORD seqnum)
-{
- CAutoLock csAutoLock(&m_csPackets);
- m_packets.RemoveAll();
- m_lastpacket.Free();
- m_lastseqnum = seqnum;
- m_rtLast = 0;
- m_fSkip = true;
-}
-
-HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page)
-{
- if (m_lastseqnum != page.m_hdr.page_sequence_number - 1) {
- ResetState(page.m_hdr.page_sequence_number);
- return S_FALSE; // FIXME
- } else {
- m_lastseqnum = page.m_hdr.page_sequence_number;
- }
-
- POSITION first = page.m_lens.GetHeadPosition();
- while (first && page.m_lens.GetAt(first) == 255) {
- page.m_lens.GetNext(first);
- }
- if (!first) {
- first = page.m_lens.GetTailPosition();
- }
-
- POSITION last = page.m_lens.GetTailPosition();
- while (last && page.m_lens.GetAt(last) == 255) {
- page.m_lens.GetPrev(last);
- }
- if (!last) {
- last = page.m_lens.GetTailPosition();
- }
-
- BYTE* pData = page.GetData();
-
- int i = 0, j = 0, len = 0;
-
- for (POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos)) {
- len = page.m_lens.GetAt(pos);
- j += len;
-
- if (len < 255 || pos == page.m_lens.GetTailPosition()) {
- if (first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
- // ASSERT(m_lastpacket);
-
- if (m_lastpacket) {
- size_t size = m_lastpacket->GetCount();
- m_lastpacket->SetCount(size + j - i);
- memcpy(m_lastpacket->GetData() + size, pData + i, j - i);
-
- CAutoLock csAutoLock(&m_csPackets);
-
- if (len < 255) {
- m_packets.AddTail(m_lastpacket);
- }
- }
- } else {
- CAutoPtr<OggPacket> p(DEBUG_NEW OggPacket());
-
- if (last == pos && page.m_hdr.granule_position != -1) {
- p->bDiscontinuity = m_fSkip;
- REFERENCE_TIME rtLast = m_rtLast;
- m_rtLast = GetRefTime(page.m_hdr.granule_position);
- // some bad encodings have a +/-1 frame difference from the normal timeline,
- // but these seem to cancel eachother out nicely so we can just ignore them
- // to make it play a bit more smooth.
- if (abs(rtLast - m_rtLast) == GetRefTime(1)) {
- m_rtLast = rtLast; // FIXME
- }
- m_fSkip = false;
- }
-
- p->TrackNumber = page.m_hdr.bitstream_serial_number;
-
- if (S_OK == UnpackPacket(p, pData + i, j - i)) {
- //if (p->TrackNumber == 1)
- //TRACE(_T("[%d]: %d, %I64d -> %I64d (skip=%d, disc=%d, sync=%d)\n"),
- // (int)p->TrackNumber, p->GetCount(), p->rtStart, p->rtStop,
- // (int)m_fSkip, (int)p->bDiscontinuity, (int)p->bSyncPoint);
-
- if (p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64 * 60) {
- CAutoLock csAutoLock(&m_csPackets);
-
- m_rtLast = p->rtStop;
- p->fSkip = m_fSkip;
-
- if (len < 255) {
- m_packets.AddTail(p);
- } else {
- m_lastpacket = p;
- }
- } else {
- ASSERT(0);
- }
- }
- }
-
- i = j;
- }
- }
-
- return S_OK;
-}
-
-CAutoPtr<OggPacket> COggSplitterOutputPin::GetPacket()
-{
- CAutoPtr<OggPacket> p;
- CAutoLock csAutoLock(&m_csPackets);
- if (m_packets.GetCount()) {
- p = m_packets.RemoveHead();
- }
- return p;
-}
-
-HRESULT COggSplitterOutputPin::DeliverEndFlush()
-{
- ResetState();
- return __super::DeliverEndFlush();
-}
-
-HRESULT COggSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- ResetState();
- return __super::DeliverNewSegment(tStart, tStop, dRate);
-}
-
-//
-// COggVorbisOutputPin
-//
-
-COggVorbisOutputPin::COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- m_audio_sample_rate = h->audio_sample_rate;
- m_blocksize[0] = 1 << h->blocksize_0;
- m_blocksize[1] = 1 << h->blocksize_1;
- m_lastblocksize = 0;
-
- CMediaType mt;
-
- mt.InitMediaType();
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_Vorbis;
- mt.formattype = FORMAT_VorbisFormat;
- VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
- ZeroMemory(mt.Format(), mt.FormatLength());
- vf->nChannels = h->audio_channels;
- vf->nSamplesPerSec = h->audio_sample_rate;
- vf->nAvgBitsPerSec = h->bitrate_nominal;
- vf->nMinBitsPerSec = h->bitrate_minimum;
- vf->nMaxBitsPerSec = h->bitrate_maximum;
- vf->fQuality = -1;
- mt.SetSampleSize(8192);
- m_mts.Add(mt);
-
- mt.InitMediaType();
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_Vorbis2;
- mt.formattype = FORMAT_VorbisFormat2;
- VORBISFORMAT2* vf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2));
- ZeroMemory(mt.Format(), mt.FormatLength());
- vf2->Channels = h->audio_channels;
- vf2->SamplesPerSec = h->audio_sample_rate;
- mt.SetSampleSize(8192);
- m_mts.InsertAt(0, mt);
-}
-
-HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
-{
- HRESULT hr = __super::UnpackPage(page);
-
- while (m_packets.GetCount()) {
- Packet* p = m_packets.GetHead();
-
- if (p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
- // yeah, right, we are going to be parsing this backwards! :P
- bitstream bs(p->GetData(), (int)p->GetCount(), true);
- while (bs.hasbits(-1) && bs.getbits(-1) != 1) {
- ;
- }
- for (int cnt = 0; bs.hasbits(-8 - 16 - 16 - 1 - 6); cnt++) {
- unsigned int modes = bs.showbits(-6) + 1;
-
- unsigned int mapping = bs.getbits(-8);
- unsigned int transformtype = bs.getbits(-16);
- unsigned int windowtype = bs.getbits(-16);
- unsigned int blockflag = bs.getbits(-1);
- UNREFERENCED_PARAMETER(mapping);
-
- if (transformtype != 0 || windowtype != 0) {
- ASSERT(modes == cnt);
- UNREFERENCED_PARAMETER(modes);
- break;
- }
-
- m_blockflags.InsertAt(0, !!blockflag);
- }
- }
-
- int cnt = (int)m_initpackets.GetCount();
- if (cnt < 3 && (p->GetCount() >= 6 && p->GetAt(0) == 1 + cnt * 2)) {
- VORBISFORMAT2* vf2 = (VORBISFORMAT2*)m_mts[0].Format();
- vf2->HeaderSize[cnt] = p->GetCount();
- int len = m_mts[0].FormatLength();
- memcpy(m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len, p->GetData(), p->GetCount());
- }
-
- m_initpackets.AddTail(m_packets.RemoveHead());
- }
-
- return hr;
-}
-
-REFERENCE_TIME COggVorbisOutputPin::GetRefTime(__int64 granule_position)
-{
- REFERENCE_TIME rt = granule_position * 10000000 / m_audio_sample_rate;
- return rt;
-}
-
-HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- if (len > 0 && m_blockflags.GetCount()) {
- bitstream bs(pData, len);
- if (bs.getbits(1) == 0) {
- unsigned int x = (unsigned int)m_blockflags.GetCount() - 1;
- int n = 0;
- while (x) {
- n++;
- x >>= 1;
- }
- DWORD blocksize = m_blocksize[m_blockflags[bs.getbits(n)] ? 1 : 0];
- if (m_lastblocksize) {
- m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
- }
- m_lastblocksize = blocksize;
- }
- }
-
- p->bSyncPoint = TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + 1;
- p->SetData(pData, len);
-
- return S_OK;
-}
-
-HRESULT COggVorbisOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
-{
- if (p->GetCount() > 0 && (p->GetAt(0) & 1)) {
- return S_OK;
- }
-
- return __super::DeliverPacket(p);
-}
-
-HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
-
- m_lastblocksize = 0;
-
- if (m_mt.subtype == MEDIASUBTYPE_Vorbis) {
- POSITION pos = m_initpackets.GetHeadPosition();
- while (pos) {
- Packet* pi = m_initpackets.GetNext(pos);
- CAutoPtr<OggPacket> p(DEBUG_NEW OggPacket());
- p->TrackNumber = pi->TrackNumber;
- p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
- p->rtStart = p->rtStop = 0;
- p->Copy(*pi);
- __super::DeliverPacket(p);
- }
- }
-
- return hr;
-}
-
-//
-// COggFlacOutputPin
-//
-
-COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- CGolombBuffer Buffer(h, nCount);
-
- Buffer.BitRead(1); // Last-metadata-block flag
-
- if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
- if (phr) {
- *phr = VFW_E_INVALID_FILE_FORMAT;
- }
- return;
- }
-
- Buffer.BitRead(24); // Length (in bytes) of metadata to follow
- Buffer.ReadShort(); // m_nMinBlocksize
- Buffer.ReadShort(); // m_nMaxBlocksize
- Buffer.BitRead(24); // m_nMinFrameSize
- Buffer.BitRead(24); // m_nMaxFrameSize
- m_nSamplesPerSec = (int)Buffer.BitRead(20);
- m_nChannels = (int)Buffer.BitRead(3) + 1;
- m_wBitsPerSample = (WORD)Buffer.BitRead(5) + 1;
- Buffer.BitRead(36); // m_i64TotalNumSamples
- m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
-
- CMediaType mt;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, sizeof(WAVEFORMATEX));
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nChannels = m_nChannels;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = m_wBitsPerSample;
-
- m_mts.InsertAt(0, mt);
- *phr = S_OK;
-}
-
-REFERENCE_TIME COggFlacOutputPin::GetRefTime(__int64 granule_position)
-{
- REFERENCE_TIME rt = (granule_position * UNITS) / m_nSamplesPerSec;
- return rt;
-}
-
-HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8) {
- return S_FALSE;
- }
-
- p->bSyncPoint = TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + 1; // TODO : find packet duration !
- p->SetData(pData, len);
-
- return S_OK;
-}
-
-HRESULT COggFlacOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
-{
- if (p->GetCount() > 0 && (p->GetAt(0) & 1)) {
- return S_OK;
- }
-
- return __super::DeliverPacket(p);
-}
-
-HRESULT COggFlacOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
-
- m_lastblocksize = 0;
-
- if (m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
- POSITION pos = m_initpackets.GetHeadPosition();
- while (pos) {
- Packet* pi = m_initpackets.GetNext(pos);
- CAutoPtr<OggPacket> p(DEBUG_NEW OggPacket());
- p->TrackNumber = pi->TrackNumber;
- p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
- p->rtStart = p->rtStop = 0;
- p->Copy(*pi);
- __super::DeliverPacket(p);
- }
- }
-
- return hr;
-}
-//
-// COggDirectShowOutputPin
-//
-
-COggDirectShowOutputPin::COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- CMediaType mt;
- memcpy((AM_MEDIA_TYPE*)&mt, pmt, FIELD_OFFSET(AM_MEDIA_TYPE, pUnk));
- mt.SetFormat((BYTE*)(pmt + 1), pmt->cbFormat);
- mt.SetSampleSize(1);
- if (mt.majortype == MEDIATYPE_Video) { // TODO: find samples for audio and find out what to return in GetRefTime...
- m_mts.Add(mt);
- }
-}
-
-REFERENCE_TIME COggDirectShowOutputPin::GetRefTime(__int64 granule_position)
-{
- REFERENCE_TIME rt = 0;
-
- if (m_mt.majortype == MEDIATYPE_Video) {
- rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
- } else if (m_mt.majortype == MEDIATYPE_Audio) {
- rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
- }
-
- return rt;
-}
-
-HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- int i = 0;
-
- BYTE hdr = pData[i++];
-
- if (!(hdr & 1)) {
- // TODO: verify if this was still present in the old format (haven't found one sample yet)
- BYTE nLenBytes = (hdr >> 6) | ((hdr & 2) << 1);
- __int64 Length = 0;
- for (int j = 0; j < nLenBytes; j++) {
- Length |= (__int64)pData[i++] << (j << 3);
- }
-
- if (len < i) {
- ASSERT(0);
- return E_FAIL;
- }
-
- p->bSyncPoint = !!(hdr & 8);
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(1));
- p->SetData(&pData[i], len - i);
-
- return S_OK;
- }
-
- return S_FALSE;
-}
-
-//
-// COggStreamOutputPin
-//
-
-COggStreamOutputPin::COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- m_time_unit = h->time_unit;
- m_samples_per_unit = h->samples_per_unit;
- m_default_len = h->default_len;
-}
-
-REFERENCE_TIME COggStreamOutputPin::GetRefTime(__int64 granule_position)
-{
- return granule_position * m_time_unit / m_samples_per_unit;
-}
-
-HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- int i = 0;
-
- BYTE hdr = pData[i++];
-
- if (!(hdr & 1)) {
- BYTE nLenBytes = (hdr >> 6) | ((hdr & 2) << 1);
- __int64 Length = 0;
- for (int j = 0; j < nLenBytes; j++) {
- Length |= (__int64)pData[i++] << (j << 3);
- }
-
- if (len < i) {
- ASSERT(0);
- return E_FAIL;
- }
-
- p->bSyncPoint = !!(hdr & 8);
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(m_default_len));
- p->SetData(&pData[i], len - i);
-
- return S_OK;
- }
-
- return S_FALSE;
-}
-
-//
-// COggVideoOutputPin
-//
-
-COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
-{
- int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
-
- CMediaType mt;
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap(MAKEFOURCC(h->subtype[0], h->subtype[1], h->subtype[2], h->subtype[3]));
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + extra);
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), h + 1, extra);
- pvih->AvgTimePerFrame = h->time_unit / h->samples_per_unit;
- pvih->bmiHeader.biWidth = h->v.w;
- pvih->bmiHeader.biHeight = h->v.h;
- pvih->bmiHeader.biBitCount = (WORD)h->bps;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- switch (pvih->bmiHeader.biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_RGB32 :
- MEDIASUBTYPE_NULL;
- break;
- case BI_RLE8:
- mt.subtype = MEDIASUBTYPE_RGB8;
- break;
- case BI_RLE4:
- mt.subtype = MEDIASUBTYPE_RGB4;
- break;
- }
- mt.SetSampleSize(max(h->buffersize, 1));
- m_mts.Add(mt);
-}
-
-//
-// COggAudioOutputPin
-//
-
-COggAudioOutputPin::COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
-{
- int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
-
- CMediaType mt;
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = FOURCCMap(strtol(CStringA(h->subtype, 4), nullptr, 16));
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + extra);
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(WAVEFORMATEX), h + 1, extra);
- wfe->cbSize = extra;
- wfe->wFormatTag = (WORD)mt.subtype.Data1;
- wfe->nChannels = h->a.nChannels;
- wfe->nSamplesPerSec = (DWORD)(10000000i64 * h->samples_per_unit / h->time_unit);
- wfe->wBitsPerSample = (WORD)h->bps;
- wfe->nAvgBytesPerSec = h->a.nAvgBytesPerSec; // TODO: verify for PCM
- wfe->nBlockAlign = h->a.nBlockAlign; // TODO: verify for PCM
- mt.SetSampleSize(max(h->buffersize, 1));
- m_mts.Add(mt);
-}
-
-//
-// COggTextOutputPin
-//
-
-COggTextOutputPin::COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
-{
- CMediaType mt;
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(1);
- m_mts.Add(mt);
-}
-
-// COggTheoraOutputPin
-
-COggTheoraOutputPin::COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- CMediaType mt;
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('OEHT');
- mt.formattype = FORMAT_MPEG2_VIDEO;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO));
- ZeroMemory(mt.Format(), mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = *(WORD*)&p[10] >> 4;
- vih->hdr.bmiHeader.biHeight = *(WORD*)&p[12] >> 4;
- vih->hdr.bmiHeader.biCompression = 'OEHT';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- m_nFpsNum = (p[22] << 24) | (p[23] << 16) | (p[24] << 8) | p[25];
- m_nFpsDenum = (p[26] << 24) | (p[27] << 16) | (p[28] << 8) | p[29];
- if (m_nFpsNum) {
- m_rtAvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * m_nFpsDenum / m_nFpsNum);
- vih->hdr.AvgTimePerFrame = m_rtAvgTimePerFrame;
- }
- vih->hdr.dwPictAspectRatioX = (p[14] << 16) | (p[15] << 8) | p[16];
- vih->hdr.dwPictAspectRatioY = (p[17] << 16) | (p[18] << 8) | p[19];
-
- m_KfgShift = (((p[40] << 8) + p[41]) & 0x3E0) >> 5;
- m_nIndexOffset = TH_VERSION_CHECK(p[7], p[8], p[9], 3, 2, 1);
-
- if (m_KfgShift == 0) {
- m_KfgShift = 6; // Is it really default value ?
- }
-
- mt.bFixedSizeSamples = 0;
- m_mts.Add(mt);
-}
-
-HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
-{
- HRESULT hr = __super::UnpackPage(page);
-
- while (m_packets.GetCount()) {
- Packet* p = m_packets.GetHead();
-
- CMediaType& mt = m_mts[0];
- int size = (int)p->GetCount();
- ASSERT(size <= 0xffff);
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.ReallocFormatBuffer(
- FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) +
- ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader +
- 2 + size);
- *(WORD*)((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader) = (size >> 8) | (size << 8);
- memcpy((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader + 2, p->GetData(), size);
- vih->cbSequenceHeader += 2 + size;
-
- m_initpackets.AddTail(m_packets.RemoveHead());
- }
-
- return hr;
-}
-
-REFERENCE_TIME COggTheoraOutputPin::GetRefTime(__int64 granule_position)
-{
- LONGLONG iframe;
- LONGLONG pframe;
-
- iframe = granule_position >> m_KfgShift;
- pframe = granule_position - (iframe << m_KfgShift);
- /*3.2.0 streams store the frame index in the granule position.
- 3.2.1 and later store the frame count.
- We return the index, so adjust the value if we have a 3.2.1 or later
- stream.*/
-
- REFERENCE_TIME rt = (iframe + pframe - m_nIndexOffset) * m_rtAvgTimePerFrame;
- return rt;
-}
-
-HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- if (!pData) {
- return E_FAIL;
- }
-
- p->bSyncPoint = len > 0 ? !(*pData & 0x40) : TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + 1;
- p->SetData(pData, len);
-
- if (!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
- p->rtStop = p->rtStart + ((MPEG2VIDEOINFO*)m_mt.Format())->hdr.AvgTimePerFrame;
- }
-
- return S_OK;
-}
diff --git a/src/filters/parser/OggSplitter/OggSplitter.def b/src/filters/parser/OggSplitter/OggSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/OggSplitter/OggSplitter.h b/src/filters/parser/OggSplitter/OggSplitter.h
deleted file mode 100644
index 1570e0116..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "OggFile.h"
-#include "../BaseSplitter/BaseSplitter.h"
-
-#define OggSplitterName L"MPC Ogg Splitter"
-#define OggSourceName L"MPC Ogg Source"
-
-class OggPacket : public Packet
-{
-public:
- OggPacket() { fSkip = false; }
- bool fSkip;
-};
-
-class COggSplitterOutputPin : public CBaseSplitterOutputPin
-{
- class CComment
- {
- public:
- CStringW m_key, m_value;
- CComment(CStringW key, CStringW value) : m_key(key), m_value(value) {
- m_key.MakeUpper();
- }
- };
-
- CAutoPtrList<CComment> m_pComments;
-
-protected:
- CCritSec m_csPackets;
- CAutoPtrList<OggPacket> m_packets;
- CAutoPtr<OggPacket> m_lastpacket;
- DWORD m_lastseqnum;
- REFERENCE_TIME m_rtLast;
- bool m_fSkip;
-
- void ResetState(DWORD seqnum = -1);
-
-public:
- COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- void AddComment(BYTE* p, int len);
- CStringW GetComment(CStringW key);
-
- HRESULT UnpackPage(OggPage& page);
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len) = 0;
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position) = 0;
- CAutoPtr<OggPacket> GetPacket();
-
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-};
-
-class COggVorbisOutputPin : public COggSplitterOutputPin
-{
- CAutoPtrList<OggPacket> m_initpackets;
-
- DWORD m_audio_sample_rate;
- DWORD m_blocksize[2], m_lastblocksize;
- CAtlArray<bool> m_blockflags;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
- HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
-public:
- COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() { return m_initpackets.GetCount() >= 3; }
-};
-
-class COggFlacOutputPin : public COggSplitterOutputPin
-{
- CAutoPtrList<OggPacket> m_initpackets;
-
- int m_nSamplesPerSec;
- int m_nChannels;
- WORD m_wBitsPerSample;
- int m_nAvgBytesPerSec;
-
- DWORD m_blocksize[2], m_lastblocksize;
- CAtlArray<bool> m_blockflags;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
- HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
-public:
- COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- bool IsInitialized() { return m_initpackets.GetCount() >= 3; }
-};
-
-class COggDirectShowOutputPin : public COggSplitterOutputPin
-{
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
-public:
- COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggStreamOutputPin : public COggSplitterOutputPin
-{
- __int64 m_time_unit, m_samples_per_unit;
- DWORD m_default_len;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
-public:
- COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggVideoOutputPin : public COggStreamOutputPin
-{
-public:
- COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggAudioOutputPin : public COggStreamOutputPin
-{
-public:
- COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggTextOutputPin : public COggStreamOutputPin
-{
-public:
- COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggTheoraOutputPin : public COggSplitterOutputPin
-{
- CAutoPtrList<OggPacket> m_initpackets;
- LONGLONG m_KfgShift;
- int m_nIndexOffset;
- int m_nFpsNum;
- int m_nFpsDenum;
- REFERENCE_TIME m_rtAvgTimePerFrame;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
-public:
- COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() { return m_initpackets.GetCount() >= 3; }
-};
-
-class __declspec(uuid("9FF48807-E133-40AA-826F-9B2959E5232D"))
- COggSplitterFilter : public CBaseSplitterFilter
-{
-protected:
- CAutoPtr<COggFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~COggSplitterFilter();
-
- // CBaseFilter
-
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
-};
-
-class __declspec(uuid("6D3688CE-3E9D-42F4-92CA-8A11119D25CD"))
- COggSourceFilter : public COggSplitterFilter
-{
-public:
- COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/OggSplitter/OggSplitter.rc b/src/filters/parser/OggSplitter/OggSplitter.rc
deleted file mode 100644
index 46fdb77ec..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "Ogg Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "Ogg Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "OggSplitter.ax"
- VALUE "ProductName", "Ogg Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/OggSplitter/OggSplitter.vcxproj b/src/filters/parser/OggSplitter/OggSplitter.vcxproj
deleted file mode 100644
index 7cb508da5..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.vcxproj
+++ /dev/null
@@ -1,255 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}</ProjectGuid>
- <RootNamespace>OggSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>OggSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="OggFile.cpp" />
- <ClCompile Include="OggSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="OggSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="OggFile.h" />
- <ClInclude Include="OggSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="OggSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters b/src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters
deleted file mode 100644
index d4687b02d..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{30dbc4b9-307c-4a34-99cd-6ae8cdc29c72}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{6f7219e1-61de-4305-b4fe-b9af26cb95f3}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{ad968fc1-5150-4f92-882e-065c3247c093}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="OggFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="OggSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="OggSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="OggFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="OggSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="OggSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/OggSplitter/resource.h b/src/filters/parser/OggSplitter/resource.h
deleted file mode 100644
index 3bf040c0b..000000000
--- a/src/filters/parser/OggSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by OggSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/OggSplitter/stdafx.cpp b/src/filters/parser/OggSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/OggSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/OggSplitter/stdafx.h b/src/filters/parser/OggSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/OggSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
deleted file mode 100644
index 75adca484..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
+++ /dev/null
@@ -1,2672 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <Shlwapi.h>
-#include <atlpath.h>
-#include <MMReg.h>
-#include <ks.h>
-#include <ksmedia.h>
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/MediaTypes.h"
-#include "RealMediaSplitter.h"
-#include "../../../Subtitles/SubtitleInputPin.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#define MAXPACKETS_RV 10000
-
-template<typename T>
-static void bswap(T& var)
-{
- BYTE* s = (BYTE*)&var;
- for (BYTE* d = s + sizeof(var) - 1; s < d; s++, d--) {
- *s ^= *d, *d ^= *s, *s ^= *d;
- }
-}
-
-void rvinfo::bswap()
-{
- ::bswap(dwSize);
- ::bswap(w);
- ::bswap(h);
- ::bswap(bpp);
- ::bswap(unk1);
- ::bswap(fps);
- ::bswap(type1);
- ::bswap(type2);
-}
-
-void rainfo3::bswap()
-{
- ::bswap(fourcc);
- ::bswap(version);
- ::bswap(header_size);
- ::bswap(data_size);
-}
-
-void rainfo::bswap()
-{
- ::bswap(version1);
- ::bswap(version2);
- ::bswap(header_size);
- ::bswap(flavor);
- ::bswap(coded_frame_size);
- ::bswap(sub_packet_h);
- ::bswap(frame_size);
- ::bswap(sub_packet_size);
-}
-
-void rainfo4::bswap()
-{
- __super::bswap();
- ::bswap(sample_rate);
- ::bswap(sample_size);
- ::bswap(channels);
-}
-
-void rainfo5::bswap()
-{
- __super::bswap();
- ::bswap(sample_rate);
- ::bswap(sample_size);
- ::bswap(channels);
-}
-
-using namespace RMFF;
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV20},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV30},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV40},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV41},
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins2[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn2), sudPinTypesIn2},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut2), sudPinTypesOut2}
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_COOK},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DNET},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
-};
-
-const AMOVIESETUP_PIN sudpPins3[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn3), sudPinTypesIn3},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut3), sudPinTypesOut3}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CRealMediaSplitterFilter), RMSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealMediaSourceFilter), RMSourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealVideoDecoder), L"MPC RealVideo Decoder", MERIT_NORMAL, _countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealAudioDecoder), L"MPC RealAudio Decoder", MERIT_NORMAL, _countof(sudpPins3), sudpPins3, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CRealMediaSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CRealMediaSourceFilter>, nullptr, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRealVideoDecoder>, nullptr, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRealAudioDecoder>, nullptr, &sudFilter[3]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_RealMedia, _T("0,4,,2E524D46"), _T(".rm"), _T(".rmvb"), _T(".ram"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_RealMedia);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CRealMediaSplitterFilter
-//
-
-CRealMediaSplitterFilter::CRealMediaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CRealMediaSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_RV)
-{
-}
-
-CRealMediaSplitterFilter::~CRealMediaSplitterFilter()
-{
-}
-
-STDMETHODIMP CRealMediaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, RMSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- {
- DWORD dw;
- if (FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
- return E_FAIL;
- }
- }
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DEBUG_NEW CRMFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = 0;
-
- m_rtStop = 10000i64 * m_pFile->m_p.tDuration;
-
- POSITION pos = m_pFile->m_mps.GetHeadPosition();
- while (pos) {
- MediaProperies* pmp = m_pFile->m_mps.GetNext(pos);
-
- CStringW name;
- name.Format(L"Output %02u", pmp->stream);
- if (!pmp->name.IsEmpty()) {
- name += L" (" + CStringW(pmp->name) + L")";
- }
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(max(pmp->maxPacketSize * 16/**/, 1));
-
- if (pmp->mime == "video/x-pn-realvideo") {
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
-
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + (ULONG)pmp->typeSpecData.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(pvih + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
-
- rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
- rvi.bswap();
-
- ASSERT(rvi.dwSize >= FIELD_OFFSET(rvinfo, morewh));
- ASSERT(rvi.fcc1 == 'ODIV');
-
- mt.subtype = FOURCCMap(rvi.fcc2);
- if (rvi.fps > 0x10000) {
- pvih->AvgTimePerFrame = REFERENCE_TIME(10000000i64 / ((float)rvi.fps / 0x10000));
- }
- pvih->dwBitRate = pmp->avgBitRate;
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = rvi.w;
- pvih->bmiHeader.biHeight = rvi.h;
- pvih->bmiHeader.biPlanes = 3;
- pvih->bmiHeader.biBitCount = rvi.bpp;
- pvih->bmiHeader.biCompression = rvi.fcc2;
- pvih->bmiHeader.biSizeImage = rvi.w * rvi.h * 3 / 2;
- mts.Add(mt);
-
- BYTE* extra = pmp->typeSpecData.GetData();
- DWORD extralen = (DWORD)pmp->typeSpecData.GetCount();
-
- if (extralen > 26) {
- extra += 26;
- extralen -= 26;
- VIDEOINFOHEADER* pvih2 = (VIDEOINFOHEADER*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER) + extralen);
- memcpy(pvih2 + 1, extra, extralen);
- mts.InsertAt(0, mt);
- }
-
- if (pmp->width > 0 && pmp->height > 0) {
- BITMAPINFOHEADER bmi = pvih->bmiHeader;
- mt.formattype = FORMAT_VideoInfo2;
- VIDEOINFOHEADER2* pvih2 = (VIDEOINFOHEADER2*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + (ULONG)pmp->typeSpecData.GetCount());
- ZeroMemory(mt.Format() + FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags), mt.FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags));
- memcpy(pvih2 + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
- pvih2->bmiHeader = bmi;
- pvih2->bmiHeader.biWidth = (DWORD)pmp->width;
- pvih2->bmiHeader.biHeight = (DWORD)pmp->height;
- pvih2->dwPictAspectRatioX = rvi.w;
- pvih2->dwPictAspectRatioY = rvi.h;
-
- mts.InsertAt(0, mt);
- }
- } else if (pmp->mime == "audio/x-pn-realaudio") {
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- mt.bTemporalCompression = 1;
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + (ULONG)pmp->typeSpecData.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(pwfe + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
-
- union {
- DWORD fcc;
- char fccstr[5];
- };
-
- fcc = 0;
- fccstr[4] = 0;
-
- BYTE* fmt = pmp->typeSpecData.GetData();
- for (size_t i = 0; i < pmp->typeSpecData.GetCount() - 4; i++, fmt++) {
- if (*(DWORD*)fmt == MAKEFOURCC('.' , 'r' , 'a' , 0xfd)) {
- break;
- }
- }
-
- BYTE* extra = nullptr;
-
- WORD ver = fmt[4] << 8 | fmt[5];
- if (ver == 3) {
- rainfo3 rai3 = *(rainfo3*)fmt;
- rai3.bswap();
- fcc = '4_41';
- pwfe->nChannels = 1;
- pwfe->nSamplesPerSec = 8000;
- pwfe->nAvgBytesPerSec = 1000;
- pwfe->nBlockAlign = 2;
- pwfe->wBitsPerSample = 16;
- } else {
- rainfo rai = *(rainfo*)fmt;
- rai.bswap();
-
- if (rai.version2 == 4) {
- rainfo4 rai4 = *(rainfo4*)fmt;
- rai4.bswap();
- pwfe->nChannels = rai4.channels;
- pwfe->wBitsPerSample = rai4.sample_size;
- pwfe->nSamplesPerSec = rai4.sample_rate;
- pwfe->nBlockAlign = rai4.frame_size;
- BYTE* p = (BYTE*)((rainfo4*)fmt + 1);
- int len = *p++;
- p += len;
- len = *p++;
- ASSERT(len == 4);
- if (len == 4) {
- fcc = MAKEFOURCC(p[0], p[1], p[2], p[3]);
- }
- extra = p + len + 3;
- } else if (rai.version2 == 5) {
- rainfo5 rai5 = *(rainfo5*)fmt;
- rai5.bswap();
- pwfe->nChannels = rai5.channels;
- pwfe->wBitsPerSample = rai5.sample_size;
- pwfe->nSamplesPerSec = rai5.sample_rate;
- pwfe->nBlockAlign = rai5.frame_size;
- fcc = rai5.fourcc3;
- extra = fmt + sizeof(rainfo5) + 4;
- } else {
- continue;
- }
- }
-
- _strupr_s(fccstr);
-
- mt.subtype = FOURCCMap(fcc);
-
- bswap(fcc);
-
- switch (fcc) {
- case '14_4':
- pwfe->wFormatTag = WAVE_FORMAT_14_4;
- break;
- case '28_8':
- pwfe->wFormatTag = WAVE_FORMAT_28_8;
- break;
- case 'ATRC':
- pwfe->wFormatTag = WAVE_FORMAT_ATRC;
- break;
- case 'COOK':
- pwfe->wFormatTag = WAVE_FORMAT_COOK;
- break;
- case 'DNET':
- pwfe->wFormatTag = WAVE_FORMAT_DNET;
- break;
- case 'SIPR':
- pwfe->wFormatTag = WAVE_FORMAT_SIPR;
- break;
- case 'RAAC':
- pwfe->wFormatTag = WAVE_FORMAT_RAAC;
- break;
- case 'RACP':
- pwfe->wFormatTag = WAVE_FORMAT_RACP;
- break;
- }
-
- if (pwfe->wFormatTag) {
- mts.Add(mt);
-
- if (fcc == 'DNET') {
- mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
- mts.InsertAt(0, mt);
- } else if (fcc == 'RAAC' || fcc == 'RACP') {
- mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_AAC);
- DWORD extralen = *(DWORD*)extra;
- extra += 4;
- ::bswap(extralen);
- ASSERT(*extra == 2); // always 2? why? what does it mean?
- if (*extra == 2) {
- extra++;
- extralen--;
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extralen);
- pwfe->cbSize = extralen;
- memcpy(pwfe + 1, extra, extralen);
- } else {
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
- pwfe->cbSize = MakeAACInitData((BYTE*)(pwfe + 1), 0, pwfe->nSamplesPerSec, pwfe->nChannels);
- }
- mts.InsertAt(0, mt);
- }
- }
- } else if (pmp->mime == "logical-fileinfo") {
- CAtlMap<CStringA, CStringA, CStringElementTraits<CStringA>> lfi;
- CStringA key, value;
-
- BYTE* p = pmp->typeSpecData.GetData();
- BYTE* end = p + pmp->typeSpecData.GetCount();
- p += 8;
-
- DWORD cnt = p <= end - 4 ? *(DWORD*)p : 0;
- bswap(cnt);
- p += 4;
-
- if (cnt > 0xffff) { // different format?
- p += 2;
- cnt = p <= end - 4 ? *(DWORD*)p : 0;
- bswap(cnt);
- p += 4;
- }
-
- while (p < end - 4 && cnt-- > 0) {
- BYTE* base = p;
- DWORD len = *(DWORD*)p;
- bswap(len);
- p += 4;
- if (base + len > end) {
- break;
- }
-
- p++;
- WORD keylen = *(WORD*)p;
- bswap(keylen);
- p += 2;
- memcpy(key.GetBufferSetLength(keylen), p, keylen);
- p += keylen;
-
- p += 4;
- WORD valuelen = *(WORD*)p;
- bswap(valuelen);
- p += 2;
- memcpy(value.GetBufferSetLength(valuelen), p, valuelen);
- p += valuelen;
-
- ASSERT(p == base + len);
- p = base + len;
-
- lfi[key] = value;
- }
-
- POSITION pos = lfi.GetStartPosition();
- while (pos) {
- lfi.GetNextAssoc(pos, key, value);
-
- int n = 0;
- if (key.Find("CHAPTER") == 0 && key.Find("TIME") == key.GetLength() - 4
- && (n = strtol(key.Mid(7), nullptr, 10)) > 0) {
- int h, m, s, ms;
- char c;
- if (7 != sscanf_s(value, "%d%c%d%c%d%c%d", &h, &c, 1, &m, &c, 1, &s, &c, 1, &ms)) {
- continue;
- }
-
- key.Format("CHAPTER%02dNAME", n);
- if (!lfi.Lookup(key, value) || value.IsEmpty()) {
- value.Format("Chapter %d", n);
- }
-
- ChapAppend(
- ((((REFERENCE_TIME)h * 60 + m) * 60 + s) * 1000 + ms) * 10000,
- CStringW(CString(value)));
- }
- }
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("Unsupported RealMedia stream (%d): %s\n"), pmp->stream, CString(pmp->mime));
- continue;
- }
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CRealMediaSplitterOutputPin(mts, name, this, this, &hr2));
- if (SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut))) {
- if (!m_rtStop) {
- m_pFile->m_p.tDuration = max(m_pFile->m_p.tDuration, pmp->tDuration);
- }
- }
- }
-
- pos = m_pFile->m_subs.GetHeadPosition();
- for (DWORD stream = 0; pos; stream++) {
- CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
-
- CStringW name;
- name.Format(L"Subtitle %02u", stream);
- if (!s.name.IsEmpty()) {
- name += L" (" + CStringW(CString(s.name)) + L")";
- }
-
- CMediaType mt;
- mt.SetSampleSize(1);
- mt.majortype = MEDIATYPE_Text;
-
- CAtlArray<CMediaType> mts;
- mts.Add(mt);
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CRealMediaSplitterOutputPin(mts, name, this, this, &hr2));
- AddOutputPin((DWORD)~stream, pPinOut);
- }
-
- m_rtDuration = m_rtNewStop = m_rtStop = 10000i64 * m_pFile->m_p.tDuration;
-
- SetProperty(L"TITL", CStringW(m_pFile->m_cd.title));
- SetProperty(L"AUTH", CStringW(m_pFile->m_cd.author));
- SetProperty(L"CPYR", CStringW(m_pFile->m_cd.copyright));
- SetProperty(L"DESC", CStringW(m_pFile->m_cd.comment));
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CRealMediaSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CRealMediaSplitterFilter");
-
- if (!m_pFile) {
- return false;
- }
-
- // reindex if needed
-
- if (m_pFile->m_irs.IsEmpty()) {
- m_nOpenProgress = 0;
- m_rtDuration = 0;
-
- int stream = m_pFile->GetMasterStream();
-
- UINT32 tLastStart = (UINT32) - 1;
- UINT32 nPacket = 0;
-
- POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while (pos && !m_fAbort) {
- DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
-
- m_pFile->Seek(pdc->pos);
-
- for (UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++) {
- UINT64 filepos = m_pFile->GetPos();
-
- HRESULT hr;
-
- MediaPacketHeader mph;
- if (S_OK != (hr = m_pFile->Read(mph, false))) {
- break;
- }
-
- m_rtDuration = max((__int64)(10000i64 * mph.tStart), m_rtDuration);
-
- if (mph.stream == stream && (mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart) {
- CAutoPtr<IndexRecord> pir(DEBUG_NEW IndexRecord);
- pir->tStart = mph.tStart;
- pir->ptrFilePos = (UINT32)filepos;
- pir->packet = nPacket;
- m_pFile->m_irs.AddTail(pir);
-
- tLastStart = mph.tStart;
- }
-
- m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
-
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- }
- }
-
- m_nOpenProgress = 100;
-
- if (m_fAbort) {
- m_pFile->m_irs.RemoveAll();
- }
-
- m_fAbort = false;
- }
-
- m_seekpos = nullptr;
- m_seekpacket = 0;
- m_seekfilepos = 0;
-
- return true;
-}
-
-void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- if (rt <= 0) {
- m_seekpos = m_pFile->m_dcs.GetHeadPosition();
- m_seekpacket = 0;
- m_seekfilepos = m_pFile->m_dcs.GetHead()->pos;
- } else {
- m_seekpos = nullptr;
-
- POSITION pos = m_pFile->m_irs.GetTailPosition();
- while (pos && !m_seekpos) {
- IndexRecord* pir = m_pFile->m_irs.GetPrev(pos);
- if (pir->tStart <= rt / 10000) {
- m_seekpacket = pir->packet;
-
- pos = m_pFile->m_dcs.GetTailPosition();
- while (pos && !m_seekpos) {
- POSITION tmp = pos;
-
- DataChunk* pdc = m_pFile->m_dcs.GetPrev(pos);
-
- if (pdc->pos <= pir->ptrFilePos) {
- m_seekpos = tmp;
- m_seekfilepos = pir->ptrFilePos;
-
- POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while (pos != m_seekpos) {
- m_seekpacket -= m_pFile->m_dcs.GetNext(pos)->nPackets;
- }
- }
- }
-
- // search the closest keyframe to the seek time (commented out 'cause rm seems to index all of its keyframes...)
- /*
- if (m_seekpos)
- {
- DataChunk* pdc = m_pFile->m_dcs.GetAt(m_seekpos);
-
- m_pFile->Seek(m_seekfilepos);
-
- REFERENCE_TIME seektime = -1;
- UINT32 seekstream = -1;
-
- for (UINT32 i = m_seekpacket; i < pdc->nPackets; i++)
- {
- UINT64 filepos = m_pFile->GetPos();
-
- MediaPacketHeader mph;
- if (S_OK != m_pFile->Read(mph, false))
- break;
-
- if (seekstream == -1) seekstream = mph.stream;
- if (seekstream != mph.stream) continue;
-
- if (seektime == 10000i64*mph.tStart) continue;
- if (rt < 10000i64*mph.tStart) break;
-
- if ((mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG))
- {
- m_seekpacket = i;
- m_seekfilepos = filepos;
- seektime = 10000i64*mph.tStart;
- }
- }
- }
- */
- }
- }
-
- if (!m_seekpos) {
- m_seekpos = m_pFile->m_dcs.GetHeadPosition();
- m_seekpacket = 0;
- m_seekfilepos = m_pFile->m_dcs.GetAt(m_seekpos)->pos;
- }
- }
-}
-
-bool CRealMediaSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
- POSITION pos;
-
- pos = m_pFile->m_subs.GetHeadPosition();
- for (DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(nullptr); stream++) {
- CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet);
-
- p->TrackNumber = ~stream;
- p->bSyncPoint = TRUE;
- p->rtStart = 0;
- p->rtStop = 1;
-
- size_t count = (4 + 1) + (2 + 4 + (s.name.GetLength() + 1) * 2) + (2 + 4 + s.data.GetLength());
- p->SetCount(count);
- BYTE* ptr = p->GetData();
-
- strcpy_s((char*)ptr, count, "GAB2");
- ptr += 4 + 1;
- count -= 4 + 1;
-
- *(WORD*)ptr = 2;
- ptr += 2;
- count -= 2;
- *(DWORD*)ptr = (s.name.GetLength() + 1) * 2;
- ptr += 4;
- count -= 4;
- wcscpy_s((WCHAR*)ptr, count / 2, CStringW(s.name));
- ptr += (s.name.GetLength() + 1) * 2;
-
- *(WORD*)ptr = 4;
- ptr += 2;
- *(DWORD*)ptr = s.data.GetLength();
- ptr += 4;
- memcpy((char*)ptr, s.data, s.data.GetLength());
- ptr += s.name.GetLength();
-
- hr = DeliverPacket(p);
- }
-
- pos = m_seekpos;
- while (pos && SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
-
- m_pFile->Seek(m_seekfilepos > 0 ? m_seekfilepos : pdc->pos);
-
- for (UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(nullptr); i++) {
- MediaPacketHeader mph;
- if (S_OK != (hr = m_pFile->Read(mph))) {
- break;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet);
- p->TrackNumber = mph.stream;
- p->bSyncPoint = !!(mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG);
- p->rtStart = 10000i64 * (mph.tStart);
- p->rtStop = p->rtStart + 1;
- p->Copy(mph.pData);
- hr = DeliverPacket(p);
- }
-
- m_seekpacket = 0;
- m_seekfilepos = 0;
- }
-
- return true;
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- nKFs = m_pFile->m_irs.GetCount();
- return S_OK;
-}
-
-STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
-
- UINT nKFsTmp = 0;
- POSITION pos = m_pFile->m_irs.GetHeadPosition();
- for (int i = 0; pos && nKFsTmp < nKFs; i++) {
- pKFs[nKFsTmp++] = 10000i64 * m_pFile->m_irs.GetNext(pos)->tStart;
- }
- nKFs = nKFsTmp;
-
- return S_OK;
-}
-
-//
-// CRealMediaSplitterOutputPin
-//
-
-CRealMediaSplitterOutputPin::CRealMediaSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_RV)
-{
-}
-
-CRealMediaSplitterOutputPin::~CRealMediaSplitterOutputPin()
-{
-}
-
-HRESULT CRealMediaSplitterOutputPin::DeliverEndFlush()
-{
- {
- CAutoLock cAutoLock(&m_csQueue);
- m_segments.Clear();
- }
-
- return __super::DeliverEndFlush();
-}
-
-HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
-{
- HRESULT hr;
-
- if (m_segments.IsEmpty()) {
- m_segments.Clear();
- return S_OK;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = (DWORD) - 1;
- p->bDiscontinuity = m_segments.fDiscontinuity;
- p->bSyncPoint = m_segments.fSyncPoint;
- p->rtStart = m_segments.rtStart;
- p->rtStop = m_segments.rtStart + 1;
-
- DWORD len = 0, total = 0;
- POSITION pos = m_segments.GetHeadPosition();
- while (pos) {
- segment* s = m_segments.GetNext(pos);
- len = max(len, s->offset + s->data.GetCount());
- total += s->data.GetCount();
- }
- ASSERT(len == total);
- len += 1 + 2 * 4 * (!m_segments.fMerged ? m_segments.GetCount() : 1);
-
- p->SetCount(len);
-
- BYTE* pData = p->GetData();
-
- *pData++ = m_segments.fMerged ? 0 : m_segments.GetCount() - 1;
-
- if (m_segments.fMerged) {
- *((DWORD*)pData) = 1;
- pData += 4;
- *((DWORD*)pData) = 0;
- pData += 4;
- } else {
- pos = m_segments.GetHeadPosition();
- while (pos) {
- *((DWORD*)pData) = 1;
- pData += 4;
- *((DWORD*)pData) = m_segments.GetNext(pos)->offset;
- pData += 4;
- }
- }
-
- pos = m_segments.GetHeadPosition();
- while (pos) {
- segment* s = m_segments.GetNext(pos);
- memcpy(pData + s->offset, s->data.GetData(), s->data.GetCount());
- }
-
- hr = __super::DeliverPacket(p);
-
- m_segments.Clear();
-
- return hr;
-}
-
-HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- HRESULT hr = S_OK;
-
- ASSERT(p->rtStart < p->rtStop);
-
- if (m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
- WORD* s = (WORD*)p->GetData();
- WORD* e = s + p->GetCount() / 2;
- while (s < e) {
- bswap(*s++);
- }
- }
-
- if (m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
- || m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40
- || m_mt.subtype == MEDIASUBTYPE_RV41) {
- CAutoLock cAutoLock(&m_csQueue);
-
- int len = (int)p->GetCount();
- BYTE* pIn = p->GetData();
- BYTE* pInOrg = pIn;
-
- if (m_segments.rtStart != p->rtStart) {
- if (S_OK != (hr = DeliverSegments())) {
- return hr;
- }
- }
-
- if (!m_segments.fDiscontinuity && p->bDiscontinuity) {
- m_segments.fDiscontinuity = true;
- }
- m_segments.fSyncPoint = !!p->bSyncPoint;
- m_segments.rtStart = p->rtStart;
-
- while (pIn - pInOrg < len) {
- BYTE hdr = *pIn++;
- DWORD packetlen = 0, packetoffset = 0;
-
- if ((hdr & 0xc0) == 0x40) {
- pIn++;
- packetlen = len - (pIn - pInOrg);
- } else {
- if ((hdr & 0x40) == 0) {
- pIn++; //BYTE subseq = (*pIn++)&0x7f;
- }
-
-#define GetWORD(var) \
- var = (var << 8) | (*pIn++); \
- var = (var << 8) | (*pIn++);
-
- GetWORD(packetlen);
- if (packetlen & 0x8000) {
- m_segments.fMerged = true;
- }
- if ((packetlen & 0x4000) == 0) {
- GetWORD(packetlen);
- packetlen &= 0x3fffffff;
- } else {
- packetlen &= 0x3fff;
- }
-
- GetWORD(packetoffset);
- if ((packetoffset & 0x4000) == 0) {
- GetWORD(packetoffset);
- packetoffset &= 0x3fffffff;
- } else {
- packetoffset &= 0x3fff;
- }
-
-#undef GetWORD
-
- if ((hdr & 0xc0) == 0xc0) {
- m_segments.rtStart = 10000i64 * packetoffset - m_rtStart, packetoffset = 0;
- } else if ((hdr & 0xc0) == 0x80) {
- packetoffset = packetlen - packetoffset;
- }
-
- pIn++; //BYTE seqnum = *pIn++;
- }
-
- int len2 = min(len - (pIn - pInOrg), int(packetlen - packetoffset));
-
- CAutoPtr<segment> s(DEBUG_NEW segment);
- s->offset = packetoffset;
- s->data.SetCount(len2);
- memcpy(s->data.GetData(), pIn, len2);
- m_segments.AddTail(s);
-
- pIn += len2;
-
- if ((hdr & 0x80) || packetoffset + len2 >= packetlen) {
- if (S_OK != (hr = DeliverSegments())) {
- return hr;
- }
- }
- }
- } else if (m_mt.subtype == MEDIASUBTYPE_RAAC || m_mt.subtype == MEDIASUBTYPE_RACP
- || m_mt.subtype == MEDIASUBTYPE_AAC) {
- BYTE* ptr = p->GetData() + 2;
-
- CAtlList<WORD> sizes;
- int total = 0;
- int remaining = (int)p->GetCount() - 2;
- int expected = *(ptr - 1) >> 4;
-
- while (total < remaining) {
- int size = (ptr[0] << 8) | (ptr[1]);
- sizes.AddTail(size);
- total += size;
- ptr += 2;
- remaining -= 2;
- expected--;
- }
-
- ASSERT(total == remaining);
- ASSERT(expected == 0);
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- REFERENCE_TIME rtDur = 10240000000i64 / wfe->nSamplesPerSec * (wfe->cbSize > 2 ? 2 : 1);
- REFERENCE_TIME rtStart = p->rtStart;
- BOOL bDiscontinuity = p->bDiscontinuity;
-
- POSITION pos = sizes.GetHeadPosition();
- while (pos) {
- WORD size = sizes.GetNext(pos);
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet);
- p->bDiscontinuity = bDiscontinuity;
- p->bSyncPoint = true;
- p->rtStart = rtStart;
- p->rtStop = rtStart += rtDur;
- p->SetData(ptr, size);
- ptr += size;
- bDiscontinuity = false;
- if (S_OK != (hr = __super::DeliverPacket(p))) {
- break;
- }
- }
- } else {
- hr = __super::DeliverPacket(p);
- }
-
- return hr;
-}
-
-//
-// CRealMediaSourceFilter
-//
-
-CRealMediaSourceFilter::CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CRealMediaSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CRMFile
-//
-
-CRMFile::CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
-{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
-}
-
-template<typename T>
-HRESULT CRMFile::Read(T& var)
-{
- HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- bswap(var);
- return hr;
-}
-
-HRESULT CRMFile::Read(ChunkHdr& hdr)
-{
- ZeroMemory(&hdr, sizeof(hdr));
- HRESULT hr;
- if (S_OK != (hr = Read(hdr.object_id))
- || S_OK != (hr = Read(hdr.size))
- || S_OK != (hr = Read(hdr.object_version))) {
- return hr;
- }
- return S_OK;
-}
-
-HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull)
-{
- ZeroMemory(&mph, FIELD_OFFSET(MediaPacketHeader, pData));
- mph.stream = (UINT16) - 1;
-
- HRESULT hr;
-
- UINT16 object_version;
- if (S_OK != (hr = Read(object_version))) {
- return hr;
- }
- if (object_version != 0 && object_version != 1) {
- return S_OK;
- }
-
- UINT8 flags;
- if (S_OK != (hr = Read(mph.len))
- || S_OK != (hr = Read(mph.stream))
- || S_OK != (hr = Read(mph.tStart))
- || S_OK != (hr = Read(mph.reserved))
- || S_OK != (hr = Read(flags))) {
- return hr;
- }
- mph.flags = (MediaPacketHeader::flag_t)flags;
-
- LONG len = mph.len;
- len -= sizeof(object_version);
- len -= FIELD_OFFSET(MediaPacketHeader, flags);
- len -= sizeof(flags);
- ASSERT(len >= 0);
- len = max(len, 0);
-
- if (fFull) {
- mph.pData.SetCount(len);
- if (mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
- return hr;
- }
- } else {
- Seek(GetPos() + len);
- }
-
- return S_OK;
-}
-
-HRESULT CRMFile::Init()
-{
- Seek(0);
-
- bool fFirstChunk = true;
-
- HRESULT hr;
-
- ChunkHdr hdr;
- while (GetRemaining() && S_OK == (hr = Read(hdr))) {
- __int64 pos = GetPos() - sizeof(hdr);
-
- if (fFirstChunk && hdr.object_id != '.RMF') {
- return E_FAIL;
- }
-
- fFirstChunk = false;
-
- if (pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
- break;
- }
-
- if (hdr.object_id == 0x2E7261FD) { // '.ra+0xFD'
- return E_FAIL;
- }
-
- if (hdr.object_version == 0) {
- switch (hdr.object_id) {
- case '.RMF':
- if (S_OK != (hr = Read(m_fh.version))) {
- return hr;
- }
- if (hdr.size == 0x10) {
- WORD w = 0;
- if (S_OK != (hr = Read(w))) {
- return hr;
- }
- m_fh.nHeaders = w;
- } else if (S_OK != (hr = Read(m_fh.nHeaders))) {
- return hr;
- }
- break;
- case 'CONT':
- UINT16 slen;
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.title.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.author.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.copyright.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.comment.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- break;
- case 'PROP':
- if (S_OK != (hr = Read(m_p.maxBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.avgBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.maxPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.avgPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.nPackets))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.tDuration))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.tPreroll))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.ptrIndex))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.ptrData))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.nStreams))) {
- return hr;
- }
- UINT16 flags;
- if (S_OK != (hr = Read(flags))) {
- return hr;
- }
- m_p.flags = (Properies::flags_t)flags;
- break;
- case 'MDPR': {
- CAutoPtr<MediaProperies> mp(DEBUG_NEW MediaProperies);
- if (S_OK != (hr = Read(mp->stream))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->maxBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->avgBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->maxPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->avgPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tStart))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tPreroll))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tDuration))) {
- return hr;
- }
- UINT8 len;
- if (S_OK != (hr = Read(len))) {
- return hr;
- }
- if (len > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(len), len))) {
- return hr;
- }
- if (S_OK != (hr = Read(len))) {
- return hr;
- }
- if (len > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(len), len))) {
- return hr;
- }
- UINT32 tsdlen;
- if (S_OK != (hr = Read(tsdlen))) {
- return hr;
- }
- mp->typeSpecData.SetCount(tsdlen);
- if (tsdlen > 0 && S_OK != (hr = ByteRead(mp->typeSpecData.GetData(), tsdlen))) {
- return hr;
- }
- mp->width = mp->height = 0;
- mp->interlaced = mp->top_field_first = false;
- m_mps.AddTail(mp);
- break;
- }
- case 'DATA': {
- CAutoPtr<DataChunk> dc(DEBUG_NEW DataChunk);
- if (S_OK != (hr = Read(dc->nPackets))) {
- return hr;
- }
- if (S_OK != (hr = Read(dc->ptrNext))) {
- return hr;
- }
- dc->pos = GetPos();
- m_dcs.AddTail(dc);
- GetDimensions();
- break;
- }
- case 'INDX': {
- IndexChunkHeader ich;
- if (S_OK != (hr = Read(ich.nIndices))) {
- return hr;
- }
- if (S_OK != (hr = Read(ich.stream))) {
- return hr;
- }
- if (S_OK != (hr = Read(ich.ptrNext))) {
- return hr;
- }
- int stream = GetMasterStream();
- while (ich.nIndices-- > 0) {
- UINT16 object_version;
- if (S_OK != (hr = Read(object_version))) {
- return hr;
- }
- if (object_version == 0) {
- CAutoPtr<IndexRecord> ir(DEBUG_NEW IndexRecord);
- if (S_OK != (hr = Read(ir->tStart))) {
- return hr;
- }
- if (S_OK != (hr = Read(ir->ptrFilePos))) {
- return hr;
- }
- if (S_OK != (hr = Read(ir->packet))) {
- return hr;
- }
- if (ich.stream == stream) {
- m_irs.AddTail(ir);
- }
- }
- }
- break;
- }
- case '.SUB':
- if (hdr.size > sizeof(hdr)) {
- int size = hdr.size - sizeof(hdr);
- CAutoVectorPtr<char> buff;
- if (!buff.Allocate(size)) {
- return E_OUTOFMEMORY;
- }
- char* p = buff;
- if (S_OK != (hr = ByteRead((BYTE*)p, size))) {
- return hr;
- }
- for (char* end = p + size; p < end;) {
- subtitle s;
- s.name = p;
- p += s.name.GetLength() + 1;
- CStringA len(p);
- p += len.GetLength() + 1;
- s.data = CStringA(p, strtol(len, nullptr, 10));
- p += s.data.GetLength();
- m_subs.AddTail(s);
- }
- }
- break;
- }
- }
-
- if (hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
- hdr.size = GetPos() - pos;
- }
-
- ASSERT(hdr.object_id == 'DATA'
- || GetPos() == pos + hdr.size
- || GetPos() == pos + sizeof(hdr));
-
- pos += hdr.size;
- if (pos > GetPos()) {
- Seek(pos);
- }
- }
-
- return S_OK;
-}
-
-#define GetBits(n) GetBits2(n, p, bit_offset, bit_buffer)
-
-unsigned int GetBits2(int n, unsigned char*& p, unsigned int& bit_offset, unsigned int& bit_buffer)
-{
- unsigned int ret = ((unsigned int)bit_buffer >> (32 - (n)));
-
- bit_offset += n;
- bit_buffer <<= n;
- if (bit_offset > (32 - 16)) {
- p += bit_offset >> 3;
- bit_offset &= 7;
- bit_buffer = (unsigned int)p[0] << 24;
- bit_buffer |= (unsigned int)p[1] << 16;
- bit_buffer |= (unsigned int)p[2] << 8;
- bit_buffer |= (unsigned int)p[3];
- bit_buffer <<= bit_offset;
- }
-
- return ret;
-}
-
-void GetDimensions(unsigned char* p, unsigned int* wi, unsigned int* hi)
-{
- unsigned int w, h, c;
-
- const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
- const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
- const unsigned int ch2[4] = {180, 360, 576, 0};
-
- unsigned int bit_offset = 0;
- unsigned int bit_buffer = *(unsigned int*)p;
- bswap(bit_buffer);
-
- GetBits(13);
-
- GetBits(13);
-
- w = cw[GetBits(3)];
- if (w == 0) {
- do {
- c = GetBits(8);
- w += (c << 2);
- } while (c == 255);
- }
-
- c = GetBits(3);
-
- h = ch1[c];
- if (h == 0) {
- c = ((c << 1) | GetBits(1)) & 3;
-
- h = ch2[c];
- if (h == 0) {
- do {
- c = GetBits(8);
- h += (c << 2);
- } while (c == 255);
- }
- }
-
- *wi = w;
- *hi = h;
-}
-
-void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi,
- bool* interlaced, bool* top_field_first, bool* repeat_field)
-{
- unsigned int w, h, c;
-
- const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
- const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
- const unsigned int ch2[4] = {180, 360, 576, 0};
-
- unsigned int bit_offset = 0;
- unsigned int bit_buffer = *(unsigned int*)p;
- bswap(bit_buffer);
-
- GetBits(9);
-
- *interlaced = false;
- *top_field_first = false;
- *repeat_field = false;
- c = GetBits(1);
- if (c) {
- c = GetBits(1);
- if (c) {
- *interlaced = true;
- }
- c = GetBits(1);
- if (c) {
- *top_field_first = true;
- }
- c = GetBits(1);
- if (c) {
- *repeat_field = true;
- }
-
- c = GetBits(1);
- c = GetBits(1);
- if (c) {
- GetBits(2);
- }
- }
-
- GetBits(16);
-
- w = cw[GetBits(3)];
- if (w == 0) {
- do {
- c = GetBits(8);
- w += (c << 2);
- } while (c == 255);
- }
-
- c = GetBits(3);
-
- h = ch1[c];
- if (h == 0) {
- c = ((c << 1) | GetBits(1)) & 3;
-
- h = ch2[c];
- if (h == 0) {
- do {
- c = GetBits(8);
- h += (c << 2);
- } while (c == 255);
- }
- }
-
- *wi = w;
- *hi = h;
-}
-
-void CRMFile::GetDimensions()
-{
- POSITION pos = m_mps.GetHeadPosition();
- while (pos) {
- UINT64 filepos = GetPos();
-
- MediaProperies* pmp = m_mps.GetNext(pos);
- if (pmp->mime == "video/x-pn-realvideo") {
- pmp->width = pmp->height = 0;
-
- rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
- rvi.bswap();
-
- if (rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
- continue;
- }
-
- MediaPacketHeader mph;
- while (S_OK == Read(mph)) {
- if (mph.stream != pmp->stream || mph.len == 0
- || !(mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG)) {
- continue;
- }
-
- BYTE* p = mph.pData.GetData();
- BYTE* p0 = p;
- int len = (int)mph.pData.GetCount();
-
- BYTE hdr = *p++;
- DWORD packetlen = 0, packetoffset = 0;
-
- if ((hdr & 0xc0) == 0x40) {
- packetlen = len - (++p - p0);
- } else {
- if ((hdr & 0x40) == 0) {
- p++;
- }
-
-#define GetWORD(var) \
- var = (var << 8) | (*p++); \
- var = (var << 8) | (*p++);
-
- GetWORD(packetlen);
- if ((packetlen & 0x4000) == 0) {
- GetWORD(packetlen);
- packetlen &= 0x3fffffff;
- } else {
- packetlen &= 0x3fff;
- }
-
- GetWORD(packetoffset);
- if ((packetoffset & 0x4000) == 0) {
- GetWORD(packetoffset);
- packetoffset &= 0x3fffffff;
- } else {
- packetoffset &= 0x3fff;
- }
-
-#undef GetWORD
-
- if ((hdr & 0xc0) == 0xc0) {
- packetoffset = 0;
- } else if ((hdr & 0xc0) == 0x80) {
- packetoffset = packetlen - packetoffset;
- }
-
- p++;
- }
-
- len = min(len - (p - p0), int(packetlen - packetoffset));
-
- if (len > 0) {
- bool repeat_field;
- if (rvi.fcc2 == '14VR') {
- ::GetDimensions_X10(p, &pmp->width, &pmp->height, &pmp->interlaced, &pmp->top_field_first, &repeat_field);
- } else {
- ::GetDimensions(p, &pmp->width, &pmp->height);
- }
-
- if (rvi.w == pmp->width && rvi.h == pmp->height) {
- pmp->width = pmp->height = 0;
- }
-
- break;
- }
- }
- }
-
- Seek(filepos);
- }
-}
-
-int CRMFile::GetMasterStream()
-{
- int s1 = -1, s2 = -1;
-
- POSITION pos = m_mps.GetHeadPosition();
- while (pos) {
- MediaProperies* pmp = m_mps.GetNext(pos);
- if (pmp->mime == "video/x-pn-realvideo") {
- s1 = pmp->stream;
- break;
- } else if (pmp->mime == "audio/x-pn-realaudio" && s2 == -1) {
- s2 = pmp->stream;
- }
- }
-
- if (s1 == -1) {
- s1 = s2;
- }
-
- return s1;
-}
-
-
-////////////////////////////
-
-//
-// CRealVideoDecoder
-//
-
-CRealVideoDecoder::CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(NAME("CRealVideoDecoder"), lpunk, phr, __uuidof(this))
- , m_hDrvDll(nullptr)
- , m_dwCookie(0)
- , m_lastBuffSizeDim(0)
-{
-}
-
-CRealVideoDecoder::~CRealVideoDecoder()
-{
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- }
-}
-
-HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
-{
- FreeRV();
-
- HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
-
- rvinfo rvi = *(rvinfo*)(pmt->Format() + (pmt->formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) : sizeof(VIDEOINFOHEADER2)));
- rvi.bswap();
-
-#pragma pack(push, 1)
- struct {
- WORD unk1, w, h, unk3;
- DWORD unk2, subformat, unk5, format;
- } i =
- {11, rvi.w, rvi.h, 0, 0, rvi.type1, 1, rvi.type2};
-#pragma pack(pop)
-
- if (FAILED(hr = RVInit(&i, &m_dwCookie))) {
- return hr;
- }
-
- if (rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002) {
- int nWidthHeight = (1 + ((rvi.type1 >> 16) & 7));
- UINT32* pWH = DEBUG_NEW UINT32[nWidthHeight * 2];
- pWH[0] = rvi.w;
- pWH[1] = rvi.h;
- for (int j = 2; j < nWidthHeight * 2; j++) {
- pWH[j] = rvi.morewh[j - 2] * 4;
- }
-#pragma pack(push, 1)
- struct {
- UINT32 data1;
- UINT32 data2;
- UINT32* dimensions;
- } cmsg_data =
- {0x24, nWidthHeight, pWH};
-#pragma pack(pop)
- hr = RVCustomMessage(&cmsg_data, m_dwCookie);
- delete [] pWH;
- }
-
- return hr;
-}
-
-void CRealVideoDecoder::FreeRV()
-{
- if (m_dwCookie) {
- RVFree(m_dwCookie);
- m_dwCookie = 0;
- }
-}
-
-HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- HRESULT hr;
-
- BYTE* pDataIn = nullptr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
-
- long len = pIn->GetActualDataLength();
- if (len <= 0) {
- return S_OK; // nothing to do
- }
-
- REFERENCE_TIME rtStart, rtStop;
- pIn->GetTime(&rtStart, &rtStop);
-
- rtStart += m_tStart;
-
- int offset = 1 + ((*pDataIn) + 1) * 8;
-
-#pragma pack(push, 1)
- struct {
- DWORD len, unk1, chunks;
- DWORD* extra;
- DWORD unk2, timestamp;
- } transform_in =
- {len - offset, 0, *pDataIn, (DWORD*)(pDataIn + 1), 0, (DWORD)(rtStart / 10000)};
- struct {
- DWORD unk1, unk2, timestamp, w, h;
- } transform_out =
- {0, 0, 0, 0, 0};
-#pragma pack(pop)
-
- pDataIn += offset;
-
- if (m_fDropFrames && m_timestamp + 1 == transform_in.timestamp) {
- m_timestamp = transform_in.timestamp;
- return S_OK;
- }
-
-
- unsigned int tmp1, tmp2;
- bool interlaced = false, tmp3, tmp4;
- ::GetDimensions_X10(pDataIn, &tmp1, &tmp2, &interlaced, &tmp3, &tmp4);
-
- int size = tmp1 * tmp2;
- if (m_lastBuffSizeDim < size) {
- _aligned_free(m_pI420);
- _aligned_free(m_pI420Tmp);
-
- m_lastBuffSizeDim = size;
- TRACE(_T("resize out put buff %d") , size);
- m_pI420 = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- if (m_pI420) {
- TRACE(_T(" m_pI420.Allocated 1"));
- ZeroMemory(m_pI420, size);
- TRACE(_T(" m_pI420.Allocated 2"));
- memset(m_pI420 + size, 0x80, size / 2);
- TRACE(_T(" m_pI420.Allocated 3"));
- } else {
- TRACE(_T(" m_pI420.Allocate fail %d") , size * 3 / 2);
- return S_OK;
- }
- m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- if (m_pI420Tmp) {
- TRACE(_T(" m_pI420Tmp.Allocated 1"));
- ZeroMemory(m_pI420Tmp, size);
- TRACE(_T(" m_pI420Tmp.Allocated 2"));
- memset(m_pI420Tmp + size, 0x80, size / 2);
- TRACE(_T(" m_pI420Tmp.Allocated 3"));
- } else {
- TRACE(_T(" m_pI420Tmp.Allocate fail %d") , size * 3 / 2);
- return S_OK;
- }
- }
-
- hr = RVTransform(pDataIn, (BYTE*)m_pI420, &transform_in, &transform_out, m_dwCookie);
-
- m_timestamp = transform_in.timestamp;
-
- if (FAILED(hr)) {
- TRACE(_T("RV returned an error code!!!\n"));
- ASSERT(!(transform_out.unk1 & 1)); // error allowed when the "render" flag is not set
- // return hr;
- }
-
- if (pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1 & 1)) {
- return S_OK;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (/*FAILED(hr = GetDeliveryBuffer(transform_out.w, transform_out.h, &pOut)) // TODO
- && */ FAILED(hr = GetDeliveryBuffer(m_w, m_h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- BYTE* pI420[3] = {m_pI420, m_pI420Tmp, nullptr};
-
- if (interlaced) {
- int iSize = m_w * m_h;
- DeinterlaceBlend(pI420[1], pI420[0], m_w, m_h, m_w, m_w);
- DeinterlaceBlend(pI420[1] + iSize, pI420[0] + iSize, m_w / 2, m_h / 2, m_w / 2, m_w / 2);
- DeinterlaceBlend(pI420[1] + iSize * 5 / 4, pI420[0] + iSize * 5 / 4, m_w / 2, m_h / 2, m_w / 2, m_w / 2);
- pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
- }
-
- if (transform_out.w != m_w || transform_out.h != m_h) {
- Resize(pI420[0], transform_out.w, transform_out.h, pI420[1], m_w, m_h);
- // only one of these can be true, and when it happens the result image must be in the tmp buffer
- if (transform_out.w == m_w || transform_out.h == m_h) {
- pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
- }
- }
-
- rtStart = 10000i64 * transform_out.timestamp - m_tStart;
- rtStop = rtStart + 1;
- pOut->SetTime(&rtStart, /*nullptr*/&rtStop);
-
- pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
-
- CopyBuffer(pDataOut, pI420[0], m_w, m_h, m_w, MEDIASUBTYPE_I420);
-
- DbgLog((LOG_TRACE, 0, _T("V: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
- rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
-
- return m_pOutput->Deliver(pOut);
-}
-
-void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
-{
- int si = wi * hi, so = wo * ho;
- ASSERT(((si * so) & 3) == 0);
-
- if (wi < wo) {
- ResizeWidth(pIn, wi, hi, pOut, wo, ho);
- ResizeWidth(pIn + si, wi / 2, hi / 2, pOut + so, wo / 2, ho / 2);
- ResizeWidth(pIn + si + si / 4, wi / 2, hi / 2, pOut + so + so / 4, wo / 2, ho / 2);
- if (hi == ho) {
- return;
- }
- ResizeHeight(pOut, wo, hi, pIn, wo, ho);
- ResizeHeight(pOut + so, wo / 2, hi / 2, pIn + so, wo / 2, ho / 2);
- ResizeHeight(pOut + so + so / 4, wo / 2, hi / 2, pIn + so + so / 4, wo / 2, ho / 2);
- } else if (hi < ho) {
- ResizeHeight(pIn, wi, hi, pOut, wo, ho);
- ResizeHeight(pIn + si, wi / 2, hi / 2, pOut + so, wo / 2, ho / 2);
- ResizeHeight(pIn + si + si / 4, wi / 2, hi / 2, pOut + so + so / 4, wo / 2, ho / 2);
- if (wi == wo) {
- return;
- }
- ASSERT(0); // this is uncreachable code, but anyway... looks nice being so symmetric
- ResizeWidth(pOut, wi, ho, pIn, wo, ho);
- ResizeWidth(pOut + so, wi / 2, ho / 2, pIn + so, wo / 2, ho / 2);
- ResizeWidth(pOut + so + so / 4, wi / 2, ho / 2, pIn + so + so / 4, wo / 2, ho / 2);
- }
-}
-
-void CRealVideoDecoder::ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
-{
- for (DWORD y = 0; y < hi; y++, pIn += wi, pOut += wo) {
- if (wi == wo) {
- memcpy(pOut, pIn, wo);
- } else {
- ResizeRow(pIn, wi, 1, pOut, wo, 1);
- }
- }
-}
-
-void CRealVideoDecoder::ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
-{
- if (hi == ho) {
- memcpy(pOut, pIn, wo * ho);
- } else {
- for (DWORD x = 0; x < wo; x++, pIn++, pOut++) {
- ResizeRow(pIn, hi, wo, pOut, ho, wo);
- }
- }
-}
-
-void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DWORD wo, DWORD dpo)
-{
- ASSERT(wi < wo);
-
- if (dpo == 1) {
- for (DWORD i = 0, j = 0, dj = (wi << 16) / wo; i < wo - 1; i++, pOut++, j += dj)
- // pOut[i] = pIn[j>>16];
- {
- BYTE* p = &pIn[j >> 16];
- DWORD jf = j & 0xffff;
- *pOut = ((p[0] * (0xffff - jf) + p[1] * jf) + 0x7fff) >> 16;
- }
-
- *pOut = pIn[wi - 1];
- } else {
- for (DWORD i = 0, j = 0, dj = (wi << 16) / wo; i < wo - 1; i++, pOut += dpo, j += dj)
- // *pOut = pIn[dpi*(j>>16)];
- {
- BYTE* p = &pIn[dpi * (j >> 16)];
- DWORD jf = j & 0xffff;
- *pOut = ((p[0] * (0xffff - jf) + p[dpi] * jf) + 0x7fff) >> 16;
- }
-
- *pOut = pIn[dpi * (wi - 1)];
- }
-}
-
-HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
-{
- if (mtIn->majortype != MEDIATYPE_Video
- || mtIn->subtype != MEDIASUBTYPE_RV20
- && mtIn->subtype != MEDIASUBTYPE_RV30
- && mtIn->subtype != MEDIASUBTYPE_RV40
- && mtIn->subtype != MEDIASUBTYPE_RV41) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (mtIn->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mtIn->Format();
- if (vih2->dwPictAspectRatioX < (DWORD)vih2->bmiHeader.biWidth
- || vih2->dwPictAspectRatioY < (DWORD)vih2->bmiHeader.biHeight) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- if (!m_pInput->IsConnected()) {
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- m_hDrvDll = nullptr;
- }
-
- CAtlList<CString> paths;
- CString olddll, newdll, oldpath, newpath;
-
- olddll.Format(_T("drv%c3260.dll"), (TCHAR)((mtIn->subtype.Data1 >> 16) & 0xff));
- newdll =
- mtIn->subtype == FOURCCMap('14VR') ? _T("drvi.dll") :
- mtIn->subtype == FOURCCMap('02VR') ? _T("drv2.dll") :
- _T("drvc.dll");
-
- CRegKey key;
- TCHAR buff[MAX_PATH];
- ULONG len = sizeof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- oldpath = buff;
- TCHAR c = oldpath[oldpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- oldpath += '\\';
- }
- key.Close();
- }
- len = sizeof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- newpath = buff;
- TCHAR c = newpath[newpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- newpath += '\\';
- }
- key.Close();
- }
-
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + newdll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + newdll);
- }
- paths.AddTail(newdll); // default dll paths
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + olddll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + olddll);
- }
- paths.AddTail(olddll); // default dll paths
-
- POSITION pos = paths.GetHeadPosition();
- do {
- if (pos) {
- m_hDrvDll = LoadLibrary(paths.GetNext(pos));
- }
- } while (pos && !m_hDrvDll);
-
- if (m_hDrvDll) {
- RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420CustomMessage");
- RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV20toYUV420Free");
- RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420HiveMessage");
- RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV20toYUV420Init");
- RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV20toYUV420Transform");
-
- if (!RVCustomMessage) {
- RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420CustomMessage");
- }
- if (!RVFree) {
- RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV40toYUV420Free");
- }
- if (!RVHiveMessage) {
- RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420HiveMessage");
- }
- if (!RVInit) {
- RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV40toYUV420Init");
- }
- if (!RVTransform) {
- RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV40toYUV420Transform");
- }
- }
-
- if (!m_hDrvDll || !RVCustomMessage
- || !RVFree || !RVHiveMessage
- || !RVInit || !RVTransform) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (FAILED(InitRV(mtIn))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return S_OK;
-}
-
-HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
-{
- if (m_pOutput && m_pOutput->IsConnected()) {
- BITMAPINFOHEADER bih1, bih2;
- if (ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
- && abs(bih1.biHeight) != abs(bih2.biHeight)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return __super::CheckTransform(mtIn, mtOut);
-}
-
-HRESULT CRealVideoDecoder::StartStreaming()
-{
- const CMediaType& mt = m_pInput->CurrentMediaType();
- if (FAILED(InitRV(&mt))) {
- return E_FAIL;
- }
-
- int size = m_w * m_h;
- m_lastBuffSizeDim = size;
- m_pI420 = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- ZeroMemory(m_pI420, size);
- memset(m_pI420 + size, 0x80, size / 2);
- m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- ZeroMemory(m_pI420Tmp, size);
- memset(m_pI420Tmp + size, 0x80, size / 2);
-
- return __super::StartStreaming();
-}
-
-HRESULT CRealVideoDecoder::StopStreaming()
-{
- _aligned_free(m_pI420);
- _aligned_free(m_pI420Tmp);
-
- FreeRV();
-
- return __super::StopStreaming();
-}
-
-HRESULT CRealVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- m_timestamp = (DWORD)~0;
- m_fDropFrames = false;
-
- DWORD tmp[2] = {20, 0};
- RVHiveMessage(tmp, m_dwCookie);
-
- m_tStart = tStart;
- return __super::NewSegment(tStart, tStop, dRate);
-}
-
-HRESULT CRealVideoDecoder::AlterQuality(Quality q)
-{
- if (q.Late > 500 * 10000i64) {
- m_fDropFrames = true;
- }
- if (q.Late <= 0) {
- m_fDropFrames = false;
- }
- // TRACE(_T("CRealVideoDecoder::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
- return E_NOTIMPL;
-}
-
-/////////////////////////
-
-//
-// CRealAudioDecoder
-//
-
-CRealAudioDecoder::CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CRealAudioDecoder"), lpunk, __uuidof(this))
- , m_hDrvDll(nullptr)
- , m_dwCookie(0)
-{
- if (phr) {
- *phr = S_OK;
- }
-}
-
-CRealAudioDecoder::~CRealAudioDecoder()
-{
- // FreeRA();
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- }
-}
-
-HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
-{
- FreeRA();
-
- HRESULT hr;
-
- if (RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
- || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->Format();
-
- // someone might be doing cbSize = sizeof(WAVEFORMATEX), chances of
- // cbSize being really sizeof(WAVEFORMATEX) is less than this,
- // especially with our rm splitter ;)
- DWORD cbSize = pwfe->cbSize;
- if (cbSize == sizeof(WAVEFORMATEX)) {
- ASSERT(0);
- cbSize = 0;
- }
-
- WORD wBitsPerSample = pwfe->wBitsPerSample;
- if (!wBitsPerSample) {
- wBitsPerSample = 16;
- }
-
-#pragma pack(push, 1)
- struct {
- DWORD freq;
- WORD bpsample, channels, quality;
- DWORD bpframe, packetsize, extralen;
- void* extra;
- } initdata = {
- pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
- 0, 0, 0, nullptr
- };
-#pragma pack(pop)
-
- CAutoVectorPtr<BYTE> pBuff;
-
- if (pmt->subtype == MEDIASUBTYPE_AAC) {
- pBuff.Allocate(cbSize + 1);
- pBuff[0] = 0x02;
- memcpy(pBuff + 1, pwfe + 1, cbSize);
- initdata.extralen = cbSize + 1;
- initdata.extra = pBuff;
- } else {
- if (pmt->FormatLength() <= sizeof(WAVEFORMATEX) + cbSize) { // must have type_specific_data appended
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- BYTE* fmt = pmt->Format() + sizeof(WAVEFORMATEX) + cbSize;
-
- for (int i = 0, len = pmt->FormatLength() - (sizeof(WAVEFORMATEX) + cbSize); i < len - 4; i++, fmt++) {
- if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
- break;
- }
- }
-
- m_rai = *(rainfo*)fmt;
- m_rai.bswap();
-
- BYTE* p;
-
- if (m_rai.version2 == 4) {
- p = (BYTE*)((rainfo4*)fmt + 1);
- int len = *p++;
- p += len;
- len = *p++;
- p += len;
- ASSERT(len == 4);
- } else if (m_rai.version2 == 5) {
- p = (BYTE*)((rainfo5*)fmt + 1);
- } else {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- p += 3;
- if (m_rai.version2 == 5) {
- p++;
- }
-
- initdata.bpframe = m_rai.sub_packet_size;
- initdata.packetsize = m_rai.coded_frame_size;
- initdata.extralen = min((pmt->Format() + pmt->FormatLength()) - (p + 4), (LONG) * (DWORD*)p);
- initdata.extra = p + 4;
- }
-
- if (FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (RASetPwd) {
- RASetPwd(m_dwCookie, "Ardubancel Quazanga");
- }
-
- if (RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- return S_OK;
-}
-
-void CRealAudioDecoder::FreeRA()
-{
- if (m_dwCookie) {
- RAFreeDecoder(m_dwCookie);
- RACloseCodec(m_dwCookie);
- m_dwCookie = 0;
- }
-}
-
-HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- HRESULT hr;
-
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
- return m_pOutput->Deliver(pIn);
- }
-
- BYTE* pDataIn = nullptr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
- BYTE* pDataInOrg = pDataIn;
- UNREFERENCED_PARAMETER(pDataInOrg);
-
- long len = pIn->GetActualDataLength();
- if (len <= 0) {
- return S_OK;
- }
-
- REFERENCE_TIME rtStart, rtStop;
- pIn->GetTime(&rtStart, &rtStop);
- /*
- if (pIn->IsPreroll() == S_OK || rtStart < 0)
- return S_OK;
- */
-
- if (S_OK == pIn->IsSyncPoint()) {
- m_bufflen = 0;
- m_rtBuffStart = rtStart;
- m_fBuffDiscontinuity = pIn->IsDiscontinuity() == S_OK;
- }
-
- BYTE* src = nullptr;
- BYTE* dst = nullptr;
-
- int w = m_rai.coded_frame_size;
- int h = m_rai.sub_packet_h;
- int sps = m_rai.sub_packet_size;
-
- if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RACP
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC) {
- src = pDataIn;
- dst = pDataIn + len;
- w = len;
- } else {
- memcpy(&m_buff[m_bufflen], pDataIn, len);
- m_bufflen += len;
-
- len = w * h;
-
- if (m_bufflen >= len) {
- ASSERT(m_bufflen == len);
-
- src = m_buff;
- dst = m_buff + len;
-
- if (sps > 0
- && (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_COOK
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_ATRC)) {
- for (int y = 0; y < h; y++) {
- for (int x = 0, w2 = w / sps; x < w2; x++) {
- // TRACE(_T("--- %d, %d\n"), (h*x+((h+1)/2)*(y&1)+(y>>1)), sps*(h*x+((h+1)/2)*(y&1)+(y>>1)));
- memcpy(dst + sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)), src, sps);
- src += sps;
- }
- }
-
- src = m_buff + len;
- dst = m_buff + len * 2;
- } else if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR) {
- // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
-
- static BYTE sipr_swaps[38][2] = {
- {0, 63}, {1, 22}, {2, 44}, {3, 90}, {5, 81}, {7, 31}, {8, 86}, {9, 58}, {10, 36}, {12, 68},
- {13, 39}, {14, 73}, {15, 53}, {16, 69}, {17, 57}, {19, 88}, {20, 34}, {21, 71}, {24, 46},
- {25, 94}, {26, 54}, {28, 75}, {29, 50}, {32, 70}, {33, 92}, {35, 74}, {38, 85}, {40, 56},
- {42, 87}, {43, 65}, {45, 59}, {48, 79}, {49, 93}, {51, 89}, {55, 95}, {61, 76}, {67, 83},
- {77, 80}
- };
-
- int bs = h * w * 2 / 96; // nibbles per subpacket
- for (int n = 0; n < 38; n++) {
- int i = bs * sipr_swaps[n][0];
- int o = bs * sipr_swaps[n][1];
- // swap nibbles of block 'i' with 'o' TODO: optimize
- for (int j = 0; j < bs; j++) {
- int x = (i & 1) ? (src[(i >> 1)] >> 4) : (src[(i >> 1)] & 15);
- int y = (o & 1) ? (src[(o >> 1)] >> 4) : (src[(o >> 1)] & 15);
- if (o & 1) {
- src[(o >> 1)] = (src[(o >> 1)] & 0x0F) | (x << 4);
- } else {
- src[(o >> 1)] = (src[(o >> 1)] & 0xF0) | x;
- }
- if (i & 1) {
- src[(i >> 1)] = (src[(i >> 1)] & 0x0F) | (y << 4);
- } else {
- src[(i >> 1)] = (src[(i >> 1)] & 0xF0) | y;
- }
- ++i;
- ++o;
- }
- }
- }
-
- m_bufflen = 0;
- }
- }
-
- rtStart = m_rtBuffStart;
-
- for (; src < dst; src += w) {
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, nullptr, nullptr, 0))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- hr = RADecode(m_dwCookie, src, w, pDataOut, &len, -1);
-
- if (FAILED(hr)) {
- TRACE(_T("RA returned an error code!!!\n"));
- continue;
- // return hr;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
-
- rtStop = rtStart + 1000i64 * len / pwfe->nAvgBytesPerSec * 10000;
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- pOut->SetDiscontinuity(m_fBuffDiscontinuity);
- m_fBuffDiscontinuity = false;
- pOut->SetSyncPoint(TRUE);
-
- pOut->SetActualDataLength(len);
-
- DbgLog((LOG_TRACE, 0, _T("A: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
- rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
-
- if (rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
- return hr;
- }
-
- rtStart = rtStop;
- }
-
- m_rtBuffStart = rtStart;
-
- return S_OK;
-}
-
-HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
-{
- if (mtIn->majortype != MEDIATYPE_Audio
- || mtIn->subtype != MEDIASUBTYPE_14_4
- && mtIn->subtype != MEDIASUBTYPE_28_8
- && mtIn->subtype != MEDIASUBTYPE_ATRC
- && mtIn->subtype != MEDIASUBTYPE_COOK
- && mtIn->subtype != MEDIASUBTYPE_DNET
- && mtIn->subtype != MEDIASUBTYPE_SIPR
- && mtIn->subtype != MEDIASUBTYPE_RAAC
- && mtIn->subtype != MEDIASUBTYPE_RACP
- && mtIn->subtype != MEDIASUBTYPE_AAC) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (!m_pInput->IsConnected()) {
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- m_hDrvDll = nullptr;
- }
-
- CAtlList<CString> paths;
- CString olddll, newdll, oldpath, newpath;
-
- TCHAR fourcc[5] = {
- (TCHAR)((mtIn->subtype.Data1 >> 0) & 0xff),
- (TCHAR)((mtIn->subtype.Data1 >> 8) & 0xff),
- (TCHAR)((mtIn->subtype.Data1 >> 16) & 0xff),
- (TCHAR)((mtIn->subtype.Data1 >> 24) & 0xff),
- 0
- };
-
- if (!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
- _tcscpy_s(fourcc, _T("RAAC"));
- }
-
- olddll.Format(_T("%s3260.dll"), fourcc);
- newdll.Format(_T("%s.dll"), fourcc);
-
- CRegKey key;
- TCHAR buff[MAX_PATH];
- ULONG len = _countof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- oldpath = buff;
- TCHAR c = oldpath[oldpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- oldpath += '\\';
- }
- key.Close();
- }
- len = _countof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- newpath = buff;
- TCHAR c = newpath[newpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- newpath += '\\';
- }
- key.Close();
- }
-
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + newdll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + newdll);
- }
- paths.AddTail(newdll); // default dll paths
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + olddll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + olddll);
- }
- paths.AddTail(olddll); // default dll paths
-
- POSITION pos = paths.GetHeadPosition();
- do {
- if (pos) {
- m_hDrvDll = LoadLibrary(paths.GetNext(pos));
- }
- } while (pos && !m_hDrvDll);
-
- if (m_hDrvDll) {
- RACloseCodec = (PCloseCodec)GetProcAddress(m_hDrvDll, "RACloseCodec");
- RADecode = (PDecode)GetProcAddress(m_hDrvDll, "RADecode");
- RAFlush = (PFlush)GetProcAddress(m_hDrvDll, "RAFlush");
- RAFreeDecoder = (PFreeDecoder)GetProcAddress(m_hDrvDll, "RAFreeDecoder");
- RAGetFlavorProperty = (PGetFlavorProperty)GetProcAddress(m_hDrvDll, "RAGetFlavorProperty");
- RAInitDecoder = (PInitDecoder)GetProcAddress(m_hDrvDll, "RAInitDecoder");
- RAOpenCodec = (POpenCodec)GetProcAddress(m_hDrvDll, "RAOpenCodec");
- RAOpenCodec2 = (POpenCodec2)GetProcAddress(m_hDrvDll, "RAOpenCodec2");
- RASetFlavor = (PSetFlavor)GetProcAddress(m_hDrvDll, "RASetFlavor");
- RASetDLLAccessPath = (PSetDLLAccessPath)GetProcAddress(m_hDrvDll, "RASetDLLAccessPath");
- RASetPwd = (PSetPwd)GetProcAddress(m_hDrvDll, "RASetPwd");
- }
-
- if (!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
- || !RAFreeDecoder || !RAGetFlavorProperty || !RAInitDecoder
- || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (m_hDrvDll) {
- char chbuff[MAX_PATH];
- GetModuleFileNameA(m_hDrvDll, chbuff, MAX_PATH);
- CPathA p(chbuff);
- p.RemoveFileSpec();
- p.AddBackslash();
- m_dllpath = p.m_strPath;
- if (RASetDLLAccessPath) {
- RASetDLLAccessPath("DT_Codecs=" + m_dllpath);
- }
- }
-
- if (FAILED(InitRA(mtIn))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return S_OK;
-}
-
-HRESULT CRealAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
-{
- return mtIn->majortype == MEDIATYPE_Audio && (mtIn->subtype == MEDIASUBTYPE_14_4
- || mtIn->subtype == MEDIASUBTYPE_28_8
- || mtIn->subtype == MEDIASUBTYPE_ATRC
- || mtIn->subtype == MEDIASUBTYPE_COOK
- || mtIn->subtype == MEDIASUBTYPE_DNET
- || mtIn->subtype == MEDIASUBTYPE_SIPR
- || mtIn->subtype == MEDIASUBTYPE_RAAC
- || mtIn->subtype == MEDIASUBTYPE_RACP
- || mtIn->subtype == MEDIASUBTYPE_AAC)
- && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
-{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- CComPtr<IMemAllocator> pAllocatorIn;
- m_pInput->GetAllocator(&pAllocatorIn);
- if (!pAllocatorIn) {
- return E_UNEXPECTED;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
-
- WORD wBitsPerSample = pwfe->wBitsPerSample;
- if (!wBitsPerSample) {
- wBitsPerSample = 16;
- }
-
- // ok, maybe this is too much...
- pProperties->cBuffers = 8;
- pProperties->cbBuffer = pwfe->nChannels * pwfe->nSamplesPerSec * wBitsPerSample >> 3; // nAvgBytesPerSec;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
-}
-
-HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
-{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- *pmt = m_pInput->CurrentMediaType();
- pmt->subtype = MEDIASUBTYPE_PCM;
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEX));
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > (pwfe->nChannels > 2 && pwfe->nChannels <= 6 ? 1 : 0)) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- if (!pwfe->wBitsPerSample) {
- pwfe->wBitsPerSample = 16;
- }
-
- pwfe->cbSize = 0;
- pwfe->wFormatTag = WAVE_FORMAT_PCM;
- pwfe->nBlockAlign = pwfe->nChannels * pwfe->wBitsPerSample >> 3;
- pwfe->nAvgBytesPerSec = pwfe->nSamplesPerSec * pwfe->nBlockAlign;
-
- if (iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
- static DWORD chmask[] = {
- KSAUDIO_SPEAKER_DIRECTOUT,
- KSAUDIO_SPEAKER_MONO,
- KSAUDIO_SPEAKER_STEREO,
- KSAUDIO_SPEAKER_STEREO | SPEAKER_FRONT_CENTER,
- KSAUDIO_SPEAKER_QUAD,
- KSAUDIO_SPEAKER_QUAD | SPEAKER_FRONT_CENTER,
- KSAUDIO_SPEAKER_5POINT1
- };
-
- WAVEFORMATEXTENSIBLE* pwfex = (WAVEFORMATEXTENSIBLE*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- pwfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
- pwfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- pwfex->dwChannelMask = chmask[pwfex->Format.nChannels];
- pwfex->Samples.wValidBitsPerSample = pwfex->Format.wBitsPerSample;
- pwfex->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
- }
-
- return S_OK;
-}
-
-HRESULT CRealAudioDecoder::StartStreaming()
-{
- int w = m_rai.coded_frame_size;
- int h = m_rai.sub_packet_h;
- int sps = m_rai.sub_packet_size;
- UNREFERENCED_PARAMETER(sps);
-
- int len = w * h;
-
- m_buff.Allocate(len * 2);
- m_bufflen = 0;
- m_rtBuffStart = 0;
-
- return __super::StartStreaming();
-}
-
-HRESULT CRealAudioDecoder::StopStreaming()
-{
- m_buff.Free();
- m_bufflen = 0;
-
- return __super::StopStreaming();
-}
-
-HRESULT CRealAudioDecoder::EndOfStream()
-{
- return __super::EndOfStream();
-}
-
-HRESULT CRealAudioDecoder::BeginFlush()
-{
- return __super::BeginFlush();
-}
-
-HRESULT CRealAudioDecoder::EndFlush()
-{
- return __super::EndFlush();
-}
-
-HRESULT CRealAudioDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
- m_tStart = tStart;
- m_bufflen = 0;
- m_rtBuffStart = 0;
- return __super::NewSegment(tStart, tStop, dRate);
-}
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.def b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
deleted file mode 100644
index b7a15722c..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "../../transform/BaseVideoFilter/BaseVideoFilter.h"
-
-#define RMSplitterName L"MPC RealMedia Splitter"
-#define RMSourceName L"MPC RealMedia Source"
-#define RMVideoDecoderName L"MPC RealVideo Decoder"
-#define RMAudioDecoderName L"MPC RealAudio Decoder"
-
-#pragma pack(push, 1)
-
-namespace RMFF
-{
- typedef struct {
- union {
- char id[4];
- UINT32 object_id;
- };
- UINT32 size;
- UINT16 object_version;
- } ChunkHdr;
- typedef struct {
- UINT32 version, nHeaders;
- } FileHdr;
- typedef struct {
- UINT32 maxBitRate, avgBitRate;
- UINT32 maxPacketSize, avgPacketSize, nPackets;
- UINT32 tDuration, tPreroll;
- UINT32 ptrIndex, ptrData;
- UINT16 nStreams;
- enum flags_t {
- PN_SAVE_ENABLED = 1,
- PN_PERFECT_PLAY_ENABLED = 2,
- PN_LIVE_BROADCAST = 4
- } flags;
- } Properies;
- typedef struct {
- UINT16 stream;
- UINT32 maxBitRate, avgBitRate;
- UINT32 maxPacketSize, avgPacketSize;
- UINT32 tStart, tPreroll, tDuration;
- CStringA name, mime;
- CAtlArray<BYTE> typeSpecData;
- UINT32 width, height;
- bool interlaced, top_field_first;
- } MediaProperies;
- typedef struct {
- CStringA title, author, copyright, comment;
- } ContentDesc;
- typedef struct {
- UINT64 pos;
- UINT32 nPackets, ptrNext;
- } DataChunk;
- typedef struct {
- UINT16 len, stream;
- UINT32 tStart;
- UINT8 reserved;
- enum flag_t {
- PN_RELIABLE_FLAG = 1,
- PN_KEYFRAME_FLAG = 2
- } flags; // UINT8
- CAtlArray<BYTE> pData;
- } MediaPacketHeader;
- typedef struct {
- UINT32 nIndices;
- UINT16 stream;
- UINT32 ptrNext;
- } IndexChunkHeader;
- typedef struct {
- UINT32 tStart, ptrFilePos, packet;
- } IndexRecord;
-}
-
-struct rvinfo {
- DWORD dwSize, fcc1, fcc2;
- WORD w, h, bpp;
- DWORD unk1, fps, type1, type2;
- BYTE morewh[14];
- void bswap();
-};
-
-struct rainfo3 {
- DWORD fourcc; // Header signature ('.', 'r', 'a', 0xfd)
- WORD version; // Version (always 3)
- WORD header_size; // Header size, not including first 8 bytes
- BYTE unknown[10]; // Unknown
- DWORD data_size; // Data size
- void bswap();
-};
-
-struct rainfo {
- DWORD fourcc1; // '.', 'r', 'a', 0xfd
- WORD version1; // 4 or 5
- WORD unknown1; // 00 000
- DWORD fourcc2; // .ra4 or .ra5
- DWORD unknown2; // ???
- WORD version2; // 4 or 5
- DWORD header_size; // == 0x4e
- WORD flavor; // codec flavor id
- DWORD coded_frame_size; // coded frame size
- DWORD unknown3; // big number
- DWORD unknown4; // bigger number
- DWORD unknown5; // yet another number
- WORD sub_packet_h;
- WORD frame_size;
- WORD sub_packet_size;
- WORD unknown6; // 00 00
- void bswap();
-};
-
-struct rainfo4 : rainfo {
- WORD sample_rate;
- WORD unknown8; // 0
- WORD sample_size;
- WORD channels;
- void bswap();
-};
-
-struct rainfo5 : rainfo {
- BYTE unknown7[6]; // 0, srate, 0
- WORD sample_rate;
- WORD unknown8; // 0
- WORD sample_size;
- WORD channels;
- DWORD genr; // "genr"
- DWORD fourcc3; // fourcc
- void bswap();
-};
-
-#pragma pack(pop)
-
-class CRMFile : public CBaseSplitterFile
-{
- // using CBaseSplitterFile::Read;
-
- HRESULT Init();
- void GetDimensions();
-
-public:
- CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- template<typename T> HRESULT Read(T& var);
- HRESULT Read(RMFF::ChunkHdr& hdr);
- HRESULT Read(RMFF::MediaPacketHeader& mph, bool fFull = true);
-
- RMFF::FileHdr m_fh;
- RMFF::ContentDesc m_cd;
- RMFF::Properies m_p;
- CAutoPtrList<RMFF::MediaProperies> m_mps;
- CAutoPtrList<RMFF::DataChunk> m_dcs;
- CAutoPtrList<RMFF::IndexRecord> m_irs;
-
- typedef struct {
- CStringA name, data;
- } subtitle;
- CAtlList<subtitle> m_subs;
-
- int GetMasterStream();
-};
-
-class CRealMediaSplitterOutputPin : public CBaseSplitterOutputPin
-{
-private:
- typedef struct {
- CAtlArray<BYTE> data;
- DWORD offset;
- } segment;
-
- class CSegments : public CAutoPtrList<segment>, public CCritSec
- {
- public:
- REFERENCE_TIME rtStart;
- bool fDiscontinuity, fSyncPoint, fMerged;
- void Clear() {
- CAutoLock cAutoLock(this);
- rtStart = 0;
- fDiscontinuity = fSyncPoint = fMerged = false;
- RemoveAll();
- }
- } m_segments;
-
- CCritSec m_csQueue;
-
- HRESULT DeliverSegments();
-
-protected:
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
-
-public:
- CRealMediaSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CRealMediaSplitterOutputPin();
-
- HRESULT DeliverEndFlush();
-};
-
-class __declspec(uuid("E21BE468-5C18-43EB-B0CC-DB93A847D769"))
- CRealMediaSplitterFilter : public CBaseSplitterFilter
-{
-protected:
- CAutoPtr<CRMFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
- POSITION m_seekpos;
- UINT32 m_seekpacket;
- UINT64 m_seekfilepos;
-
-public:
- CRealMediaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CRealMediaSplitterFilter();
-
- // CBaseFilter
-
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IKeyFrameInfo
-
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-};
-
-class __declspec(uuid("765035B3-5944-4A94-806B-20EE3415F26F"))
- CRealMediaSourceFilter : public CRealMediaSplitterFilter
-{
-public:
- CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-////////////
-
-class __declspec(uuid("238D0F23-5DC9-45A6-9BE2-666160C324DD"))
- CRealVideoDecoder : public CBaseVideoFilter
-{
- typedef HRESULT(WINAPI* PRVCustomMessage)(void*, DWORD);
- typedef HRESULT(WINAPI* PRVFree)(DWORD);
- typedef HRESULT(WINAPI* PRVHiveMessage)(void*, DWORD);
- typedef HRESULT(WINAPI* PRVInit)(void*, DWORD* dwCookie);
- typedef HRESULT(WINAPI* PRVTransform)(BYTE*, BYTE*, void*, void*, DWORD);
-
- PRVCustomMessage RVCustomMessage;
- PRVFree RVFree;
- PRVHiveMessage RVHiveMessage;
- PRVInit RVInit;
- PRVTransform RVTransform;
-
- HMODULE m_hDrvDll;
- DWORD m_dwCookie;
- int m_lastBuffSizeDim;
-
- HRESULT InitRV(const CMediaType* pmt);
- void FreeRV();
-
- REFERENCE_TIME m_tStart;
-
- void Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DWORD wo, DWORD dpo);
-
- BYTE* m_pI420, *m_pI420Tmp;
-
-public:
- CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CRealVideoDecoder();
-
- HRESULT Transform(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
-
- HRESULT StartStreaming();
- HRESULT StopStreaming();
-
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
- DWORD m_timestamp;
- bool m_fDropFrames;
- HRESULT AlterQuality(Quality q);
-};
-
-class __declspec(uuid("941A4793-A705-4312-8DFC-C11CA05F397E"))
- CRealAudioDecoder : public CTransformFilter
-{
- typedef HRESULT(WINAPI* PCloseCodec)(DWORD);
- typedef HRESULT(WINAPI* PDecode)(DWORD, BYTE*, long, BYTE*, long*, long);
- typedef HRESULT(WINAPI* PFlush)(DWORD, DWORD, DWORD);
- typedef HRESULT(WINAPI* PFreeDecoder)(DWORD);
- typedef void* (WINAPI* PGetFlavorProperty)(void*, DWORD, DWORD, int*);
- typedef HRESULT(WINAPI* PInitDecoder)(DWORD, void*);
- typedef HRESULT(WINAPI* POpenCodec)(void*);
- typedef HRESULT(WINAPI* POpenCodec2)(void*, const char*);
- typedef HRESULT(WINAPI* PSetFlavor)(DWORD, WORD);
- typedef void (WINAPI* PSetDLLAccessPath)(const char*);
- typedef void (WINAPI* PSetPwd)(DWORD, const char*);
-
- PCloseCodec RACloseCodec;
- PDecode RADecode;
- PFlush RAFlush;
- PFreeDecoder RAFreeDecoder;
- PGetFlavorProperty RAGetFlavorProperty;
- PInitDecoder RAInitDecoder;
- POpenCodec RAOpenCodec;
- POpenCodec2 RAOpenCodec2;
- PSetFlavor RASetFlavor;
- PSetDLLAccessPath RASetDLLAccessPath;
- PSetPwd RASetPwd;
-
- CStringA m_dllpath;
- HMODULE m_hDrvDll;
- DWORD m_dwCookie;
-
- HRESULT InitRA(const CMediaType* pmt);
- void FreeRA();
-
- REFERENCE_TIME m_tStart;
-
- rainfo m_rai;
- CAutoVectorPtr<BYTE> m_buff;
- int m_bufflen;
- REFERENCE_TIME m_rtBuffStart;
- bool m_fBuffDiscontinuity;
-
-public:
- CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CRealAudioDecoder();
-
- HRESULT Receive(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
-
- HRESULT StartStreaming();
- HRESULT StopStreaming();
-
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-};
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc
deleted file mode 100644
index 2a64ab6b2..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "RealMedia Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "RealMedia Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "RealMediaSplitter.ax"
- VALUE "ProductName", "RealMedia Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj
deleted file mode 100644
index 9ffcc1d09..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj
+++ /dev/null
@@ -1,256 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{53CF9195-19DB-457D-8F55-8DB1706DFA84}</ProjectGuid>
- <RootNamespace>RealMediaSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>RealMediaSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="RealMediaSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="RealMediaSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="RealMediaSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="RealMediaSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\transform\BaseVideoFilter\BaseVideoFilter.vcxproj">
- <Project>{54dda60f-e528-4d07-a152-960a1e818680}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters
deleted file mode 100644
index 263090f65..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{87fab731-8112-4bbb-8e3a-65188e022232}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{1636a0aa-ab63-48eb-81e1-c644318584f1}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{c30231bb-4c89-4fc3-934f-c0ce5e8f1872}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="RealMediaSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="RealMediaSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="RealMediaSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="RealMediaSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/RealMediaSplitter/resource.h b/src/filters/parser/RealMediaSplitter/resource.h
deleted file mode 100644
index 713badf0e..000000000
--- a/src/filters/parser/RealMediaSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by RealMediaSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/RealMediaSplitter/stdafx.cpp b/src/filters/parser/RealMediaSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/RealMediaSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/RealMediaSplitter/stdafx.h b/src/filters/parser/RealMediaSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/RealMediaSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"