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:
authorXhmikosR <xhmikosr@users.sourceforge.net>2011-01-10 03:05:13 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2011-01-10 03:05:13 +0300
commit0eb98dcebf3ff5c8fbdc1235474c0d5640f9a04c (patch)
tree65e403462fdb55541e4a98358c824aa8a15b8027 /src/filters/parser
parent93411f0c1eef8de213410b0544b246dd7086be74 (diff)
legacy branch: merge r2785-r2825,r2827 from trunk
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/branches/legacy@2830 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser')
-rw-r--r--src/filters/parser/AviSplitter/AviFile.cpp548
-rw-r--r--src/filters/parser/AviSplitter/AviFile.h25
-rw-r--r--src/filters/parser/AviSplitter/AviReportWnd.cpp116
-rw-r--r--src/filters/parser/AviSplitter/AviReportWnd.h4
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.cpp550
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.h12
-rw-r--r--src/filters/parser/AviSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/AviSplitter/stdafx.h6
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.cpp117
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.h56
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.cpp723
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.h154
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.cpp88
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.h18
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp924
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.h44
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.cpp85
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.h12
-rw-r--r--src/filters/parser/BaseSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/BaseSplitter/stdafx.h6
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitter.cpp104
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitter.h10
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitterFile.cpp213
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitterFile.h7
-rw-r--r--src/filters/parser/DSMSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/DSMSplitter/stdafx.h6
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitter.cpp844
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitter.h12
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitterFile.cpp286
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitterFile.h10
-rw-r--r--src/filters/parser/DiracSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/DiracSplitter/stdafx.h32
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.cpp646
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.h24
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.h6
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h10
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp6
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp33
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.cpp1215
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.h19
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.cpp8
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.h6
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.cpp1178
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.h797
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp789
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.h29
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.h6
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.cpp74
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.h12
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.cpp199
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.h22
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.h6
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.cpp1082
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.h26
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.cpp564
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.h75
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.h6
-rw-r--r--src/filters/parser/NutSplitter/NutFile.cpp125
-rw-r--r--src/filters/parser/NutSplitter/NutFile.h47
-rw-r--r--src/filters/parser/NutSplitter/NutSplitter.cpp193
-rw-r--r--src/filters/parser/NutSplitter/NutSplitter.h16
-rw-r--r--src/filters/parser/NutSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/NutSplitter/stdafx.h6
-rw-r--r--src/filters/parser/OggSplitter/OggFile.cpp44
-rw-r--r--src/filters/parser/OggSplitter/OggFile.h29
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.cpp634
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.h42
-rw-r--r--src/filters/parser/OggSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/OggSplitter/stdafx.h6
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp1367
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.h120
-rw-r--r--src/filters/parser/RoQSplitter/RoQSplitter.cpp530
-rw-r--r--src/filters/parser/RoQSplitter/RoQSplitter.h51
-rw-r--r--src/filters/parser/RoQSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/RoQSplitter/stdafx.h6
-rw-r--r--src/filters/parser/SSFSplitter/SSFSplitter.cpp110
-rw-r--r--src/filters/parser/SSFSplitter/SSFSplitter.h13
-rw-r--r--src/filters/parser/SSFSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/SSFSplitter/stdafx.h6
-rw-r--r--src/filters/parser/StreamDriveThru/StreamDriveThru.cpp330
-rw-r--r--src/filters/parser/StreamDriveThru/StreamDriveThru.h34
-rw-r--r--src/filters/parser/StreamDriveThru/stdafx.cpp6
-rw-r--r--src/filters/parser/StreamDriveThru/stdafx.h6
88 files changed, 8411 insertions, 7238 deletions
diff --git a/src/filters/parser/AviSplitter/AviFile.cpp b/src/filters/parser/AviSplitter/AviFile.cpp
index 8e98d906b..96958a710 100644
--- a/src/filters/parser/AviSplitter/AviFile.cpp
+++ b/src/filters/parser/AviSplitter/AviFile.cpp
@@ -8,7 +8,9 @@
CAviFile::CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
m_isamv = false;
hr = Init();
}
@@ -17,38 +19,43 @@ 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 ')))
+ 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());
UNUSED_ALWAYS(hr);
- if(m_movis.GetCount() == 0) // FAILED(hr) is allowed as long as there was a movi chunk found
+ if(m_movis.GetCount() == 0) { // FAILED(hr) is allowed as long as there was a movi chunk found
return E_FAIL;
+ }
- if(m_avih.dwStreams == 0 && m_strms.GetCount() > 0)
+ if(m_avih.dwStreams == 0 && m_strms.GetCount() > 0) {
m_avih.dwStreams = m_strms.GetCount();
+ }
- if(m_avih.dwStreams != m_strms.GetCount())
+ if(m_avih.dwStreams != m_strms.GetCount()) {
return E_FAIL;
+ }
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
- if(s->strh.fccType != FCC('auds')) continue;
+ 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)
- {
+ 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())))
+ if (!m_isamv && (FAILED(BuildIndex()))) {
EmptyIndex();
+ }
return S_OK;
}
@@ -60,26 +67,24 @@ HRESULT CAviFile::BuildAMVIndex()
ULONG ulSize;
memset (&NewChunk, 0, 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;
+ 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);
+ Seek(GetPos() + ulSize);
}
TRACE ("Video packet : %d Audio packet :%d\n", m_strms[0]->cs.GetCount(), m_strms[1]->cs.GetCount());
@@ -93,177 +98,188 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end)
CAutoPtr<strm_t> strm;
- while(S_OK == hr && GetPos() < end)
- {
+ while(S_OK == hr && GetPos() < end) {
UINT64 pos = GetPos();
DWORD id = 0, size;
- if(S_OK != Read(id) || id == 0)
+ 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))
+ if(id == FCC('RIFF') || id == FCC('LIST')) {
+ if(S_OK != Read(size) || S_OK != Read(id)) {
return E_FAIL;
+ }
- if (m_isamv) size = end - GetPos() - 8; // No size set in AVM : guess end of file...
+ if (m_isamv) {
+ size = end - 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));
+ 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'))
- {
+ if(id == FCC('movi')) {
m_movis.AddTail(pos);
- if (m_isamv) BuildAMVIndex();
- }
- else
- {
+ if (m_isamv) {
+ BuildAMVIndex();
+ }
+ } else {
hr = Parse(id, pos + size);
}
- }
- else
- {
- if(S_OK != Read(size))
+ } else {
+ if(S_OK != Read(size)) {
return E_FAIL;
+ }
- 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.”
- {
+ 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;
+ 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(DNew 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.GetCount() == 0 ? 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(DNew 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);
+ 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(DNew 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.GetCount() == 0 ? 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(DNew 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);
}
- m_strms.Add(strm);
- }
- break;
- case FCC('indx'):
- if(!strm) strm.Attach(DNew strm_t());
- ASSERT(strm->indx == NULL);
- AVISUPERINDEX* pSuperIndex;
- if (size < MAXDWORD-8)
- {
- // Fix buffer overrun vulnerability : http://www.vulnhunt.com/advisories/CAL-20070912-1_Multiple_vendor_produce_handling_AVI_file_vulnerabilities.txt
- TRY
- {
- pSuperIndex = (AVISUPERINDEX*)DNew unsigned char [(size_t)(size + 8)];
+ break;
+ case FCC('indx'):
+ if(!strm) {
+ strm.Attach(DNew strm_t());
+ }
+ ASSERT(strm->indx == NULL);
+ AVISUPERINDEX* pSuperIndex;
+ if (size < MAXDWORD-8) {
+ // Fix buffer overrun vulnerability : http://www.vulnhunt.com/advisories/CAL-20070912-1_Multiple_vendor_produce_handling_AVI_file_vulnerabilities.txt
+ TRY {
+ pSuperIndex = (AVISUPERINDEX*)DNew unsigned char [(size_t)(size + 8)];
+ }
+ CATCH (CMemoryException, e) {
+ pSuperIndex = NULL;
+ }
+ END_CATCH
+ 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);
+ }
}
- CATCH (CMemoryException, e)
- {
- pSuperIndex = NULL;
+ break;
+ case FCC('dmlh'):
+ if(S_OK != Read(m_dmlh)) {
+ return E_FAIL;
}
- END_CATCH
- 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('vprp'):
+ // if(S_OK != Read(m_vprp)) return E_FAIL;
+ break;
+ case FCC('idx1'):
+ ASSERT(m_idx1 == NULL);
+ m_idx1.Attach((AVIOLDINDEX*)DNew 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;
- 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 == NULL);
- m_idx1.Attach((AVIOLDINDEX*)DNew 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;
+ 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;
@@ -272,7 +288,9 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end)
Seek(pos + size);
}
- if(strm) m_strms.Add(strm);
+ if(strm) {
+ m_strms.Add(strm);
+ }
return hr;
}
@@ -281,14 +299,15 @@ REFERENCE_TIME CAviFile::GetTotalTime()
{
REFERENCE_TIME t = 0/*10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames*/;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
REFERENCE_TIME t2 = s->GetRefTime(s->cs.GetCount(), s->totalsize);
t = max(t, t2);
}
- if(t == 0) t = 10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames;
+ if(t == 0) {
+ t = 10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames;
+ }
return(t);
}
@@ -299,63 +318,56 @@ HRESULT CAviFile::BuildIndex()
DWORD nSuperIndexes = 0;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
- if(s->indx && s->indx->nEntriesInUse > 0) nSuperIndexes++;
+ if(s->indx && s->indx->nEntriesInUse > 0) {
+ nSuperIndexes++;
+ }
}
- if(nSuperIndexes == m_avih.dwStreams)
- {
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ if(nSuperIndexes == m_avih.dwStreams) {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
AVISUPERINDEX* idx = (AVISUPERINDEX*)s->indx;
DWORD nEntriesInUse = 0;
- for(int j = 0; j < (int)idx->nEntriesInUse; j++)
- {
+ for(int j = 0; j < (int)idx->nEntriesInUse; j++) {
Seek(idx->aIndex[j].qwOffset);
AVISTDINDEX stdidx;
- if(S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex)))
- {
+ 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(int j = 0; j < (int)idx->nEntriesInUse; j++)
- {
+ for(int j = 0; j < (int)idx->nEntriesInUse; j++) {
Seek(idx->aIndex[j].qwOffset);
CAutoPtr<AVISTDINDEX> p((AVISTDINDEX*)DNew BYTE[idx->aIndex[j].dwSize]);
- if(!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize))
- {
+ if(!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize)) {
EmptyIndex();
return E_FAIL;
}
- for(int k = 0; k < (int)p->nEntriesInUse; k++)
- {
+ for(int k = 0; k < (int)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].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)
- {
+ if(m_idx1) {
s->cs[frame].filepos -= 8;
s->cs[frame].fChunkHdr = true;
}
@@ -367,23 +379,20 @@ HRESULT CAviFile::BuildIndex()
s->totalsize = size;
}
- }
- else if(AVIOLDINDEX* idx = m_idx1)
- {
+ } else if(AVIOLDINDEX* idx = m_idx1) {
int len = idx->cb/sizeof(idx->aIndex[0]);
UINT64 offset = m_movis.GetHead() + 8;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
int nFrames = 0;
- for(int j = 0; j < len; j++)
- {
- if(TRACKNUM(idx->aIndex[j].dwChunkId) == i)
+ for(int j = 0; j < len; j++) {
+ if(TRACKNUM(idx->aIndex[j].dwChunkId) == i) {
nFrames++;
+ }
}
s->cs.SetCount(nFrames);
@@ -391,19 +400,15 @@ HRESULT CAviFile::BuildIndex()
DWORD frame = 0;
UINT64 size = 0;
- for(int j = 0; j < len; j++)
- {
+ for(int j = 0; j < len; j++) {
DWORD TrackNumber = TRACKNUM(idx->aIndex[j].dwChunkId);
- if(TrackNumber == i)
- {
- if(j == 0 && idx->aIndex[j].dwOffset > offset)
- {
+ if(TrackNumber == i) {
+ if(j == 0 && idx->aIndex[j].dwOffset > offset) {
DWORD id;
Seek(offset + idx->aIndex[j].dwOffset);
Read(id);
- if(id != idx->aIndex[j].dwChunkId)
- {
+ if(id != idx->aIndex[j].dwChunkId) {
TRACE(_T("WARNING: CAviFile::Init() detected absolute chunk addressing in \'idx1\'"));
offset = 0;
}
@@ -411,9 +416,9 @@ HRESULT CAviFile::BuildIndex()
s->cs[frame].size = size;
s->cs[frame].filepos = offset + idx->aIndex[j].dwOffset;
- s->cs[frame].fKeyFrame = !!(idx->aIndex[j].dwFlags&AVIIF_KEYFRAME)
- || s->strh.fccType == FCC('auds') // FIXME: some audio index is without any kf flag
- || frame == 0; // grrr
+ s->cs[frame].fKeyFrame = !!(idx->aIndex[j].dwFlags&AVIIF_KEYFRAME)
+ || s->strh.fccType == FCC('auds') // FIXME: some audio index is without any kf flag
+ || frame == 0; // grrr
s->cs[frame].fChunkHdr = j == len-1 || idx->aIndex[j].dwOffset != idx->aIndex[j+1].dwOffset;
s->cs[frame].orgsize = idx->aIndex[j].dwSize;
@@ -427,16 +432,16 @@ HRESULT CAviFile::BuildIndex()
}
m_idx1.Free();
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
m_strms[i]->indx.Free();
+ }
return S_OK;
}
void CAviFile::EmptyIndex()
{
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
s->cs.RemoveAll();
s->totalsize = 0;
@@ -445,14 +450,16 @@ void CAviFile::EmptyIndex()
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
+ if(m_strms.GetCount() < 2) {
return(true);
-*/
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
+ }
+ /*
+ if(m_avih.dwFlags&AVIF_ISINTERLEAVED) // not reliable, nandub can write f*cked up files and still sets it
+ return(true);
+ */
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
m_strms[i]->cs2.SetCount(m_strms[i]->cs.GetCount());
+ }
DWORD* curchunks = DNew DWORD[m_avih.dwStreams];
UINT64* cursizes = DNew UINT64[m_avih.dwStreams];
@@ -462,30 +469,34 @@ bool CAviFile::IsInterleaved(bool fKeepInfo)
int end = 0;
- while(1)
- {
+ while(1) {
UINT64 fpmin = _I64_MAX;
DWORD n = (DWORD)-1;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
int 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(curchunk >= cs.GetCount()) {
+ continue;
+ }
+ UINT64 fp = cs[curchunk].filepos;
+ if(fp < fpmin) {
+ fpmin = fp;
+ n = i;
+ }
+ }
+ if(n == -1) {
+ break;
}
- if(n == -1) break;
strm_t* s = m_strms[n];
DWORD& curchunk = curchunks[n];
UINT64& cursize = cursizes[n];
- if(!s->IsRawSubtitleStream())
- {
+ 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.t = (DWORD)(s->GetRefTime(curchunk, cursize)/10000);
cs2.n = end++;
}
@@ -499,24 +510,30 @@ bool CAviFile::IsInterleaved(bool fKeepInfo)
bool fInterleaved = true;
- while(fInterleaved)
- {
+ while(fInterleaved) {
strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
int n = -1;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
int curchunk = curchunks[i];
- if(curchunk >= m_strms[i]->cs2.GetCount()) continue;
+ 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(cs2.t < cs2min.t) {
+ cs2min = cs2;
+ n = i;
+ }
+ }
+ if(n == -1) {
+ break;
}
- if(n == -1) break;
curchunks[n]++;
- if(cs2last.t >= 0 && abs((int)cs2min.n - (int)cs2last.n) >= 1000)
+ if(cs2last.t >= 0 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
fInterleaved = false;
+ }
cs2last = cs2min;
}
@@ -524,11 +541,11 @@ bool CAviFile::IsInterleaved(bool fKeepInfo)
delete [] curchunks;
delete [] cursizes;
- if(fInterleaved && !fKeepInfo)
- {
+ if(fInterleaved && !fKeepInfo) {
// this is not needed anymore, let's save a little memory then
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
m_strms[i]->cs2.RemoveAll();
+ }
}
return(fInterleaved);
@@ -538,8 +555,7 @@ REFERENCE_TIME CAviFile::strm_t::GetRefTime(DWORD frame, UINT64 size)
{
float dframe = frame;
- if(strh.fccType == FCC('auds'))
- {
+ if(strh.fccType == FCC('auds')) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
dframe = wfe->nBlockAlign ? 1.0f * size / wfe->nBlockAlign : 0;
@@ -556,27 +572,24 @@ int CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
float rate_per_scale = strh.dwScale ? 1.0f * strh.dwRate / strh.dwScale : 0;
- if(strh.fccType == FCC('auds'))
- {
+ if(strh.fccType == FCC('auds')) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
__int64 size = (__int64)(rate_per_scale * wfe->nBlockAlign * rt / 10000000 + 0.5f);
- for(frame = 0; frame < cs.GetCount(); frame++)
- {
- if(cs[frame].size > size)
- {
+ for(frame = 0; frame < cs.GetCount(); frame++) {
+ if(cs[frame].size > size) {
frame--;
break;
}
}
- }
- else
- {
+ } else {
frame = (int)(rate_per_scale * rt / 10000000 + 0.5f);
}
- if(frame >= cs.GetCount()) frame = cs.GetCount()-1;
+ if(frame >= cs.GetCount()) {
+ frame = cs.GetCount()-1;
+ }
return frame;
}
@@ -584,14 +597,17 @@ int CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
int CAviFile::strm_t::GetKeyFrame(REFERENCE_TIME rt)
{
int i = GetFrame(rt);
- for(; i > 0; i--) {if(cs[i].fKeyFrame) break;}
+ for(; i > 0; i--) {
+ if(cs[i].fKeyFrame) {
+ break;
+ }
+ }
return(i);
}
DWORD CAviFile::strm_t::GetChunkSize(DWORD size)
{
- if(strh.fccType == FCC('auds'))
- {
+ 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
}
diff --git a/src/filters/parser/AviSplitter/AviFile.h b/src/filters/parser/AviSplitter/AviFile.h
index dfc851426..ed35fd958 100644
--- a/src/filters/parser/AviSplitter/AviFile.h
+++ b/src/filters/parser/AviSplitter/AviFile.h
@@ -14,23 +14,27 @@ public:
//using CBaseSplitterFile::Read;
template<typename T>
- HRESULT Read(T& var, int offset = 0)
- {
+ HRESULT Read(T& var, int offset = 0) {
memset(&var, 0, 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
- {
+ 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;};
+ 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);
@@ -41,7 +45,10 @@ public:
bool IsRawSubtitleStream();
// tmp
- struct chunk2 {DWORD t; DWORD n;};
+ struct chunk2 {
+ DWORD t;
+ DWORD n;
+ };
CAtlArray<chunk2> cs2;
};
CAutoPtrArray<strm_t> m_strms;
@@ -50,7 +57,7 @@ public:
CAtlList<UINT64> m_movis;
bool m_isamv;
-
+
REFERENCE_TIME GetTotalTime();
HRESULT BuildIndex();
void EmptyIndex();
diff --git a/src/filters/parser/AviSplitter/AviReportWnd.cpp b/src/filters/parser/AviSplitter/AviReportWnd.cpp
index f9489f566..18b2dc44f 100644
--- a/src/filters/parser/AviSplitter/AviReportWnd.cpp
+++ b/src/filters/parser/AviSplitter/AviReportWnd.cpp
@@ -15,10 +15,11 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT
m_nChunks = 0;
m_rtDur = 0;
- for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++) {
int cnt = pAF->m_strms[i]->cs2.GetCount();
- if(cnt <= 0) continue;
+ if(cnt <= 0) {
+ continue;
+ }
CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt-1];
m_nChunks = max(m_nChunks, c2.n);
m_rtDur = max(m_rtDur, (REFERENCE_TIME)c2.t<<13);
@@ -29,9 +30,9 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT
r.DeflateRect(r.Width()/4, r.Height()/4);
LPCTSTR wndclass = AfxRegisterWndClass(
- CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS,
- AfxGetApp()->LoadStandardCursor(IDC_ARROW),
- (HBRUSH)(COLOR_BTNFACE + 1), 0);
+ CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS,
+ AfxGetApp()->LoadStandardCursor(IDC_ARROW),
+ (HBRUSH)(COLOR_BTNFACE + 1), 0);
CreateEx(0, wndclass, TITLE, WS_POPUPWINDOW|WS_CAPTION|WS_CLIPCHILDREN, r, NULL, 0);
@@ -76,14 +77,11 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT
//
- if(!fShowWarningText)
- {
+ if(!fShowWarningText) {
m_message.ShowWindow(SW_HIDE);
m_checkbox.ShowWindow(SW_HIDE);
r = cr;
- }
- else
- {
+ } else {
r.SetRect(cr.left, r.bottom + 10, cr.right, cr.bottom);
}
@@ -124,8 +122,7 @@ void CAviReportWnd::OnMouseMove(UINT nFlags, CPoint p)
r.bottom -= GRAPHFOOTER;
r2.top = r.bottom;
- if(r.PtInRect(p))
- {
+ if(r.PtInRect(p)) {
SetCapture();
int x = p.x - r.left;
@@ -146,20 +143,18 @@ void CAviReportWnd::OnMouseMove(UINT nFlags, CPoint p)
CString str;
str.Format(_T("%s (%d - %d:%02d:%02d.%03d)"), TITLE, chunk, h, m, s, ms);
SetWindowText(str);
- }
- else if(r2.PtInRect(p))
- {
+ } else if(r2.PtInRect(p)) {
SetCapture();
int dist = m_graph.GetChunkDist(p.x - r2.left);
CString str;
str.Format(_T("%s (chunk distance: %d"), TITLE, dist);
- if(dist >= 1000) str += _T(" - over the limit!");
+ if(dist >= 1000) {
+ str += _T(" - over the limit!");
+ }
str += ")";
SetWindowText(str);
- }
- else if(GetCapture() == this)
- {
+ } else if(GetCapture() == this) {
SetWindowText(TITLE);
ReleaseCapture();
@@ -176,8 +171,9 @@ CAviPlotterWnd::CAviPlotterWnd()
bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
{
- if(!CreateEx(WS_EX_CLIENTEDGE, _T("STATIC"), _T(""), WS_CHILD|WS_VISIBLE, r, pParentWnd, 0))
+ if(!CreateEx(WS_EX_CLIENTEDGE, _T("STATIC"), _T(""), WS_CHILD|WS_VISIBLE, r, pParentWnd, 0)) {
return(false);
+ }
GetClientRect(r);
int w = r.Width();
@@ -189,14 +185,26 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
ReleaseDC(pDC);
CBitmap* pOldBitmap = m_dc.SelectObject(&m_bm);
-
+
m_dc.FillSolidRect(r, 0);
{
CPen pen(PS_DOT, 1, 0x008000);
CPen* pOldPen = m_dc.SelectObject(&pen);
- for(int y = 0, dy = max(h/10,1); y < h; y += dy) {if(y == 0) continue; m_dc.MoveTo(0, y); m_dc.LineTo(w, y);}
- for(int x = 0, dx = max(w/10,1); x < w; x += dx) {if(x == 0) continue; m_dc.MoveTo(x, 0); m_dc.LineTo(x, w);}
+ for(int y = 0, dy = max(h/10,1); y < h; y += dy) {
+ if(y == 0) {
+ continue;
+ }
+ m_dc.MoveTo(0, y);
+ m_dc.LineTo(w, y);
+ }
+ for(int x = 0, dx = max(w/10,1); x < w; x += dx) {
+ if(x == 0) {
+ continue;
+ }
+ m_dc.MoveTo(x, 0);
+ m_dc.LineTo(x, w);
+ }
m_dc.SelectObject(pOldPen);
}
@@ -208,7 +216,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
m_dc.LineTo(19, 10);
m_dc.LineTo(11, 10);
m_dc.LineTo(15, 2);
- m_dc.MoveTo(w-30-10, h-15);
+ m_dc.MoveTo(w-30-10, h-15);
m_dc.LineTo(w-2-10, h-15);
m_dc.LineTo(w-10-10, h-19);
m_dc.LineTo(w-10-10, h-11);
@@ -224,8 +232,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
COLORREF clr[] = {0x0000ff,0xff0000,0x40ffff,0xff40ff,0xffff40,0xffffff};
- for(int i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < (int)pAF->m_avih.dwStreams; i++, y += dy)
- {
+ for(int i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < (int)pAF->m_avih.dwStreams; i++, y += dy) {
m_dc.SetTextColor(clr[i%pAF->m_avih.dwStreams]);
m_dc.SetBkMode(TRANSPARENT);
CString str;
@@ -235,26 +242,28 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
DWORD nmax = 0, tmax = 0;
- for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++) {
int cnt = pAF->m_strms[i]->cs2.GetCount();
- if(cnt <= 0) continue;
+ if(cnt <= 0) {
+ continue;
+ }
CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt-1];
nmax = max(nmax, c2.n);
tmax = max(tmax, c2.t);
}
- if(nmax > 0 && tmax > 0)
- {
+ if(nmax > 0 && tmax > 0) {
CAtlArray<CPen> pen;
pen.SetCount(pAF->m_avih.dwStreams);
- for(int i = 0; i < pen.GetCount(); i++)
+ for(int i = 0; i < pen.GetCount(); i++) {
pen[i].CreatePen(PS_SOLID, 2, clr[i]);
+ }
CAtlArray<CPoint> pp;
pp.SetCount(pAF->m_avih.dwStreams);
- for(int i = 0; i < pen.GetCount(); i++)
+ for(int i = 0; i < pen.GetCount(); i++) {
pp[i].SetPoint(-1, -1);
+ }
m_chunkdist.SetCount(w);
memset(m_chunkdist.GetData(), 0, sizeof(int)*w);
@@ -264,39 +273,45 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
CAviFile::strm_t::chunk2 cs2last = {(DWORD)-1, 0};
- while(1)
- {
+ while(1) {
CAviFile::strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
int n = -1;
- for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++) {
int curchunk = curchunks[i];
- if(curchunk >= pAF->m_strms[i]->cs2.GetCount()) continue;
+ if(curchunk >= pAF->m_strms[i]->cs2.GetCount()) {
+ continue;
+ }
CAviFile::strm_t::chunk2& cs2 = pAF->m_strms[i]->cs2[curchunk];
- if(cs2.t < cs2min.t) {cs2min = cs2; n = i;}
+ if(cs2.t < cs2min.t) {
+ cs2min = cs2;
+ n = i;
+ }
+ }
+ if(n == -1) {
+ break;
}
- if(n == -1) break;
CPoint p;
p.x = (int)(1.0 * w * cs2min.t / tmax);
p.y = (int)(h - 1.0 * h * cs2min.n / nmax);
- if(pp[n] != p)
- {
+ if(pp[n] != p) {
CPen* pOldPen = m_dc.SelectObject(&pen[n]);
- if(pp[n] == CPoint(-1, -1)) m_dc.MoveTo(p);
- else {m_dc.MoveTo(pp[n]); m_dc.LineTo(p);}
+ if(pp[n] == CPoint(-1, -1)) {
+ m_dc.MoveTo(p);
+ } else {
+ m_dc.MoveTo(pp[n]);
+ m_dc.LineTo(p);
+ }
m_dc.SelectObject(pOldPen);
pp[n] = p;
}
int dist = abs((int)cs2min.n - (int)cs2last.n);
- if(cs2last.t >= 0 /*&& dist >= 1000*/)
- {
- if(p.x >= 0 && p.x < w)
- {
+ if(cs2last.t >= 0 /*&& dist >= 1000*/) {
+ if(p.x >= 0 && p.x < w) {
m_chunkdist[p.x] = max(m_chunkdist[p.x], dist);
}
}
@@ -308,8 +323,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
CPen red(PS_SOLID, 1, 0x0000ff);
CPen green(PS_SOLID, 1, 0x00ff00);
- for(int x = 0; x < w; x++)
- {
+ for(int x = 0; x < w; x++) {
CPen* pOldPen = m_dc.SelectObject(m_chunkdist[x] >= 1000 ? &red : &green);
m_dc.MoveTo(x, h);
m_dc.LineTo(x, h + GRAPHFOOTER);
diff --git a/src/filters/parser/AviSplitter/AviReportWnd.h b/src/filters/parser/AviSplitter/AviReportWnd.h
index cd5c3b331..c68e6f618 100644
--- a/src/filters/parser/AviSplitter/AviReportWnd.h
+++ b/src/filters/parser/AviSplitter/AviReportWnd.h
@@ -16,7 +16,9 @@ public:
CAviPlotterWnd();
bool Create(CAviFile* pAF, CRect r, CWnd* pParentWnd);
- int GetChunkDist(int x) {return x >= 0 && x < m_chunkdist.GetCount() ? m_chunkdist[x] : 0;}
+ int GetChunkDist(int x) {
+ return x >= 0 && x < m_chunkdist.GetCount() ? m_chunkdist[x] : 0;
+ }
DECLARE_MESSAGE_MAP()
afx_msg void OnPaint();
diff --git a/src/filters/parser/AviSplitter/AviSplitter.cpp b/src/filters/parser/AviSplitter/AviSplitter.cpp
index 3f1e5a0c7..da1093520 100644
--- a/src/filters/parser/AviSplitter/AviSplitter.cpp
+++ b/src/filters/parser/AviSplitter/AviSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,26 +27,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_Avi},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CAviSplitterFilter), L"MPC - Avi Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CAviSourceFilter), L"MPC - Avi Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAviSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CAviSourceFilter>, NULL, &sudFilter[1]},
};
@@ -61,9 +57,9 @@ STDAPI DllRegisterServer()
chkbytes.AddTail(_T("0,4,,52494646,8,4,,414D5620")); // 'RIFF' ... 'AMV '
RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Avi,
- chkbytes,
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Avi,
+ chkbytes,
_T(".avi"), _T(".divx"), _T(".vp6"), _T(".amv"), NULL);
return AMovieDllRegisterServer2(TRUE);
@@ -71,7 +67,7 @@ STDAPI DllRegisterServer()
STDAPI DllUnregisterServer()
{
-// UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
+ // UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
return AMovieDllRegisterServer2(FALSE);
}
@@ -83,21 +79,20 @@ class CAviSplitterApp : public CWinApp
public:
CAviSplitterApp() {}
- BOOL InitInstance()
- {
- if(!__super::InitInstance()) return FALSE;
+ BOOL InitInstance() {
+ if(!__super::InitInstance()) {
+ return FALSE;
+ }
DllEntryPoint(m_hInstance, DLL_PROCESS_ATTACH, 0);
return TRUE;
}
- BOOL ExitInstance()
- {
+ BOOL ExitInstance() {
DllEntryPoint(m_hInstance, DLL_PROCESS_DETACH, 0);
return __super::ExitInstance();
}
- void SetDefaultRegistryKey()
- {
+ void SetDefaultRegistryKey() {
SetRegistryKey(_T("Gabest"));
}
@@ -127,7 +122,7 @@ STDMETHODIMP CAviSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void**
*ppv = NULL;
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -141,29 +136,34 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_tFrame.Free();
m_pFile.Attach(DNew CAviFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
bool fShiftDown = !!(::GetKeyState(VK_SHIFT)&0x8000);
bool fShowWarningText = !m_pFile->IsInterleaved(fShiftDown);
- if(SUCCEEDED(hr) && (fShowWarningText || fShiftDown))
- {
+ if(SUCCEEDED(hr) && (fShowWarningText || fShiftDown)) {
#ifdef REGISTER_FILTER
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif
bool fHideWarning = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), 0);
- if(!fHideWarning && !dynamic_cast<CAviSourceFilter*>(this) || fShiftDown)
- {
+ if(!fHideWarning && !dynamic_cast<CAviSourceFilter*>(this) || fShiftDown) {
CAviReportWnd wnd;
fHideWarning = wnd.DoModal(m_pFile, fHideWarning, fShowWarningText);
AfxGetApp()->WriteProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), fHideWarning);
}
- if(fShowWarningText) hr = E_FAIL;
+ if(fShowWarningText) {
+ hr = E_FAIL;
+ }
}
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetTotalTime();
@@ -171,22 +171,23 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool fHasIndex = false;
for(DWORD i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); i++)
- if(m_pFile->m_strms[i]->cs.GetCount() > 0)
+ if(m_pFile->m_strms[i]->cs.GetCount() > 0) {
fHasIndex = true;
+ }
- for(DWORD i = 0; i < m_pFile->m_strms.GetCount(); i++)
- {
+ for(DWORD i = 0; i < m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(fHasIndex && s->cs.GetCount() == 0) continue;
+ if(fHasIndex && s->cs.GetCount() == 0) {
+ continue;
+ }
CMediaType mt;
CAtlArray<CMediaType> mts;
-
+
CStringW name, label;
- if(s->strh.fccType == FCC('vids'))
- {
+ if(s->strh.fccType == FCC('vids')) {
label = L"Video";
ASSERT(s->strf.GetCount() >= sizeof(BITMAPINFOHEADER));
@@ -199,10 +200,13 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + s->strf.GetCount() - sizeof(BITMAPINFOHEADER));
memset(mt.Format(), 0, mt.FormatLength());
memcpy(&pvih->bmiHeader, s->strf.GetData(), s->strf.GetCount());
- if(s->strh.dwRate > 0) pvih->AvgTimePerFrame = 10000000i64 * s->strh.dwScale / s->strh.dwRate;
- switch(pbmi->biCompression)
- {
- case BI_RGB: case BI_BITFIELDS: mt.subtype =
+ if(s->strh.dwRate > 0) {
+ pvih->AvgTimePerFrame = 10000000i64 * s->strh.dwScale / s->strh.dwRate;
+ }
+ 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 :
@@ -210,77 +214,78 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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;
+ break;
+ // case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
+ // case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
}
- if(s->cs.GetCount() && pvih->AvgTimePerFrame > 0)
- {
+ if(s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
__int64 size = 0;
- for(int i = 0; i < s->cs.GetCount(); i++)
+ for(int i = 0; i < s->cs.GetCount(); i++) {
size += s->cs[i].orgsize;
+ }
pvih->dwBitRate = size*8 / s->cs.GetCount() * 10000000i64 / pvih->AvgTimePerFrame;
}
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (pvih->bmiHeader.biWidth*pvih->bmiHeader.biHeight*4));
+ 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'))
- {
+ } 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));
+ || s->strf.GetCount() == sizeof(PCMWAVEFORMAT));
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
- if(pwfe->nBlockAlign == 0) continue;
+ if(pwfe->nBlockAlign == 0) {
+ continue;
+ }
mt.majortype = MEDIATYPE_Audio;
- if (m_pFile->m_isamv)
+ if (m_pFile->m_isamv) {
mt.subtype = FOURCCMap(MAKEFOURCC('A','M','V','A'));
- else
+ } else {
mt.subtype = FOURCCMap(pwfe->wFormatTag);
+ }
mt.formattype = FORMAT_WaveFormatEx;
mt.SetFormat(s->strf.GetData(), max(s->strf.GetCount(), sizeof(WAVEFORMATEX)));
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 = FOURCCMap(WAVE_FORMAT_PCM); // audio renderer doesn't accept fffe in the subtype
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (pwfe->nChannels*pwfe->nSamplesPerSec*32>>3));
+ 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 = FOURCCMap(WAVE_FORMAT_PCM); // audio renderer doesn't accept fffe in the subtype
+ }
+ 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'))
- {
+ } 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));
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize*3/2
+ : (1024*1024));
mts.Add(mt);
- }
- else if(s->strh.fccType == FCC('txts'))
- {
+ } 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));
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize*3/2
+ : (1024*1024));
mts.Add(mt);
- }
- else if(s->strh.fccType == FCC('iavs'))
- {
+ } else if(s->strh.fccType == FCC('iavs')) {
label = L"Interleaved";
ASSERT(s->strh.fccHandler == FCC('dvsd'));
@@ -289,25 +294,25 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mt.subtype = FOURCCMap(s->strh.fccHandler);
mt.formattype = FORMAT_DvInfo;
mt.SetFormat(s->strf.GetData(), max(s->strf.GetCount(), sizeof(DVINFO)));
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (1024*1024));
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize*3/2
+ : (1024*1024));
mts.Add(mt);
}
- if(mts.IsEmpty())
- {
+ 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 %d", label , i);
- else
- name.Format(L"%s %d %s", label , i , CStringW(s->strn) );
+ //If you know why, please emailto: tomasen@gmail.com
+ if(s->strn.IsEmpty()) {
+ name.Format(L"%s %d", label, i);
+ } else {
+ name.Format(L"%s (%s %d)", CStringW(s->strn), label, i);
+ }
HRESULT hr;
@@ -316,18 +321,24 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
POSITION pos = m_pFile->m_info.GetStartPosition();
- while(pos)
- {
+ 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;
+ 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;
}
}
@@ -340,20 +351,21 @@ bool CAviSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CAviSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
// reindex if needed
bool fReIndex = false;
- for(int i = 0; i < (int)m_pFile->m_avih.dwStreams && !fReIndex; i++)
- {
- if(m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i))
+ for(int i = 0; i < (int)m_pFile->m_avih.dwStreams && !fReIndex; i++) {
+ if(m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i)) {
fReIndex = true;
+ }
}
- if(fReIndex)
- {
+ if(fReIndex) {
m_pFile->EmptyIndex();
m_fAbort = false;
@@ -365,9 +377,11 @@ bool CAviSplitterFilter::DemuxInit()
pSize.Allocate(m_pFile->m_avih.dwStreams);
memset((UINT64*)pSize, 0, sizeof(UINT64)*m_pFile->m_avih.dwStreams);
m_pFile->Seek(0);
- ReIndex(m_pFile->GetLength(), pSize);
+ ReIndex(m_pFile->GetLength(), pSize);
- if(m_fAbort) m_pFile->EmptyIndex();
+ if(m_fAbort) {
+ m_pFile->EmptyIndex();
+ }
m_fAbort = false;
m_nOpenProgress = 100;
@@ -380,40 +394,38 @@ HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize)
{
HRESULT hr = S_OK;
- while(S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort)
- {
+ 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)
+ 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))
+ 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 '))
+ 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))
+ }
+ } else {
+ if(S_OK != m_pFile->Read(size)) {
return E_FAIL;
+ }
DWORD TrackNumber = TRACKNUM(id);
- if(TrackNumber < m_pFile->m_strms.GetCount())
- {
+ 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')
- {
+ || type == 'iv' || type == '__' || type == 'xx') {
CAviFile::strm_t::chunk c;
c.filepos = pos;
c.size = pSize[TrackNumber];
@@ -437,10 +449,12 @@ HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize)
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);
+ if(CheckRequest(&cmd)) {
+ if(cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
}
}
@@ -454,30 +468,26 @@ void CAviSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
DbgLog((LOG_TRACE, 0, _T("Seek: %I64d"), rt/10000));
- if(rt > 0)
- {
+ if(rt > 0) {
UINT64 minfp = _I64_MAX;
- for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++)
- {
+ for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++) {
CAviFile::strm_t* s = m_pFile->m_strms[j];
int f = s->GetKeyFrame(rt);
UINT64 fp = f >= 0 ? s->cs[f].filepos : m_pFile->GetLength();
- if(!s->IsRawSubtitleStream())
+ if(!s->IsRawSubtitleStream()) {
minfp = min(minfp, fp);
+ }
}
- for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++)
- {
+ for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++) {
CAviFile::strm_t* s = m_pFile->m_strms[j];
- for(int i = 0; i < s->cs.GetCount(); i++)
- {
+ for(int i = 0; i < s->cs.GetCount(); i++) {
CAviFile::strm_t::chunk& c = s->cs[i];
- if(c.filepos >= minfp)
- {
+ if(c.filepos >= minfp) {
m_tFrame[j] = i;
break;
}
@@ -498,66 +508,62 @@ bool CAviSplitterFilter::DemuxLoop()
fDiscontinuity.SetCount(nTracks);
memset(fDiscontinuity.GetData(), 0, nTracks*sizeof(bool));
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
int minTrack = nTracks;
UINT64 minFilePos = _I64_MAX;
- for(int i = 0; i < nTracks; i++)
- {
+ for(int i = 0; i < nTracks; i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
DWORD f = m_tFrame[i];
- if(f >= (DWORD)s->cs.GetCount()) continue;
+ if(f >= (DWORD)s->cs.GetCount()) {
+ continue;
+ }
bool fUrgent = s->IsRawSubtitleStream();
- if(fUrgent || s->cs[f].filepos < minFilePos)
- {
+ if(fUrgent || s->cs[f].filepos < minFilePos) {
minTrack = i;
minFilePos = s->cs[f].filepos;
}
- if(fUrgent) break;
+ if(fUrgent) {
+ break;
+ }
}
- if(minTrack == nTracks)
+ if(minTrack == nTracks) {
break;
+ }
DWORD& f = m_tFrame[minTrack];
- do
- {
+ do {
CAviFile::strm_t* s = m_pFile->m_strms[minTrack];
m_pFile->Seek(s->cs[f].filepos);
DWORD size = 0;
- if(s->cs[f].fChunkHdr)
- {
+ if(s->cs[f].fChunkHdr) {
DWORD id = 0;
if(S_OK != m_pFile->Read(id) || id == 0 || minTrack != TRACKNUM(id)
- || S_OK != m_pFile->Read(size))
- {
+ || S_OK != m_pFile->Read(size)) {
fDiscontinuity[minTrack] = true;
break;
}
UINT64 expectedsize = (UINT64)-1;
expectedsize = f < (DWORD)s->cs.GetCount()-1
- ? s->cs[f+1].size - s->cs[f].size
- : s->totalsize - s->cs[f].size;
+ ? s->cs[f+1].size - s->cs[f].size
+ : s->totalsize - s->cs[f].size;
- if(expectedsize != s->GetChunkSize(size))
- {
+ if(expectedsize != s->GetChunkSize(size)) {
fDiscontinuity[minTrack] = true;
// ASSERT(0);
break;
}
- }
- else
- {
+ } else {
size = s->cs[f].orgsize;
}
@@ -568,22 +574,22 @@ bool CAviSplitterFilter::DemuxLoop()
p->bDiscontinuity = fDiscontinuity[minTrack];
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;
-/*
- 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));
-*/
+ if(S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
+ return(true); // break;
+ }
+ /*
+ 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));
+ */
hr = DeliverPacket(p);
fDiscontinuity[minTrack] = false;
- }
- while(0);
+ } while(0);
f++;
}
@@ -598,13 +604,10 @@ STDMETHODIMP CAviSplitterFilter::GetDuration(LONGLONG* pDuration)
CheckPointer(pDuration, E_POINTER);
CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
- if(m_timeformat == TIME_FORMAT_FRAME)
- {
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ if(m_timeformat == TIME_FORMAT_FRAME) {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType == FCC('vids'))
- {
+ if(s->strh.fccType == FCC('vids')) {
*pDuration = s->cs.GetCount();
return S_OK;
}
@@ -622,7 +625,9 @@ STDMETHODIMP CAviSplitterFilter::IsFormatSupported(const GUID* pFormat)
{
CheckPointer(pFormat, E_POINTER);
HRESULT hr = __super::IsFormatSupported(pFormat);
- if(S_OK == hr) return hr;
+ if(S_OK == hr) {
+ return hr;
+ }
return *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
}
@@ -642,7 +647,9 @@ STDMETHODIMP CAviSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
{
CheckPointer(pFormat, E_POINTER);
- if(S_OK != IsFormatSupported(pFormat)) return E_FAIL;
+ if(S_OK != IsFormatSupported(pFormat)) {
+ return E_FAIL;
+ }
m_timeformat = *pFormat;
return S_OK;
}
@@ -650,10 +657,16 @@ STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
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;
+ 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;
+ if(FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
+ return E_FAIL;
+ }
return S_OK;
}
@@ -663,101 +676,119 @@ STDMETHODIMP CAviSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID
const GUID& SourceFormat = pSourceFormat ? *pSourceFormat : m_timeformat;
const GUID& TargetFormat = pTargetFormat ? *pTargetFormat : m_timeformat;
-
- if(TargetFormat == SourceFormat)
- {
- *pTarget = Source;
+
+ if(TargetFormat == SourceFormat) {
+ *pTarget = Source;
return S_OK;
- }
- else if(TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME)
- {
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ } else if(TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType == FCC('vids'))
- {
+ 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(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ } else if(TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
+ for(int i = 0; i < (int)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 >= s->cs.GetCount()) return E_FAIL;
+ if(s->strh.fccType == FCC('vids')) {
+ if(Source < 0 || Source >= s->cs.GetCount()) {
+ return E_FAIL;
+ }
CAviFile::strm_t::chunk& c = s->cs[(int)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)
+ 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(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;
+ 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)
+ 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)
+ || (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;
+ REFERENCE_TIME
+ rtCurrent = m_rtCurrent,
+ rtStop = m_rtStop;
if((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtCurrent, &TIME_FORMAT_FRAME, rtCurrent, &TIME_FORMAT_MEDIA_TIME)))
+ && 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)))
+ && 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;
- }
+ 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;
- }
+ 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;
+ && 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;
+ && pStop)
+ if(FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
+ return E_FAIL;
+ }
return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
@@ -766,25 +797,30 @@ HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, D
STDMETHODIMP CAviSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
HRESULT hr = S_OK;
nKFs = 0;
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType != FCC('vids')) continue;
+ if(s->strh.fccType != FCC('vids')) {
+ continue;
+ }
- for(int j = 0; j < s->cs.GetCount(); j++)
- {
+ for(int j = 0; j < s->cs.GetCount(); j++) {
CAviFile::strm_t::chunk& c = s->cs[j];
- if(c.fKeyFrame) nKFs++;
+ if(c.fKeyFrame) {
+ nKFs++;
+ }
}
- if(nKFs == s->cs.GetCount())
+ if(nKFs == s->cs.GetCount()) {
hr = S_FALSE;
+ }
break;
}
@@ -797,22 +833,27 @@ STDMETHODIMP CAviSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
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;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
+ if(*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
+ return E_INVALIDARG;
+ }
UINT nKFsTmp = 0;
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType != FCC('vids')) continue;
+ if(s->strh.fccType != FCC('vids')) {
+ continue;
+ }
bool fConvertToRefTime = !!(*pFormat == TIME_FORMAT_MEDIA_TIME);
- for(int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; j++)
- {
- if(s->cs[j].fKeyFrame)
+ for(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;
+ }
}
break;
@@ -847,16 +888,15 @@ 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'))))
- {
+ 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)
+ if(clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
return E_FAIL;
+ }
}
mt.InitMediaType();
diff --git a/src/filters/parser/AviSplitter/AviSplitter.h b/src/filters/parser/AviSplitter/AviSplitter.h
index e022cc0c9..c414c5175 100644
--- a/src/filters/parser/AviSplitter/AviSplitter.h
+++ b/src/filters/parser/AviSplitter/AviSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -36,7 +36,7 @@ public:
};
class __declspec(uuid("9736D831-9D6C-4E72-B6E7-560EF9181001"))
-CAviSplitterFilter : public CBaseSplitterFilter
+ CAviSplitterFilter : public CBaseSplitterFilter
{
CAutoVectorPtr<DWORD> m_tFrame;
@@ -54,7 +54,7 @@ public:
CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IMediaSeeking
@@ -79,7 +79,7 @@ public:
};
class __declspec(uuid("CEA8DEFF-0AF7-4DB9-9A38-FB3C3AEFC0DE"))
-CAviSourceFilter : public CAviSplitterFilter
+ CAviSourceFilter : public CAviSplitterFilter
{
public:
CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/AviSplitter/stdafx.cpp b/src/filters/parser/AviSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/AviSplitter/stdafx.cpp
+++ b/src/filters/parser/AviSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/AviSplitter/stdafx.h b/src/filters/parser/AviSplitter/stdafx.h
index 7e2652f5d..37bcea3a7 100644
--- a/src/filters/parser/AviSplitter/stdafx.h
+++ b/src/filters/parser/AviSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.cpp b/src/filters/parser/BaseSplitter/AsyncReader.cpp
index deb21fd1d..cfe36e69a 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.cpp
+++ b/src/filters/parser/BaseSplitter/AsyncReader.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,30 +30,34 @@
// CAsyncFileReader
//
-CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr)
+CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr)
: CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
, m_len((ULONGLONG)-1)
, m_hBreakEvent(NULL)
, m_lOsError(0)
{
hr = Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if(SUCCEEDED(hr)) m_len = GetLength();
+ if(SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
-CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr)
+CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr)
: CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
, m_len((ULONGLONG)-1)
, m_hBreakEvent(NULL)
, m_lOsError(0)
{
hr = OpenFiles(Items, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if(SUCCEEDED(hr)) m_len = GetLength();
+ if(SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
STDMETHODIMP CAsyncFileReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IAsyncReader)
QI(ISyncReader)
QI(IFileHandle)
@@ -64,36 +68,46 @@ STDMETHODIMP CAsyncFileReader::NonDelegatingQueryInterface(REFIID riid, void** p
STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer)
{
- do
- {
- try
- {
- if((ULONGLONG)llPosition+lLength > GetLength()) return E_FAIL; // strange, but the Seek below can return llPosition even if the file is not that big (?)
- if((ULONGLONG)llPosition != Seek(llPosition, begin)) return E_FAIL;
- if((UINT)lLength < Read(pBuffer, lLength)) return E_FAIL;
+ do {
+ try {
+ if((ULONGLONG)llPosition+lLength > GetLength()) {
+ return E_FAIL; // strange, but the Seek below can return llPosition even if the file is not that big (?)
+ }
+ if((ULONGLONG)llPosition != Seek(llPosition, begin)) {
+ return E_FAIL;
+ }
+ if((UINT)lLength < Read(pBuffer, lLength)) {
+ return E_FAIL;
+ }
#if 0 // def DEBUG
static __int64 s_total = 0, s_laststoppos = 0;
s_total += lLength;
- if(s_laststoppos > llPosition)
+ if(s_laststoppos > llPosition) {
TRACE(_T("[%I64d - %I64d] %d (%I64d)\n"), llPosition, llPosition + lLength, lLength, s_total);
+ }
s_laststoppos = llPosition + lLength;
#endif
return S_OK;
- }
- catch(CFileException* e)
- {
+ } catch(CFileException* e) {
m_lOsError = e->m_lOsError;
e->Delete();
Sleep(1);
CString fn = m_strFileName;
- try {Close();} catch(CFileException* e) {e->Delete();}
- try {Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan);} catch(CFileException* e) {e->Delete();}
+ try {
+ Close();
+ } catch(CFileException* e) {
+ e->Delete();
+ }
+ try {
+ Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan);
+ } catch(CFileException* e) {
+ e->Delete();
+ }
m_strFileName = fn;
}
- }
- while(m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
+ } while(m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
return E_FAIL;
}
@@ -101,8 +115,12 @@ STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE*
STDMETHODIMP CAsyncFileReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
LONGLONG len = m_len >= 0 ? m_len : GetLength();
- if(pTotal) *pTotal = len;
- if(pAvailable) *pAvailable = len;
+ if(pTotal) {
+ *pTotal = len;
+ }
+ if(pAvailable) {
+ *pAvailable = len;
+ }
return S_OK;
}
@@ -122,15 +140,18 @@ STDMETHODIMP_(LPCTSTR) CAsyncFileReader::GetFileName()
// CAsyncUrlReader
//
-CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
+CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
: CAsyncFileReader(url, hr)
{
- if(SUCCEEDED(hr)) return;
+ if(SUCCEEDED(hr)) {
+ return;
+ }
m_url = url;
- if(CAMThread::Create())
+ if(CAMThread::Create()) {
CallWorker(CMD_INIT);
+ }
hr = Open(m_fn, modeRead|shareDenyRead|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
m_len = (ULONGLONG)-1; // force GetLength() return actual length always
@@ -138,11 +159,11 @@ CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
CAsyncUrlReader::~CAsyncUrlReader()
{
- if(ThreadExists())
+ if(ThreadExists()) {
CallWorker(CMD_EXIT);
+ }
- if(!m_fn.IsEmpty())
- {
+ if(!m_fn.IsEmpty()) {
CMultiFiles::Close();
DeleteFile(m_fn);
}
@@ -152,7 +173,9 @@ CAsyncUrlReader::~CAsyncUrlReader()
STDMETHODIMP CAsyncUrlReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
- if(pTotal) *pTotal = 0;
+ if(pTotal) {
+ *pTotal = 0;
+ }
return __super::Length(NULL, pAvailable);
}
@@ -163,41 +186,41 @@ DWORD CAsyncUrlReader::ThreadProc()
AfxSocketInit(NULL);
DWORD cmd = GetRequest();
- if(cmd != CMD_INIT) {Reply((DWORD)E_FAIL); return (DWORD)-1;}
+ if(cmd != CMD_INIT) {
+ Reply((DWORD)E_FAIL);
+ return (DWORD)-1;
+ }
- try
- {
+ try {
CInternetSession is;
CAutoPtr<CStdioFile> fin(is.OpenURL(m_url, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT|INTERNET_FLAG_NO_CACHE_WRITE));
TCHAR path[_MAX_PATH], fn[_MAX_PATH];
CFile fout;
if(GetTempPath(MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn)
- && fout.Open(fn, modeCreate|modeWrite|shareDenyWrite|typeBinary))
- {
+ && fout.Open(fn, modeCreate|modeWrite|shareDenyWrite|typeBinary)) {
m_fn = fn;
char buff[1024];
int len = fin->Read(buff, sizeof(buff));
- if(len > 0) fout.Write(buff, len);
+ if(len > 0) {
+ fout.Write(buff, len);
+ }
Reply(S_OK);
- while(!CheckRequest(&cmd))
- {
+ while(!CheckRequest(&cmd)) {
int len = fin->Read(buff, sizeof(buff));
- if(len > 0) fout.Write(buff, len);
+ if(len > 0) {
+ fout.Write(buff, len);
+ }
}
- }
- else
- {
+ } else {
Reply((DWORD)E_FAIL);
}
fin->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
- }
- catch(CInternetException* ie)
- {
+ } catch(CInternetException* ie) {
ie->Delete();
Reply((DWORD)E_FAIL);
}
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.h b/src/filters/parser/BaseSplitter/AsyncReader.h
index 64c4e9113..f649ac102 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.h
+++ b/src/filters/parser/BaseSplitter/AsyncReader.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,8 +24,8 @@
#include "MultiFiles.h"
interface __declspec(uuid("6DDB4EE7-45A0-4459-A508-BD77B32C91B2"))
-ISyncReader : public IUnknown
-{
+ISyncReader :
+public IUnknown {
STDMETHOD_(void, SetBreakEvent) (HANDLE hBreakEvent) = 0;
STDMETHOD_(bool, HasErrors) () = 0;
STDMETHOD_(void, ClearErrors) () = 0;
@@ -33,8 +33,8 @@ ISyncReader : public IUnknown
};
interface __declspec(uuid("7D55F67A-826E-40B9-8A7D-3DF0CBBD272D"))
-IFileHandle : public IUnknown
-{
+IFileHandle :
+public IUnknown {
STDMETHOD_(HANDLE, GetFileHandle)() = 0;
STDMETHOD_(LPCTSTR, GetFileName)() = 0;
};
@@ -55,21 +55,41 @@ public:
// IAsyncReader
- STDMETHODIMP RequestAllocator(IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator** ppActual) {return E_NOTIMPL;}
- STDMETHODIMP Request(IMediaSample* pSample, DWORD_PTR dwUser) {return E_NOTIMPL;}
- STDMETHODIMP WaitForNext(DWORD dwTimeout, IMediaSample** ppSample, DWORD_PTR* pdwUser) {return E_NOTIMPL;}
- STDMETHODIMP SyncReadAligned(IMediaSample* pSample) {return E_NOTIMPL;}
+ STDMETHODIMP RequestAllocator(IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator** ppActual) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Request(IMediaSample* pSample, DWORD_PTR dwUser) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP WaitForNext(DWORD dwTimeout, IMediaSample** ppSample, DWORD_PTR* pdwUser) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SyncReadAligned(IMediaSample* pSample) {
+ return E_NOTIMPL;
+ }
STDMETHODIMP SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer);
STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
- STDMETHODIMP BeginFlush() {return E_NOTIMPL;}
- STDMETHODIMP EndFlush() {return E_NOTIMPL;}
+ STDMETHODIMP BeginFlush() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP EndFlush() {
+ return E_NOTIMPL;
+ }
// ISyncReader
- STDMETHODIMP_(void) SetBreakEvent(HANDLE hBreakEvent) {m_hBreakEvent = hBreakEvent;}
- STDMETHODIMP_(bool) HasErrors() {return m_lOsError != 0;}
- STDMETHODIMP_(void) ClearErrors() {m_lOsError = 0;}
- STDMETHODIMP_(void) SetPTSOffset (REFERENCE_TIME* rtPTSOffset) { m_pCurrentPTSOffset = rtPTSOffset;};
+ STDMETHODIMP_(void) SetBreakEvent(HANDLE hBreakEvent) {
+ m_hBreakEvent = hBreakEvent;
+ }
+ STDMETHODIMP_(bool) HasErrors() {
+ return m_lOsError != 0;
+ }
+ STDMETHODIMP_(void) ClearErrors() {
+ m_lOsError = 0;
+ }
+ STDMETHODIMP_(void) SetPTSOffset (REFERENCE_TIME* rtPTSOffset) {
+ m_pCurrentPTSOffset = rtPTSOffset;
+ };
// IFileHandle
@@ -84,7 +104,7 @@ class CAsyncUrlReader : public CAsyncFileReader, protected CAMThread
protected:
enum {CMD_EXIT, CMD_INIT};
- DWORD ThreadProc();
+ DWORD ThreadProc();
public:
CAsyncUrlReader(CString url, HRESULT& hr);
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.cpp b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
index 173442b29..c23a2cd8a 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -45,15 +45,13 @@ void CPacketQueue::Add(CAutoPtr<Packet> p)
{
CAutoLock cAutoLock(this);
- if(p)
- {
+ if(p) {
m_size += p->GetDataSize();
if(p->bAppendable && !p->bDiscontinuity && !p->pmt
- && p->rtStart == Packet::INVALID_TIME
- && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME)
- {
- Packet* tail = GetTail();
+ && p->rtStart == Packet::INVALID_TIME
+ && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME) {
+ Packet* tail = GetTail();
int oldsize = tail->GetCount();
int newsize = tail->GetCount() + p->GetCount();
tail->SetCount(newsize, max(1024, newsize)); // doubles the reserved buffer size
@@ -73,7 +71,9 @@ CAutoPtr<Packet> CPacketQueue::Remove()
CAutoLock cAutoLock(this);
ASSERT(__super::GetCount() > 0);
CAutoPtr<Packet> p = RemoveHead();
- if(p) m_size -= p->GetDataSize();
+ if(p) {
+ m_size -= p->GetDataSize();
+ }
return p;
}
@@ -86,13 +86,13 @@ void CPacketQueue::RemoveAll()
int CPacketQueue::GetCount()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
return __super::GetCount();
}
int CPacketQueue::GetSize()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
return m_size;
}
@@ -122,25 +122,26 @@ STDMETHODIMP CBaseSplitterInputPin::NonDelegatingQueryInterface(REFIID riid, voi
{
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CBaseSplitterInputPin::CheckMediaType(const CMediaType* pmt)
{
return S_OK;
-/*
- return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
-*/
+ /*
+ return pmt->majortype == MEDIATYPE_Stream
+ ? S_OK
+ : E_INVALIDARG;
+ */
}
HRESULT CBaseSplitterInputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin)))
+ if(FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
+ }
return CComQIPtr<IAsyncReader>(pPin) ? S_OK : E_NOINTERFACE;
}
@@ -149,11 +150,13 @@ HRESULT CBaseSplitterInputPin::BreakConnect()
{
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this)))
+ if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this))) {
return hr;
+ }
m_pAsyncReader.Release();
@@ -164,15 +167,17 @@ HRESULT CBaseSplitterInputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
CheckPointer(pPin, E_POINTER);
m_pAsyncReader = pPin;
CheckPointer(m_pAsyncReader, E_NOINTERFACE);
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this)))
+ if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this))) {
return hr;
+ }
return S_OK;
}
@@ -222,8 +227,8 @@ STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, vo
{
CheckPointer(ppv, E_POINTER);
- return
-// riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
+ return
+ // riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
QI(IMediaSeeking)
QI(IPropertyBag)
QI(IPropertyBag2)
@@ -235,7 +240,9 @@ STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, vo
HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
{
CheckPointer(pName, E_POINTER);
- if(m_pName) delete [] m_pName;
+ if(m_pName) {
+ delete [] m_pName;
+ }
m_pName = DNew WCHAR[wcslen(pName)+1];
CheckPointer(m_pName, E_OUTOFMEMORY);
wcscpy(m_pName, pName);
@@ -244,35 +251,38 @@ HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
HRESULT CBaseSplitterOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
pProperties->cBuffers = m_nBuffers;
pProperties->cbBuffer = max(m_mt.lSampleSize, 1);
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat) {
// oh great, the oggds vorbis decoder assumes there will be two at least, stupid thing...
pProperties->cBuffers = max(pProperties->cBuffers, 2);
}
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if(Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CBaseSplitterOutputPin::CheckMediaType(const CMediaType* pmt)
{
- for(int i = 0; i < m_mts.GetCount(); i++)
- {
- if(*pmt == m_mts[i])
+ for(int i = 0; i < m_mts.GetCount(); i++) {
+ if(*pmt == m_mts[i]) {
return S_OK;
+ }
}
return E_INVALIDARG;
@@ -280,10 +290,14 @@ HRESULT CBaseSplitterOutputPin::CheckMediaType(const CMediaType* pmt)
HRESULT CBaseSplitterOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= m_mts.GetCount()) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= m_mts.GetCount()) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
*pmt = m_mts[iPosition];
@@ -299,20 +313,22 @@ STDMETHODIMP CBaseSplitterOutputPin::Notify(IBaseFilter* pSender, Quality q)
HRESULT CBaseSplitterOutputPin::Active()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(m_Connected)
+ if(m_Connected) {
Create();
+ }
return __super::Active();
}
HRESULT CBaseSplitterOutputPin::Inactive()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(ThreadExists())
+ if(ThreadExists()) {
CallWorker(CMD_EXIT);
+ }
return __super::Inactive();
}
@@ -325,13 +341,17 @@ HRESULT CBaseSplitterOutputPin::DeliverBeginFlush()
m_hrDeliver = S_FALSE;
m_queue.RemoveAll();
HRESULT hr = IsConnected() ? GetConnected()->BeginFlush() : S_OK;
- if(S_OK != hr) m_eEndFlush.Set();
+ if(S_OK != hr) {
+ m_eEndFlush.Set();
+ }
return(hr);
}
HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
{
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;
m_hrDeliver = S_OK;
m_fFlushing = false;
@@ -343,11 +363,17 @@ HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
HRESULT CBaseSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
- if(m_fFlushing) return S_FALSE;
+ if(m_fFlushing) {
+ return S_FALSE;
+ }
m_rtStart = tStart;
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
MakeISCRHappy();
return hr;
}
@@ -369,15 +395,19 @@ HRESULT CBaseSplitterOutputPin::QueueEndOfStream()
HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
{
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
- while(S_OK == m_hrDeliver
- && (!(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()
- || m_queue.GetSize() > MAXPACKETSIZE*100))
+ while(S_OK == m_hrDeliver
+ && (!(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()
+ || m_queue.GetSize() > MAXPACKETSIZE*100)) {
Sleep(1);
+ }
- if(S_OK != m_hrDeliver)
+ if(S_OK != m_hrDeliver) {
return m_hrDeliver;
+ }
m_queue.Add(p);
@@ -387,25 +417,24 @@ HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
bool CBaseSplitterOutputPin::IsDiscontinuous()
{
return m_mt.majortype == MEDIATYPE_Text
- || m_mt.majortype == MEDIATYPE_ScriptCommand
- || m_mt.majortype == MEDIATYPE_Subtitle
- || m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE;
+ || m_mt.majortype == MEDIATYPE_ScriptCommand
+ || m_mt.majortype == MEDIATYPE_Subtitle
+ || m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE;
}
bool CBaseSplitterOutputPin::IsActive()
{
CComPtr<IPin> pPin = this;
- do
- {
+ do {
CComPtr<IPin> pPinTo;
CComQIPtr<IStreamSwitcherInputPin> pSSIP;
- if(S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive())
+ if(S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive()) {
return(false);
+ }
pPin = GetFirstPin(GetFilterFromPin(pPinTo), PINDIR_OUTPUT);
- }
- while(pPin);
+ } while(pPin);
return(true);
}
@@ -417,13 +446,11 @@ DWORD CBaseSplitterOutputPin::ThreadProc()
m_fFlushing = m_fFlushed = false;
m_eEndFlush.Set();
- while(1)
- {
+ while(1) {
Sleep(1);
DWORD cmd;
- if(CheckRequest(&cmd))
- {
+ if(CheckRequest(&cmd)) {
m_hThread = NULL;
cmd = GetRequest();
Reply(S_OK);
@@ -432,39 +459,36 @@ DWORD CBaseSplitterOutputPin::ThreadProc()
}
int cnt = 0;
- do
- {
+ do {
CAutoPtr<Packet> p;
{
CAutoLock cAutoLock(&m_queue);
- if((cnt = m_queue.GetCount()) > 0)
+ if((cnt = m_queue.GetCount()) > 0) {
p = m_queue.Remove();
+ }
}
- if(S_OK == m_hrDeliver && cnt > 0)
- {
+ if(S_OK == m_hrDeliver && cnt > 0) {
ASSERT(!m_fFlushing);
m_fFlushed = false;
// flushing can still start here, to release a blocked deliver call
- HRESULT hr = p
- ? DeliverPacket(p)
- : DeliverEndOfStream();
+ HRESULT hr = p
+ ? DeliverPacket(p)
+ : DeliverEndOfStream();
m_eEndFlush.Wait(); // .. so we have to wait until it is done
- if(hr != S_OK && !m_fFlushed) // and only report the error in m_hrDeliver if we didn't flush the stream
- {
+ if(hr != S_OK && !m_fFlushed) { // and only report the error in m_hrDeliver if we didn't flush the stream
// CAutoLock cAutoLock(&m_csQueueLock);
m_hrDeliver = hr;
break;
}
}
- }
- while(--cnt > 0);
+ } while(--cnt > 0);
}
}
@@ -474,23 +498,19 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
INT_PTR nBytes = p->GetCount();
- if(nBytes == 0)
- {
+ if(nBytes == 0) {
return S_OK;
}
m_brs.nBytesSinceLastDeliverTime += nBytes;
- if(p->rtStart != Packet::INVALID_TIME)
- {
- if(m_brs.rtLastDeliverTime == Packet::INVALID_TIME)
- {
+ if(p->rtStart != Packet::INVALID_TIME) {
+ if(m_brs.rtLastDeliverTime == Packet::INVALID_TIME) {
m_brs.rtLastDeliverTime = p->rtStart;
m_brs.nBytesSinceLastDeliverTime = 0;
}
- if(m_brs.rtLastDeliverTime + 10000000 < p->rtStart)
- {
+ if(m_brs.rtLastDeliverTime + 10000000 < p->rtStart) {
REFERENCE_TIME rtDiff = p->rtStart - m_brs.rtLastDeliverTime;
double secs, bits;
@@ -508,80 +528,106 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_brs.rtLastDeliverTime = p->rtStart;
m_brs.nBytesSinceLastDeliverTime = 0;
-/*
- TRACE(_T("[%d] c: %d kbps, a: %d kbps\n"),
- p->TrackNumber,
- (m_brs.nCurrentBitRate+500)/1000,
- (m_brs.nAverageBitRate+500)/1000);
-*/
+ /*
+ TRACE(_T("[%d] c: %d kbps, a: %d kbps\n"),
+ p->TrackNumber,
+ (m_brs.nCurrentBitRate+500)/1000,
+ (m_brs.nAverageBitRate+500)/1000);
+ */
}
double dRate = 1.0;
- if(SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate)))
- {
+ if(SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate))) {
p->rtStart = (REFERENCE_TIME)((double)p->rtStart / dRate);
p->rtStop = (REFERENCE_TIME)((double)p->rtStop / dRate);
}
}
- do
- {
+ do {
CComPtr<IMediaSample> pSample;
- if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) break;
+ if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ break;
+ }
- if(nBytes > pSample->GetSize())
- {
+ if(nBytes > pSample->GetSize()) {
pSample.Release();
ALLOCATOR_PROPERTIES props, actual;
- if(S_OK != (hr = m_pAllocator->GetProperties(&props))) break;
+ if(S_OK != (hr = m_pAllocator->GetProperties(&props))) {
+ break;
+ }
props.cbBuffer = nBytes*3/2;
- if(props.cBuffers > 1)
- {
- if(S_OK != (hr = __super::DeliverBeginFlush())) break;
- if(S_OK != (hr = __super::DeliverEndFlush())) break;
+ if(props.cBuffers > 1) {
+ if(S_OK != (hr = __super::DeliverBeginFlush())) {
+ break;
+ }
+ if(S_OK != (hr = __super::DeliverEndFlush())) {
+ break;
+ }
}
- if(S_OK != (hr = m_pAllocator->Decommit())) break;
- if(S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) break;
- if(S_OK != (hr = m_pAllocator->Commit())) break;
- if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) break;
+ if(S_OK != (hr = m_pAllocator->Decommit())) {
+ break;
+ }
+ if(S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) {
+ break;
+ }
+ if(S_OK != (hr = m_pAllocator->Commit())) {
+ break;
+ }
+ if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ break;
+ }
}
- if(p->pmt)
- {
+ if(p->pmt) {
pSample->SetMediaType(p->pmt);
p->bDiscontinuity = true;
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
m_mts.RemoveAll();
m_mts.Add(*p->pmt);
}
bool fTimeValid = p->rtStart != Packet::INVALID_TIME;
-/*
-//if(p->TrackNumber == 1)
-//if(p->rtStart != Packet::INVALID_TIME)
-TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
- nBytes, p->rtStart, p->rtStop);
-*/
+ /*
+ //if(p->TrackNumber == 1)
+ //if(p->rtStart != Packet::INVALID_TIME)
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
+ nBytes, p->rtStart, p->rtStop);
+ */
ASSERT(!p->bSyncPoint || fTimeValid);
BYTE* pData = NULL;
- if(S_OK != (hr = pSample->GetPointer(&pData)) || !pData) break;
+ if(S_OK != (hr = pSample->GetPointer(&pData)) || !pData) {
+ break;
+ }
memcpy(pData, p->GetData(), nBytes);
- if(S_OK != (hr = pSample->SetActualDataLength(nBytes))) break;
- if(S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) break;
- if(S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) break;
- if(S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) break;
- if(S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) break;
- if(S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) break;
- if(S_OK != (hr = Deliver(pSample))) break;
- }
- while(false);
+ if(S_OK != (hr = pSample->SetActualDataLength(nBytes))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) {
+ break;
+ }
+ if(S_OK != (hr = Deliver(pSample))) {
+ break;
+ }
+ } while(false);
return hr;
}
@@ -589,17 +635,16 @@ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
void CBaseSplitterOutputPin::MakeISCRHappy()
{
CComPtr<IPin> pPinTo = this, pTmp;
- while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp))
- {
+ while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
pTmp = NULL;
CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
- if(GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) // ISCR
- {
+ if(GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = (DWORD)-1;
- p->rtStart = -1; p->rtStop = 0;
+ p->rtStart = -1;
+ p->rtStop = 0;
p->bSyncPoint = FALSE;
p->SetData(" ", 2);
QueuePacket(p);
@@ -705,7 +750,9 @@ CBaseSplitterFilter::CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT*
, m_rtLastStop(_I64_MIN)
, m_priority(THREAD_PRIORITY_NORMAL)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput.Attach(DNew CBaseSplitterInputPin(NAME("CBaseSplitterInputPin"), this, this, phr));
}
@@ -724,10 +771,11 @@ STDMETHODIMP CBaseSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void*
*ppv = NULL;
- if(m_pInput && riid == __uuidof(IFileSourceFilter))
+ if(m_pInput && riid == __uuidof(IFileSourceFilter)) {
return E_NOINTERFACE;
+ }
- return
+ return
QI(IFileSourceFilter)
QI(IMediaSeeking)
QI(IAMOpenProgress)
@@ -747,7 +795,7 @@ CBaseSplitterOutputPin* CBaseSplitterFilter::GetOutputPin(DWORD TrackNum)
{
CAutoLock cAutoLock(&m_csPinMap);
- CBaseSplitterOutputPin* pPin = NULL;
+ CBaseSplitterOutputPin* pPin = NULL;
m_pPinMap.Lookup(TrackNum, pPin);
return pPin;
}
@@ -757,12 +805,13 @@ DWORD CBaseSplitterFilter::GetOutputTrackNum(CBaseSplitterOutputPin* pPin)
CAutoLock cAutoLock(&m_csPinMap);
POSITION pos = m_pPinMap.GetStartPosition();
- while(pos)
- {
+ while(pos) {
DWORD TrackNum;
CBaseSplitterOutputPin* pPinTmp;
m_pPinMap.GetNextAssoc(pos, TrackNum, pPinTmp);
- if(pPinTmp == pPin) return TrackNum;
+ if(pPinTmp == pPin) {
+ return TrackNum;
+ }
}
return (DWORD)-1;
@@ -773,19 +822,17 @@ HRESULT CBaseSplitterFilter::RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDs
CAutoLock cAutoLock(&m_csPinMap);
CBaseSplitterOutputPin* pPin;
- if(m_pPinMap.Lookup(TrackNumSrc, pPin))
- {
- if(CComQIPtr<IPin> pPinTo = pPin->GetConnected())
- {
- if(pmt && S_OK != pPinTo->QueryAccept(pmt))
+ if(m_pPinMap.Lookup(TrackNumSrc, pPin)) {
+ if(CComQIPtr<IPin> pPinTo = pPin->GetConnected()) {
+ if(pmt && S_OK != pPinTo->QueryAccept(pmt)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
m_pPinMap.RemoveKey(TrackNumSrc);
m_pPinMap[TrackNumDst] = pPin;
- if(pmt)
- {
+ if(pmt) {
CAutoLock cAutoLock(&m_csmtnew);
m_mtnew[TrackNumDst] = *pmt;
}
@@ -800,7 +847,9 @@ HRESULT CBaseSplitterFilter::AddOutputPin(DWORD TrackNum, CAutoPtr<CBaseSplitter
{
CAutoLock cAutoLock(&m_csPinMap);
- if(!pPin) return E_INVALIDARG;
+ if(!pPin) {
+ return E_INVALIDARG;
+ }
m_pPinMap[TrackNum] = pPin;
m_pOutputs.AddTail(pPin);
return S_OK;
@@ -813,12 +862,15 @@ HRESULT CBaseSplitterFilter::DeleteOutputs()
m_pRetiredOutputs.RemoveAll();
CAutoLock cAutoLockF(this);
- if(m_State != State_Stopped) return VFW_E_NOT_STOPPED;
+ if(m_State != State_Stopped) {
+ return VFW_E_NOT_STOPPED;
+ }
- while(m_pOutputs.GetCount())
- {
+ while(m_pOutputs.GetCount()) {
CAutoPtr<CBaseSplitterOutputPin> pPin = m_pOutputs.RemoveHead();
- if(IPin* pPinTo = pPin->GetConnected()) pPinTo->Disconnect();
+ if(IPin* pPinTo = pPin->GetConnected()) {
+ pPinTo->Disconnect();
+ }
pPin->Disconnect();
// we can't just let it be deleted now, something might have AddRefed on it (graphedit...)
m_pRetiredOutputs.AddTail(pPin);
@@ -845,40 +897,45 @@ void CBaseSplitterFilter::DeliverBeginFlush()
{
m_fFlushing = true;
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->DeliverBeginFlush();
+ while(pos) {
+ m_pOutputs.GetNext(pos)->DeliverBeginFlush();
+ }
}
void CBaseSplitterFilter::DeliverEndFlush()
{
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->DeliverEndFlush();
+ while(pos) {
+ m_pOutputs.GetNext(pos)->DeliverEndFlush();
+ }
m_fFlushing = false;
m_eEndFlush.Set();
}
DWORD CBaseSplitterFilter::ThreadProc()
{
- if(m_pSyncReader)
+ if(m_pSyncReader) {
m_pSyncReader->SetBreakEvent(GetRequestHandle());
+ }
- if(!DemuxInit())
- {
- while(1)
- {
+ if(!DemuxInit()) {
+ while(1) {
DWORD cmd = GetRequest();
- if(cmd == CMD_EXIT) CAMThread::m_hThread = NULL;
+ if(cmd == CMD_EXIT) {
+ CAMThread::m_hThread = NULL;
+ }
Reply(S_OK);
- if(cmd == CMD_EXIT) return 0;
+ if(cmd == CMD_EXIT) {
+ return 0;
+ }
}
}
m_eEndFlush.Set();
m_fFlushing = false;
- for(DWORD cmd = (DWORD)-1; ; cmd = GetRequest())
- {
- if(cmd == CMD_EXIT)
- {
+ for(DWORD cmd = (DWORD)-1; ; cmd = GetRequest()) {
+ if(cmd == CMD_EXIT) {
m_hThread = NULL;
Reply(S_OK);
return 0;
@@ -891,30 +948,31 @@ DWORD CBaseSplitterFilter::ThreadProc()
DemuxSeek(m_rtStart);
- if(cmd != (DWORD)-1)
+ if(cmd != (DWORD)-1) {
Reply(S_OK);
+ }
m_eEndFlush.Wait();
m_pActivePins.RemoveAll();
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !m_fFlushing)
- {
+ while(pos && !m_fFlushing) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetNext(pos);
- if(pPin->IsConnected() && pPin->IsActive())
- {
+ if(pPin->IsConnected() && pPin->IsActive()) {
m_pActivePins.AddTail(pPin);
pPin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);
}
}
- do {m_bDiscontinuitySent.RemoveAll();}
- while(!DemuxLoop());
+ do {
+ m_bDiscontinuitySent.RemoveAll();
+ } while(!DemuxLoop());
pos = m_pActivePins.GetHeadPosition();
- while(pos && !CheckRequest(&cmd))
+ while(pos && !CheckRequest(&cmd)) {
m_pActivePins.GetNext(pos)->QueueEndOfStream();
+ }
}
ASSERT(0); // we should only exit via CMD_EXIT
@@ -928,11 +986,11 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p)
HRESULT hr = S_FALSE;
CBaseSplitterOutputPin* pPin = GetOutputPin(p->TrackNumber);
- if(!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin))
+ if(!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin)) {
return S_FALSE;
+ }
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ if(p->rtStart != Packet::INVALID_TIME) {
m_rtCurrent = p->rtStart;
p->rtStart -= m_rtStart;
@@ -945,42 +1003,44 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p)
CAutoLock cAutoLock(&m_csmtnew);
CMediaType mt;
- if(m_mtnew.Lookup(p->TrackNumber, mt))
- {
+ if(m_mtnew.Lookup(p->TrackNumber, mt)) {
p->pmt = CreateMediaType(&mt);
m_mtnew.RemoveKey(p->TrackNumber);
}
}
- if(!m_bDiscontinuitySent.Find(p->TrackNumber))
+ if(!m_bDiscontinuitySent.Find(p->TrackNumber)) {
p->bDiscontinuity = TRUE;
+ }
DWORD TrackNumber = p->TrackNumber;
BOOL bDiscontinuity = p->bDiscontinuity;
-/*
-//if(p->TrackNumber == 1)
-//if(p->rtStart != Packet::INVALID_TIME)
-TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
- p->GetCount(), p->rtStart, p->rtStop);
-*/
+ /*
+ //if(p->TrackNumber == 1)
+ //if(p->rtStart != Packet::INVALID_TIME)
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
+ p->GetCount(), p->rtStart, p->rtStop);
+ */
hr = pPin->QueuePacket(p);
- if(S_OK != hr)
- {
- if(POSITION pos = m_pActivePins.Find(pPin))
+ if(S_OK != hr) {
+ if(POSITION pos = m_pActivePins.Find(pPin)) {
m_pActivePins.RemoveAt(pos);
+ }
- if(!m_pActivePins.IsEmpty()) // only die when all pins are down
+ if(!m_pActivePins.IsEmpty()) { // only die when all pins are down
hr = S_OK;
+ }
return hr;
}
- if(bDiscontinuity)
+ if(bDiscontinuity) {
m_bDiscontinuitySent.AddTail(TrackNumber);
+ }
return hr;
}
@@ -990,19 +1050,18 @@ bool CBaseSplitterFilter::IsAnyPinDrying()
int totalcount = 0, totalsize = 0;
POSITION pos = m_pActivePins.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBaseSplitterOutputPin* pPin = m_pActivePins.GetNext(pos);
int count = pPin->QueueCount();
int size = pPin->QueueSize();
- if(!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE))
- {
-// if(m_priority != THREAD_PRIORITY_ABOVE_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
- if(m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
- {
+ if(!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE)) {
+ // if(m_priority != THREAD_PRIORITY_ABOVE_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
+ if(m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3)) {
// SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_ABOVE_NORMAL);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
+ while(pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
+ }
m_priority = THREAD_PRIORITY_BELOW_NORMAL;
}
return(true);
@@ -1011,16 +1070,18 @@ bool CBaseSplitterFilter::IsAnyPinDrying()
totalsize += size;
}
- if(m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*2/3 || totalsize > MAXPACKETSIZE*2/3))
- {
-// SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
+ if(m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*2/3 || totalsize > MAXPACKETSIZE*2/3)) {
+ // SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
+ while(pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
+ }
m_priority = THREAD_PRIORITY_NORMAL;
}
- if(totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE)
+ if(totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE) {
return(true);
+ }
return(false);
}
@@ -1029,15 +1090,10 @@ HRESULT CBaseSplitterFilter::BreakConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
DeleteOutputs();
- }
- else if(dir == PINDIR_OUTPUT)
- {
- }
- else
- {
+ } else if(dir == PINDIR_OUTPUT) {
+ } else {
return E_UNEXPECTED;
}
@@ -1048,28 +1104,24 @@ HRESULT CBaseSplitterFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CBaseSplitterInputPin* pIn = static_cast<CBaseSplitterInputPin*>(pPin);
HRESULT hr;
CComPtr<IAsyncReader> pAsyncReader;
if(FAILED(hr = pIn->GetAsyncReader(&pAsyncReader))
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader)))
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
return hr;
+ }
ChapSort();
m_pSyncReader = pAsyncReader;
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
m_pRetiredOutputs.RemoveAll();
- }
- else
- {
+ } else {
return E_UNEXPECTED;
}
@@ -1083,16 +1135,15 @@ int CBaseSplitterFilter::GetPinCount()
CBasePin* CBaseSplitterFilter::GetPin(int n)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if(n >= 0 && n < (int)m_pOutputs.GetCount())
- {
- if(POSITION pos = m_pOutputs.FindIndex(n))
+ if(n >= 0 && n < (int)m_pOutputs.GetCount()) {
+ if(POSITION pos = m_pOutputs.FindIndex(n)) {
return m_pOutputs.GetAt(pos);
+ }
}
- if(n == (int)m_pOutputs.GetCount() && m_pInput)
- {
+ if(n == (int)m_pOutputs.GetCount() && m_pInput) {
return m_pInput;
}
@@ -1108,8 +1159,9 @@ STDMETHODIMP CBaseSplitterFilter::Stop()
DeliverEndFlush();
HRESULT hr;
- if(FAILED(hr = __super::Stop()))
+ if(FAILED(hr = __super::Stop())) {
return hr;
+ }
return S_OK;
}
@@ -1121,11 +1173,11 @@ STDMETHODIMP CBaseSplitterFilter::Pause()
FILTER_STATE fs = m_State;
HRESULT hr;
- if(FAILED(hr = __super::Pause()))
+ if(FAILED(hr = __super::Pause())) {
return hr;
+ }
- if(fs == State_Stopped)
- {
+ if(fs == State_Stopped) {
Create();
}
@@ -1137,8 +1189,9 @@ STDMETHODIMP CBaseSplitterFilter::Run(REFERENCE_TIME tStart)
CAutoLock cAutoLock(this);
HRESULT hr;
- if(FAILED(hr = __super::Run(tStart)))
+ if(FAILED(hr = __super::Run(tStart))) {
return hr;
+ }
return S_OK;
}
@@ -1153,14 +1206,14 @@ STDMETHODIMP CBaseSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYP
HRESULT hr = E_FAIL;
CComPtr<IAsyncReader> pAsyncReader;
CAtlList<CHdmvClipInfo::PlaylistItem> Items;
- if (BuildPlaylist (pszFileName, Items))
+ if (BuildPlaylist (pszFileName, Items)) {
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(Items, hr);
- else
+ } else {
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(CString(pszFileName), hr);
+ }
if(FAILED(hr)
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader)))
- {
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
m_fn = "";
return hr;
}
@@ -1176,8 +1229,9 @@ STDMETHODIMP CBaseSplitterFilter::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TY
{
CheckPointer(ppszFileName, E_POINTER);
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
return S_OK;
}
@@ -1192,87 +1246,150 @@ LPCTSTR CBaseSplitterFilter::GetPartFilename(IAsyncReader* pAsyncReader)
STDMETHODIMP CBaseSplitterFilter::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities =
- AM_SEEKING_CanGetStopPos|
- AM_SEEKING_CanGetDuration|
- AM_SEEKING_CanSeekAbsolute|
- AM_SEEKING_CanSeekForwards|
- AM_SEEKING_CanSeekBackwards, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities =
+ AM_SEEKING_CanGetStopPos|
+ AM_SEEKING_CanGetDuration|
+ AM_SEEKING_CanSeekAbsolute|
+ AM_SEEKING_CanSeekForwards|
+ AM_SEEKING_CanSeekBackwards, S_OK : E_POINTER;
}
STDMETHODIMP CBaseSplitterFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ if(*pCapabilities == 0) {
+ return S_OK;
+ }
DWORD caps;
GetCapabilities(&caps);
- if((caps&*pCapabilities) == 0) return E_FAIL;
- if(caps == *pCapabilities) return S_OK;
+ if((caps&*pCapabilities) == 0) {
+ return E_FAIL;
+ }
+ if(caps == *pCapabilities) {
+ return S_OK;
+ }
return S_FALSE;
}
-STDMETHODIMP CBaseSplitterFilter::IsFormatSupported(const GUID* pFormat) {return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;}
-STDMETHODIMP CBaseSplitterFilter::QueryPreferredFormat(GUID* pFormat) {return GetTimeFormat(pFormat);}
-STDMETHODIMP CBaseSplitterFilter::GetTimeFormat(GUID* pFormat) {return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;}
-STDMETHODIMP CBaseSplitterFilter::IsUsingTimeFormat(const GUID* pFormat) {return IsFormatSupported(pFormat);}
-STDMETHODIMP CBaseSplitterFilter::SetTimeFormat(const GUID* pFormat) {return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;}
-STDMETHODIMP CBaseSplitterFilter::GetDuration(LONGLONG* pDuration) {CheckPointer(pDuration, E_POINTER); *pDuration = m_rtDuration; return S_OK;}
-STDMETHODIMP CBaseSplitterFilter::GetStopPosition(LONGLONG* pStop) {return GetDuration(pStop);}
-STDMETHODIMP CBaseSplitterFilter::GetCurrentPosition(LONGLONG* pCurrent) {return E_NOTIMPL;}
-STDMETHODIMP CBaseSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {return E_NOTIMPL;}
+STDMETHODIMP CBaseSplitterFilter::IsFormatSupported(const GUID* pFormat)
+{
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+}
+STDMETHODIMP CBaseSplitterFilter::QueryPreferredFormat(GUID* pFormat)
+{
+ return GetTimeFormat(pFormat);
+}
+STDMETHODIMP CBaseSplitterFilter::GetTimeFormat(GUID* pFormat)
+{
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+}
+STDMETHODIMP CBaseSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
+{
+ return IsFormatSupported(pFormat);
+}
+STDMETHODIMP CBaseSplitterFilter::SetTimeFormat(const GUID* pFormat)
+{
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+}
+STDMETHODIMP CBaseSplitterFilter::GetDuration(LONGLONG* pDuration)
+{
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = m_rtDuration;
+ return S_OK;
+}
+STDMETHODIMP CBaseSplitterFilter::GetStopPosition(LONGLONG* pStop)
+{
+ return GetDuration(pStop);
+}
+STDMETHODIMP CBaseSplitterFilter::GetCurrentPosition(LONGLONG* pCurrent)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CBaseSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
+{
+ return E_NOTIMPL;
+}
STDMETHODIMP CBaseSplitterFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
return SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
STDMETHODIMP CBaseSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- if(pCurrent) *pCurrent = m_rtCurrent;
- if(pStop) *pStop = m_rtStop;
+ if(pCurrent) {
+ *pCurrent = m_rtCurrent;
+ }
+ if(pStop) {
+ *pStop = m_rtStop;
+ }
return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- if(pEarliest) *pEarliest = 0;
+ if(pEarliest) {
+ *pEarliest = 0;
+ }
return GetDuration(pLatest);
}
-STDMETHODIMP CBaseSplitterFilter::SetRate(double dRate) {return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;}
-STDMETHODIMP CBaseSplitterFilter::GetRate(double* pdRate) {return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;}
-STDMETHODIMP CBaseSplitterFilter::GetPreroll(LONGLONG* pllPreroll) {return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;}
+STDMETHODIMP CBaseSplitterFilter::SetRate(double dRate)
+{
+ return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;
+}
+STDMETHODIMP CBaseSplitterFilter::GetRate(double* pdRate)
+{
+ return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;
+}
+STDMETHODIMP CBaseSplitterFilter::GetPreroll(LONGLONG* pllPreroll)
+{
+ return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
+}
HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
CAutoLock cAutoLock(this);
if(!pCurrent && !pStop
- || (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
- && (dwStopFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)
+ || (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;
+ REFERENCE_TIME
+ rtCurrent = m_rtCurrent,
+ rtStop = m_rtStop;
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;
- }
+ 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;
- }
+ 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(m_rtCurrent == rtCurrent && m_rtStop == rtStop)
+ if(m_rtCurrent == rtCurrent && m_rtStop == rtStop) {
return S_OK;
+ }
- if(m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id))
- {
+ if(m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) {
m_LastSeekers.AddTail(id);
return S_OK;
}
@@ -1282,19 +1399,18 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent,
m_LastSeekers.RemoveAll();
m_LastSeekers.AddTail(id);
-DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
+ DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
m_rtNewStart = m_rtCurrent = rtCurrent;
m_rtNewStop = rtStop;
- if(ThreadExists())
- {
+ if(ThreadExists()) {
DeliverBeginFlush();
CallWorker(CMD_SEEK);
DeliverEndFlush();
}
-DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
+ DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
return S_OK;
}
@@ -1351,7 +1467,9 @@ STDMETHODIMP CBaseSplitterFilter::get_ExSeekCapabilities(long* pExCapabilities)
{
CheckPointer(pExCapabilities, E_POINTER);
*pExCapabilities = AM_EXSEEK_CANSEEK;
- if(ChapGetCount()) *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
+ if(ChapGetCount()) {
+ *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
+ }
return S_OK;
}
@@ -1367,7 +1485,9 @@ STDMETHODIMP CBaseSplitterFilter::get_CurrentMarker(long* pCurrentMarker)
CheckPointer(pCurrentMarker, E_POINTER);
REFERENCE_TIME rt = m_rtCurrent;
long i = ChapLookup(&rt);
- if(i < 0) return E_FAIL;
+ if(i < 0) {
+ return E_FAIL;
+ }
*pCurrentMarker = i+1;
return S_OK;
}
@@ -1376,7 +1496,9 @@ STDMETHODIMP CBaseSplitterFilter::GetMarkerTime(long MarkerNum, double* pMarkerT
{
CheckPointer(pMarkerTime, E_POINTER);
REFERENCE_TIME rt;
- if(FAILED(ChapGet((int)MarkerNum-1, &rt))) return E_FAIL;
+ if(FAILED(ChapGet((int)MarkerNum-1, &rt))) {
+ return E_FAIL;
+ }
*pMarkerTime = (double)rt / 10000000;
return S_OK;
}
@@ -1411,8 +1533,7 @@ STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size)
{
CAutoLock cAutoLock(m_pLock);
- if(POSITION pos = m_pOutputs.FindIndex(i))
- {
+ if(POSITION pos = m_pOutputs.FindIndex(i)) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetAt(pos);
samples = pPin->QueueCount();
size = pPin->QueueSize();
@@ -1424,5 +1545,5 @@ STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size)
STDMETHODIMP_(DWORD) CBaseSplitterFilter::GetPriority()
{
- return m_priority;
+ return m_priority;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.h b/src/filters/parser/BaseSplitter/BaseSplitter.h
index 656fafa81..e030187c1 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -40,13 +40,25 @@ public:
static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
REFERENCE_TIME rtStart, rtStop;
AM_MEDIA_TYPE* pmt;
- Packet() {pmt = NULL; bDiscontinuity = bAppendable = FALSE;}
- virtual ~Packet() {if(pmt) DeleteMediaType(pmt);}
- virtual int GetDataSize() {return GetCount();}
- void SetData(const void* ptr, DWORD len) {SetCount(len); memcpy(GetData(), ptr, len);}
+ Packet() {
+ pmt = NULL;
+ bDiscontinuity = bAppendable = FALSE;
+ }
+ virtual ~Packet() {
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ }
+ virtual int GetDataSize() {
+ return GetCount();
+ }
+ void SetData(const void* ptr, DWORD len) {
+ SetCount(len);
+ memcpy(GetData(), ptr, len);
+ }
};
-class CPacketQueue
+class CPacketQueue
: public CCritSec
, protected CAutoPtrList<Packet>
{
@@ -62,7 +74,7 @@ public:
class CBaseSplitterFilter;
-class CBaseSplitterInputPin
+class CBaseSplitterInputPin
: public CBasePin
{
protected:
@@ -75,19 +87,19 @@ public:
HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
HRESULT CompleteConnect(IPin* pPin);
STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush();
};
-class CBaseSplitterOutputPin
+class CBaseSplitterOutputPin
: public CBaseOutputPin
, public IDSMPropertyBagImpl
, protected CAMThread
@@ -107,18 +119,17 @@ private:
CAMEvent m_eEndFlush;
enum {CMD_EXIT};
- DWORD ThreadProc();
+ DWORD ThreadProc();
void MakeISCRHappy();
// please only use DeliverPacket from the derived class
- HRESULT GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
- HRESULT Deliver(IMediaSample* pSample);
+ HRESULT GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
+ HRESULT Deliver(IMediaSample* pSample);
// bitrate stats
- struct
- {
+ struct {
UINT64 nTotalBytesDelivered;
REFERENCE_TIME rtTotalTimeDelivered;
UINT64 nBytesSinceLastDeliverTime;
@@ -160,32 +171,41 @@ public:
virtual ~CBaseSplitterOutputPin();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
HRESULT SetName(LPCWSTR pName);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- CMediaType& CurrentMediaType() {return m_mt;}
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
// Queueing
- HANDLE GetThreadHandle() {ASSERT(m_hThread != NULL); return m_hThread;}
- void SetThreadPriority(int nPriority) {if(m_hThread) ::SetThreadPriority(m_hThread, nPriority);}
+ HANDLE GetThreadHandle() {
+ ASSERT(m_hThread != NULL);
+ return m_hThread;
+ }
+ void SetThreadPriority(int nPriority) {
+ if(m_hThread) {
+ ::SetThreadPriority(m_hThread, nPriority);
+ }
+ }
HRESULT Active();
- HRESULT Inactive();
+ HRESULT Inactive();
- HRESULT DeliverBeginFlush();
+ HRESULT DeliverBeginFlush();
HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
int QueueCount();
int QueueSize();
- HRESULT QueueEndOfStream();
+ HRESULT QueueEndOfStream();
HRESULT QueuePacket(CAutoPtr<Packet> p);
// returns true for everything which (the lack of) would not block other streams (subtitle streams, basically)
@@ -196,11 +216,15 @@ public:
// IBitRateInfo
- STDMETHODIMP_(DWORD) GetCurrentBitRate() {return m_brs.nCurrentBitRate;}
- STDMETHODIMP_(DWORD) GetAverageBitRate() {return m_brs.nAverageBitRate;}
+ STDMETHODIMP_(DWORD) GetCurrentBitRate() {
+ return m_brs.nCurrentBitRate;
+ }
+ STDMETHODIMP_(DWORD) GetAverageBitRate() {
+ return m_brs.nAverageBitRate;
+ }
};
-class CBaseSplitterFilter
+class CBaseSplitterFilter
: public CBaseFilter
, public CCritSec
, public IDSMPropertyBagImpl
@@ -262,20 +286,22 @@ protected:
protected:
enum {CMD_EXIT, CMD_SEEK};
- DWORD ThreadProc();
+ DWORD ThreadProc();
// ... and also override all these too
virtual bool DemuxInit() = 0;
virtual void DemuxSeek(REFERENCE_TIME rt) = 0;
virtual bool DemuxLoop() = 0;
- virtual bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items) { return false; };
+ virtual bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items) {
+ return false;
+ };
public:
CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid);
virtual ~CBaseSplitterFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
bool IsAnyPinDrying();
@@ -330,10 +356,18 @@ public:
// IDispatch
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
- STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {return E_NOTIMPL;}
- STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {return E_NOTIMPL;}
- STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {return E_NOTIMPL;}
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {
+ return E_NOTIMPL;
+ }
// IAMMediaContent
@@ -342,14 +376,30 @@ public:
STDMETHODIMP get_Rating(BSTR* pbstrRating);
STDMETHODIMP get_Description(BSTR* pbstrDescription);
STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
- STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) {return E_NOTIMPL;}
- STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
- STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
- STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) {return E_NOTIMPL;}
+ STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) {
+ return E_NOTIMPL;
+ }
// IAMExtendedSeeking
@@ -358,8 +408,12 @@ public:
STDMETHODIMP get_CurrentMarker(long* pCurrentMarker);
STDMETHODIMP GetMarkerTime(long MarkerNum, double* pMarkerTime);
STDMETHODIMP GetMarkerName(long MarkerNum, BSTR* pbstrMarkerName);
- STDMETHODIMP put_PlaybackSpeed(double Speed) {return E_NOTIMPL;}
- STDMETHODIMP get_PlaybackSpeed(double* pSpeed) {return E_NOTIMPL;}
+ STDMETHODIMP put_PlaybackSpeed(double Speed) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_PlaybackSpeed(double* pSpeed) {
+ return E_NOTIMPL;
+ }
// IKeyFrameInfo
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
index 483c3c7a2..36521c465 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -35,7 +35,10 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in
, m_bitbuff(0), m_bitlen(0)
, m_cachepos(0), m_cachelen(0)
{
- if(!m_pAsyncReader) {hr = E_UNEXPECTED; return;}
+ if(!m_pAsyncReader) {
+ hr = E_UNEXPECTED;
+ return;
+ }
LONGLONG total = 0, available;
hr = m_pAsyncReader->Length(&total, &available);
@@ -44,15 +47,13 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in
m_fRandomAccess = total > 0 && total == available;
m_len = total;
- if(FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0)
- {
+ if(FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0) {
hr = E_FAIL;
return;
}
- if(!SetCacheSize(cachelen))
- {
- hr = E_OUTOFMEMORY;
+ if(!SetCacheSize(cachelen)) {
+ hr = E_OUTOFMEMORY;
return;
}
@@ -64,7 +65,9 @@ bool CBaseSplitterFile::SetCacheSize(int cachelen)
m_pCache.Free();
m_cachetotal = 0;
m_pCache.Allocate((size_t)cachelen);
- if(!m_pCache) return false;
+ if(!m_pCache) {
+ return false;
+ }
m_cachetotal = cachelen;
m_cachelen = 0;
return true;
@@ -84,12 +87,9 @@ __int64 CBaseSplitterFile::GetAvailable()
__int64 CBaseSplitterFile::GetLength(bool fUpdate)
{
- if(m_fStreaming)
- {
+ if(m_fStreaming) {
m_len = GetAvailable();
- }
- else if(fUpdate)
- {
+ } else if(fUpdate) {
LONGLONG total = 0, available;
m_pAsyncReader->Length(&total, &available);
m_len = total;
@@ -111,15 +111,16 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
HRESULT hr = S_OK;
- if(!m_fRandomAccess)
- {
+ if(!m_fRandomAccess) {
LONGLONG total = 0, available = -1;
m_pAsyncReader->Length(&total, &available);
- if(total == available) {m_fRandomAccess = true; OnComplete();}
+ if(total == available) {
+ m_fRandomAccess = true;
+ OnComplete();
+ }
}
- if(m_cachetotal == 0 || !m_pCache)
- {
+ if(m_cachetotal == 0 || !m_pCache) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)len, pData);
m_pos += len;
return hr;
@@ -127,8 +128,7 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
BYTE* pCache = m_pCache;
- if(m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen)
- {
+ if(m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen) {
__int64 minlen = min(len, m_cachelen - (m_pos - m_cachepos));
memcpy(pData, &pCache[m_pos - m_cachepos], (size_t)minlen);
@@ -138,25 +138,29 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
pData += minlen;
}
- while(len > m_cachetotal)
- {
+ while(len > m_cachetotal) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)m_cachetotal, pData);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
len -= m_cachetotal;
m_pos += m_cachetotal;
pData += m_cachetotal;
}
- while(len > 0)
- {
+ while(len > 0) {
__int64 tmplen = GetLength();
__int64 maxlen = min(tmplen - m_pos, m_cachetotal);
__int64 minlen = min(len, maxlen);
- if(minlen <= 0) return S_FALSE;
+ if(minlen <= 0) {
+ return S_FALSE;
+ }
hr = m_pAsyncReader->SyncRead(m_pos, (long)maxlen, pCache);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
m_cachepos = m_pos;
m_cachelen = maxlen;
@@ -175,10 +179,11 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek)
{
ASSERT(nBits >= 0 && nBits <= 64);
- while(m_bitlen < nBits)
- {
+ while(m_bitlen < nBits) {
m_bitbuff <<= 8;
- if(S_OK != Read((BYTE*)&m_bitbuff, 1)) {return 0;} // EOF? // ASSERT(0);
+ if(S_OK != Read((BYTE*)&m_bitbuff, 1)) {
+ return 0; // EOF? // ASSERT(0);
+ }
m_bitlen += 8;
}
@@ -186,8 +191,7 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek)
UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if(!fPeek)
- {
+ if(!fPeek) {
m_bitbuff &= ((1ui64 << bitlen) - 1);
m_bitlen = bitlen;
}
@@ -207,14 +211,16 @@ void CBaseSplitterFile::BitFlush()
HRESULT CBaseSplitterFile::ByteRead(BYTE* pData, __int64 len)
{
- Seek(GetPos());
+ Seek(GetPos());
return Read(pData, len);
}
UINT64 CBaseSplitterFile::UExpGolombRead()
{
int n = -1;
- for(BYTE b = 0; !b; n++) b = BitRead(1);
+ for(BYTE b = 0; !b; n++) {
+ b = BitRead(1);
+ }
return (1ui64 << n) - 1 + BitRead(n);
}
@@ -228,14 +234,14 @@ HRESULT CBaseSplitterFile::HasMoreData(__int64 len, DWORD ms)
{
__int64 available = GetLength() - GetPos();
- if(!m_fStreaming)
- {
+ if(!m_fStreaming) {
return available < 1 ? E_FAIL : S_OK;
}
- if(available < len)
- {
- if(ms > 0) Sleep(ms);
+ if(available < len) {
+ if(ms > 0) {
+ Sleep(ms);
+ }
return S_FALSE;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.h b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
index 8b61961e1..279471748 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -51,7 +51,9 @@ public:
__int64 GetPos();
__int64 GetAvailable();
__int64 GetLength(bool fUpdate = false);
- __int64 GetRemaining() {return max(0, GetLength() - GetPos());}
+ __int64 GetRemaining() {
+ return max(0, GetLength() - GetPos());
+ }
virtual void Seek(__int64 pos);
UINT64 UExpGolombRead();
@@ -61,8 +63,12 @@ public:
void BitByteAlign(), BitFlush();
HRESULT ByteRead(BYTE* pData, __int64 len);
- bool IsStreaming() const {return m_fStreaming;}
- bool IsRandomAccess() const {return m_fRandomAccess;}
+ bool IsStreaming() const {
+ return m_fStreaming;
+ }
+ bool IsRandomAccess() const {
+ return m_fRandomAccess;
+ }
HRESULT HasMoreData(__int64 len = 1, DWORD ms = 1);
};
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
index 85e259fc3..3a0df88ee 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -50,12 +50,12 @@ bool CBaseSplitterFileEx::NextMpegStartCode(BYTE& code, __int64 len)
{
BitByteAlign();
DWORD dw = (DWORD)-1;
- do
- {
- if(len-- == 0 || !GetRemaining()) return(false);
+ do {
+ if(len-- == 0 || !GetRemaining()) {
+ return(false);
+ }
dw = (dw << 8) | (BYTE)BitRead(8);
- }
- while((dw&0xffffff00) != 0x00000100);
+ } while((dw&0xffffff00) != 0x00000100);
code = (BYTE)(dw&0xff);
return(true);
}
@@ -70,36 +70,44 @@ bool CBaseSplitterFileEx::Read(pshdr& h)
BYTE b = (BYTE)BitRead(8, true);
- if((b&0xf1) == 0x21)
- {
+ if((b&0xf1) == 0x21) {
h.type = mpeg1;
EXECUTE_ASSERT(BitRead(4) == 2);
h.scr = 0;
- h.scr |= BitRead(3) << 30; MARKER; // 32..30
- h.scr |= BitRead(15) << 15; MARKER; // 29..15
- h.scr |= BitRead(15); MARKER; MARKER; // 14..0
- h.bitrate = BitRead(22); MARKER;
- }
- else if((b&0xc4) == 0x44)
- {
+ h.scr |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.scr |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.scr |= BitRead(15);
+ MARKER;
+ MARKER; // 14..0
+ h.bitrate = BitRead(22);
+ MARKER;
+ } else if((b&0xc4) == 0x44) {
h.type = mpeg2;
EXECUTE_ASSERT(BitRead(2) == 1);
h.scr = 0;
- h.scr |= BitRead(3) << 30; MARKER; // 32..30
- h.scr |= BitRead(15) << 15; MARKER; // 29..15
- h.scr |= BitRead(15); MARKER; // 14..0
- h.scr = (h.scr*300 + BitRead(9)) * 10 / 27; MARKER;
- h.bitrate = BitRead(22); MARKER; MARKER;
+ h.scr |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.scr |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.scr |= BitRead(15);
+ MARKER; // 14..0
+ h.scr = (h.scr*300 + BitRead(9)) * 10 / 27;
+ MARKER;
+ h.bitrate = BitRead(22);
+ MARKER;
+ MARKER;
BitRead(5); // reserved
UINT64 stuffing = BitRead(3);
- while(stuffing-- > 0) EXECUTE_ASSERT(BitRead(8) == 0xff);
- }
- else
- {
+ while(stuffing-- > 0) {
+ EXECUTE_ASSERT(BitRead(8) == 0xff);
+ }
+ } else {
return(false);
}
@@ -112,19 +120,21 @@ bool CBaseSplitterFileEx::Read(pssyshdr& h)
{
memset(&h, 0, sizeof(h));
- WORD len = (WORD)BitRead(16); MARKER;
- h.rate_bound = (DWORD)BitRead(22); MARKER;
+ WORD len = (WORD)BitRead(16);
+ MARKER;
+ h.rate_bound = (DWORD)BitRead(22);
+ MARKER;
h.audio_bound = (BYTE)BitRead(6);
h.fixed_rate = !!BitRead(1);
h.csps = !!BitRead(1);
h.sys_audio_loc_flag = !!BitRead(1);
- h.sys_video_loc_flag = !!BitRead(1); MARKER;
+ h.sys_video_loc_flag = !!BitRead(1);
+ MARKER;
h.video_bound = (BYTE)BitRead(5);
EXECUTE_ASSERT((BitRead(8)&0x7f) == 0x7f); // reserved (should be 0xff, but not in reality)
- for(len -= 6; len > 3; len -= 3) // TODO: also store these, somewhere, if needed
- {
+ for(len -= 6; len > 3; len -= 3) { // TODO: also store these, somewhere, if needed
UINT64 stream_id = BitRead(8);
UNUSED_ALWAYS(stream_id);
EXECUTE_ASSERT(BitRead(2) == 3);
@@ -139,42 +149,42 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
{
memset(&h, 0, sizeof(h));
- if(!(code >= 0xbd && code < 0xf0 || code == 0xfd)) // 0xfd => blu-ray (.m2ts)
+ if(!(code >= 0xbd && code < 0xf0 || code == 0xfd)) { // 0xfd => blu-ray (.m2ts)
return(false);
+ }
h.len = (WORD)BitRead(16);
- if(code == 0xbe || code == 0xbf)
+ if(code == 0xbe || code == 0xbf) {
return(true);
+ }
// mpeg1 stuffing (ff ff .. , max 16x)
- for(int i = 0; i < 16 && BitRead(8, true) == 0xff; i++)
- {
- BitRead(8);
- if(h.len) h.len--;
+ for(int i = 0; i < 16 && BitRead(8, true) == 0xff; i++) {
+ BitRead(8);
+ if(h.len) {
+ h.len--;
+ }
}
h.type = (BYTE)BitRead(2, true) == mpeg2 ? mpeg2 : mpeg1;
- if(h.type == mpeg1)
- {
+ if(h.type == mpeg1) {
BYTE b = (BYTE)BitRead(2);
- if(b == 1)
- {
+ if(b == 1) {
h.std_buff_size = (BitRead(1)?1024:128)*BitRead(13);
- if(h.len) h.len -= 2;
+ if(h.len) {
+ h.len -= 2;
+ }
b = (BYTE)BitRead(2);
}
- if(b == 0)
- {
+ if(b == 0) {
h.fpts = (BYTE)BitRead(1);
h.fdts = (BYTE)BitRead(1);
}
- }
- else if(h.type == mpeg2)
- {
+ } else if(h.type == mpeg2) {
EXECUTE_ASSERT(BitRead(2) == mpeg2);
h.scrambling = (BYTE)BitRead(2);
h.priority = (BYTE)BitRead(1);
@@ -190,17 +200,15 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
h.crc = (BYTE)BitRead(1);
h.extension = (BYTE)BitRead(1);
h.hdrlen = (BYTE)BitRead(8);
- }
- else
- {
- if(h.len) while(h.len-- > 0) BitRead(8);
+ } else {
+ if(h.len) while(h.len-- > 0) {
+ BitRead(8);
+ }
return(false);
}
- if(h.fpts)
- {
- if(h.type == mpeg2)
- {
+ if(h.fpts) {
+ if(h.type == mpeg2) {
// Temporary(dirty) fix - needs more testing
//BYTE b = (BYTE)BitRead(4);
//if(!(h.fdts && b == 3 || !h.fdts && b == 2)) {ASSERT(0); return(false);}
@@ -208,57 +216,73 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
}
h.pts = 0;
- h.pts |= BitRead(3) << 30; MARKER; // 32..30
- h.pts |= BitRead(15) << 15; MARKER; // 29..15
- h.pts |= BitRead(15); MARKER; // 14..0
+ h.pts |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.pts |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.pts |= BitRead(15);
+ MARKER; // 14..0
h.pts = 10000*h.pts/90 + m_rtPTSOffset;
}
- if(h.fdts)
- {
+ if(h.fdts) {
// Temporary(dirty) fix - needs more testing
//if((BYTE)BitRead(4) != 1) {ASSERT(0); return(false);}
BitRead(4);
h.dts = 0;
- h.dts |= BitRead(3) << 30; MARKER; // 32..30
- h.dts |= BitRead(15) << 15; MARKER; // 29..15
- h.dts |= BitRead(15); MARKER; // 14..0
+ h.dts |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.dts |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.dts |= BitRead(15);
+ MARKER; // 14..0
h.dts = 10000*h.dts/90 + m_rtPTSOffset;
}
// skip to the end of header
- if(h.type == mpeg1)
- {
- if(!h.fpts && !h.fdts && BitRead(4) != 0xf) {/*ASSERT(0);*/ return(false);}
+ if(h.type == mpeg1) {
+ if(!h.fpts && !h.fdts && BitRead(4) != 0xf) {
+ /*ASSERT(0);*/ return(false);
+ }
- if(h.len)
- {
+ if(h.len) {
h.len--;
- if(h.pts) h.len -= 4;
- if(h.dts) h.len -= 5;
+ if(h.pts) {
+ h.len -= 4;
+ }
+ if(h.dts) {
+ h.len -= 5;
+ }
}
}
- if(h.type == mpeg2)
- {
- if(h.len) h.len -= 3+h.hdrlen;
+ if(h.type == mpeg2) {
+ if(h.len) {
+ h.len -= 3+h.hdrlen;
+ }
int left = h.hdrlen;
- if(h.fpts) left -= 5;
- if(h.fdts) left -= 5;
- while(left-- > 0) BitRead(8);
-/*
- // mpeg2 stuffing (ff ff .. , max 32x)
- while(BitRead(8, true) == 0xff) {BitRead(8); if(h.len) h.len--;}
- Seek(GetPos()); // put last peeked byte back for Read()
-
- // FIXME: this doesn't seems to be here,
- // infact there can be ff's as part of the data
- // right at the beginning of the packet, which
- // we should not skip...
-*/
+ if(h.fpts) {
+ left -= 5;
+ }
+ if(h.fdts) {
+ left -= 5;
+ }
+ while(left-- > 0) {
+ BitRead(8);
+ }
+ /*
+ // mpeg2 stuffing (ff ff .. , max 32x)
+ while(BitRead(8, true) == 0xff) {BitRead(8); if(h.len) h.len--;}
+ Seek(GetPos()); // put last peeked byte back for Read()
+
+ // FIXME: this doesn't seems to be here,
+ // infact there can be ff's as part of the data
+ // right at the beginning of the packet, which
+ // we should not skip...
+ */
}
return(true);
@@ -270,40 +294,43 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
BYTE id = 0;
- while(GetPos() < endpos && id != 0xb3)
- {
- if(!NextMpegStartCode(id, len))
+ while(GetPos() < endpos && id != 0xb3) {
+ if(!NextMpegStartCode(id, len)) {
return(false);
+ }
}
- if(id != 0xb3)
+ if(id != 0xb3) {
return(false);
+ }
__int64 shpos = GetPos() - 4;
h.width = (WORD)BitRead(12);
h.height = (WORD)BitRead(12);
h.ar = BitRead(4);
- static int ifps[16] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000, 0, 0, 0, 0, 0, 0, 0};
+ static int ifps[16] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000, 0, 0, 0, 0, 0, 0, 0};
h.ifps = ifps[BitRead(4)];
- h.bitrate = (DWORD)BitRead(18); MARKER;
+ h.bitrate = (DWORD)BitRead(18);
+ MARKER;
h.vbv = (DWORD)BitRead(10);
h.constrained = BitRead(1);
h.fiqm = BitRead(1);
if(h.fiqm)
- for(int i = 0; i < countof(h.iqm); i++)
+ for(int i = 0; i < countof(h.iqm); i++) {
h.iqm[i] = (BYTE)BitRead(8);
+ }
h.fniqm = BitRead(1);
if(h.fniqm)
- for(int i = 0; i < countof(h.niqm); i++)
+ for(int i = 0; i < countof(h.niqm); i++) {
h.niqm[i] = (BYTE)BitRead(8);
+ }
__int64 shlen = GetPos() - shpos;
- static float ar[] =
- {
+ static float ar[] = {
1.0000f,1.0000f,0.6735f,0.7031f,0.7615f,0.8055f,0.8437f,0.8935f,
0.9157f,0.9815f,1.0255f,1.0695f,1.0950f,1.1575f,1.2015f,1.0000f
};
@@ -315,8 +342,7 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
__int64 shextpos = 0, shextlen = 0;
- if(NextMpegStartCode(id, 8) && id == 0xb5) // sequence header ext
- {
+ if(NextMpegStartCode(id, 8) && id == 0xb5) { // sequence header ext
shextpos = GetPos() - 4;
h.startcodeid = BitRead(4);
@@ -327,14 +353,17 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
h.chroma = BitRead(2);
h.width |= (BitRead(2)<<12);
h.height |= (BitRead(2)<<12);
- h.bitrate |= (BitRead(12)<<18); MARKER;
+ h.bitrate |= (BitRead(12)<<18);
+ MARKER;
h.vbv |= (BitRead(8)<<10);
h.lowdelay = BitRead(1);
h.ifps = (DWORD)(h.ifps * (BitRead(2)+1) / (BitRead(5)+1));
shextlen = GetPos() - shextpos;
- struct {DWORD x, y;} ar[] = {{h.width,h.height},{4,3},{16,9},{221,100},{h.width,h.height}};
+ struct {
+ DWORD x, y;
+ } ar[] = {{h.width,h.height},{4,3},{16,9},{221,100},{h.width,h.height}};
int i = min(max(h.ar, 1), 5)-1;
h.arx = ar[i].x;
h.ary = ar[i].y;
@@ -346,15 +375,22 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
h.bitrate = h.bitrate == (1<<30)-1 ? 0 : h.bitrate * 400;
DWORD a = h.arx, b = h.ary;
- while(a) {DWORD tmp = a; a = b % tmp; b = tmp;}
- if(b) h.arx /= b, h.ary /= b;
+ while(a) {
+ DWORD tmp = a;
+ a = b % tmp;
+ b = tmp;
+ }
+ if(b) {
+ h.arx /= b, h.ary /= b;
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
- if(type == mpeg1)
- {
+ if(type == mpeg1) {
pmt->subtype = MEDIASUBTYPE_MPEG1Payload;
pmt->formattype = FORMAT_MPEGVideo;
int len = FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader) + shlen + shextlen;
@@ -370,13 +406,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->bSequenceHeader[0], shlen);
- if(shextpos && shextlen) Seek(shextpos);
+ if(shextpos && shextlen) {
+ Seek(shextpos);
+ }
ByteRead((BYTE*)&vi->bSequenceHeader[0] + shlen, shextlen);
pmt->SetFormat((BYTE*)vi, len);
delete [] vi;
- }
- else if(type == mpeg2)
- {
+ } else if(type == mpeg2) {
pmt->subtype = MEDIASUBTYPE_MPEG2_VIDEO;
pmt->formattype = FORMAT_MPEG2_VIDEO;
int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + shlen + shextlen;
@@ -394,13 +430,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->dwSequenceHeader[0], shlen);
- if(shextpos && shextlen) Seek(shextpos);
+ if(shextpos && shextlen) {
+ Seek(shextpos);
+ }
ByteRead((BYTE*)&vi->dwSequenceHeader[0] + shlen, shextlen);
pmt->SetFormat((BYTE*)vi, len);
delete [] vi;
- }
- else
- {
+ } else {
return(false);
}
@@ -413,11 +449,13 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
int syncbits = fAllowV25 ? 11 : 12;
- for(; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--)
+ for(; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--) {
BitRead(8);
+ }
- if(len < 4)
+ if(len < 4) {
return(false);
+ }
h.sync = BitRead(11);
h.version = BitRead(2);
@@ -433,22 +471,22 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
h.original = BitRead(1);
h.emphasis = BitRead(2);
- if(h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2)
+ if(h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2) {
return(false);
+ }
- if(h.version == 3 && h.layer == 2)
- {
+ if(h.version == 3 && h.layer == 2) {
if((h.bitrate == 1 || h.bitrate == 2 || h.bitrate == 3 || h.bitrate == 5) && h.channels != 3
- && (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3)
+ && (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3) {
return(false);
+ }
}
h.layer = 4 - h.layer;
//
- static int brtbl[][5] =
- {
+ static int brtbl[][5] = {
{0,0,0,0,0},
{32,32,32,32,8},
{64,48,40,48,16},
@@ -469,7 +507,9 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
static int brtblcol[][4] = {{0,3,4,4},{0,0,1,2}};
int bitrate = 1000*brtbl[h.bitrate][brtblcol[h.version&1][h.layer]];
- if(bitrate == 0) return(false);
+ if(bitrate == 0) {
+ return(false);
+ }
static int freq[][4] = {{11025,0,22050,44100},{12000,0,24000,48000},{8000,0,16000,32000}};
@@ -477,42 +517,51 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
h.nSamplesPerSec = freq[h.freq][h.version];
h.FrameSize = h.layer == 1
- ? (12 * bitrate / h.nSamplesPerSec + h.padding) * 4
- : (l3ext ? 72 : 144) * bitrate / h.nSamplesPerSec + h.padding;
+ ? (12 * bitrate / h.nSamplesPerSec + h.padding) * 4
+ : (l3ext ? 72 : 144) * bitrate / h.nSamplesPerSec + h.padding;
h.rtDuration = 10000000i64 * (h.layer == 1 ? 384 : l3ext ? 576 : 1152) / h.nSamplesPerSec;// / (h.channels == 3 ? 1 : 2);
h.nBytesPerSec = bitrate / 8;
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
- /*int*/ len = h.layer == 3
- ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
- : sizeof(MPEG1WAVEFORMAT);
+ /*int*/ len = h.layer == 3
+ ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
+ : sizeof(MPEG1WAVEFORMAT);
WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[len];
memset(wfe, 0, len);
wfe->cbSize = len - sizeof(WAVEFORMATEX);
- if(h.layer == 3)
- {
+ if(h.layer == 3) {
wfe->wFormatTag = WAVE_FORMAT_MP3;
-/* MPEGLAYER3WAVEFORMAT* f = (MPEGLAYER3WAVEFORMAT*)wfe;
- f->wfx.wFormatTag = WAVE_FORMAT_MP3;
- f->wID = MPEGLAYER3_ID_UNKNOWN;
- f->fdwFlags = h.padding ? MPEGLAYER3_FLAG_PADDING_ON : MPEGLAYER3_FLAG_PADDING_OFF; // _OFF or _ISO ?
-*/
- }
- else
- {
+ /* MPEGLAYER3WAVEFORMAT* f = (MPEGLAYER3WAVEFORMAT*)wfe;
+ f->wfx.wFormatTag = WAVE_FORMAT_MP3;
+ f->wID = MPEGLAYER3_ID_UNKNOWN;
+ f->fdwFlags = h.padding ? MPEGLAYER3_FLAG_PADDING_ON : MPEGLAYER3_FLAG_PADDING_OFF; // _OFF or _ISO ?
+ */
+ } else {
MPEG1WAVEFORMAT* f = (MPEG1WAVEFORMAT*)wfe;
f->wfx.wFormatTag = WAVE_FORMAT_MPEG;
f->fwHeadMode = 1 << h.channels;
f->fwHeadModeExt = 1 << h.modeext;
f->wHeadEmphasis = h.emphasis+1;
- if(h.privatebit) f->fwHeadFlags |= ACM_MPEG_PRIVATEBIT;
- if(h.copyright) f->fwHeadFlags |= ACM_MPEG_COPYRIGHT;
- if(h.original) f->fwHeadFlags |= ACM_MPEG_ORIGINALHOME;
- if(h.crc == 0) f->fwHeadFlags |= ACM_MPEG_PROTECTIONBIT;
- if(h.version == 3) f->fwHeadFlags |= ACM_MPEG_ID_MPEG1;
+ if(h.privatebit) {
+ f->fwHeadFlags |= ACM_MPEG_PRIVATEBIT;
+ }
+ if(h.copyright) {
+ f->fwHeadFlags |= ACM_MPEG_COPYRIGHT;
+ }
+ if(h.original) {
+ f->fwHeadFlags |= ACM_MPEG_ORIGINALHOME;
+ }
+ if(h.crc == 0) {
+ f->fwHeadFlags |= ACM_MPEG_PROTECTIONBIT;
+ }
+ if(h.version == 3) {
+ f->fwHeadFlags |= ACM_MPEG_ID_MPEG1;
+ }
f->fwHeadLayer = 1 << (h.layer-1);
f->dwHeadBitrate = bitrate;
}
@@ -536,11 +585,13 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- for(; len >= 7 && BitRead(12, true) != 0xfff; len--)
+ for(; len >= 7 && BitRead(12, true) != 0xfff; len--) {
BitRead(8);
+ }
- if(len < 7)
+ if(len < 7) {
return(false);
+ }
h.sync = BitRead(12);
h.version = BitRead(1);
@@ -559,17 +610,22 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt)
h.adts_buffer_fullness = BitRead(11);
h.no_raw_data_blocks_in_frame = BitRead(2);
- if(h.fcrc == 0) h.crc = BitRead(16);
+ if(h.fcrc == 0) {
+ h.crc = BitRead(16);
+ }
- if(h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7))
+ if(h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7)) {
return(false);
+ }
h.FrameSize = h.aac_frame_length - (h.fcrc == 0 ? 9 : 7);
- static int freq[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
+ static int freq[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
h.nBytesPerSec = h.aac_frame_length * freq[h.freq] / 1024; // ok?
h.rtDuration = 10000000i64 * 1024 / freq[h.freq]; // ok?
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[sizeof(WAVEFORMATEX)+5];
memset(wfe, 0, sizeof(WAVEFORMATEX)+5);
@@ -597,33 +653,45 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
memset(&h, 0, sizeof(h));
- for(; len >= 7 && BitRead(16, true) != 0x0b77; len--)
+ for(; len >= 7 && BitRead(16, true) != 0x0b77; len--) {
BitRead(8);
+ }
- if(len < 7)
+ if(len < 7) {
return(false);
+ }
h.sync = (WORD)BitRead(16);
- if(h.sync != 0x0B77)
+ if(h.sync != 0x0B77) {
return(false);
+ }
_int64 pos = GetPos();
h.crc1 = (WORD)BitRead(16);
h.fscod = BitRead(2);
h.frmsizecod = BitRead(6);
h.bsid = BitRead(5);
- if(h.bsid > 16)
+ if(h.bsid > 16) {
return(false);
+ }
if(h.bsid <= 10) {
/* Normal AC-3 */
- if(h.fscod == 3)
+ if(h.fscod == 3) {
return(false);
- if(h.frmsizecod > 37)
+ }
+ if(h.frmsizecod > 37) {
return(false);
+ }
h.bsmod = BitRead(3);
h.acmod = BitRead(3);
- if(h.acmod == 2) h.dsurmod = BitRead(2);
- if((h.acmod & 1) && h.acmod != 1) h.cmixlev = BitRead(2);
- if(h.acmod & 4) h.surmixlev = BitRead(2);
+ if(h.acmod == 2) {
+ h.dsurmod = BitRead(2);
+ }
+ if((h.acmod & 1) && h.acmod != 1) {
+ h.cmixlev = BitRead(2);
+ }
+ if(h.acmod & 4) {
+ h.surmixlev = BitRead(2);
+ }
h.lfeon = BitRead(1);
h.sr_shift = max(h.bsid, 8) - 8;
} else {
@@ -632,22 +700,22 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
Seek(pos);
h.frame_type = BitRead(2);
h.substreamid = BitRead(3);
- if(h.frame_type || h.substreamid)
+ if(h.frame_type || h.substreamid) {
return(false);
+ }
h.frame_size = (BitRead(11) + 1) << 1;
- if(h.frame_size < 7)
+ if(h.frame_size < 7) {
return(false);
+ }
h.sr_code = BitRead(2);
- if(h.sr_code == 3)
- {
+ if(h.sr_code == 3) {
int sr_code2 = BitRead(2);
- if(sr_code2 == 3)
+ if(sr_code2 == 3) {
return(false);
+ }
h.sample_rate = freq[sr_code2] / 2;
h.sr_shift = 1;
- }
- else
- {
+ } else {
static int eac3_blocks[4] = {1, 2, 3, 6};
h.num_blocks = eac3_blocks[BitRead(2)];
h.sample_rate = freq[h.sr_code];
@@ -657,34 +725,34 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
h.lfeon = BitRead(1);
}
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
wfe.wFormatTag = WAVE_FORMAT_DOLBY_AC3;
-
+
static int channels[] = {2, 1, 2, 3, 3, 4, 4, 5};
wfe.nChannels = channels[h.acmod] + h.lfeon;
- if(h.bsid <= 10)
- {
+ if(h.bsid <= 10) {
wfe.nSamplesPerSec = freq[h.fscod] >> h.sr_shift;
static int rate[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, 768, 896, 1024, 1152, 1280};
wfe.nAvgBytesPerSec = ((rate[h.frmsizecod>>1] * 1000) >> h.sr_shift) / 8;
- }
- else
- {
+ } else {
wfe.nSamplesPerSec = h.sample_rate;
wfe.nAvgBytesPerSec = h.frame_size * h.sample_rate / (h.num_blocks * 256);
}
-
+
wfe.nBlockAlign = (WORD)(1536 * wfe.nAvgBytesPerSec / wfe.nSamplesPerSec);
pmt->majortype = MEDIATYPE_Audio;
- if(e_ac3)
+ if(e_ac3) {
pmt->subtype = MEDIASUBTYPE_DOLBY_DDPLUS;
- else
+ } else {
pmt->subtype = MEDIASUBTYPE_DOLBY_AC3;
+ }
pmt->formattype = FORMAT_WaveFormatEx;
pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
@@ -695,11 +763,13 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- for(; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--)
+ for(; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--) {
BitRead(8);
+ }
- if(len < 10)
+ if(len < 10) {
return(false);
+ }
h.sync = (DWORD)BitRead(32);
h.frametype = BitRead(1);
@@ -711,19 +781,21 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
h.sfreq = BitRead(4);
h.rate = BitRead(5);
- h.downmix = BitRead(1);
- h.dynrange = BitRead(1);
- h.timestamp = BitRead(1);
- h.aux_data = BitRead(1);
- h.hdcd = BitRead(1);
- h.ext_descr = BitRead(3);
- h.ext_coding = BitRead(1);
- h.aspf = BitRead(1);
- h.lfe = BitRead(2);
- h.predictor_history = BitRead(1);
+ h.downmix = BitRead(1);
+ h.dynrange = BitRead(1);
+ h.timestamp = BitRead(1);
+ h.aux_data = BitRead(1);
+ h.hdcd = BitRead(1);
+ h.ext_descr = BitRead(3);
+ h.ext_coding = BitRead(1);
+ h.aspf = BitRead(1);
+ h.lfe = BitRead(2);
+ h.predictor_history = BitRead(1);
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
@@ -731,18 +803,17 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
static int channels[] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
- if(h.amode < countof(channels))
- {
+ if(h.amode < countof(channels)) {
wfe.nChannels = channels[h.amode];
- if (h.lfe > 0)
+ if (h.lfe > 0) {
++wfe.nChannels;
+ }
}
static int freq[] = {0,8000,16000,32000,0,0,11025,22050,44100,0,0,12000,24000,48000,0,0};
wfe.nSamplesPerSec = freq[h.sfreq];
- static int rate[] =
- {
+ static int rate[] = {
32000,56000,64000,96000,112000,128000,192000,224000,
256000,320000,384000,448000,512000,576000,640000,754500,
960000,1024000,1152000,1280000,1344000,1408000,1411200,1472000,
@@ -769,12 +840,15 @@ bool CBaseSplitterFileEx::Read(hdmvlpcmhdr& h, CMediaType* pmt)
h.samplerate = BitRead(4);
h.bitpersample = BitRead(2);
- if (h.channels==0 || h.channels==2 ||
- (h.samplerate != 1 && h.samplerate!= 4 && h.samplerate!= 5) ||
- h.bitpersample<0 || h.bitpersample>3)
+ if (h.channels==0 || h.channels==2 ||
+ (h.samplerate != 1 && h.samplerate!= 4 && h.samplerate!= 5) ||
+ h.bitpersample<0 || h.bitpersample>3) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX_HDMV_LPCM wfe;
wfe.wFormatTag = WAVE_FORMAT_PCM;
@@ -814,10 +888,13 @@ bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt)
h.channels = BitRead(3);
h.drc = (BYTE)BitRead(8);
- if(h.quantwordlen == 3 || h.reserved1 || h.reserved2)
+ if(h.quantwordlen == 3 || h.reserved1 || h.reserved2) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
@@ -825,17 +902,16 @@ bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt)
wfe.nChannels = h.channels+1;
static int freq[] = {48000, 96000, 44100, 32000};
wfe.nSamplesPerSec = freq[h.freq];
- switch (h.quantwordlen)
- {
- case 0:
- wfe.wBitsPerSample = 16;
- break;
- case 1:
- wfe.wBitsPerSample = 20;
- break;
- case 2:
- wfe.wBitsPerSample = 24;
- break;
+ switch (h.quantwordlen) {
+ case 0:
+ wfe.wBitsPerSample = 16;
+ break;
+ case 1:
+ wfe.wBitsPerSample = 20;
+ break;
+ case 2:
+ wfe.wBitsPerSample = 24;
+ break;
}
wfe.nBlockAlign = (wfe.nChannels*2*wfe.wBitsPerSample) / 8;
wfe.nAvgBytesPerSec = (wfe.nBlockAlign*wfe.nSamplesPerSec) / 2;
@@ -854,7 +930,9 @@ bool CBaseSplitterFileEx::Read(dvdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_DVD_SUBPICTURE;
@@ -867,15 +945,16 @@ bool CBaseSplitterFileEx::Read(hdmvsubhdr& h, CMediaType* pmt, const char* langu
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Subtitle;
pmt->subtype = MEDIASUBTYPE_HDMVSUB;
pmt->formattype = FORMAT_None;
SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- if (psi)
- {
+ if (psi) {
memset(psi, 0, pmt->FormatLength());
strcpy(psi->IsoLang, language_code ? language_code : "eng");
}
@@ -887,7 +966,9 @@ bool CBaseSplitterFileEx::Read(svcdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_SVCD_SUBPICTURE;
@@ -900,7 +981,9 @@ bool CBaseSplitterFileEx::Read(cvdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_CVD_SUBPICTURE;
@@ -913,26 +996,23 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(BitRead(16, true) != 'SS')
+ if(BitRead(16, true) != 'SS') {
return(false);
+ }
__int64 pos = GetPos();
- while(BitRead(16, true) == 'SS')
- {
+ while(BitRead(16, true) == 'SS') {
DWORD tag = (DWORD)BitRead(32, true);
DWORD size = 0;
-
- if(tag == 'SShd')
- {
+
+ if(tag == 'SShd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
ASSERT(size == 0x18);
Seek(GetPos());
ByteRead((BYTE*)&h, sizeof(h));
- }
- else if(tag == 'SSbd')
- {
+ } else if(tag == 'SSbd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
break;
@@ -941,11 +1021,13 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt)
Seek(pos);
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEXPS2 wfe;
- wfe.wFormatTag =
- h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
+ wfe.wFormatTag =
+ h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
h.unk1 == 0x10 ? WAVE_FORMAT_PS2_ADPCM :
WAVE_FORMAT_UNKNOWN;
wfe.nChannels = (WORD)h.channels;
@@ -967,7 +1049,9 @@ bool CBaseSplitterFileEx::Read(ps2subhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Subtitle;
pmt->subtype = MEDIASUBTYPE_PS2_SUB;
@@ -982,19 +1066,22 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
BitByteAlign();
- if(m_tslen == 0)
- {
+ if(m_tslen == 0) {
__int64 pos = GetPos();
- for(int i = 0; i < 192; i++)
- {
- if(BitRead(8, true) == 0x47)
- {
+ for(int i = 0; i < 192; i++) {
+ if(BitRead(8, true) == 0x47) {
__int64 pos = GetPos();
Seek(pos + 188);
- if(BitRead(8, true) == 0x47) {m_tslen = 188; break;} // TS stream
+ if(BitRead(8, true) == 0x47) {
+ m_tslen = 188; // TS stream
+ break;
+ }
Seek(pos + 192);
- if(BitRead(8, true) == 0x47) {m_tslen = 192; break;} // M2TS stream
+ if(BitRead(8, true) == 0x47) {
+ m_tslen = 192; // M2TS stream
+ break;
+ }
}
BitRead(8);
@@ -1002,32 +1089,35 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
Seek(pos);
- if(m_tslen == 0)
- {
+ if(m_tslen == 0) {
return(false);
}
}
- if(fSync)
- {
- for(int i = 0; i < m_tslen; i++)
- {
- if(BitRead(8, true) == 0x47)
- {
- if(i == 0) break;
+ if(fSync) {
+ for(int i = 0; i < m_tslen; i++) {
+ if(BitRead(8, true) == 0x47) {
+ if(i == 0) {
+ break;
+ }
Seek(GetPos()+m_tslen);
- if(BitRead(8, true) == 0x47) {Seek(GetPos()-m_tslen); break;}
+ if(BitRead(8, true) == 0x47) {
+ Seek(GetPos()-m_tslen);
+ break;
+ }
}
BitRead(8);
- if(i == m_tslen-1)
+ if(i == m_tslen-1) {
return(false);
+ }
}
}
- if(BitRead(8, true) != 0x47)
+ if(BitRead(8, true) != 0x47) {
return(false);
+ }
h.next = GetPos() + m_tslen;
@@ -1043,12 +1133,10 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
h.bytes = 188 - 4;
- if(h.adapfield)
- {
+ if(h.adapfield) {
h.length = (BYTE)BitRead(8);
- if(h.length > 0)
- {
+ if(h.length > 0) {
h.discontinuity = BitRead(1);
h.randomaccess = BitRead(1);
h.priority = BitRead(1);
@@ -1060,8 +1148,7 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
int i = 1;
- if(h.fPCR)
- {
+ if(h.fPCR) {
h.PCR = BitRead(33);
BitRead(6);
UINT64 PCRExt = BitRead(9);
@@ -1071,13 +1158,17 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
ASSERT(i <= h.length);
- for(; i < h.length; i++)
+ for(; i < h.length; i++) {
BitRead(8);
+ }
}
h.bytes -= h.length+1;
- if(h.bytes < 0) {ASSERT(0); return false;}
+ if(h.bytes < 0) {
+ ASSERT(0);
+ return false;
+ }
}
return true;
@@ -1086,7 +1177,9 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
bool CBaseSplitterFileEx::Read(trsechdr& h)
{
BYTE pointer_field = BitRead(8);
- while(pointer_field-- > 0) BitRead(8);
+ while(pointer_field-- > 0) {
+ BitRead(8);
+ }
h.table_id = BitRead(8);
h.section_syntax_indicator = BitRead(1);
h.zero = BitRead(1);
@@ -1107,18 +1200,18 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
BitByteAlign();
- if(fSync)
- {
- for(int i = 0; i < 65536; i++)
- {
- if((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64)
+ if(fSync) {
+ for(int i = 0; i < 65536; i++) {
+ if((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64) {
break;
+ }
BitRead(8);
}
}
- if((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64)
+ if((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64) {
return(false);
+ }
h.sync = (WORD)BitRead(16);
h.streamid = (BYTE)BitRead(8);
@@ -1130,24 +1223,28 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
h.prebytes = BitRead(2);
h.length = (WORD)BitRead(16);
- if(h.length > 6136)
+ if(h.length > 6136) {
return(false);
+ }
__int64 pos = GetPos();
- if(h.streamid == 1 && h.fpts)
- {
+ if(h.streamid == 1 && h.fpts) {
h.pts = 10000*BitRead(32)/90 + m_rtPTSOffset;
- }
- else if(h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0))
- {
+ } else if(h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0)) {
BYTE b;
- if(!NextMpegStartCode(b, 4)) return(false);
+ if(!NextMpegStartCode(b, 4)) {
+ return(false);
+ }
peshdr h2;
- if(!Read(h2, b)) return(false);
+ if(!Read(h2, b)) {
+ return(false);
+ }
// Maybe bug, code before: if(h.fpts = h2.fpts) h.pts = h2.pts;
h.fpts = h2.fpts;
- if(h.fpts) h.pts = h2.pts;
+ if(h.fpts) {
+ h.pts = h2.pts;
+ }
}
BitRead(8*h.prebytes);
@@ -1159,26 +1256,27 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
void CBaseSplitterFileEx::RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length)
-{
- int si=0;
+{
+ int si=0;
int di=0;
- while(si+2<length){
- //remove escapes (very rare 1:2^22)
- if(src[si+2]>3){
- dst[di++]= src[si++];
- dst[di++]= src[si++];
- }else if(src[si]==0 && src[si+1]==0){
- if(src[si+2]==3){ //escape
- dst[di++]= 0;
- dst[di++]= 0;
- si+=3;
- continue;
- }else //next start code
- return;
- }
-
- dst[di++]= src[si++];
- }
+ while(si+2<length) {
+ //remove escapes (very rare 1:2^22)
+ if(src[si+2]>3) {
+ dst[di++]= src[si++];
+ dst[di++]= src[si++];
+ } else if(src[si]==0 && src[si+1]==0) {
+ if(src[si+2]==3) { //escape
+ dst[di++]= 0;
+ dst[di++]= 0;
+ si+=3;
+ continue;
+ } else { //next start code
+ return;
+ }
+ }
+
+ dst[di++]= src[si++];
+ }
}
bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
@@ -1187,10 +1285,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
DWORD dwStartCode;
- while(GetPos() < endpos+4 /*&& BitRead(32, true) == 0x00000001*/ && (!h.spslen || !h.ppslen))
- {
- if (BitRead(32, true) != 0x00000001)
- {
+ while(GetPos() < endpos+4 /*&& BitRead(32, true) == 0x00000001*/ && (!h.spslen || !h.ppslen)) {
+ if (BitRead(32, true) != 0x00000001) {
BitRead(8);
continue;
}
@@ -1198,9 +1294,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
BitRead(32);
BYTE id = BitRead(8);
-
- if((id&0x9f) == 0x07 && (id&0x60) != 0)
- {
+
+ if((id&0x9f) == 0x07 && (id&0x60) != 0) {
#if 1
BYTE SPSTemp[MAX_SPS];
BYTE SPSBuff[MAX_SPS];
@@ -1221,10 +1316,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
gb.UExpGolombRead(); // seq_parameter_set_id
- if(h.profile >= 100) // high profile
- {
- if(gb.UExpGolombRead() == 3) // chroma_format_idc
- {
+ if(h.profile >= 100) { // high profile
+ if(gb.UExpGolombRead() == 3) { // chroma_format_idc
gb.BitRead(1); // residue_transform_flag
}
@@ -1236,26 +1329,25 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
if(gb.BitRead(1)) // seq_scaling_matrix_present_flag
for(int i = 0; i < 8; i++)
if(gb.BitRead(1)) // seq_scaling_list_present_flag
- for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j)
+ for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
next = (next + gb.SExpGolombRead() + 256) & 255;
+ }
}
gb.UExpGolombRead(); // log2_max_frame_num_minus4
UINT64 pic_order_cnt_type = gb.UExpGolombRead();
- if(pic_order_cnt_type == 0)
- {
+ if(pic_order_cnt_type == 0) {
gb.UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- }
- else if(pic_order_cnt_type == 1)
- {
+ } else if(pic_order_cnt_type == 1) {
gb.BitRead(1); // delta_pic_order_always_zero_flag
gb.SExpGolombRead(); // offset_for_non_ref_pic
gb.SExpGolombRead(); // offset_for_top_to_bottom_field
UINT64 num_ref_frames_in_pic_order_cnt_cycle = gb.UExpGolombRead();
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
- gb.SExpGolombRead(); // offset_for_ref_frame[i]
+ for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ gb.SExpGolombRead(); // offset_for_ref_frame[i]
+ }
}
gb.UExpGolombRead(); // num_ref_frames
@@ -1268,75 +1360,66 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
h.width = (pic_width_in_mbs_minus1 + 1) * 16;
h.height = (2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16;
- if (h.height == 1088) h.height = 1080; // Prevent blur lines
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
+ }
- if (!frame_mbs_only_flag)
- gb.BitRead(1); // mb_adaptive_frame_field_flag
+ if (!frame_mbs_only_flag) {
+ gb.BitRead(1); // mb_adaptive_frame_field_flag
+ }
gb.BitRead(1); // direct_8x8_inference_flag
- if (gb.BitRead(1)) // frame_cropping_flag
- {
+ if (gb.BitRead(1)) { // frame_cropping_flag
gb.UExpGolombRead(); // frame_cropping_rect_left_offset
gb.UExpGolombRead(); // frame_cropping_rect_right_offset
gb.UExpGolombRead(); // frame_cropping_rect_top_offset
gb.UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
-
- if (gb.BitRead(1)) // vui_parameters_present_flag
- {
- if (gb.BitRead(1)) // aspect_ratio_info_present_flag
- {
- if (255==(BYTE)gb.BitRead(8)) // aspect_ratio_idc)
- {
+
+ if (gb.BitRead(1)) { // vui_parameters_present_flag
+ if (gb.BitRead(1)) { // aspect_ratio_info_present_flag
+ if (255==(BYTE)gb.BitRead(8)) { // aspect_ratio_idc)
gb.BitRead(16); // sar_width
gb.BitRead(16); // sar_height
}
}
- if (gb.BitRead(1)) // overscan_info_present_flag
- {
+ if (gb.BitRead(1)) { // overscan_info_present_flag
gb.BitRead(1); // overscan_appropriate_flag
}
- if (gb.BitRead(1)) // video_signal_type_present_flag
- {
+ if (gb.BitRead(1)) { // video_signal_type_present_flag
gb.BitRead(3); // video_format
gb.BitRead(1); // video_full_range_flag
- if(gb.BitRead(1)) // colour_description_present_flag
- {
+ if(gb.BitRead(1)) { // colour_description_present_flag
gb.BitRead(8); // colour_primaries
gb.BitRead(8); // transfer_characteristics
gb.BitRead(8); // matrix_coefficients
}
}
- if(gb.BitRead(1)) // chroma_location_info_present_flag
- {
+ if(gb.BitRead(1)) { // chroma_location_info_present_flag
gb.UExpGolombRead(); // chroma_sample_loc_type_top_field
gb.UExpGolombRead(); // chroma_sample_loc_type_bottom_field
}
- if (gb.BitRead(1)) // timing_info_present_flag
- {
+ if (gb.BitRead(1)) { // timing_info_present_flag
num_units_in_tick = gb.BitRead(32);
time_scale = gb.BitRead(32);
fixed_frame_rate_flag = gb.BitRead(1);
// Trick for weird parameters (10x to Madshi)!
- if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001))
- {
- if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0))
- {
+ if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001)) {
+ if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0)) {
time_scale = (time_scale * 1001) / num_units_in_tick;
num_units_in_tick = 1001;
- }
- else
- {
+ } else {
time_scale = (time_scale * 1000) / num_units_in_tick;
num_units_in_tick = 1000;
}
}
time_scale = time_scale / 2; // VUI consider fields even for progressive stream : divide by 2!
- if (time_scale)
+ if (time_scale) {
h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
+ }
}
}
@@ -1354,10 +1437,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
UExpGolombRead(); // seq_parameter_set_id
- if(h.profile >= 100) // high profile
- {
- if(UExpGolombRead() == 3) // chroma_format_idc
- {
+ if(h.profile >= 100) { // high profile
+ if(UExpGolombRead() == 3) { // chroma_format_idc
BitRead(1); // residue_transform_flag
}
@@ -1369,26 +1450,25 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
if(BitRead(1)) // seq_scaling_matrix_present_flag
for(int i = 0; i < 8; i++)
if(BitRead(1)) // seq_scaling_list_present_flag
- for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j)
+ for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
next = (next + SExpGolombRead() + 256) & 255;
+ }
}
UExpGolombRead(); // log2_max_frame_num_minus4
UINT64 pic_order_cnt_type = UExpGolombRead();
- if(pic_order_cnt_type == 0)
- {
+ if(pic_order_cnt_type == 0) {
UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- }
- else if(pic_order_cnt_type == 1)
- {
+ } else if(pic_order_cnt_type == 1) {
BitRead(1); // delta_pic_order_always_zero_flag
SExpGolombRead(); // offset_for_non_ref_pic
SExpGolombRead(); // offset_for_top_to_bottom_field
UINT64 num_ref_frames_in_pic_order_cnt_cycle = UExpGolombRead();
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
- SExpGolombRead(); // offset_for_ref_frame[i]
+ for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ SExpGolombRead(); // offset_for_ref_frame[i]
+ }
}
UExpGolombRead(); // num_ref_frames
@@ -1401,119 +1481,112 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
h.width = (pic_width_in_mbs_minus1 + 1) * 16;
h.height = (2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16;
- if (h.height == 1088) h.height = 1080; // Prevent blur lines
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
+ }
- if (!frame_mbs_only_flag)
- BitRead(1); // mb_adaptive_frame_field_flag
+ if (!frame_mbs_only_flag) {
+ BitRead(1); // mb_adaptive_frame_field_flag
+ }
BitRead(1); // direct_8x8_inference_flag
- if (BitRead(1)) // frame_cropping_flag
- {
+ if (BitRead(1)) { // frame_cropping_flag
UExpGolombRead(); // frame_cropping_rect_left_offset
UExpGolombRead(); // frame_cropping_rect_right_offset
UExpGolombRead(); // frame_cropping_rect_top_offset
UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
-
- if (BitRead(1)) // vui_parameters_present_flag
- {
- if (BitRead(1)) // aspect_ratio_info_present_flag
- {
- if (255==(BYTE)BitRead(8)) // aspect_ratio_idc)
- {
+
+ if (BitRead(1)) { // vui_parameters_present_flag
+ if (BitRead(1)) { // aspect_ratio_info_present_flag
+ if (255==(BYTE)BitRead(8)) { // aspect_ratio_idc)
BitRead(16); // sar_width
BitRead(16); // sar_height
}
}
- if (BitRead(1)) // overscan_info_present_flag
- {
+ if (BitRead(1)) { // overscan_info_present_flag
BitRead(1); // overscan_appropriate_flag
}
- if (BitRead(1)) // video_signal_type_present_flag
- {
+ if (BitRead(1)) { // video_signal_type_present_flag
BitRead(3); // video_format
BitRead(1); // video_full_range_flag
- if(BitRead(1)) // colour_description_present_flag
- {
+ if(BitRead(1)) { // colour_description_present_flag
BitRead(8); // colour_primaries
BitRead(8); // transfer_characteristics
BitRead(8); // matrix_coefficients
}
}
- if(BitRead(1)) // chroma_location_info_present_flag
- {
+ if(BitRead(1)) { // chroma_location_info_present_flag
UExpGolombRead(); // chroma_sample_loc_type_top_field
UExpGolombRead(); // chroma_sample_loc_type_bottom_field
}
- if (BitRead(1)) // timing_info_present_flag
- {
+ if (BitRead(1)) { // timing_info_present_flag
num_units_in_tick = BitRead(32);
time_scale = BitRead(32);
fixed_frame_rate_flag = BitRead(1);
// Trick for weird parameters (10x to Madshi)!
- if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001))
- {
- if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0))
- {
+ if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001)) {
+ if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0)) {
time_scale = (time_scale * 1001) / num_units_in_tick;
num_units_in_tick = 1001;
- }
- else
- {
+ } else {
time_scale = (time_scale * 1000) / num_units_in_tick;
num_units_in_tick = 1000;
}
}
time_scale = time_scale / 2; // VUI consider fields even for progressive stream : divide by 2!
- if (time_scale)
+ if (time_scale) {
h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
+ }
}
}
#endif
- }
- else if((id&0x9f) == 0x08 && (id&0x60) != 0)
- {
+ } else if((id&0x9f) == 0x08 && (id&0x60) != 0) {
h.ppspos = pos;
}
BitByteAlign();
dwStartCode = BitRead(32, true);
- while(GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100)
- {
+ while(GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100) {
BitRead(8);
dwStartCode = BitRead(32, true);
}
- if(h.spspos != 0 && h.spslen == 0)
+ if(h.spspos != 0 && h.spslen == 0) {
h.spslen = GetPos() - h.spspos;
- else if(h.ppspos != 0 && h.ppslen == 0)
+ } else if(h.ppspos != 0 && h.ppslen == 0) {
h.ppslen = GetPos() - h.ppspos;
+ }
}
- if(!h.spspos || !h.spslen || !h.ppspos || !h.ppslen)
+ if(!h.spspos || !h.spslen || !h.ppspos || !h.ppslen) {
return(false);
-
+ }
+
if(!h.AvgTimePerFrame || !(
- (h.level == 10) || (h.level == 11) || (h.level == 12) || (h.level == 13) ||
- (h.level == 20) || (h.level == 21) || (h.level == 22) ||
- (h.level == 30) || (h.level == 31) || (h.level == 32) ||
- (h.level == 40) || (h.level == 41) || (h.level == 42) ||
- (h.level == 50) || (h.level == 51)))
+ (h.level == 10) || (h.level == 11) || (h.level == 12) || (h.level == 13) ||
+ (h.level == 20) || (h.level == 21) || (h.level == 22) ||
+ (h.level == 30) || (h.level == 31) || (h.level == 32) ||
+ (h.level == 40) || (h.level == 41) || (h.level == 42) ||
+ (h.level == 50) || (h.level == 51))) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
{
int extra = 2+h.spslen-4 + 2+h.ppslen-4;
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = FOURCCMap('1CVA');
-//pmt->subtype = MEDIASUBTYPE_H264; // TODO : put MEDIASUBTYPE_H264 to support Windows 7 decoder !
+ //pmt->subtype = MEDIASUBTYPE_H264; // TODO : put MEDIASUBTYPE_H264 to support Windows 7 decoder !
pmt->formattype = FORMAT_MPEG2_VIDEO;
int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + extra;
MPEG2VIDEOINFO* vi = (MPEG2VIDEOINFO*)DNew BYTE[len];
@@ -1555,8 +1628,7 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
__int64 extrapos = 0, extralen = 0;
int nFrameRateNum = 0, nFrameRateDen = 1;
- if (GetPos() < endpos+4 && BitRead(32, true) == 0x0000010F)
- {
+ if (GetPos() < endpos+4 && BitRead(32, true) == 0x0000010F) {
extrapos = GetPos();
BitRead(32);
@@ -1564,7 +1636,9 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
h.profile = BitRead(2);
// Check if advanced profile
- if (h.profile != 3) return(false);
+ if (h.profile != 3) {
+ return(false);
+ }
h.level = BitRead (3);
h.chromaformat = BitRead (2);
@@ -1584,41 +1658,36 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
h.finterpflag = BitRead (1);
BitRead (1); // reserved
h.psf = BitRead (1);
- if(BitRead (1))
- {
+ if(BitRead (1)) {
int ar = 0;
h.ArX = BitRead (14) + 1;
h.ArY = BitRead (14) + 1;
- if(BitRead (1))
+ if(BitRead (1)) {
ar = BitRead (4);
- // TODO : next is not the true A/R!
- if(ar && ar < 14)
- {
-// h.ArX = ff_vc1_pixel_aspect[ar].num;
-// h.ArY = ff_vc1_pixel_aspect[ar].den;
}
- else if(ar == 15)
- {
+ // TODO : next is not the true A/R!
+ if(ar && ar < 14) {
+ // h.ArX = ff_vc1_pixel_aspect[ar].num;
+ // h.ArY = ff_vc1_pixel_aspect[ar].den;
+ } else if(ar == 15) {
/*h.ArX =*/ BitRead (8);
- /*h.ArY =*/ BitRead (8);
+ /*h.ArY =*/
+ BitRead (8);
}
// Read framerate
const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 },
- ff_vc1_fps_dr[2] = { 1000, 1001 };
+ ff_vc1_fps_dr[2] = { 1000, 1001 };
- if(BitRead (1))
- {
- if(BitRead (1))
- {
+ if(BitRead (1)) {
+ if(BitRead (1)) {
nFrameRateNum = 32;
nFrameRateDen = BitRead (16) + 1;
} else {
int nr, dr;
nr = BitRead (8);
dr = BitRead (4);
- if(nr && nr < 8 && dr && dr < 3)
- {
+ if(nr && nr < 8 && dr && dr < 3) {
nFrameRateNum = ff_vc1_fps_dr[dr - 1];
nFrameRateDen = ff_vc1_fps_nr[nr - 1] * 1000;
}
@@ -1631,17 +1700,19 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
extralen = 0;
long parse = 0;
- while (GetPos() < endpos+4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100))
- {
+ while (GetPos() < endpos+4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100)) {
parse = (parse<<8) | BitRead(8);
extralen++;
}
}
- if(!extrapos || !extralen)
+ if(!extrapos || !extralen) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
{
//pmt->majortype = MEDIATYPE_Video;
@@ -1695,8 +1766,7 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
bool CBaseSplitterFileEx::Read(dvbsub& h, int len, CMediaType* pmt)
{
- if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00)
- {
+ if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00) {
static const SUBTITLEINFO SubFormat = { 0, "", L"" };
pmt->majortype = MEDIATYPE_Subtitle;
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
index 0d55a9366..942cfa4bc 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -42,22 +42,19 @@ public:
enum mpeg_t {mpegunk, mpeg1, mpeg2};
- struct pshdr
- {
+ struct pshdr {
mpeg_t type;
UINT64 scr, bitrate;
};
- struct pssyshdr
- {
+ struct pssyshdr {
DWORD rate_bound;
BYTE video_bound, audio_bound;
bool fixed_rate, csps;
bool sys_video_loc_flag, sys_audio_loc_flag;
};
- struct peshdr
- {
+ struct peshdr {
WORD len;
BYTE type:2, fpts:1, fdts:1;
@@ -71,7 +68,9 @@ public:
BYTE escr:1, esrate:1, dsmtrickmode:1, morecopyright:1, crc:1, extension:1;
BYTE hdrlen;
- struct peshdr() {memset(this, 0, sizeof(*this));}
+ struct peshdr() {
+ memset(this, 0, sizeof(*this));
+ }
};
class seqhdr
@@ -116,7 +115,7 @@ public:
WORD copyright:1;
WORD original:1;
WORD emphasis:2;
-
+
int nSamplesPerSec, FrameSize, nBytesPerSec;
REFERENCE_TIME rtDuration;
};
@@ -232,7 +231,7 @@ public:
public:
// nothing ;)
};
-
+
class svcdspuhdr
{
public:
@@ -264,8 +263,7 @@ public:
// nothing ;)
};
- struct trhdr
- {
+ struct trhdr {
BYTE sync; // 0x47
BYTE error:1;
BYTE payloadstart:1;
@@ -292,8 +290,7 @@ public:
__int64 next;
};
- struct trsechdr
- {
+ struct trsechdr {
BYTE table_id;
WORD section_syntax_indicator:1;
WORD zero:1;
@@ -309,8 +306,7 @@ public:
// http://www.technotrend.de/download/av_format_v1.pdf
- struct pvahdr
- {
+ struct pvahdr {
WORD sync; // 'VA'
BYTE streamid; // 1 - video, 2 - audio
BYTE counter;
@@ -323,16 +319,14 @@ public:
REFERENCE_TIME pts;
};
- struct avchdr
- {
+ struct avchdr {
BYTE profile, level;
unsigned int width, height;
__int64 spspos, spslen;
__int64 ppspos, ppslen;
__int64 AvgTimePerFrame;
- avchdr()
- {
+ avchdr() {
spspos = 0;
spslen = 0;
ppspos = 0;
@@ -341,8 +335,7 @@ public:
}
};
- struct vc1hdr
- {
+ struct vc1hdr {
BYTE profile;
BYTE level;
BYTE chromaformat;
@@ -359,8 +352,7 @@ public:
unsigned int width, height;
};
- struct dvbsub
- {
+ struct dvbsub {
};
#pragma pack(pop)
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.cpp b/src/filters/parser/BaseSplitter/MultiFiles.cpp
index beb3a2e84..853fca54c 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.cpp
+++ b/src/filters/parser/BaseSplitter/MultiFiles.cpp
@@ -28,10 +28,10 @@
IMPLEMENT_DYNAMIC(CMultiFiles, CObject)
CMultiFiles::CMultiFiles()
- : m_hFile(INVALID_HANDLE_VALUE)
- , m_llTotalLength(0)
- , m_nCurPart(-1)
- , m_pCurrentPTSOffset(NULL)
+ : m_hFile(INVALID_HANDLE_VALUE)
+ , m_llTotalLength(0)
+ , m_nCurPart(-1)
+ , m_pCurrentPTSOffset(NULL)
{
}
@@ -59,11 +59,12 @@ BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT n
REFERENCE_TIME rtDur = 0;
Reset();
- while(pos)
- {
+ while(pos) {
CHdmvClipInfo::PlaylistItem& s = files.GetNext(pos);
m_strFiles.Add(s.m_strFileName);
- if (!OpenPart(nPos)) return false;
+ if (!OpenPart(nPos)) {
+ return false;
+ }
llSize.QuadPart = 0;
GetFileSizeEx (m_hFile, &llSize);
@@ -74,8 +75,10 @@ BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT n
nPos++;
}
- if (files.GetCount() > 1) ClosePart();
-
+ if (files.GetCount() > 1) {
+ ClosePart();
+ }
+
return TRUE;
}
@@ -85,21 +88,17 @@ ULONGLONG CMultiFiles::Seek(LONGLONG lOff, UINT nFrom)
LARGE_INTEGER llNewPos;
LARGE_INTEGER llOff;
- if (m_strFiles.GetCount() == 1)
- {
+ if (m_strFiles.GetCount() == 1) {
llOff.QuadPart = lOff;
SetFilePointerEx (m_hFile, llOff, &llNewPos, nFrom);
return llNewPos.QuadPart;
- }
- else
- {
+ } else {
LONGLONG lAbsolutePos = GetAbsolutePosition(lOff, nFrom);
int nNewPart = 0;
ULONGLONG llSum = 0;
- while (m_FilesSize[nNewPart]+llSum <= lAbsolutePos)
- {
+ while (m_FilesSize[nNewPart]+llSum <= lAbsolutePos) {
llSum += m_FilesSize[nNewPart];
nNewPart++;
}
@@ -117,42 +116,39 @@ ULONGLONG CMultiFiles::GetAbsolutePosition(LONGLONG lOff, UINT nFrom)
LARGE_INTEGER llNoMove = {0, 0};
LARGE_INTEGER llCurPos;
- switch (nFrom)
- {
- case begin :
- return lOff;
- case current :
- SetFilePointerEx (m_hFile, llNoMove, &llCurPos, FILE_CURRENT);
- return llCurPos.QuadPart + lOff;
- case end :
- return m_llTotalLength - lOff;
- default:
- return 0; // just used to quash "not all control paths return a value" warning
+ switch (nFrom) {
+ case begin :
+ return lOff;
+ case current :
+ SetFilePointerEx (m_hFile, llNoMove, &llCurPos, FILE_CURRENT);
+ return llCurPos.QuadPart + lOff;
+ case end :
+ return m_llTotalLength - lOff;
+ default:
+ return 0; // just used to quash "not all control paths return a value" warning
}
}
ULONGLONG CMultiFiles::GetLength() const
{
- if (m_strFiles.GetCount() == 1)
- {
+ if (m_strFiles.GetCount() == 1) {
LARGE_INTEGER llSize;
GetFileSizeEx (m_hFile, &llSize);
return llSize.QuadPart;
- }
- else
+ } else {
return m_llTotalLength;
+ }
}
UINT CMultiFiles::Read(void* lpBuf, UINT nCount)
{
DWORD dwRead;
- do
- {
- if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL))
+ do {
+ if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) {
break;
-
- if (dwRead != nCount && m_nCurPart < m_strFiles.GetCount()-1)
- {
+ }
+
+ if (dwRead != nCount && m_nCurPart < m_strFiles.GetCount()-1) {
OpenPart (m_nCurPart+1);
lpBuf = (void*)((BYTE*)lpBuf + dwRead);
nCount -= dwRead;
@@ -174,10 +170,9 @@ CMultiFiles::~CMultiFiles()
BOOL CMultiFiles::OpenPart(int nPart)
{
- if (m_nCurPart == nPart)
+ if (m_nCurPart == nPart) {
return TRUE;
- else
- {
+ } else {
CString fn;
ClosePart();
@@ -185,10 +180,11 @@ BOOL CMultiFiles::OpenPart(int nPart)
fn = m_strFiles.GetAt(nPart);
m_hFile = CreateFile (fn, GENERIC_READ, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
m_nCurPart = nPart;
- if (m_pCurrentPTSOffset != NULL) *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
+ if (m_pCurrentPTSOffset != NULL) {
+ *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
+ }
}
return (m_hFile != INVALID_HANDLE_VALUE);
@@ -198,8 +194,7 @@ BOOL CMultiFiles::OpenPart(int nPart)
void CMultiFiles::ClosePart()
{
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
CloseHandle (m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
m_nCurPart = -1;
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.h b/src/filters/parser/BaseSplitter/MultiFiles.h
index b07862a0a..dbb700fed 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.h
+++ b/src/filters/parser/BaseSplitter/MultiFiles.h
@@ -31,7 +31,7 @@ class CMultiFiles : public CObject
DECLARE_DYNAMIC(CMultiFiles)
public:
-// Flag values
+ // Flag values
enum OpenFlags {
modeRead = (int) 0x00000,
modeWrite = (int) 0x00001,
@@ -50,7 +50,7 @@ public:
osWriteThrough = (int) 0x20000,
osRandomAccess = (int) 0x40000,
osSequentialScan = (int) 0x80000,
- };
+ };
enum Attribute {
normal = 0x00,
@@ -60,16 +60,16 @@ public:
volume = 0x08,
directory = 0x10,
archive = 0x20
- };
+ };
enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
-// Constructors
+ // Constructors
CMultiFiles();
CString m_strFileName;
-// Operations
+ // Operations
virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags);
virtual BOOL OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT nOpenFlags);
@@ -80,7 +80,7 @@ public:
virtual UINT Read(void* lpBuf, UINT nCount);
virtual void Close();
-// Implementation
+ // Implementation
public:
virtual ~CMultiFiles();
diff --git a/src/filters/parser/BaseSplitter/stdafx.cpp b/src/filters/parser/BaseSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/BaseSplitter/stdafx.cpp
+++ b/src/filters/parser/BaseSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/BaseSplitter/stdafx.h b/src/filters/parser/BaseSplitter/stdafx.h
index 4811c9499..eb1a0a29e 100644
--- a/src/filters/parser/BaseSplitter/stdafx.h
+++ b/src/filters/parser/BaseSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.cpp b/src/filters/parser/DSMSplitter/DSMSplitter.cpp
index 3b562b417..eaac42a0a 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitter.cpp
+++ b/src/filters/parser/DSMSplitter/DSMSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,26 +28,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CDSMSplitterFilter), L"MPC - DSM Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CDSMSourceFilter), L"MPC - DSM Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDSMSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDSMSourceFilter>, NULL, &sudFilter[1]},
};
@@ -61,8 +57,8 @@ STDAPI DllRegisterServer()
str.Format(CString(str), DSMSW);
RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_DirectShowMedia,
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_DirectShowMedia,
str, NULL);
return AMovieDllRegisterServer2(TRUE);
@@ -94,7 +90,10 @@ CDSMSplitterFilter::~CDSMSplitterFilter()
{
}
-static int compare_id(const void* id1, const void* id2) {return (int)*(BYTE*)id1 - (int)*(BYTE*)id2;}
+static int compare_id(const void* id1, const void* id2)
+{
+ return (int)*(BYTE*)id1 - (int)*(BYTE*)id2;
+}
HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
@@ -104,8 +103,13 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CDSMSplitterFile(pAsyncReader, hr, *this, *this));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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 = m_pFile->m_rtDuration;
@@ -113,8 +117,7 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAtlArray<BYTE> ids;
POSITION pos = m_pFile->m_mts.GetStartPosition();
- while(pos)
- {
+ while(pos) {
BYTE id;
CMediaType mt;
m_pFile->m_mts.GetNextAssoc(pos, id, mt);
@@ -123,8 +126,7 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
qsort(ids.GetData(), ids.GetCount(), sizeof(BYTE), compare_id);
- for(int i = 0; i < ids.GetCount(); i++)
- {
+ for(int i = 0; i < ids.GetCount(); i++) {
BYTE id = ids[i];
CMediaType& mt = m_pFile->m_mts[id];
@@ -135,24 +137,32 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.Add(mt);
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
-
+
name.Empty();
pos = m_pFile->m_sim[id].GetStartPosition();
- while(pos)
- {
- CStringA key; CStringW value;
+ while(pos) {
+ CStringA key;
+ CStringW value;
m_pFile->m_sim[id].GetNextAssoc(pos, key, value);
pPinOut->SetProperty(CStringW(key), value);
- if(key == "NAME") name = value;
- if(key == "LANG") if((lang = ISO6392ToLanguage(CStringA(CString(value)))).IsEmpty()) lang = value;
+ if(key == "NAME") {
+ name = value;
+ }
+ if(key == "LANG") if((lang = ISO6392ToLanguage(CStringA(CString(value)))).IsEmpty()) {
+ lang = value;
+ }
}
- if(!name.IsEmpty() || !lang.IsEmpty())
- {
- if(!name.IsEmpty()) {if(!lang.IsEmpty()) name += L" (" + lang + L")";}
- else if(!lang.IsEmpty()) name = lang;
+ if(!name.IsEmpty() || !lang.IsEmpty()) {
+ if(!name.IsEmpty()) {
+ if(!lang.IsEmpty()) {
+ name += L" (" + lang + L")";
+ }
+ } else if(!lang.IsEmpty()) {
+ name = lang;
+ }
pPinOut->SetName(name);
}
@@ -160,18 +170,18 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
pos = m_pFile->m_fim.GetStartPosition();
- while(pos)
- {
- CStringA key; CStringW value;
+ while(pos) {
+ CStringA key;
+ CStringW value;
m_pFile->m_fim.GetNextAssoc(pos, key, value);
SetProperty(CStringW(key), value);
}
- for(int i = 0; i < m_resources.GetCount(); i++)
- {
+ for(int i = 0; i < m_resources.GetCount(); i++) {
const CDSMResource& r = m_resources[i];
- if(r.mime == "application/x-truetype-font")
+ if(r.mime == "application/x-truetype-font") {
m_fontinst.InstallFont(r.data);
+ }
}
return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
@@ -192,23 +202,20 @@ bool CDSMSplitterFilter::DemuxLoop()
{
HRESULT hr = S_OK;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining())
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
dsmp_t type;
UINT64 len;
- if(!m_pFile->Sync(type, len))
+ if(!m_pFile->Sync(type, len)) {
continue;
+ }
__int64 pos = m_pFile->GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
CAutoPtr<Packet> p(DNew Packet());
- if(m_pFile->Read(len, p))
- {
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ if(m_pFile->Read(len, p)) {
+ if(p->rtStart != Packet::INVALID_TIME) {
p->rtStart -= m_pFile->m_rtFirst;
p->rtStop -= m_pFile->m_rtFirst;
}
@@ -238,11 +245,14 @@ STDMETHODIMP CDSMSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
CheckPointer(pKFs, E_POINTER);
CheckPointer(m_pFile, E_UNEXPECTED);
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) return E_INVALIDARG;
+ if(*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ return E_INVALIDARG;
+ }
// these aren't really the keyframes, but quicky accessable points in the stream
- for(nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++)
+ for(nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++) {
pKFs[nKFs] = m_pFile->m_sps[nKFs].rt;
+ }
return S_OK;
}
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.h b/src/filters/parser/DSMSplitter/DSMSplitter.h
index ef57df9a3..616d84b0d 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitter.h
+++ b/src/filters/parser/DSMSplitter/DSMSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,7 +27,7 @@
#include "../BaseSplitter/BaseSplitter.h"
class __declspec(uuid("0912B4DD-A30A-4568-B590-7179EBB420EC"))
-CDSMSplitterFilter : public CBaseSplitterFilter
+ CDSMSplitterFilter : public CBaseSplitterFilter
{
protected:
CAutoPtr<CDSMSplitterFile> m_pFile;
@@ -48,7 +48,7 @@ public:
};
class __declspec(uuid("803E8280-F3CE-4201-982C-8CD8FB512004"))
-CDSMSourceFilter : public CDSMSplitterFilter
+ CDSMSourceFilter : public CDSMSplitterFilter
{
public:
CDSMSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
index cb58bd929..b46bc4cd2 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
+++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
@@ -3,12 +3,14 @@
#include "../../../DSUtil/DSUtil.h"
#include <moreuuids.h>
-CDSMSplitterFile::CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
+CDSMSplitterFile::CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
: CBaseSplitterFile(pReader, hr, DEFAULT_CACHE_LENGTH, false)
, m_rtFirst(0)
, m_rtDuration(0)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init(res, chap);
}
@@ -17,8 +19,9 @@ HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& cha
{
Seek(0);
- if(BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO)
+ if(BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO) {
return E_FAIL;
+ }
Seek(0);
@@ -35,68 +38,72 @@ HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& cha
// examine the beginning of the file ...
- while(Sync(type, len, 0))
- {
+ while(Sync(type, len, 0)) {
__int64 pos = GetPos();
- if(type == DSMP_MEDIATYPE)
- {
+ if(type == DSMP_MEDIATYPE) {
BYTE id;
CMediaType mt;
- if(Read(len, id, mt)) m_mts[id] = mt;
- }
- else if(type == DSMP_SAMPLE)
- {
+ if(Read(len, id, mt)) {
+ m_mts[id] = mt;
+ }
+ } else if(type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
- {
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
m_rtFirst = p.rtStart;
break;
}
+ } else if(type == DSMP_FILEINFO) {
+ if((BYTE)BitRead(8) > DSMF_VERSION) {
+ return E_FAIL;
+ }
+ Read(len-1, m_fim);
+ } else if(type == DSMP_STREAMINFO) {
+ Read(len-1, m_sim[(BYTE)BitRead(8)]);
+ } else if(type == DSMP_SYNCPOINTS) {
+ Read(len, m_sps);
+ } else if(type == DSMP_RESOURCE) {
+ Read(len, res);
+ } else if(type == DSMP_CHAPTERS) {
+ Read(len, chap);
}
- else if(type == DSMP_FILEINFO) {if((BYTE)BitRead(8) > DSMF_VERSION) return E_FAIL; Read(len-1, m_fim);}
- else if(type == DSMP_STREAMINFO) {Read(len-1, m_sim[(BYTE)BitRead(8)]);}
- else if(type == DSMP_SYNCPOINTS) {Read(len, m_sps);}
- else if(type == DSMP_RESOURCE) {Read(len, res);}
- else if(type == DSMP_CHAPTERS) {Read(len, chap);}
Seek(pos + len);
}
- if(type != DSMP_SAMPLE)
+ if(type != DSMP_SAMPLE) {
return E_FAIL;
+ }
- // ... and the end
+ // ... and the end
if(IsRandomAccess())
- for(int i = 1, j = (int)((GetLength()+limit/2)/limit); i <= j; i++)
- {
- __int64 seekpos = max(0, (__int64)GetLength()-i*limit);
- Seek(seekpos);
-
- while(Sync(type, len, limit) && GetPos() < seekpos+limit)
- {
- __int64 pos = GetPos();
+ for(int i = 1, j = (int)((GetLength()+limit/2)/limit); i <= j; i++) {
+ __int64 seekpos = max(0, (__int64)GetLength()-i*limit);
+ Seek(seekpos);
+
+ while(Sync(type, len, limit) && GetPos() < seekpos+limit) {
+ __int64 pos = GetPos();
+
+ if(type == DSMP_SAMPLE) {
+ Packet p;
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ m_rtDuration = max(m_rtDuration, p.rtStop - m_rtFirst); // max isn't really needed, only for safety
+ i = j;
+ }
+ } else if(type == DSMP_SYNCPOINTS) {
+ Read(len, m_sps);
+ } else if(type == DSMP_RESOURCE) {
+ Read(len, res);
+ } else if(type == DSMP_CHAPTERS) {
+ Read(len, chap);
+ }
- if(type == DSMP_SAMPLE)
- {
- Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
- {
- m_rtDuration = max(m_rtDuration, p.rtStop - m_rtFirst); // max isn't really needed, only for safety
- i = j;
- }
+ Seek(pos + len);
}
- else if(type == DSMP_SYNCPOINTS) {Read(len, m_sps);}
- else if(type == DSMP_RESOURCE) {Read(len, res);}
- else if(type == DSMP_CHAPTERS) {Read(len, chap);}
-
- Seek(pos + len);
}
- }
- if(m_rtFirst < 0)
- {
+ if(m_rtFirst < 0) {
m_rtDuration += m_rtFirst;
m_rtFirst = 0;
}
@@ -116,10 +123,10 @@ bool CDSMSplitterFile::Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64
limit += DSMSW_SIZE;
- for(UINT64 id = 0; (id&((1ui64<<(DSMSW_SIZE<<3))-1)) != DSMSW; id = (id << 8) | (BYTE)BitRead(8))
- {
- if(limit-- <= 0 || GetRemaining() <= 2)
+ for(UINT64 id = 0; (id&((1ui64<<(DSMSW_SIZE<<3))-1)) != DSMSW; id = (id << 8) | (BYTE)BitRead(8)) {
+ if(limit-- <= 0 || GetRemaining() <= 2) {
return(false);
+ }
}
syncpos = GetPos() - (DSMSW_SIZE<<3);
@@ -140,14 +147,20 @@ bool CDSMSplitterFile::Read(__int64 len, BYTE& id, CMediaType& mt)
ByteRead((BYTE*)&mt.formattype, sizeof(mt.formattype));
len -= 5 + sizeof(GUID)*3;
ASSERT(len >= 0);
- if(len > 0) {mt.AllocFormatBuffer((LONG)len); ByteRead(mt.Format(), mt.FormatLength());}
- else mt.ResetFormatBuffer();
+ if(len > 0) {
+ mt.AllocFormatBuffer((LONG)len);
+ ByteRead(mt.Format(), mt.FormatLength());
+ } else {
+ mt.ResetFormatBuffer();
+ }
return true;
}
bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData)
{
- if(!p) return false;
+ if(!p) {
+ return false;
+ }
p->TrackNumber = (DWORD)BitRead(8);
p->bSyncPoint = (BOOL)BitRead(1);
@@ -155,21 +168,17 @@ bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData)
int iTimeStamp = (int)BitRead(3);
int iDuration = (int)BitRead(3);
- if(fSign && !iTimeStamp)
- {
+ if(fSign && !iTimeStamp) {
ASSERT(!iDuration);
p->rtStart = Packet::INVALID_TIME;
p->rtStop = Packet::INVALID_TIME + 1;
- }
- else
- {
+ } else {
p->rtStart = (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
p->rtStop = p->rtStart + BitRead(iDuration<<3);
}
- if(fData)
- {
- p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration));
+ if(fData) {
+ p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration));
ByteRead(p->GetData(), p->GetCount());
}
@@ -181,8 +190,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
SyncPoint sp = {0, 0};
sps.RemoveAll();
- while(len > 0)
- {
+ while(len > 0) {
bool fSign = !!BitRead(1);
int iTimeStamp = (int)BitRead(3);
int iFilePos = (int)BitRead(3);
@@ -195,8 +203,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
len -= 1 + iTimeStamp + iFilePos;
}
- if(len != 0)
- {
+ if(len != 0) {
sps.RemoveAll();
return false;
}
@@ -208,8 +215,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
bool CDSMSplitterFile::Read(__int64 len, CStreamInfoMap& im)
{
- while(len >= 5)
- {
+ while(len >= 5) {
CStringA key;
ByteRead((BYTE*)key.GetBufferSetLength(4), 4);
len -= 4;
@@ -231,7 +237,9 @@ bool CDSMSplitterFile::Read(__int64 len, IDSMResourceBagImpl& res)
len -= Read(len, r.desc);
len -= Read(len, r.mime);
- if(compression != 0) return false; // TODO
+ if(compression != 0) {
+ return false; // TODO
+ }
r.data.SetCount(len);
ByteRead(r.data.GetData(), r.data.GetCount());
@@ -245,8 +253,7 @@ bool CDSMSplitterFile::Read(__int64 len, IDSMChapterBagImpl& chap)
{
CDSMChapter c(0, L"");
- while(len > 0)
- {
+ while(len > 0) {
bool fSign = !!BitRead(1);
int iTimeStamp = (int)BitRead(3);
BitRead(4); // reserved
@@ -269,21 +276,23 @@ __int64 CDSMSplitterFile::Read(__int64 len, CStringW& str)
char c;
CStringA s;
__int64 i = 0;
- while(i++ < len && (c = (char)BitRead(8)) != 0) s += c;
+ while(i++ < len && (c = (char)BitRead(8)) != 0) {
+ s += c;
+ }
str = UTF8To16(s);
return i;
}
__int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
{
- if(/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1)
- {
+ if(/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1) {
int i = range_bsearch(m_sps, m_rtFirst + rt);
return i >= 0 ? m_sps[i].fp : 0;
}
- if(m_rtDuration <= 0 || rt <= m_rtFirst)
+ if(m_rtDuration <= 0 || rt <= m_rtFirst) {
return 0;
+ }
// ok, do the hard way then
@@ -294,25 +303,25 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
__int64 minpos = 0, maxpos = GetLength();
- for(int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++)
- {
+ for(int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++) {
Seek((minpos + maxpos) / 2);
- while(GetPos() < maxpos)
- {
- if(!Sync(syncpos, type, len))
+ while(GetPos() < maxpos) {
+ if(!Sync(syncpos, type, len)) {
continue;
+ }
__int64 pos = GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
- {
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
- if(dt >= 0) maxpos = max((__int64)syncpos - 65536, minpos);
- else minpos = syncpos;
+ if(dt >= 0) {
+ maxpos = max((__int64)syncpos - 65536, minpos);
+ } else {
+ minpos = syncpos;
+ }
break;
}
}
@@ -325,20 +334,21 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
Seek(minpos);
- while(GetRemaining())
- {
- if(!Sync(syncpos, type, len))
+ while(GetRemaining()) {
+ if(!Sync(syncpos, type, len)) {
continue;
+ }
__int64 pos = GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
- {
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
- if(dt >= 0) {maxpos = (__int64)syncpos; break;}
+ if(dt >= 0) {
+ maxpos = (__int64)syncpos;
+ break;
+ }
}
}
@@ -351,40 +361,35 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
{
POSITION pos = m_mts.GetStartPosition();
- while(pos)
- {
+ while(pos) {
BYTE id;
CMediaType mt;
m_mts.GetNextAssoc(pos, id, mt);
- if(mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle)
+ if(mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
ids[id] = 0;
+ }
}
}
__int64 ret = maxpos;
- while(maxpos > 0 && !ids.IsEmpty())
- {
+ while(maxpos > 0 && !ids.IsEmpty()) {
minpos = max(0, maxpos - 65536);
Seek(minpos);
- while(Sync(syncpos, type, len) && GetPos() < maxpos)
- {
+ while(Sync(syncpos, type, len) && GetPos() < maxpos) {
UINT64 pos = GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint)
- {
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint) {
BYTE id = (BYTE)p.TrackNumber, tmp;
- if(ids.Lookup(id, tmp))
- {
+ if(ids.Lookup(id, tmp)) {
ids.RemoveKey((BYTE)p.TrackNumber);
ret = min(ret, (__int64)syncpos);
}
- }
+ }
}
Seek(pos + len);
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.h b/src/filters/parser/DSMSplitter/DSMSplitterFile.h
index 7c350db2f..b61e5e1b7 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitterFile.h
+++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.h
@@ -14,7 +14,10 @@ public:
CAtlMap<BYTE, CMediaType> m_mts;
REFERENCE_TIME m_rtFirst, m_rtDuration;
- struct SyncPoint {REFERENCE_TIME rt; __int64 fp;};
+ struct SyncPoint {
+ REFERENCE_TIME rt;
+ __int64 fp;
+ };
CAtlArray<SyncPoint> m_sps;
typedef CAtlMap<CStringA, CStringW, CStringElementTraits<CStringA>, CStringElementTraits<CStringW> > CStreamInfoMap;
@@ -30,6 +33,6 @@ public:
bool Read(__int64 len, IDSMResourceBagImpl& res);
bool Read(__int64 len, IDSMChapterBagImpl& chap);
__int64 Read(__int64 len, CStringW& str);
-
+
__int64 FindSyncPoint(REFERENCE_TIME rt);
};
diff --git a/src/filters/parser/DSMSplitter/stdafx.cpp b/src/filters/parser/DSMSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/DSMSplitter/stdafx.cpp
+++ b/src/filters/parser/DSMSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DSMSplitter/stdafx.h b/src/filters/parser/DSMSplitter/stdafx.h
index cdc946aa0..9b252ac14 100644
--- a/src/filters/parser/DSMSplitter/stdafx.h
+++ b/src/filters/parser/DSMSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DiracSplitter/DiracSplitter.cpp b/src/filters/parser/DiracSplitter/DiracSplitter.cpp
index 1d5a483dc..815de3f8e 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitter.cpp
+++ b/src/filters/parser/DiracSplitter/DiracSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2004 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,66 +27,59 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Dirac},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_Dirac},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
- {&MEDIATYPE_Video, &MEDIASUBTYPE_DiracVideo},
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_DiracVideo},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins2[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut2), sudPinTypesOut2}
+const AMOVIESETUP_PIN sudpPins2[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut2), sudPinTypesOut2}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
- {&__uuidof(CDiracSplitterFilter), L"MPC - Dirac Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CDiracSourceFilter), L"MPC - Dirac Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CDiracVideoDecoder), L"MPC - Dirac Video Decoder", MERIT_UNLIKELY, countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
+const AMOVIESETUP_FILTER sudFilter[] = {
+ {&__uuidof(CDiracSplitterFilter), L"MPC - Dirac Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDiracSourceFilter), L"MPC - Dirac Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDiracVideoDecoder), L"MPC - Dirac Video Decoder", MERIT_UNLIKELY, countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDiracSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDiracSourceFilter>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CDiracVideoDecoder>, NULL, &sudFilter[2]},
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDiracSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDiracSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CDiracVideoDecoder>, NULL, &sudFilter[2]},
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Dirac,
- _T("0,8,,4B572D4449524143"), // KW-DIRAC
- _T(".drc"), NULL);
+ RegisterSourceFilter(
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Dirac,
+ _T("0,8,,4B572D4449524143"), // KW-DIRAC
+ _T(".drc"), NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_Dirac);
+ UnRegisterSourceFilter(MEDIASUBTYPE_Dirac);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -99,134 +92,144 @@ CFilterApp theApp;
//
CDiracSplitterFilter::CDiracSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CDiracSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CDiracSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
STDMETHODIMP CDiracSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CDiracSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
+ CheckPointer(pAsyncReader, E_POINTER);
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- m_pFile.Free();
+ m_pFile.Free();
- m_pFile.Attach(DNew CDiracSplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ m_pFile.Attach(DNew CDiracSplitterFile(pAsyncReader, hr));
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
- CAtlArray<CMediaType> mts;
- mts.Add(m_pFile->GetMediaType());
+ CAtlArray<CMediaType> mts;
+ mts.Add(m_pFile->GetMediaType());
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
- AddOutputPin(0, pPinOut);
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
+ AddOutputPin(0, pPinOut);
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CDiracSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CDiracSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
- // TODO
+ // TODO
- return(true);
+ return(true);
}
void CDiracSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- REFERENCE_TIME rtPreroll = 0; //10000000;
+ REFERENCE_TIME rtPreroll = 0; //10000000;
- if(rt <= rtPreroll || m_rtDuration <= 0)
- {
- //m_pFile->Seek(8);
- m_pFile->Seek(0);
- }
- else
- {
- // TODO
+ if(rt <= rtPreroll || m_rtDuration <= 0) {
+ //m_pFile->Seek(8);
+ m_pFile->Seek(0);
+ } else {
+ // TODO
- __int64 len = m_pFile->GetLength();
- __int64 seekpos = (__int64)(1.0*rt/m_rtDuration*len);
+ __int64 len = m_pFile->GetLength();
+ __int64 seekpos = (__int64)(1.0*rt/m_rtDuration*len);
- m_pFile->Seek(seekpos);
- seekpos = 0;
+ m_pFile->Seek(seekpos);
+ seekpos = 0;
- REFERENCE_TIME rtmax = rt - rtPreroll;
- REFERENCE_TIME rtmin = rtmax - 5000000;
+ REFERENCE_TIME rtmax = rt - rtPreroll;
+ REFERENCE_TIME rtmin = rtmax - 5000000;
- REFERENCE_TIME pdt = _I64_MIN;
+ REFERENCE_TIME pdt = _I64_MIN;
- BYTE code;
- for(int j = 0; j < 10; j++)
- {
- while(m_pFile->Next(code) && code != AU_START_CODE);
- if(code != AU_START_CODE) {m_pFile->Seek(seekpos >>= 1); continue;}
+ BYTE code;
+ for(int j = 0; j < 10; j++) {
+ while(m_pFile->Next(code) && code != AU_START_CODE) {
+ ;
+ }
+ if(code != AU_START_CODE) {
+ m_pFile->Seek(seekpos >>= 1);
+ continue;
+ }
- __int64 pos = m_pFile->GetPos() - 5;
+ __int64 pos = m_pFile->GetPos() - 5;
- REFERENCE_TIME rt = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame * m_pFile->UnsignedGolombDecode();
- REFERENCE_TIME dt = rt - rtmax;
- if(dt > 0 && dt == pdt) dt = 10000000i64;
+ REFERENCE_TIME rt = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame * m_pFile->UnsignedGolombDecode();
+ REFERENCE_TIME dt = rt - rtmax;
+ if(dt > 0 && dt == pdt) {
+ dt = 10000000i64;
+ }
- if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0)
- {
- seekpos = pos;
- break;
- }
+ if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
+ seekpos = pos;
+ break;
+ }
- m_pFile->Seek(pos - (__int64)(1.0*dt/m_rtDuration*len));
+ m_pFile->Seek(pos - (__int64)(1.0*dt/m_rtDuration*len));
- pdt = dt;
- }
+ pdt = dt;
+ }
- m_pFile->Seek(seekpos);
- }
+ m_pFile->Seek(seekpos);
+ }
}
bool CDiracSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
- REFERENCE_TIME rtAvgTimePerFrame = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame;
-
- BYTE code;
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
- int size = 0, fnum = 0;
- const BYTE* pBuff = m_pFile->NextBlock(code, size, fnum);
- if(!pBuff || size < 5) break;
-
- if(isFrameStartCode(code))
- {
- CAutoPtr<Packet> p(DNew Packet());
- p->SetCount(size);
- memcpy(p->GetData(), pBuff, size);
-
- p->TrackNumber = 0;
- p->rtStart = rtAvgTimePerFrame*fnum;
- p->rtStop = p->rtStart + rtAvgTimePerFrame;
- p->bSyncPoint = code == AU_START_CODE;
-
- hr = DeliverPacket(p);
- }
-
- if(code == SEQ_END_CODE)
- break;
- }
-
- return(true);
+ HRESULT hr = S_OK;
+ REFERENCE_TIME rtAvgTimePerFrame = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame;
+
+ BYTE code;
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ int size = 0, fnum = 0;
+ const BYTE* pBuff = m_pFile->NextBlock(code, size, fnum);
+ if(!pBuff || size < 5) {
+ break;
+ }
+
+ if(isFrameStartCode(code)) {
+ CAutoPtr<Packet> p(DNew Packet());
+ p->SetCount(size);
+ memcpy(p->GetData(), pBuff, size);
+
+ p->TrackNumber = 0;
+ p->rtStart = rtAvgTimePerFrame*fnum;
+ p->rtStop = p->rtStart + rtAvgTimePerFrame;
+ p->bSyncPoint = code == AU_START_CODE;
+
+ hr = DeliverPacket(p);
+ }
+
+ if(code == SEQ_END_CODE) {
+ break;
+ }
+ }
+
+ return(true);
}
//
@@ -234,10 +237,10 @@ bool CDiracSplitterFilter::DemuxLoop()
//
CDiracSourceFilter::CDiracSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CDiracSplitterFilter(pUnk, phr)
+ : CDiracSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -245,365 +248,382 @@ CDiracSourceFilter::CDiracSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CDiracVideoDecoder::CDiracVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CDiracVideoDecoder"), lpunk, __uuidof(this))
+ : CTransformFilter(NAME("CDiracVideoDecoder"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
- m_decoder = NULL;
- m_pYUV[0] = NULL;
+ m_decoder = NULL;
+ m_pYUV[0] = NULL;
}
CDiracVideoDecoder::~CDiracVideoDecoder()
{
- delete [] m_pYUV[0];
+ delete [] m_pYUV[0];
}
void CDiracVideoDecoder::InitDecoder()
{
- FreeDecoder();
+ FreeDecoder();
- dirac_decoder_t* decoder = dirac_decoder_init(0);
+ dirac_decoder_t* decoder = dirac_decoder_init(0);
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
- dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + dvih->cbSequenceHeader);
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
+ dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + dvih->cbSequenceHeader);
- m_decoder = decoder;
+ m_decoder = decoder;
}
void CDiracVideoDecoder::FreeDecoder()
{
- if(m_decoder)
- {
- dirac_decoder_close((dirac_decoder_t*)m_decoder);
- m_decoder = NULL;
- delete [] m_pYUV[0]; m_pYUV[0] = NULL;
- }
+ if(m_decoder) {
+ dirac_decoder_close((dirac_decoder_t*)m_decoder);
+ m_decoder = NULL;
+ delete [] m_pYUV[0];
+ m_pYUV[0] = NULL;
+ }
}
HRESULT CDiracVideoDecoder::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 = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
-
- long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK; // nothing to do
-
- if(pIn->IsDiscontinuity() == S_OK)
- InitDecoder();
-
- dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
-
- hr = S_OK;
- while(SUCCEEDED(hr))
- {
- switch(dirac_parse(decoder))
- {
- case STATE_BUFFER:
- if(len == 0) return S_OK;
- dirac_buffer(decoder, pDataIn, pDataIn + len);
- len = 0;
- break;
-
- case STATE_SEQUENCE:
- TRACE(_T("STATE_SEQUENCE\n"));
-
- {
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
- if(dvih->hdr.bmiHeader.biWidth != decoder->src_params.width
- || dvih->hdr.bmiHeader.biHeight != decoder->src_params.height)
- return E_FAIL; // hmm
- }
-
- if(!m_pYUV[0])
- {
- int w = decoder->src_params.width;
- int h = decoder->src_params.height;
- int wc = decoder->src_params.chroma_width;
- int hc = decoder->src_params.chroma_height;
- delete [] m_pYUV[0]; m_pYUV[0] = NULL;
- m_pYUV[0] = DNew BYTE[w*h + wc*hc*2 + w/2*h/2];
- m_pYUV[1] = m_pYUV[0] + w*h;
- m_pYUV[2] = m_pYUV[1] + wc*hc;
- m_pYUV[3] = m_pYUV[2] + wc*hc;
- memset(m_pYUV[3], 0x80, w/2*h/2);
- m_rtAvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
- dirac_set_buf(decoder, m_pYUV, NULL);
- }
-
- break;
-
- case STATE_SEQUENCE_END:
- TRACE(_T("STATE_SEQUENCE_END\n"));
- break;
-
- case STATE_INVALID:
- TRACE(_T("STATE_INVALID\n"));
- return E_FAIL; // TODO: can we recover from this state?
- // break;
-
- default:
- TRACE(_T("unknown state\n"));
- continue;
- }
- }
-
- return hr;
+ 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 = NULL;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
+
+ long len = pIn->GetActualDataLength();
+ if(len <= 0) {
+ return S_OK; // nothing to do
+ }
+
+ if(pIn->IsDiscontinuity() == S_OK) {
+ InitDecoder();
+ }
+
+ dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
+
+ hr = S_OK;
+ while(SUCCEEDED(hr)) {
+ switch(dirac_parse(decoder)) {
+ case STATE_BUFFER:
+ if(len == 0) {
+ return S_OK;
+ }
+ dirac_buffer(decoder, pDataIn, pDataIn + len);
+ len = 0;
+ break;
+
+ case STATE_SEQUENCE:
+ TRACE(_T("STATE_SEQUENCE\n"));
+
+ {
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
+ if(dvih->hdr.bmiHeader.biWidth != decoder->src_params.width
+ || dvih->hdr.bmiHeader.biHeight != decoder->src_params.height) {
+ return E_FAIL; // hmm
+ }
+ }
+
+ if(!m_pYUV[0]) {
+ int w = decoder->src_params.width;
+ int h = decoder->src_params.height;
+ int wc = decoder->src_params.chroma_width;
+ int hc = decoder->src_params.chroma_height;
+ delete [] m_pYUV[0];
+ m_pYUV[0] = NULL;
+ m_pYUV[0] = DNew BYTE[w*h + wc*hc*2 + w/2*h/2];
+ m_pYUV[1] = m_pYUV[0] + w*h;
+ m_pYUV[2] = m_pYUV[1] + wc*hc;
+ m_pYUV[3] = m_pYUV[2] + wc*hc;
+ memset(m_pYUV[3], 0x80, w/2*h/2);
+ m_rtAvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
+ dirac_set_buf(decoder, m_pYUV, NULL);
+ }
+
+ break;
+
+ case STATE_SEQUENCE_END:
+ TRACE(_T("STATE_SEQUENCE_END\n"));
+ break;
+
+ case STATE_INVALID:
+ TRACE(_T("STATE_INVALID\n"));
+ return E_FAIL; // TODO: can we recover from this state?
+ // break;
+
+ default:
+ TRACE(_T("unknown state\n"));
+ continue;
+ }
+ }
+
+ return hr;
}
HRESULT CDiracVideoDecoder::Deliver(IMediaSample* pIn, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- CheckPointer(pIn, E_POINTER);
+ CheckPointer(pIn, E_POINTER);
- HRESULT hr;
+ HRESULT hr;
- if(pIn->IsPreroll() == S_OK || rtStart < 0)
- return S_OK;
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
+ return S_OK;
+ }
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if(FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
- return hr;
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if(FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 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);
- }
+ AM_MEDIA_TYPE* pmt;
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
- TRACE(_T("CDiracVideoDecoder::Deliver(%I64d, %I64d)\n"), rtStart, rtStop);
+ TRACE(_T("CDiracVideoDecoder::Deliver(%I64d, %I64d)\n"), rtStart, rtStop);
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
- pOut->SetSyncPoint(TRUE);
+ pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
+ pOut->SetSyncPoint(TRUE);
- if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer)
- pOut->SetDiscontinuity(TRUE);
+ if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
+ pOut->SetDiscontinuity(TRUE);
+ }
- Copy(pDataOut);
+ Copy(pDataOut);
- return m_pOutput->Deliver(pOut);
+ return m_pOutput->Deliver(pOut);
}
void CDiracVideoDecoder::Copy(BYTE* pOut)
{
- // FIXME: modes other than I420 and Y-only
-
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
-
- dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
-
- int w = decoder->src_params.width;
- int h = decoder->src_params.height;
- int wc = decoder->src_params.chroma_width;
- int hc = decoder->src_params.chroma_height;
-
- int pitchIn = w;
-
- BYTE* pY = m_pYUV[0];
- BYTE* pU = w/2 == wc && h/2 == hc ? m_pYUV[1] : m_pYUV[3]; // FIXME
- BYTE* pV = w/2 == wc && h/2 == hc ? m_pYUV[2] : m_pYUV[3]; // FIXME
-
- if(bihOut.biCompression == '2YUY')
- {
- BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pY, pU, pV, pitchIn);
- }
- else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI')
- {
- BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h, pOut + bihOut.biWidth*h*5/4, bihOut.biWidth, pY, pU, pV, pitchIn);
- }
- else if(bihOut.biCompression == '21VY')
- {
- BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h*5/4, pOut + bihOut.biWidth*h, bihOut.biWidth, pY, pU, pV, pitchIn);
- }
- else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
- int pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
-
- if(bihOut.biHeight > 0)
- {
- pOut += pitchOut*(h-1);
- pitchOut = -pitchOut;
- }
-
- if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pY, pU, pV, pitchIn))
- {
- for(DWORD y = 0; y < h; y++, pOut += pitchOut)
- memset(pOut, 0, pitchOut);
- }
- }
+ // FIXME: modes other than I420 and Y-only
+
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
+
+ dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
+
+ int w = decoder->src_params.width;
+ int h = decoder->src_params.height;
+ int wc = decoder->src_params.chroma_width;
+ int hc = decoder->src_params.chroma_height;
+
+ int pitchIn = w;
+
+ BYTE* pY = m_pYUV[0];
+ BYTE* pU = w/2 == wc && h/2 == hc ? m_pYUV[1] : m_pYUV[3]; // FIXME
+ BYTE* pV = w/2 == wc && h/2 == hc ? m_pYUV[2] : m_pYUV[3]; // FIXME
+
+ if(bihOut.biCompression == '2YUY') {
+ BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pY, pU, pV, pitchIn);
+ } else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI') {
+ BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h, pOut + bihOut.biWidth*h*5/4, bihOut.biWidth, pY, pU, pV, pitchIn);
+ } else if(bihOut.biCompression == '21VY') {
+ BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h*5/4, pOut + bihOut.biWidth*h, bihOut.biWidth, pY, pU, pV, pitchIn);
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ int pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
+
+ if(bihOut.biHeight > 0) {
+ pOut += pitchOut*(h-1);
+ pitchOut = -pitchOut;
+ }
+
+ if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pY, pU, pV, pitchIn)) {
+ for(DWORD y = 0; y < h; y++, pOut += pitchOut) {
+ memset(pOut, 0, pitchOut);
+ }
+ }
+ }
}
HRESULT CDiracVideoDecoder::CheckInputType(const CMediaType* mtIn)
{
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mtIn->Format();
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mtIn->Format();
- if(mtIn->majortype != MEDIATYPE_Video
- || mtIn->subtype != MEDIASUBTYPE_DiracVideo
- || mtIn->formattype != FORMAT_DiracVideoInfo
- || (dvih->hdr.bmiHeader.biWidth&1) || (dvih->hdr.bmiHeader.biHeight&1))
- return VFW_E_TYPE_NOT_ACCEPTED;
+ if(mtIn->majortype != MEDIATYPE_Video
+ || mtIn->subtype != MEDIASUBTYPE_DiracVideo
+ || mtIn->formattype != FORMAT_DiracVideoInfo
+ || (dvih->hdr.bmiHeader.biWidth&1) || (dvih->hdr.bmiHeader.biHeight&1)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CDiracVideoDecoder::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 mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_DiracVideo
- && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
- || mtOut->subtype == MEDIASUBTYPE_YV12
- || mtOut->subtype == MEDIASUBTYPE_I420
- || mtOut->subtype == MEDIASUBTYPE_IYUV
- || mtOut->subtype == MEDIASUBTYPE_ARGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB24
- || mtOut->subtype == MEDIASUBTYPE_RGB565
- || mtOut->subtype == MEDIASUBTYPE_RGB555)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ 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 mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_DiracVideo
+ && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
+ || mtOut->subtype == MEDIASUBTYPE_YV12
+ || mtOut->subtype == MEDIASUBTYPE_I420
+ || mtOut->subtype == MEDIASUBTYPE_IYUV
+ || mtOut->subtype == MEDIASUBTYPE_ARGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB24
+ || mtOut->subtype == MEDIASUBTYPE_RGB565
+ || mtOut->subtype == MEDIASUBTYPE_RGB555)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CDiracVideoDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
-
- BITMAPINFOHEADER bih;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
-
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = bih.biSizeImage;
- 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);
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ BITMAPINFOHEADER bih;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
+
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = bih.biSizeImage;
+ 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 CDiracVideoDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
-
- struct {const GUID* subtype; WORD biPlanes, biBitCount; DWORD biCompression;} fmts[] =
- {
- {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
- {&MEDIASUBTYPE_I420, 3, 12, '024I'},
- {&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
- {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
- {&MEDIASUBTYPE_ARGB32, 1, 32, BI_RGB},
- {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
- {&MEDIASUBTYPE_RGB24, 1, 24, BI_RGB},
- {&MEDIASUBTYPE_RGB565, 1, 16, BI_RGB},
- {&MEDIASUBTYPE_RGB555, 1, 16, BI_RGB},
- {&MEDIASUBTYPE_ARGB32, 1, 32, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB32, 1, 32, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB24, 1, 24, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB565, 1, 16, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB555, 1, 16, BI_BITFIELDS},
- };
-
- if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo)
- iPosition = iPosition*2 + 1;
-
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= 2*countof(fmts)) return VFW_S_NO_MORE_ITEMS;
-
- BITMAPINFOHEADER bih;
- ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
-
- pmt->majortype = MEDIATYPE_Video;
- pmt->subtype = *fmts[iPosition/2].subtype;
-
- BITMAPINFOHEADER bihOut;
- memset(&bihOut, 0, sizeof(bihOut));
- bihOut.biSize = sizeof(bihOut);
- bihOut.biWidth = bih.biWidth;
- bihOut.biHeight = bih.biHeight;
- bihOut.biPlanes = fmts[iPosition/2].biPlanes;
- bihOut.biBitCount = fmts[iPosition/2].biBitCount;
- bihOut.biCompression = fmts[iPosition/2].biCompression;
- bihOut.biSizeImage = bih.biWidth*bih.biHeight*bihOut.biBitCount>>3;
-
- if(iPosition&1)
- {
- pmt->formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
- vih->bmiHeader = bihOut;
-
- if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2)
- {
- vih->bmiHeader.biWidth = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
- vih->bmiHeader.biHeight = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
- vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth*vih->bmiHeader.biHeight*vih->bmiHeader.biBitCount>>3;
- }
- }
- else
- {
- pmt->formattype = FORMAT_VideoInfo2;
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
- vih2->bmiHeader = bihOut;
- vih2->dwPictAspectRatioX = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
- vih2->dwPictAspectRatioY = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
- }
-
- CorrectMediaType(pmt);
-
- return S_OK;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ struct {
+ const GUID* subtype;
+ WORD biPlanes, biBitCount;
+ DWORD biCompression;
+ } fmts[] = {
+ {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
+ {&MEDIASUBTYPE_I420, 3, 12, '024I'},
+ {&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
+ {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
+ {&MEDIASUBTYPE_ARGB32, 1, 32, BI_RGB},
+ {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
+ {&MEDIASUBTYPE_RGB24, 1, 24, BI_RGB},
+ {&MEDIASUBTYPE_RGB565, 1, 16, BI_RGB},
+ {&MEDIASUBTYPE_RGB555, 1, 16, BI_RGB},
+ {&MEDIASUBTYPE_ARGB32, 1, 32, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB32, 1, 32, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB24, 1, 24, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB565, 1, 16, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB555, 1, 16, BI_BITFIELDS},
+ };
+
+ if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo) {
+ iPosition = iPosition*2 + 1;
+ }
+
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= 2*countof(fmts)) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ BITMAPINFOHEADER bih;
+ ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
+
+ pmt->majortype = MEDIATYPE_Video;
+ pmt->subtype = *fmts[iPosition/2].subtype;
+
+ BITMAPINFOHEADER bihOut;
+ memset(&bihOut, 0, sizeof(bihOut));
+ bihOut.biSize = sizeof(bihOut);
+ bihOut.biWidth = bih.biWidth;
+ bihOut.biHeight = bih.biHeight;
+ bihOut.biPlanes = fmts[iPosition/2].biPlanes;
+ bihOut.biBitCount = fmts[iPosition/2].biBitCount;
+ bihOut.biCompression = fmts[iPosition/2].biCompression;
+ bihOut.biSizeImage = bih.biWidth*bih.biHeight*bihOut.biBitCount>>3;
+
+ if(iPosition&1) {
+ pmt->formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+ vih->bmiHeader = bihOut;
+
+ if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2) {
+ vih->bmiHeader.biWidth = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
+ vih->bmiHeader.biHeight = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
+ vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth*vih->bmiHeader.biHeight*vih->bmiHeader.biBitCount>>3;
+ }
+ } else {
+ pmt->formattype = FORMAT_VideoInfo2;
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
+ memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
+ vih2->bmiHeader = bihOut;
+ vih2->dwPictAspectRatioX = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
+ vih2->dwPictAspectRatioY = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
+ }
+
+ CorrectMediaType(pmt);
+
+ return S_OK;
}
HRESULT CDiracVideoDecoder::StartStreaming()
{
- InitDecoder();
- return __super::StartStreaming();
+ InitDecoder();
+ return __super::StartStreaming();
}
HRESULT CDiracVideoDecoder::StopStreaming()
{
- FreeDecoder();
- return __super::StopStreaming();
+ FreeDecoder();
+ return __super::StopStreaming();
}
HRESULT CDiracVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- m_fDropFrames = false;
- m_tStart = tStart;
+ m_fDropFrames = false;
+ m_tStart = tStart;
- return __super::NewSegment(tStart, tStop, dRate);
+ return __super::NewSegment(tStart, tStop, dRate);
}
HRESULT CDiracVideoDecoder::AlterQuality(Quality q)
{
- if(q.Late > 500*10000i64) m_fDropFrames = true;
- if(q.Late <= 0) m_fDropFrames = false;
- return E_NOTIMPL;
+ if(q.Late > 500*10000i64) {
+ m_fDropFrames = true;
+ }
+ if(q.Late <= 0) {
+ m_fDropFrames = false;
+ }
+ return E_NOTIMPL;
}
diff --git a/src/filters/parser/DiracSplitter/DiracSplitter.h b/src/filters/parser/DiracSplitter/DiracSplitter.h
index d11f1db82..0a083edb0 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitter.h
+++ b/src/filters/parser/DiracSplitter/DiracSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,7 +25,7 @@
#include "DiracSplitterFile.h"
class __declspec(uuid("5899CFB9-948F-4869-A999-5544ECB38BA5"))
-CDiracSplitterFilter : public CBaseSplitterFilter
+ CDiracSplitterFilter : public CBaseSplitterFilter
{
protected:
CAutoPtr<CDiracSplitterFile> m_pFile;
@@ -43,14 +43,14 @@ public:
};
class __declspec(uuid("09E7F58E-71A1-419D-B0A0-E524AE1454A9"))
-CDiracSourceFilter : public CDiracSplitterFilter
+ CDiracSourceFilter : public CDiracSplitterFilter
{
public:
CDiracSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("F78CF248-180E-4713-B107-B13F7B5C31E1"))
-CDiracVideoDecoder : public CTransformFilter
+ CDiracVideoDecoder : public CTransformFilter
{
void* m_decoder; // dirac_decoder_t*
void InitDecoder(), FreeDecoder();
diff --git a/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp b/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp
index 5833ae0b1..5eda6ad73 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp
+++ b/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp
@@ -6,159 +6,171 @@
#include <moreuuids.h>
CDiracSplitterFile::CDiracSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
- , m_rtDuration(0)
+ : CBaseSplitterFile(pAsyncReader, hr)
+ , m_rtDuration(0)
{
- if(SUCCEEDED(hr)) hr = Init();
- m_pBuff.SetSize(1024, 1024);
+ if(SUCCEEDED(hr)) {
+ hr = Init();
+ }
+ m_pBuff.SetSize(1024, 1024);
}
HRESULT CDiracSplitterFile::Init()
{
- HRESULT hr = E_FAIL;
-
- Seek(0);
-
- // Dirac streams are no longer preceded with KW-DIRAC
- //UINT64 hdr;
- //if(FAILED(Read((BYTE*)&hdr, sizeof(hdr))) || hdr != 0x43415249442D574Bui64) // KW-DIRAC
- //return E_FAIL;
-
- dirac_decoder_t* decoder = dirac_decoder_init(0);
-
- __int64 limit = min(GetLength(), 2048);
-
- while(GetPos() < limit)
- {
- BYTE b;
- if(!Next(b)) {ASSERT(0); break;}
-
- if(b == AU_START_CODE)
- {
- __int64 pos = GetPos() - 13; //Parse info size = 13
- if(!Next(b)) {ASSERT(0); break;}
- __int64 len = GetPos() - pos;
- Seek(pos);
-
- m_mt.majortype = MEDIATYPE_Video;
- m_mt.subtype = MEDIASUBTYPE_DiracVideo;
- m_mt.formattype = FORMAT_DiracVideoInfo;
- m_mt.SetSampleSize(1);
-
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + len);
- memset(m_mt.Format(), 0, m_mt.FormatLength());
-
- dvih->cbSequenceHeader = len;
- ByteRead((BYTE*)&dvih->dwSequenceHeader[0], len);
-
- dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + len);
- DecoderState dec_state = dirac_parse(decoder);
- if(dec_state != STATE_SEQUENCE) {ASSERT(0); break;}
-
- if(decoder->src_params.frame_rate.denominator)
- dvih->hdr.AvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
- dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
- dvih->hdr.bmiHeader.biWidth = decoder->src_params.width;
- dvih->hdr.bmiHeader.biHeight = decoder->src_params.height;
- dvih->hdr.bmiHeader.biCompression = m_mt.subtype.Data1;
- dvih->hdr.dwInterlaceFlags = 0;
- if(decoder->src_params.source_sampling) dvih->hdr.dwInterlaceFlags |= AMINTERLACE_IsInterlaced;
- if(decoder->src_params.topfieldfirst) dvih->hdr.dwInterlaceFlags |= AMINTERLACE_Field1First;
- dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
- dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
-
- m_rtDuration = 0;// dvih->hdr.AvgTimePerFrame * decoder->src_params.num_frames; // WTF
-
- hr = S_OK;
- // TESTING
- //ASSERT(0);
- break;
- }
- }
-
- dirac_decoder_close(decoder);
-
- return hr;
+ HRESULT hr = E_FAIL;
+
+ Seek(0);
+
+ // Dirac streams are no longer preceded with KW-DIRAC
+ //UINT64 hdr;
+ //if(FAILED(Read((BYTE*)&hdr, sizeof(hdr))) || hdr != 0x43415249442D574Bui64) // KW-DIRAC
+ //return E_FAIL;
+
+ dirac_decoder_t* decoder = dirac_decoder_init(0);
+
+ __int64 limit = min(GetLength(), 2048);
+
+ while(GetPos() < limit) {
+ BYTE b;
+ if(!Next(b)) {
+ ASSERT(0);
+ break;
+ }
+
+ if(b == AU_START_CODE) {
+ __int64 pos = GetPos() - 13; //Parse info size = 13
+ if(!Next(b)) {
+ ASSERT(0);
+ break;
+ }
+ __int64 len = GetPos() - pos;
+ Seek(pos);
+
+ m_mt.majortype = MEDIATYPE_Video;
+ m_mt.subtype = MEDIASUBTYPE_DiracVideo;
+ m_mt.formattype = FORMAT_DiracVideoInfo;
+ m_mt.SetSampleSize(1);
+
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + len);
+ memset(m_mt.Format(), 0, m_mt.FormatLength());
+
+ dvih->cbSequenceHeader = len;
+ ByteRead((BYTE*)&dvih->dwSequenceHeader[0], len);
+
+ dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + len);
+ DecoderState dec_state = dirac_parse(decoder);
+ if(dec_state != STATE_SEQUENCE) {
+ ASSERT(0);
+ break;
+ }
+
+ if(decoder->src_params.frame_rate.denominator) {
+ dvih->hdr.AvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
+ }
+ dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
+ dvih->hdr.bmiHeader.biWidth = decoder->src_params.width;
+ dvih->hdr.bmiHeader.biHeight = decoder->src_params.height;
+ dvih->hdr.bmiHeader.biCompression = m_mt.subtype.Data1;
+ dvih->hdr.dwInterlaceFlags = 0;
+ if(decoder->src_params.source_sampling) {
+ dvih->hdr.dwInterlaceFlags |= AMINTERLACE_IsInterlaced;
+ }
+ if(decoder->src_params.topfieldfirst) {
+ dvih->hdr.dwInterlaceFlags |= AMINTERLACE_Field1First;
+ }
+ dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
+ dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
+
+ m_rtDuration = 0;// dvih->hdr.AvgTimePerFrame * decoder->src_params.num_frames; // WTF
+
+ hr = S_OK;
+ // TESTING
+ //ASSERT(0);
+ break;
+ }
+ }
+
+ dirac_decoder_close(decoder);
+
+ return hr;
}
UINT64 CDiracSplitterFile::UnsignedGolombDecode()
-{
- int M = 0;
- while(M < 64 && !BitRead(1))
- M++;
+{
+ int M = 0;
+ while(M < 64 && !BitRead(1)) {
+ M++;
+ }
- UINT64 info = 0;
- for(int i = 0; i < M; i++)
- info |= BitRead(1) << i;
+ UINT64 info = 0;
+ for(int i = 0; i < M; i++) {
+ info |= BitRead(1) << i;
+ }
- return (1ui64<<M)-1 + info;
+ return (1ui64<<M)-1 + info;
}
bool CDiracSplitterFile::Next(BYTE& code, __int64 len)
{
- BitByteAlign();
- UINT64 qw = (UINT64)-1;
- do
- {
- if(len-- == 0 || GetPos() >= GetLength()) return(false);
- qw = (qw << 8) | (BYTE)BitRead(8);
- }
- while((qw&0xffffffff00) != ((UINT64)START_CODE_PREFIX<<8));
- int size_bytes = 0;
- // Read in the 6 bytes of next and previous parse unit offsets.
- while (size_bytes < 6)
- {
- if(len-- == 0 || GetPos() >= GetLength()) return(false);
- BitRead(8);
- size_bytes++;
- }
- code = (BYTE)(qw & 0xff);
- return(true);
+ BitByteAlign();
+ UINT64 qw = (UINT64)-1;
+ do {
+ if(len-- == 0 || GetPos() >= GetLength()) {
+ return(false);
+ }
+ qw = (qw << 8) | (BYTE)BitRead(8);
+ } while((qw&0xffffffff00) != ((UINT64)START_CODE_PREFIX<<8));
+ int size_bytes = 0;
+ // Read in the 6 bytes of next and previous parse unit offsets.
+ while (size_bytes < 6) {
+ if(len-- == 0 || GetPos() >= GetLength()) {
+ return(false);
+ }
+ BitRead(8);
+ size_bytes++;
+ }
+ code = (BYTE)(qw & 0xff);
+ return(true);
}
const BYTE* CDiracSplitterFile::NextBlock(BYTE& code, int& size, int& fnum)
{
- BYTE* pBuff = m_pBuff.GetData();
- size = 0;
-
- // TODO: make sure we are at a start code right now
-
- while(GetPos() < GetLength())
- {
- if(GetPos() <= GetLength() - 5)
- {
- UINT64 qw = BitRead(40, true);
-
- if(size == 0)
- {
- if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8) )
- code = (BYTE)(qw & 0xff);
-
- if(isFrameStartCode(code))
- {
- __int64 pos = GetPos();
- Seek(pos + 5);
- //fnum = (int)UnsignedGolombDecode();
- ByteRead((BYTE*)&fnum, sizeof(fnum));
- Seek(pos);
- }
- }
- else
- {
- if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8))
- break;
- }
- }
-
- if(size >= m_pBuff.GetSize())
- {
- int newsize = max(1024, size*2);
- m_pBuff.SetSize(newsize, newsize);
- pBuff = m_pBuff.GetData();
- }
-
- pBuff[size++] = (BYTE)BitRead(8);
- }
-
- return pBuff;
+ BYTE* pBuff = m_pBuff.GetData();
+ size = 0;
+
+ // TODO: make sure we are at a start code right now
+
+ while(GetPos() < GetLength()) {
+ if(GetPos() <= GetLength() - 5) {
+ UINT64 qw = BitRead(40, true);
+
+ if(size == 0) {
+ if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8) ) {
+ code = (BYTE)(qw & 0xff);
+ }
+
+ if(isFrameStartCode(code)) {
+ __int64 pos = GetPos();
+ Seek(pos + 5);
+ //fnum = (int)UnsignedGolombDecode();
+ ByteRead((BYTE*)&fnum, sizeof(fnum));
+ Seek(pos);
+ }
+ } else {
+ if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8)) {
+ break;
+ }
+ }
+ }
+
+ if(size >= m_pBuff.GetSize()) {
+ int newsize = max(1024, size*2);
+ m_pBuff.SetSize(newsize, newsize);
+ pBuff = m_pBuff.GetData();
+ }
+
+ pBuff[size++] = (BYTE)BitRead(8);
+ }
+
+ return pBuff;
}
diff --git a/src/filters/parser/DiracSplitter/DiracSplitterFile.h b/src/filters/parser/DiracSplitter/DiracSplitterFile.h
index cc2ec185a..113d653e9 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitterFile.h
+++ b/src/filters/parser/DiracSplitter/DiracSplitterFile.h
@@ -16,12 +16,16 @@ class CDiracSplitterFile : public CBaseSplitterFile
public:
CDiracSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-// using CBaseSplitterFile::Read;
+ // using CBaseSplitterFile::Read;
bool Next(BYTE& code, __int64 len = -1);
const BYTE* NextBlock(BYTE& code, int& size, int& fnum);
UINT64 UnsignedGolombDecode();
- const CMediaType& GetMediaType() {return m_mt;}
- REFERENCE_TIME GetDuration() {return m_rtDuration;}
+ const CMediaType& GetMediaType() {
+ return m_mt;
+ }
+ REFERENCE_TIME GetDuration() {
+ return m_rtDuration;
+ }
};
diff --git a/src/filters/parser/DiracSplitter/stdafx.cpp b/src/filters/parser/DiracSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/DiracSplitter/stdafx.cpp
+++ b/src/filters/parser/DiracSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DiracSplitter/stdafx.h b/src/filters/parser/DiracSplitter/stdafx.h
index b0322e83d..80f199e99 100644
--- a/src/filters/parser/DiracSplitter/stdafx.h
+++ b/src/filters/parser/DiracSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -55,17 +55,17 @@ using namespace dirac;
// === Imported from Dirac library
#define isFrameStartCode(c) ((c) == 0x00 || (c) == 0x0C || (c) == 0x08 || (c) == 0x0D || (c) == 0x0E || (c) == 0x09 || (c) == 0x0A || (c) == 0x10)
- const unsigned int START_CODE_PREFIX = 0x42424344; //BBCD
- const unsigned int START_CODE_PREFIX_BYTE0 =
- (START_CODE_PREFIX >> 24) & 0xFF;
- const unsigned int START_CODE_PREFIX_BYTE1 =
- (START_CODE_PREFIX >> 16) & 0xFF;
- const unsigned int START_CODE_PREFIX_BYTE2 =
- (START_CODE_PREFIX >> 8) & 0xFF;
- const unsigned int START_CODE_PREFIX_BYTE3 =
- START_CODE_PREFIX & 0xFF;
+const unsigned int START_CODE_PREFIX = 0x42424344; //BBCD
+const unsigned int START_CODE_PREFIX_BYTE0 =
+ (START_CODE_PREFIX >> 24) & 0xFF;
+const unsigned int START_CODE_PREFIX_BYTE1 =
+ (START_CODE_PREFIX >> 16) & 0xFF;
+const unsigned int START_CODE_PREFIX_BYTE2 =
+ (START_CODE_PREFIX >> 8) & 0xFF;
+const unsigned int START_CODE_PREFIX_BYTE3 =
+ START_CODE_PREFIX & 0xFF;
- //! Access unit start code
- const unsigned char AU_START_CODE = 0x00;
- //! Sequence end code
- const unsigned char SEQ_END_CODE = 0x10;
+//! Access unit start code
+const unsigned char AU_START_CODE = 0x00;
+//! Sequence end code
+const unsigned char SEQ_END_CODE = 0x10;
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.cpp b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
index e7495dc5a..9dfd01bb6 100644
--- a/src/filters/parser/FLVSplitter/FLVSplitter.cpp
+++ b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,31 +28,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_FLV},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CFLVSplitterFilter), L"MPC - FLV Splitter (Gabest)", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CFLVSourceFilter), L"MPC - FLV Source (Gabest)", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLVSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CFLVSourceFilter>, NULL, &sudFilter[1]},
};
@@ -92,8 +87,9 @@ CFLVSplitterFilter::CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
bool CFLVSplitterFilter::ReadTag(Tag& t)
{
- if(m_pFile->GetRemaining() < 15)
+ if(m_pFile->GetRemaining() < 15) {
return false;
+ }
t.PreviousTagSize = (UINT32)m_pFile->BitRead(32);
t.TagType = (BYTE)m_pFile->BitRead(8);
@@ -107,8 +103,9 @@ bool CFLVSplitterFilter::ReadTag(Tag& t)
bool CFLVSplitterFilter::ReadTag(AudioTag& at)
{
- if(!m_pFile->GetRemaining())
+ if(!m_pFile->GetRemaining()) {
return false;
+ }
at.SoundFormat = (BYTE)m_pFile->BitRead(4);
at.SoundRate = (BYTE)m_pFile->BitRead(2);
@@ -120,8 +117,9 @@ bool CFLVSplitterFilter::ReadTag(AudioTag& at)
bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
{
- if(!m_pFile->GetRemaining())
+ if(!m_pFile->GetRemaining()) {
return false;
+ }
vt.FrameType = (BYTE)m_pFile->BitRead(4);
vt.CodecID = (BYTE)m_pFile->BitRead(4);
@@ -132,8 +130,9 @@ bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
#ifndef NOVIDEOTWEAK
bool CFLVSplitterFilter::ReadTag(VideoTweak& vt)
{
- if(!m_pFile->GetRemaining())
+ if(!m_pFile->GetRemaining()) {
return false;
+ }
vt.x = (BYTE)m_pFile->BitRead(4);
vt.y = (BYTE)m_pFile->BitRead(4);
@@ -146,13 +145,16 @@ bool CFLVSplitterFilter::Sync(__int64& pos)
{
m_pFile->Seek(pos);
- while(m_pFile->GetRemaining() >= 15)
- {
+ while(m_pFile->GetRemaining() >= 15) {
__int64 limit = m_pFile->GetRemaining();
while (true) {
BYTE b = m_pFile->BitRead(8);
- if (b == 8 || b == 9) break;
- if (--limit < 15) return false;
+ if (b == 8 || b == 9) {
+ break;
+ }
+ if (--limit < 15) {
+ return false;
+ }
}
pos = m_pFile->GetPos() - 5;
@@ -164,16 +166,14 @@ bool CFLVSplitterFilter::Sync(__int64& pos)
if(next == m_pFile->GetLength() - 4) {
m_pFile->Seek(pos);
return true;
- }
- else if (next <= m_pFile->GetLength() - 19) {
+ } else if (next <= m_pFile->GetLength() - 19) {
m_pFile->Seek(next);
Tag nt;
if (ReadTag(nt) && (nt.TagType == 8 || nt.TagType == 9 || nt.TagType == 18)) {
if ((nt.PreviousTagSize == ct.DataSize + 11) ||
- (m_IgnorePrevSizes &&
- nt.TimeStamp >= ct.TimeStamp &&
- nt.TimeStamp - ct.TimeStamp <= 1000))
- {
+ (m_IgnorePrevSizes &&
+ nt.TimeStamp >= ct.TimeStamp &&
+ nt.TimeStamp - ct.TimeStamp <= 1000)) {
m_pFile->Seek(pos);
return true;
}
@@ -195,14 +195,20 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
- if(m_pFile->BitRead(24) != 'FLV' || m_pFile->BitRead(8) != 1)
+ 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);
@@ -222,8 +228,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile->Seek(m_DataOffset);
- for(int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio) && i < 100; i++)
- {
+ for(int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio) && i < 100; i++) {
UINT64 next = m_pFile->GetPos() + t.DataSize;
CStringW name;
@@ -237,14 +242,12 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
prevTagSize = t.DataSize + 11;
- if(t.TagType == 8 && t.DataSize != 0 && fTypeFlagsAudio)
- {
+ if(t.TagType == 8 && t.DataSize != 0 && fTypeFlagsAudio) {
UNREFERENCED_PARAMETER(at);
AudioTag at;
name = L"Audio";
- if(ReadTag(at))
- {
+ if(ReadTag(at)) {
int dataSize = t.DataSize - 1;
fTypeFlagsAudio = false;
@@ -256,83 +259,84 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
wfe->nSamplesPerSec = 44100*(1<<at.SoundRate)/8;
wfe->wBitsPerSample = 8*(at.SoundSize+1);
wfe->nChannels = 1*(at.SoundType+1);
-
- switch(at.SoundFormat)
- {
- case 0: // FLV_CODECID_PCM_BE
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
- break;
- case 1: // FLV_CODECID_ADPCM
- mt.subtype = FOURCCMap(MAKEFOURCC('A','S','W','F'));
- break;
- case 2: // FLV_CODECID_MP3
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
-
- {
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if(m_pFile->Read(h, 4, false, &mt2))
- mt = mt2;
- }
- break;
- case 3 : // FLV_CODECID_PCM_LE
- // ToDo
- break;
- case 4 : // unknown
- break;
- case 5 : // FLV_CODECID_NELLYMOSER_8HZ_MONO
- mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
- wfe->nSamplesPerSec = 8000;
- break;
- case 6 : // FLV_CODECID_NELLYMOSER
- mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
- break;
- case 10: { // FLV_CODECID_AAC
- if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
- fTypeFlagsAudio = true;
+
+ switch(at.SoundFormat) {
+ case 0: // FLV_CODECID_PCM_BE
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
+ break;
+ case 1: // FLV_CODECID_ADPCM
+ mt.subtype = FOURCCMap(MAKEFOURCC('A','S','W','F'));
+ break;
+ case 2: // FLV_CODECID_MP3
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
+
+ {
+ CBaseSplitterFileEx::mpahdr h;
+ CMediaType mt2;
+ if(m_pFile->Read(h, 4, false, &mt2)) {
+ mt = mt2;
+ }
+ }
+ break;
+ case 3 : // FLV_CODECID_PCM_LE
+ // ToDo
break;
+ case 4 : // unknown
+ break;
+ case 5 : // FLV_CODECID_NELLYMOSER_8HZ_MONO
+ mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
+ wfe->nSamplesPerSec = 8000;
+ break;
+ case 6 : // FLV_CODECID_NELLYMOSER
+ mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
+ break;
+ case 10: { // FLV_CODECID_AAC
+ if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
+ fTypeFlagsAudio = true;
+ 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
+ };
+
+ __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 = m_pFile->BitRead(4);
+ int iChannels = m_pFile->BitRead(4);
+ if (iSampleRate > 12 || iChannels > 7) {
+ break;
+ }
+
+ wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + configSize);
+ memset(wfe, 0, 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);
+
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
}
- 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
- };
-
- __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 = m_pFile->BitRead(4);
- int iChannels = m_pFile->BitRead(4);
- if (iSampleRate > 12 || iChannels > 7) break;
-
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + configSize);
- memset(wfe, 0, 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);
-
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- }
-
}
}
- }
- else if(t.TagType == 9 && t.DataSize != 0 && fTypeFlagsVideo)
- {
+ } else if(t.TagType == 9 && t.DataSize != 0 && fTypeFlagsVideo) {
UNREFERENCED_PARAMETER(vt);
VideoTag vt;
- if(ReadTag(vt) && vt.FrameType == 1)
- {
+ if(ReadTag(vt) && vt.FrameType == 1) {
int dataSize = t.DataSize - 1;
fTypeFlagsVideo = false;
@@ -347,188 +351,202 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
int w, h, arx, ary;
- switch(vt.CodecID)
- {
- case 2: // 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;
- }
+ switch(vt.CodecID) {
+ case 2: // H.263
+ if(m_pFile->BitRead(17) != 1) {
+ break;
+ }
- if(!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) 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;
+ }
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
+ if(!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
+ break;
+ }
- break;
+ mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
- case 5: // VP6 with alpha
- m_pFile->BitRead(24);
- case 4: { // 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 = m_pFile->BitRead(2);
- m_pFile->BitRead(1);
- if (fSeparatedCoeff || !filterHeader) {
- m_pFile->BitRead(16);
- }
- h = m_pFile->BitRead(8) * 16;
- w = m_pFile->BitRead(8) * 16;
-
- ary = m_pFile->BitRead(8) * 16;
- arx = m_pFile->BitRead(8) * 16;
+ case 5: // VP6 with alpha
+ m_pFile->BitRead(24);
+ case 4: { // VP6
+#ifdef NOVIDEOTWEAK
+ m_pFile->BitRead(8);
+#else
+ VideoTweak fudge;
+ ReadTag(fudge);
+#endif
- if(arx && arx != w || ary && ary != h) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
- vih2->dwPictAspectRatioX = arx;
- vih2->dwPictAspectRatioY = ary;
- bih = &vih2->bmiHeader;
- mt.formattype = FORMAT_VideoInfo2;
- vih = (VIDEOINFOHEADER *)vih2;
- }
+ 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 = m_pFile->BitRead(2);
+ m_pFile->BitRead(1);
+ if (fSeparatedCoeff || !filterHeader) {
+ m_pFile->BitRead(16);
+ }
- 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
+ h = m_pFile->BitRead(8) * 16;
+ w = m_pFile->BitRead(8) * 16;
- mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
+ ary = m_pFile->BitRead(8) * 16;
+ arx = m_pFile->BitRead(8) * 16;
- break;
- }
- case 7: { // 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 = DNew BYTE[headerSize];
-
- m_pFile->ByteRead(headerData, headerSize);
+ if(arx && arx != w || ary && ary != h) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
+ memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
+ vih2->dwPictAspectRatioX = arx;
+ vih2->dwPictAspectRatioY = ary;
+ bih = &vih2->bmiHeader;
+ mt.formattype = FORMAT_VideoInfo2;
+ vih = (VIDEOINFOHEADER *)vih2;
+ }
- m_pFile->Seek(headerOffset + 9);
+ 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.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + headerSize);
- memset(vih, 0, 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
+ mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
- 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
- if(vih->dwProfile >= 100) { // high profile
- if(m_pFile->UExpGolombRead() == 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 i = 0; i < 8; i++)
- if(m_pFile->BitRead(1)) // seq_scaling_list_present_flag
- for(int j = 0, size = i < 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 i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
- m_pFile->SExpGolombRead(); // offset_for_ref_frame[i]
+ break;
}
- 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);
- vih->hdr.bmiHeader.biWidth = vih->hdr.dwPictAspectRatioX = (LONG)((pic_width_in_mbs_minus1 + 1) * 16);
- vih->hdr.bmiHeader.biHeight = vih->hdr.dwPictAspectRatioY = (LONG)((2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16);
-
- 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;
+ case 7: { // 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 = DNew 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);
+ memset(vih, 0, 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
+ if(vih->dwProfile >= 100) { // high profile
+ if(m_pFile->UExpGolombRead() == 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 i = 0; i < 8; i++)
+ if(m_pFile->BitRead(1)) // seq_scaling_list_present_flag
+ for(int j = 0, size = i < 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 i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ m_pFile->SExpGolombRead(); // offset_for_ref_frame[i]
+ }
+ }
+ 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);
+ vih->hdr.bmiHeader.biWidth = vih->hdr.dwPictAspectRatioX = (LONG)((pic_width_in_mbs_minus1 + 1) * 16);
+ vih->hdr.bmiHeader.biHeight = vih->hdr.dwPictAspectRatioY = (LONG)((2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16);
+
+ 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;
}
- 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;
+ delete[] headerData;
- mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
+ mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
- break;
- }
- default:
- fTypeFlagsVideo = true;
+ break;
+ }
+ default:
+ fTypeFlagsVideo = true;
}
}
}
-
- if(mt.subtype != GUID_NULL)
- {
+
+ if(mt.subtype != GUID_NULL) {
CAtlArray<CMediaType> mts;
mts.Add(mt);
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
@@ -538,23 +556,19 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile->Seek(next);
}
- if(m_pFile->IsRandomAccess())
- {
+ if(m_pFile->IsRandomAccess()) {
__int64 pos = max(m_DataOffset, m_pFile->GetLength() - 256 * 1024);
- if(Sync(pos))
- {
+ if(Sync(pos)) {
Tag t;
AudioTag at;
VideoTag vt;
- while(ReadTag(t))
- {
+ while(ReadTag(t)) {
UINT64 next = m_pFile->GetPos() + t.DataSize;
- if(t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt))
- {
- m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
+ if(t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt)) {
+ m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
}
m_pFile->Seek(next);
@@ -577,11 +591,9 @@ void CFLVSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
if(!m_rtDuration || rt <= 0) {
m_pFile->Seek(m_DataOffset);
- }
- else if (!m_IgnorePrevSizes) {
+ } else if (!m_IgnorePrevSizes) {
NormalSeek(rt);
- }
- else {
+ } else {
AlternateSeek(rt);
}
}
@@ -593,8 +605,7 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
__int64 pos = m_DataOffset + 1.0 * rt / m_rtDuration * (m_pFile->GetLength() - m_DataOffset);
- if(!Sync(pos))
- {
+ if(!Sync(pos)) {
ASSERT(0);
m_pFile->Seek(m_DataOffset);
return;
@@ -604,10 +615,8 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
AudioTag at;
VideoTag vt;
- while(ReadTag(t))
- {
- if(10000i64 * t.TimeStamp >= rt)
- {
+ while(ReadTag(t)) {
+ if(10000i64 * t.TimeStamp >= rt) {
m_pFile->Seek(m_pFile->GetPos() - 15);
break;
}
@@ -615,18 +624,13 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
m_pFile->Seek(m_pFile->GetPos() + t.DataSize);
}
- while(m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t))
- {
+ 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 == 8 && ReadTag(at))
- {
+ if(10000i64 * t.TimeStamp <= rt) {
+ if(t.TagType == 8 && ReadTag(at)) {
fAudio = false;
- }
- else if(t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1)
- {
+ } else if(t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
fVideo = false;
}
}
@@ -634,8 +638,7 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
m_pFile->Seek(prev);
}
- if(fAudio || fVideo)
- {
+ if(fAudio || fVideo) {
ASSERT(0);
m_pFile->Seek(m_DataOffset);
}
@@ -668,9 +671,10 @@ void CFLVSplitterFilter::AlternateSeek(REFERENCE_TIME rt)
if (hasAudio && t.TagType == 8 && ReadTag(at)) {
foundAudio = true;
- if (!hasVideo) bestPos = cur;
- }
- else if (hasVideo && t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
+ if (!hasVideo) {
+ bestPos = cur;
+ }
+ } else if (hasVideo && t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
foundVideo = true;
bestPos = cur;
}
@@ -684,8 +688,7 @@ void CFLVSplitterFilter::AlternateSeek(REFERENCE_TIME rt)
m_pFile->Seek(m_DataOffset);
return;
}
- }
- else {
+ } else {
m_pFile->Seek(bestPos);
return;
}
@@ -702,35 +705,44 @@ bool CFLVSplitterFilter::DemuxLoop()
AudioTag at;
VideoTag vt;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining())
- {
- if(!ReadTag(t)) break;
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
+ if(!ReadTag(t)) {
+ break;
+ }
__int64 next = m_pFile->GetPos() + t.DataSize;
- if((t.DataSize > 0) && (t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt)))
- {
+ if((t.DataSize > 0) && (t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt))) {
UINT32 tsOffset = 0;
- if(t.TagType == 9)
- {
- if(vt.FrameType == 5) goto NextTag; // video info/command frame
- if(vt.CodecID == 4) m_pFile->BitRead(8);
- else if(vt.CodecID == 5) m_pFile->BitRead(32);
- else if(vt.CodecID == 7) {
- if (m_pFile->BitRead(8) != 1) goto NextTag;
+ if(t.TagType == 9) {
+ if(vt.FrameType == 5) {
+ goto NextTag; // video info/command frame
+ }
+ if(vt.CodecID == 4) {
+ m_pFile->BitRead(8);
+ } else if(vt.CodecID == 5) {
+ m_pFile->BitRead(32);
+ } else if(vt.CodecID == 7) {
+ if (m_pFile->BitRead(8) != 1) {
+ goto NextTag;
+ }
// Tag timestamps specify decode time, this is the display time offset
tsOffset = m_pFile->BitRead(24);
tsOffset = (tsOffset + 0xff800000) ^ 0xff800000; // sign extension
}
}
if(t.TagType == 8 && at.SoundFormat == 10) {
- if (m_pFile->BitRead(8) != 1) goto NextTag;
+ if (m_pFile->BitRead(8) != 1) {
+ goto NextTag;
+ }
}
__int64 dataSize = next - m_pFile->GetPos();
- if (dataSize <= 0) goto NextTag;
+ if (dataSize <= 0) {
+ goto NextTag;
+ }
p.Attach(DNew Packet());
p->TrackNumber = t.TagType;
- p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
+ p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
p->rtStop = p->rtStart + 1;
p->bSyncPoint = t.TagType == 9 ? vt.FrameType == 1 : true;
p->SetCount(dataSize);
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.h b/src/filters/parser/FLVSplitter/FLVSplitter.h
index 4899ef8cc..3e1690384 100644
--- a/src/filters/parser/FLVSplitter/FLVSplitter.h
+++ b/src/filters/parser/FLVSplitter/FLVSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,23 +25,21 @@
#include "../BaseSplitter/BaseSplitter.h"
class __declspec(uuid("47E792CF-0BBE-4F7A-859C-194B0768650A"))
-CFLVSplitterFilter : public CBaseSplitterFilter
+ CFLVSplitterFilter : public CBaseSplitterFilter
{
UINT32 m_DataOffset;
bool m_IgnorePrevSizes;
bool Sync(__int64& pos);
- struct VideoTweak
- {
+ struct VideoTweak {
BYTE x;
BYTE y;
};
bool ReadTag(VideoTweak& t);
-
- struct Tag
- {
+
+ struct Tag {
UINT32 PreviousTagSize;
BYTE TagType;
UINT32 DataSize;
@@ -51,8 +49,7 @@ CFLVSplitterFilter : public CBaseSplitterFilter
bool ReadTag(Tag& t);
- struct AudioTag
- {
+ struct AudioTag {
BYTE SoundFormat;
BYTE SoundRate;
BYTE SoundSize;
@@ -61,8 +58,7 @@ CFLVSplitterFilter : public CBaseSplitterFilter
bool ReadTag(AudioTag& at);
- struct VideoTag
- {
+ struct VideoTag {
BYTE FrameType;
BYTE CodecID;
};
@@ -85,7 +81,7 @@ public:
};
class __declspec(uuid("C9ECE7B3-1D8E-41F5-9F24-B255DF16C087"))
-CFLVSourceFilter : public CFLVSplitterFilter
+ CFLVSourceFilter : public CFLVSplitterFilter
{
public:
CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/FLVSplitter/stdafx.cpp b/src/filters/parser/FLVSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/FLVSplitter/stdafx.cpp
+++ b/src/filters/parser/FLVSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/FLVSplitter/stdafx.h b/src/filters/parser/FLVSplitter/stdafx.h
index cdc946aa0..9b252ac14 100644
--- a/src/filters/parser/FLVSplitter/stdafx.h
+++ b/src/filters/parser/FLVSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h
index a0d849bb0..69339653d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h
@@ -244,6 +244,7 @@ const AP4_Atom::Type AP4_ATOM_TYPE_CVID = AP4_ATOM_TYPE('c','v','i','d');
const AP4_Atom::Type AP4_ATOM_TYPE_SVQ1 = AP4_ATOM_TYPE('S','V','Q','1');
const AP4_Atom::Type AP4_ATOM_TYPE_SVQ2 = AP4_ATOM_TYPE('S','V','Q','2');
const AP4_Atom::Type AP4_ATOM_TYPE_SVQ3 = AP4_ATOM_TYPE('S','V','Q','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_H261 = AP4_ATOM_TYPE('h','2','6','1');
const AP4_Atom::Type AP4_ATOM_TYPE_H263 = AP4_ATOM_TYPE('h','2','6','3');
const AP4_Atom::Type AP4_ATOM_TYPE_S263 = AP4_ATOM_TYPE('s','2','6','3');
const AP4_Atom::Type AP4_ATOM_TYPE_SAMR = AP4_ATOM_TYPE('s','a','m','r');
@@ -251,6 +252,7 @@ const AP4_Atom::Type AP4_ATOM_TYPE__MP3 = AP4_ATOM_TYPE('.','m','p','3');
const AP4_Atom::Type AP4_ATOM_TYPE_IMA4 = AP4_ATOM_TYPE('i','m','a','4');
const AP4_Atom::Type AP4_ATOM_TYPE_QDMC = AP4_ATOM_TYPE('Q','D','M','C');
const AP4_Atom::Type AP4_ATOM_TYPE_QDM2 = AP4_ATOM_TYPE('Q','D','M','2');
+//PCM Audio
const AP4_Atom::Type AP4_ATOM_TYPE_NONE = AP4_ATOM_TYPE('N','O','N','E');
const AP4_Atom::Type AP4_ATOM_TYPE_TWOS = AP4_ATOM_TYPE('t','w','o','s');
const AP4_Atom::Type AP4_ATOM_TYPE_SOWT = AP4_ATOM_TYPE('s','o','w','t');
@@ -258,6 +260,7 @@ const AP4_Atom::Type AP4_ATOM_TYPE_IN24 = AP4_ATOM_TYPE('i','n','2','4');
const AP4_Atom::Type AP4_ATOM_TYPE_IN32 = AP4_ATOM_TYPE('i','n','3','2');
const AP4_Atom::Type AP4_ATOM_TYPE_FL32 = AP4_ATOM_TYPE('f','l','3','2');
const AP4_Atom::Type AP4_ATOM_TYPE_FL64 = AP4_ATOM_TYPE('f','l','6','4');
+//
const AP4_Atom::Type AP4_ATOM_TYPE_CHPL = AP4_ATOM_TYPE('c','h','p','l');
const AP4_Atom::Type AP4_ATOM_TYPE_NAM = AP4_ATOM_TYPE(169,'n','a','m');
const AP4_Atom::Type AP4_ATOM_TYPE_ART = AP4_ATOM_TYPE(169,'A','R','T');
@@ -286,15 +289,22 @@ const AP4_Atom::Type AP4_ATOM_TYPE_PNG = AP4_ATOM_TYPE('p','n','g',' ');
const AP4_Atom::Type AP4_ATOM_TYPE_ALAW = AP4_ATOM_TYPE('a','l','a','w');
const AP4_Atom::Type AP4_ATOM_TYPE_ULAW = AP4_ATOM_TYPE('u','l','a','w');
const AP4_Atom::Type AP4_ATOM_TYPE_RLE = AP4_ATOM_TYPE('r','l','e',' ');
+//Motion-JPEG
const AP4_Atom::Type AP4_ATOM_TYPE_MJPA = AP4_ATOM_TYPE('m','j','p','a');
const AP4_Atom::Type AP4_ATOM_TYPE_MJPB = AP4_ATOM_TYPE('m','j','p','b');
const AP4_Atom::Type AP4_ATOM_TYPE_MJPG = AP4_ATOM_TYPE('M','J','P','G');
+const AP4_Atom::Type AP4_ATOM_TYPE_DMB1 = AP4_ATOM_TYPE('d','m','b','1');
+//
const AP4_Atom::Type AP4_ATOM_TYPE_RPZA = AP4_ATOM_TYPE('r','p','z','a');
const AP4_Atom::Type AP4_ATOM_TYPE_DVC = AP4_ATOM_TYPE('d','v','c',' ');
const AP4_Atom::Type AP4_ATOM_TYPE_DIV3 = AP4_ATOM_TYPE('D','I','V','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_DIVX = AP4_ATOM_TYPE('d','i','v','x');
const AP4_Atom::Type AP4_ATOM_TYPE_8BPS = AP4_ATOM_TYPE('8','B','P','S');
const AP4_Atom::Type AP4_ATOM_TYPE_3IV1 = AP4_ATOM_TYPE('3','I','V','1');
const AP4_Atom::Type AP4_ATOM_TYPE_3IV2 = AP4_ATOM_TYPE('3','I','V','2');
+const AP4_Atom::Type AP4_ATOM_TYPE_IV32 = AP4_ATOM_TYPE('I','V','3','2');
+const AP4_Atom::Type AP4_ATOM_TYPE_VP31 = AP4_ATOM_TYPE('V','P','3','1');
+const AP4_Atom::Type AP4_ATOM_TYPE_YV12 = AP4_ATOM_TYPE('y','v','1','2');
/*----------------------------------------------------------------------
| AP4_AtomListInspector
+---------------------------------------------------------------------*/
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp
index 2caeb96a2..794d3139b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp
@@ -392,6 +392,7 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
case AP4_ATOM_TYPE_SVQ1:
case AP4_ATOM_TYPE_SVQ2:
case AP4_ATOM_TYPE_SVQ3:
+ case AP4_ATOM_TYPE_H261:
case AP4_ATOM_TYPE_H263:
case AP4_ATOM_TYPE_S263:
case AP4_ATOM_TYPE_JPEG:
@@ -400,12 +401,17 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
case AP4_ATOM_TYPE_MJPA:
case AP4_ATOM_TYPE_MJPB:
case AP4_ATOM_TYPE_MJPG:
+ case AP4_ATOM_TYPE_DMB1:
case AP4_ATOM_TYPE_RPZA:
case AP4_ATOM_TYPE_DVC:
case AP4_ATOM_TYPE_DIV3:
+ case AP4_ATOM_TYPE_DIVX:
case AP4_ATOM_TYPE_8BPS:
case AP4_ATOM_TYPE_3IV1:
case AP4_ATOM_TYPE_3IV2:
+ case AP4_ATOM_TYPE_IV32:
+ case AP4_ATOM_TYPE_VP31:
+ case AP4_ATOM_TYPE_YV12:
atom = DNew AP4_VisualSampleEntry(type, size, stream, *this);
break;
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
index 1f0240054..496efa659 100644
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
+++ b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "Ap4AsyncReaderStream.h"
-AP4_AsyncReaderStream::AP4_AsyncReaderStream(CBaseSplitterFile* pFile)
+AP4_AsyncReaderStream::AP4_AsyncReaderStream(CBaseSplitterFile* pFile)
: m_refs(1)
, m_pFile(pFile)
{
@@ -15,45 +15,50 @@ AP4_AsyncReaderStream::~AP4_AsyncReaderStream()
void AP4_AsyncReaderStream::AddReference()
{
- ASSERT(m_refs > 0);
+ ASSERT(m_refs > 0);
++m_refs;
}
void AP4_AsyncReaderStream::Release()
{
- ASSERT(m_refs > 0);
- if(--m_refs == 0) delete this;
+ 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 < bytesToRead)
- {
- if(bytesRead) *bytesRead = bytesAvail;
+ if(bytesAvail < bytesToRead) {
+ if(bytesRead) {
+ *bytesRead = bytesAvail;
+ }
bytesToRead = bytesAvail;
}
- if(bytesAvail == 0)
- {
+ if(bytesAvail == 0) {
return AP4_ERROR_EOS;
}
- if(FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead)))
- {
- if(bytesRead) *bytesRead = 0;
+ if(FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead))) {
+ if(bytesRead) {
+ *bytesRead = 0;
+ }
return AP4_ERROR_READ_FAILED;
}
- if(bytesRead) *bytesRead = bytesToRead;
+ 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;
+ return AP4_ERROR_WRITE_FAILED;
}
AP4_Result AP4_AsyncReaderStream::Seek(AP4_Offset offset)
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.cpp b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
index b395e590a..d0d641aec 100644
--- a/src/filters/parser/MP4Splitter/MP4Splitter.cpp
+++ b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -39,28 +39,24 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MP4},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMP4SplitterFilter), L"MPC - MP4 Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMP4SourceFilter), L"MPC - MP4 Source", MERIT_NORMAL, 0, NULL, 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, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMPEG4VideoSourceFilter), L"MPC - MPEG4 Video Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMP4SplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMP4SourceFilter>, NULL, &sudFilter[1]},
{sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CMPEG4VideoSplitterFilter>, NULL, &sudFilter[2]},
@@ -127,32 +123,37 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CMP4SplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
m_framesize.SetSize(640, 480);
- if(AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie())
- {
+ if(AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
for(AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext())
- {
+ 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)
+ 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;
+ }
AP4_Sample sample;
- if(!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF)
+ if(!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
continue;
+ }
CStringW TrackName = UTF8To16(track->GetTrackName().c_str());
CStringA TrackLanguage = track->GetTrackLanguage().c_str();
@@ -167,25 +168,22 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
AP4_DataBuffer empty;
- if(AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex()))
- {
+ if(AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
AP4_MpegSampleDescription* mpeg_desc = NULL;
- if(desc->GetType() == AP4_SampleDescription::TYPE_MPEG)
- {
+ if(desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(desc);
- }
- else if(desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP)
- {
+ } else if(desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
AP4_IsmaCrypSampleDescription* isma_desc = dynamic_cast<AP4_IsmaCrypSampleDescription*>(desc);
mpeg_desc = isma_desc->GetOriginalSampleDescription();
}
- if(AP4_MpegVideoSampleDescription* video_desc =
- dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc))
- {
+ if(AP4_MpegVideoSampleDescription* video_desc =
+ dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc)) {
const AP4_DataBuffer* di = video_desc->GetDecoderInfo();
- if(!di) di = &empty;
+ if(!di) {
+ di = &empty;
+ }
mt.majortype = MEDIATYPE_Video;
mt.formattype = FORMAT_VideoInfo;
@@ -197,68 +195,68 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
vih->bmiHeader.biHeight = (LONG)video_desc->GetHeight();
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* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- memset(vih, 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = (LONG)video_desc->GetWidth();
- vih->hdr.bmiHeader.biHeight = (LONG)video_desc->GetHeight();
- vih->hdr.bmiHeader.biCompression = 'v4pm';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- vih->hdr.dwPictAspectRatioX = vih->hdr.bmiHeader.biWidth;
- vih->hdr.dwPictAspectRatioY = vih->hdr.bmiHeader.biHeight;
- vih->cbSequenceHeader = di->GetDataSize();
- memcpy(vih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
- }
- 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;
+ switch(video_desc->GetObjectTypeId()) {
+ case AP4_MPEG4_VISUAL_OTI:
+ mt.subtype = FOURCCMap('v4pm');
+ mt.formattype = FORMAT_MPEG2Video;
+ {
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
+ memset(vih, 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = (LONG)video_desc->GetWidth();
+ vih->hdr.bmiHeader.biHeight = (LONG)video_desc->GetHeight();
+ vih->hdr.bmiHeader.biCompression = 'v4pm';
+ vih->hdr.bmiHeader.biPlanes = 1;
+ vih->hdr.bmiHeader.biBitCount = 24;
+ vih->hdr.dwPictAspectRatioX = vih->hdr.bmiHeader.biWidth;
+ vih->hdr.dwPictAspectRatioY = vih->hdr.bmiHeader.biHeight;
+ vih->cbSequenceHeader = di->GetDataSize();
+ memcpy(vih->dwSequenceHeader, di->GetData(), di->GetDataSize());
+ mts.Add(mt);
+ mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = 'V4PM');
+ mts.Add(mt);
+ }
+ 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)
- {
+ 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))
- {
+ } else if(AP4_MpegAudioSampleDescription* audio_desc =
+ dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
const AP4_DataBuffer* di = audio_desc->GetDecoderInfo();
- if(!di) di = &empty;
+ if(!di) {
+ di = &empty;
+ }
mt.majortype = MEDIATYPE_Audio;
mt.formattype = FORMAT_WaveFormatEx;
@@ -274,103 +272,96 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
memcpy(wfe + 1, di->GetData(), di->GetDataSize());
- 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: // ???
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- if(wfe->cbSize >= 2) wfe->nChannels = (((BYTE*)(wfe+1))[1]>>3) & 0xf;
- mts.Add(mt);
- break;
- case AP4_MPEG2_PART3_AUDIO_OTI: // ???
- case AP4_MPEG1_AUDIO_OTI:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
- {
- 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;
+ 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: // ???
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
+ if(wfe->cbSize >= 2) {
+ wfe->nChannels = (((BYTE*)(wfe+1))[1]>>3) & 0xf;
+ }
+ mts.Add(mt);
+ break;
+ case AP4_MPEG2_PART3_AUDIO_OTI: // ???
+ case AP4_MPEG1_AUDIO_OTI:
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
+ {
+ 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;
}
- if(mt.subtype == GUID_NULL)
- {
+ 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))
- {
+ } 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;
- }
+ if(!di) {
+ di = &empty;
+ }
- 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);
- }
+ 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;
+ }
- 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());
- memset(si, 0, 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;
+ 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());
+ memset(si, 0, 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)
- {
+ 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
- {
+ } 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))
- {
+ || dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
mt.majortype = MEDIATYPE_Subtitle;
mt.subtype = MEDIASUBTYPE_ASS2;
mt.formattype = FORMAT_SubtitleInfo;
@@ -384,7 +375,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
"[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.cx,
m_framesize.cy);
SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
memset(si, 0, mt.FormatLength());
@@ -395,14 +386,13 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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)))
- {
+ } 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))) {
const AP4_DataBuffer* di = avcC->GetDecoderInfo();
- if(!di) di = &empty;
+ if(!di) {
+ di = &empty;
+ }
const AP4_Byte* data = di->GetData();
AP4_Size size = di->GetDataSize();
@@ -421,8 +411,9 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
vih->hdr.bmiHeader.biBitCount = 24;
vih->hdr.dwPictAspectRatioX = vih->hdr.bmiHeader.biWidth;
vih->hdr.dwPictAspectRatioY = vih->hdr.bmiHeader.biHeight;
- if (item->GetData()->GetSampleCount() > 1)
+ if (item->GetData()->GetSampleCount() > 1) {
vih->hdr.AvgTimePerFrame = item->GetData()->GetDurationMs()*10000 / (item->GetData()->GetSampleCount()-1);
+ }
vih->dwProfile = data[1];
vih->dwLevel = data[3];
vih->dwFlags = (data[4] & 3) + 1;
@@ -435,14 +426,15 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
BYTE* src_end = (BYTE*)data + size;
BYTE* dst_end = (BYTE*)vih->dwSequenceHeader + size;
- for(int i = 0; i < 2; i++)
- {
- for(int n = *src++ & 0x1f; n > 0; n--)
- {
+ 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;}
+ if(src + len > src_end || dst + len > dst_end) {
+ ASSERT(0);
+ break;
+ }
memcpy(dst, src, len);
- src += len;
+ src += len;
dst += len;
vih->cbSequenceHeader += len;
}
@@ -453,44 +445,33 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
mts.Add(mt);
}
- }
- else if(AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
- track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd")))
- {
+ } else if(AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
+ track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd"))) {
const AP4_DataBuffer& db = stsd->GetDataBuffer();
- for(AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
+ for(AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
AP4_Atom::Type type = atom->GetType();
DWORD fourcc;
- if((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0))
- {
+ if((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
fourcc = type & 0xffff;
- }
- else if(type == AP4_ATOM_TYPE__MP3)
- {
+ } else if(type == AP4_ATOM_TYPE__MP3) {
fourcc = 0x0055;
- }
- else if((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3))
- {
+ } else if((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3)) {
fourcc = 0x2000;
- }
- else
- {
- fourcc =
+ } else {
+ fourcc =
((type >> 24) & 0x000000ff) |
((type >> 8) & 0x0000ff00) |
((type << 8) & 0x00ff0000) |
((type << 24) & 0xff000000);
}
- if(AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom))
- {
+ if(AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
mt.majortype = MEDIATYPE_Video;
mt.subtype = FOURCCMap(fourcc);
mt.formattype = FORMAT_VideoInfo;
@@ -511,8 +492,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
strlwr((char*)&buff);
AP4_Atom::Type typelwr = *(AP4_Atom::Type*)buff;
- if(typelwr != fourcc)
- {
+ if(typelwr != fourcc) {
mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typelwr);
mts.Add(mt);
}
@@ -520,28 +500,27 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
strupr((char*)&buff);
AP4_Atom::Type typeupr = *(AP4_Atom::Type*)buff;
- if(typeupr != fourcc)
- {
+ if(typeupr != fourcc) {
mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typeupr);
mts.Add(mt);
}
break;
- }
- else if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom))
- {
- if (ase->IsLittleEndian()==1)
- {
+ } else if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
+ if (ase->IsLittleEndian()==1) {
if (type==AP4_ATOM_TYPE_IN24 || type==AP4_ATOM_TYPE_IN32 ||
- type==AP4_ATOM_TYPE_FL32 || type==AP4_ATOM_TYPE_FL64)
- fourcc = type; //reverse fourcc
+ type==AP4_ATOM_TYPE_FL32 || type==AP4_ATOM_TYPE_FL64) {
+ fourcc = type; //reverse fourcc
+ }
}
mt.majortype = MEDIATYPE_Audio;
mt.subtype = FOURCCMap(fourcc);
mt.formattype = FORMAT_WaveFormatEx;
wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + db.GetDataSize());
memset(wfe, 0, mt.FormatLength());
- if(!(fourcc & 0xffff0000)) wfe->wFormatTag = (WORD)fourcc;
+ if(!(fourcc & 0xffff0000)) {
+ wfe->wFormatTag = (WORD)fourcc;
+ }
wfe->nSamplesPerSec = ase->GetSampleRate();
wfe->nChannels = ase->GetChannelCount();
wfe->wBitsPerSample = ase->GetSampleSize();
@@ -551,37 +530,39 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
memcpy(wfe+1, db.GetData(), db.GetDataSize());
mts.Add(mt);
break;
- }else{
+ } else {
TRACE(_T("Unknow MP4 Steam %x") , fourcc);
}
}
}
- if(mts.IsEmpty()) continue;
+ if(mts.IsEmpty()) {
+ continue;
+ }
REFERENCE_TIME rtDuration = 10000i64 * track->GetDurationMs();
- if(m_rtDuration < rtDuration) m_rtDuration = rtDuration;
+ if(m_rtDuration < rtDuration) {
+ m_rtDuration = rtDuration;
+ }
DWORD id = track->GetId();
CStringW name, lang;
name.Format(L"Output %d", id);
- if(!TrackName.IsEmpty())
- {
+ if(!TrackName.IsEmpty()) {
name = TrackName;
}
- if(!TrackLanguage.IsEmpty())
- {
- if(TrackLanguage != L"und") name += " (" + TrackLanguage + ")";
+ if(!TrackLanguage.IsEmpty()) {
+ if(TrackLanguage != L"und") {
+ name += " (" + TrackLanguage + ")";
+ }
}
- for(int i = 0, j = mts.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = mts.GetCount(); i < j; i++) {
BITMAPINFOHEADER bih;
- if(ExtractBIH(&mts[i], &bih))
- {
+ if(ExtractBIH(&mts[i], &bih)) {
m_framesize.cx = bih.biWidth;
m_framesize.cy = abs(bih.biHeight);
}
@@ -589,15 +570,18 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
- if(!TrackName.IsEmpty()) pPinOut->SetProperty(L"NAME", TrackName);
- if(!TrackLanguage.IsEmpty()) pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
+ 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)
- {
+ if(mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
LPCWSTR postfix = L" (plain text)";
mts[0].subtype = MEDIASUBTYPE_UTF8;
@@ -609,19 +593,21 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name + postfix, this, this, &hr));
- if(!TrackName.IsEmpty()) pPinOut->SetProperty(L"NAME", TrackName + postfix);
- if(!TrackLanguage.IsEmpty()) pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
+ 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")))
- {
+ 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++)
- {
+ 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
}
@@ -629,64 +615,88 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
ChapSort();
}
- if(AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst")))
- {
+ 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)))
- {
+ 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)
- {
+ 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"%02d", n);
- else if(n >= 100) track.Format(L"%d", n);
+ if(n > 0 && n < 100) {
+ track.Format(L"%02d", n);
+ } else if(n >= 100) {
+ track.Format(L"%d", n);
+ }
}
- }
- else
- {
+ } 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;
+ 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;
+ 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(!artist.IsEmpty()) {
+ SetProperty(L"AUTH", artist);
+ } else if(!writer.IsEmpty()) {
+ SetProperty(L"AUTH", writer);
+ }
- if(!appl.IsEmpty()) SetProperty(L"APPL", appl);
+ if(!appl.IsEmpty()) {
+ SetProperty(L"APPL", appl);
+ }
- if(!desc.IsEmpty()) SetProperty(L"DESC", desc);
+ if(!desc.IsEmpty()) {
+ SetProperty(L"DESC", desc);
+ }
}
}
@@ -702,8 +712,7 @@ bool CMP4SplitterFilter::DemuxInit()
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
pPair->m_value.index = 0;
@@ -712,8 +721,9 @@ bool CMP4SplitterFilter::DemuxInit()
AP4_Track* track = movie->GetTrack(pPair->m_key);
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(0, sample)))
+ if(AP4_SUCCEEDED(track->GetSample(0, sample))) {
pPair->m_value.ts = sample.GetCts();
+ }
}
return true;
@@ -726,42 +736,48 @@ void CMP4SplitterFilter::DemuxSeek(REFERENCE_TIME rt)
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
- if(AP4_FAILED(track->GetSampleIndexForTimeStampMs(ts, pPair->m_value.index)))
+ if(AP4_FAILED(track->GetSampleIndexForTimeStampMs(ts, pPair->m_value.index))) {
pPair->m_value.index = 0;
+ }
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, 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)
- {
+ 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() && stss->m_Entries[i]-1 <= pPair->m_value.index);
- if(i > 0) i--;
+ while(++i < stss->m_Entries.ItemCount() && stss->m_Entries[i]-1 <= pPair->m_value.index) {
+ ;
+ }
+ if(i > 0) {
+ i--;
+ }
pPair->m_value.index = stss->m_Entries[i]-1;
}
}
}
}
-struct SSACharacter {CString pre, post; WCHAR c;};
+struct SSACharacter {
+ CString pre, post;
+ WCHAR c;
+};
static CStringW ConvertTX3GToSSA(
- CStringW str,
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
+ CStringW str,
+ const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
CStringW font,
- const AP4_Byte* mods,
- int size,
+ const AP4_Byte* mods,
+ int size,
CSize framesize,
CPoint translation,
int durationms,
@@ -770,7 +786,9 @@ static CStringW ConvertTX3GToSSA(
int str_len = str.GetLength();
SSACharacter* chars = DNew SSACharacter[str_len];
- for(int i = 0; i < str_len; i++) chars[i].c = str[i];
+ for(int i = 0; i < str_len; i++) {
+ chars[i].c = str[i];
+ }
str.Empty();
//
@@ -780,21 +798,35 @@ static CStringW ConvertTX3GToSSA(
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;
+ 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));
+ 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;
@@ -809,42 +841,49 @@ static CStringW ConvertTX3GToSSA(
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);
+ 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;
+ 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(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)
- {
+ if(start < end) {
CStringW s;
s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", color[2], color[1], color[0], 255 - color[3]);
@@ -856,24 +895,23 @@ static CStringW ConvertTX3GToSSA(
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[start].pre += s;
chars[end-1].post += font_flags;
}
}
- }
- else if(tag == 'hclr')
- {
+ } 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;
+ } 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)
- {
+ if(start < end) {
CStringW s;
s.Format(L"{\\3c%02x%02x%02x\\3a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
@@ -883,20 +921,20 @@ static CStringW ConvertTX3GToSSA(
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;
+ } 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)
- {
+ if(start < end) {
// cheap...
- for(int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha)
- {
+ 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;
@@ -904,29 +942,34 @@ static CStringW ConvertTX3GToSSA(
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;
+ } 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)
- {
+ if(start < end) {
CStringW s;
s.Format(L"{\\kt%d\\kf%d}", start_time/10, (end_time - start_time)/10);
@@ -945,8 +988,7 @@ static CStringW ConvertTX3GToSSA(
// continous karaoke
- if(desc.DisplayFlags & 0x800)
- {
+ if(desc.DisplayFlags & 0x800) {
CStringW s;
s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
@@ -954,22 +996,17 @@ static CStringW ConvertTX3GToSSA(
int breaks = 0;
- for(int i = 0, j = 0; i <= str_len; i++)
- {
- if(chars[i].c == '\n' /*|| chars[i].c == ' '*/)
- {
+ for(int i = 0, j = 0; i <= str_len; i++) {
+ if(chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
breaks++;
}
}
- if(str_len > 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 == ' '*/)
- {
+ 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;
@@ -980,11 +1017,12 @@ static CStringW ConvertTX3GToSSA(
//
- for(int i = 0; i < str_len; i++)
- {
+ for(int i = 0; i < str_len; i++) {
str += chars[i].pre;
str += chars[i].c;
- if(desc.DisplayFlags & 0x20000) str += L"\\N";
+ if(desc.DisplayFlags & 0x20000) {
+ str += L"\\N";
+ }
str += chars[i].post;
}
@@ -992,20 +1030,28 @@ static CStringW ConvertTX3GToSSA(
//
- if(rbox.IsRectEmpty()) rbox.SetRect(0, 0, framesize.cx, framesize.cy);
+ 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;}
+ 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);
+ 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);
//
@@ -1018,31 +1064,32 @@ bool CMP4SplitterFilter::DemuxLoop()
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
CAtlMap<DWORD, trackpos>::CPair* pPairNext = NULL;
REFERENCE_TIME rtNext = 0;
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ 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;
+ 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))
- {
+ if(pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
pPairNext = pPair;
rtNext = rt;
}
}
- if(!pPairNext) break;
+ if(!pPairNext) {
+ break;
+ }
AP4_Track* track = movie->GetTrack(pPairNext->m_key);
@@ -1051,8 +1098,7 @@ bool CMP4SplitterFilter::DemuxLoop()
AP4_Sample sample;
AP4_DataBuffer data;
- if(pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data)))
- {
+ if(pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
const CMediaType& mt = pPin->CurrentMediaType();
CAutoPtr<Packet> p(DNew Packet());
@@ -1063,29 +1109,26 @@ bool CMP4SplitterFilter::DemuxLoop()
// 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)
- {
+ if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if(stss->m_Entries.ItemCount() > 0) {
p->bSyncPoint = FALSE;
AP4_Cardinal i = -1;
while(++i < stss->m_Entries.ItemCount())
- if(stss->m_Entries[i]-1 == pPairNext->m_value.index)
+ if(stss->m_Entries[i]-1 == pPairNext->m_value.index) {
p->bSyncPoint = TRUE;
+ }
}
}
//
- if(track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() == 1)
- {
+ if(track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() == 1) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
int nBlockAlign = 1200;
- if(wfe->nBlockAlign > 1)
- {
+ if(wfe->nBlockAlign > 1) {
nBlockAlign = wfe->nBlockAlign;
pPairNext->m_value.index -= pPairNext->m_value.index % wfe->nBlockAlign;
}
@@ -1094,109 +1137,102 @@ bool CMP4SplitterFilter::DemuxLoop()
TRACE(_T("track->GetSampleCount() %d %d "), track->GetSampleCount(),pPairNext->m_value.index);
int fFirst = true;
- while(AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data)))
- {
+ while(AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
AP4_Size size = data.GetDataSize();
const AP4_Byte* ptr = data.GetData();
- for(int i = 0; i < size; i++) p->Add(ptr[i]);
+ for(int i = 0; i < size; i++) {
+ p->Add(ptr[i]);
+ }
- if(fFirst) {p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts()); fFirst = false;}
+ if(fFirst) {
+ p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
+ fFirst = false;
+ }
p->rtStop += (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
- if(pPairNext->m_value.index+1 >= track->GetSampleCount() || p->GetCount() >= nBlockAlign)
+ if(pPairNext->m_value.index+1 >= track->GetSampleCount() || p->GetCount() >= nBlockAlign) {
break;
+ }
pPairNext->m_value.index++;
}
- }
- else if(track->GetType() == AP4_Track::TYPE_TEXT)
- {
+ } 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)
- {
+ if(avail > 2) {
AP4_UI16 size = (ptr[0] << 8) | ptr[1];
- if(size <= avail-2)
- {
+ if(size <= avail-2) {
CStringA str;
- if(size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff)
- {
+ 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));
+ for(int i = 0; i < wstr.GetLength(); i++) {
+ wstr.SetAt(i, ((WORD)wstr[i] >> 8) | ((WORD)wstr[i] << 8));
+ }
str = UTF16To8(wstr);
- }
- else
- {
+ } else {
str = CStringA((LPCSTR)&ptr[2], size);
}
CStringA dlgln = str;
- if(mt.subtype == MEDIASUBTYPE_ASS2)
- {
+ 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)))
- {
+ 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
- {
+ 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))
- {
+ 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))
- {
+ } 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)))
- {
+ 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)))
+ 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);
+ 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])
- {
+ 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],
+ "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.left, rbox.top,
rbox.right, rbox.top,
rbox.right, rbox.bottom,
rbox.left, rbox.bottom);
@@ -1212,8 +1248,7 @@ bool CMP4SplitterFilter::DemuxLoop()
}
}
- if(!dlgln_bkg.IsEmpty())
- {
+ if(!dlgln_bkg.IsEmpty()) {
CAutoPtr<Packet> p2(DNew Packet());
p2->TrackNumber = p->TrackNumber;
p2->rtStart = p->rtStart;
@@ -1223,8 +1258,7 @@ bool CMP4SplitterFilter::DemuxLoop()
hr = DeliverPacket(p2);
}
- if(!dlgln_plaintext.IsEmpty())
- {
+ if(!dlgln_plaintext.IsEmpty()) {
CAutoPtr<Packet> p2(DNew Packet());
p2->TrackNumber = p->TrackNumber ^ 0x80402010;
p2->rtStart = p->rtStart;
@@ -1233,9 +1267,7 @@ bool CMP4SplitterFilter::DemuxLoop()
p2->SetData((LPCSTR)dlgln_plaintext, dlgln_plaintext.GetLength());
hr = DeliverPacket(p2);
}
- }
- else
- {
+ } else {
p->SetData(data.GetData(), data.GetDataSize());
}
@@ -1244,8 +1276,9 @@ bool CMP4SplitterFilter::DemuxLoop()
{
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample)))
+ if(AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
pPairNext->m_value.ts = sample.GetCts();
+ }
}
}
@@ -1259,22 +1292,23 @@ STDMETHODIMP CMP4SplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
CheckPointer(m_pFile, E_UNEXPECTED);
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ 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)
+ if(track->GetType() != AP4_Track::TYPE_VIDEO) {
continue;
+ }
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss")))
- {
+ if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
nKFs = stss->m_Entries.ItemCount();
return S_OK;
}
@@ -1289,31 +1323,34 @@ STDMETHODIMP CMP4SplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
CheckPointer(pKFs, E_POINTER);
CheckPointer(m_pFile, E_UNEXPECTED);
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) return E_INVALIDARG;
+ if(*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ return E_INVALIDARG;
+ }
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ 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)
+ if(track->GetType() != AP4_Track::TYPE_VIDEO) {
continue;
+ }
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss")))
- {
+ if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
nKFs = 0;
- for(AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); i++)
- {
+ for(AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); i++) {
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i]-1, sample)))
+ if(AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i]-1, sample))) {
pKFs[nKFs++] = 10000000i64 * sample.GetCts() / track->GetMediaTimeScale();
+ }
}
return S_OK;
@@ -1347,8 +1384,9 @@ void CMPEG4VideoSplitterFilter::SkipUserData()
{
m_pFile->BitByteAlign();
while(m_pFile->BitRead(32, true) == 0x000001b2)
- while(m_pFile->BitRead(24, true) != 0x000001)
+ while(m_pFile->BitRead(24, true) != 0x000001) {
m_pFile->BitRead(8);
+ }
}
HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
@@ -1359,8 +1397,13 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -1373,36 +1416,31 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
BYTE pary = 1;
REFERENCE_TIME atpf = 400000;
- if(m_pFile->BitRead(24, true) != 0x000001)
+ if(m_pFile->BitRead(24, true) != 0x000001) {
return E_FAIL;
+ }
BYTE id;
- while(m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos()))
- {
- if(id == 0xb5)
- {
+ 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)
- {
+ 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)
- {
+
+ if(visual_object_type == 1 || visual_object_type == 2) {
BYTE video_signal_type = (BYTE)m_pFile->BitRead(1);
-
- if(video_signal_type)
- {
+
+ 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)
- {
+ 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);
@@ -1412,111 +1450,147 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
SkipUserData();
- if(visual_object_type == 1)
- {
- if(m_pFile->BitRead(24) != 0x000001)
+ 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)
+ if(video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
break;
+ }
- if(m_pFile->BitRead(24) != 0x000001)
+ 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)
+ 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
+ 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)
- {
+ 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;
+ 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)
- {
+ 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)
- {
+ if(vbv_parameters) {
WORD first_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD latter_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD first_half_vbv_buffer_size = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ 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;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD latter_half_vbv_occupancy = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ 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)
- {
+ 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;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD vop_time_increment_resolution = (WORD)m_pFile->BitRead(16);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
BYTE fixed_vop_rate = (BYTE)m_pFile->BitRead(1);
- if(fixed_vop_rate)
- {
+ if(fixed_vop_rate) {
int bits = 0;
- for(WORD i = vop_time_increment_resolution; i; i /= 2)
+ 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)
- {
+ 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;
+ 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;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
height = (WORD)m_pFile->BitRead(13);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
}
BYTE interlaced = (BYTE)m_pFile->BitRead(1);
@@ -1525,15 +1599,14 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
// ...
}
}
- }
- else if(id == 0xb6)
- {
- m_seqhdrsize = m_pFile->GetPos() - 4;
+ } else if(id == 0xb6) {
+ m_seqhdrsize = m_pFile->GetPos() - 4;
}
}
- if(!width || !height)
+ if(!width || !height) {
return E_FAIL;
+ }
CAtlArray<CMediaType> mts;
@@ -1592,28 +1665,26 @@ bool CMPEG4VideoSplitterFilter::DemuxLoop()
DWORD sync = ~0;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining())
- {
- for(int i = 0; i < 65536; i++) // don't call CheckRequest so often
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && 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))
- {
+ if(p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
hr = DeliverPacket(p);
}
- if(eof) break;
+ if(eof) {
+ break;
+ }
- if(!p)
- {
+ if(!p) {
p.Attach(DNew Packet());
p->SetCount(0, 1024);
p->TrackNumber = 0;
- p->rtStart = rt;
+ p->rtStart = rt;
p->rtStop = rt + atpf;
p->bSyncPoint = FALSE;
- rt += atpf;
+ rt += atpf;
// rt = Packet::INVALID_TIME;
}
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.h b/src/filters/parser/MP4Splitter/MP4Splitter.h
index 62d4e9c30..49f7b243a 100644
--- a/src/filters/parser/MP4Splitter/MP4Splitter.h
+++ b/src/filters/parser/MP4Splitter/MP4Splitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,9 +27,12 @@
#include "../BaseSplitter/BaseSplitter.h"
class __declspec(uuid("61F47056-E400-43d3-AF1E-AB7DFFD4C4AD"))
-CMP4SplitterFilter : public CBaseSplitterFilter
+ CMP4SplitterFilter : public CBaseSplitterFilter
{
- struct trackpos {DWORD /*AP4_Ordinal*/ index; unsigned __int64 /*AP4_TimeStamp*/ ts;};
+ struct trackpos {
+ DWORD /*AP4_Ordinal*/ index;
+ unsigned __int64 /*AP4_TimeStamp*/ ts;
+ };
CAtlMap<DWORD, trackpos> m_trackpos;
CSize m_framesize;
@@ -52,7 +55,7 @@ public:
};
class __declspec(uuid("3CCC052E-BDEE-408a-BEA7-90914EF2964B"))
-CMP4SourceFilter : public CMP4SplitterFilter
+ CMP4SourceFilter : public CMP4SplitterFilter
{
public:
CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
@@ -61,7 +64,7 @@ public:
// for raw mpeg4 elementary streams:
class __declspec(uuid("D3D9D58B-45B5-48AB-B199-B8C40560AEC7"))
-CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
+ CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
{
__int64 m_seqhdrsize;
int NextStartCode();
@@ -80,7 +83,7 @@ public:
};
class __declspec(uuid("E2B98EEA-EE55-4E9B-A8C1-6E5288DF785A"))
-CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
+ CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
{
public:
CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
index c28950291..88ce5ebfa 100644
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
+++ b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
@@ -2,11 +2,13 @@
#include "MP4SplitterFile.h"
#include "Ap4AsyncReaderStream.h"
-CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr)
+CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr)
: CBaseSplitterFileEx(pReader, hr, DEFAULT_CACHE_LENGTH, false)
, m_pAp4File(NULL)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
@@ -31,7 +33,7 @@ HRESULT CMP4SplitterFile::Init()
AP4_ByteStream* stream = DNew AP4_AsyncReaderStream(this);
m_pAp4File = DNew AP4_File(*stream);
-
+
AP4_Movie* movie = ((AP4_File*)m_pAp4File)->GetMovie();
stream->Release();
diff --git a/src/filters/parser/MP4Splitter/stdafx.cpp b/src/filters/parser/MP4Splitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MP4Splitter/stdafx.cpp
+++ b/src/filters/parser/MP4Splitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MP4Splitter/stdafx.h b/src/filters/parser/MP4Splitter/stdafx.h
index cdc946aa0..9b252ac14 100644
--- a/src/filters/parser/MP4Splitter/stdafx.h
+++ b/src/filters/parser/MP4Splitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
index e498af087..8fc4b7afa 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
+++ b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,15 +25,14 @@
#include "../../../thirdparty/zlib/zlib.h"
#define DOCTYPE _T("matroska")
-#define DOCTYPE_WEBM _T("webm")
+#define DOCTYPE_WEBM _T("webm")
#define DOCTYPEVERSION 2
static void LOG(LPCTSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
- if(FILE* f = _tfopen(_T("c:\\matroskasplitterlog.txt"), _T("at")))
- {
+ if(FILE* f = _tfopen(_T("c:\\matroskasplitterlog.txt"), _T("at"))) {
fseek(f, 0, 2);
_vftprintf(f, fmt, args);
fclose(f);
@@ -53,46 +52,50 @@ using namespace MatroskaReader;
{ \
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--)
+ for(BYTE* d = s + len-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
//
// CMatroskaFile
//
-CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr)
+CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
, m_rtOffset(0)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
HRESULT CMatroskaFile::Init()
{
DWORD dw;
- if(FAILED(Read(dw)) || dw != 0x1A45DFA3)
+ if(FAILED(Read(dw)) || dw != 0x1A45DFA3) {
return E_FAIL;
+ }
CMatroskaNode Root(this);
- if(FAILED(Parse(&Root)))
+ if(FAILED(Parse(&Root))) {
return E_FAIL;
+ }
CAutoPtr<CMatroskaNode> pSegment, pCluster;
if((pSegment = Root.Child(0x18538067))
- && (pCluster = pSegment->Child(0x1F43B675)))
- {
+ && (pCluster = pSegment->Child(0x1F43B675))) {
Cluster c0;
c0.ParseTimeCode(pCluster);
m_rtOffset = m_segment.GetRefTime(c0.TimeCode);
@@ -105,19 +108,26 @@ template <class T>
HRESULT CMatroskaFile::Read(T& var)
{
HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- if(S_OK == hr) bswap((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;
+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
}
@@ -126,13 +136,27 @@ HRESULT CMatroskaFile::Parse(CMatroskaNode* pMN0)
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;
+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
}
@@ -141,14 +165,28 @@ 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;
+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
}
@@ -160,53 +198,65 @@ HRESULT Segment::ParseMinimal(CMatroskaNode* pMN0)
len = pMN0->m_len;
CAutoPtr<CMatroskaNode> pMN = pMN0->Child();
- if(!pMN) return S_FALSE;
+ if(!pMN) {
+ return S_FALSE;
+ }
int n = 0;
- do
- {
- switch(pMN->m_id)
- {
- case 0x1549A966: SegmentInfo.Parse(pMN); n++; break;
- case 0x114D9B74: MetaSeekInfo.Parse(pMN); n++; break;
- case 0x1654AE6B: Tracks.Parse(pMN); n++; break;
- case 0x1C53BB6B: Cues.Parse(pMN); break;
+ do {
+ switch(pMN->m_id) {
+ case 0x1549A966:
+ SegmentInfo.Parse(pMN);
+ n++;
+ break;
+ case 0x114D9B74:
+ MetaSeekInfo.Parse(pMN);
+ n++;
+ break;
+ case 0x1654AE6B:
+ Tracks.Parse(pMN);
+ n++;
+ break;
+ case 0x1C53BB6B:
+ Cues.Parse(pMN);
+ break;
}
- }
- while(n < 3 && pMN->Next());
+ } while(n < 3 && pMN->Next());
- if(!pMN->IsRandomAccess())
- {
+ if(!pMN->IsRandomAccess()) {
return S_OK;
}
- while(MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos()))
- {
+ while(MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
pMN->SeekTo(pos);
pMN->Parse();
- if(pMN->m_id != 0x114D9B74) {ASSERT(0); break;}
+ if(pMN->m_id != 0x114D9B74) {
+ ASSERT(0);
+ break;
+ }
MetaSeekInfo.Parse(pMN);
}
- if(n == 3)
- {
- if(Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false)))
- {
- do {Cues.Parse(pMN);}
- while(pMN->Next(true));
+ if(n == 3) {
+ 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(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));
+ if(Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
+ do {
+ Attachments.Parse(pMN); /*BIG UGLY HACK:*/
+ break;
+ } while (pMN->Next(true));
}
}
@@ -218,43 +268,44 @@ UINT64 Segment::GetMasterTrack()
UINT64 TrackNumber = 0, AltTrackNumber = 0;
POSITION pos1 = Tracks.GetHeadPosition();
- while(pos1 && TrackNumber == 0)
- {
+ while(pos1 && TrackNumber == 0) {
Track* pT = Tracks.GetNext(pos1);
-
+
POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while(pos2 && TrackNumber == 0)
- {
+ while(pos2 && TrackNumber == 0) {
TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
- if(pTE->TrackType == TrackEntry::TypeVideo)
- {
+ if(pTE->TrackType == TrackEntry::TypeVideo) {
TrackNumber = pTE->TrackNumber;
break;
- }
- else if(pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0)
- {
+ } else if(pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0) {
AltTrackNumber = pTE->TrackNumber;
}
}
}
- if(TrackNumber == 0) TrackNumber = AltTrackNumber;
- if(TrackNumber == 0) TrackNumber = 1;
+ if(TrackNumber == 0) {
+ TrackNumber = AltTrackNumber;
+ }
+ if(TrackNumber == 0) {
+ TrackNumber = 1;
+ }
return TrackNumber;
}
ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
{
- if(ChapterUID == id)
+ if(ChapterUID == id) {
return(this);
+ }
POSITION pos = ChapterAtoms.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ChapterAtom* ca = ChapterAtoms.GetNext(pos)->FindChapterAtom(id);
- if(ca) return ca;
+ if(ca) {
+ return ca;
+ }
}
return(NULL);
@@ -263,17 +314,14 @@ ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
{
POSITION pos1 = Chapters.GetHeadPosition();
- while(pos1)
- {
+ while(pos1) {
Chapter* c = Chapters.GetNext(pos1);
POSITION pos2 = c->EditionEntries.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
EditionEntry* ee = c->EditionEntries.GetNext(pos2);
- if(nEditionEntry-- == 0)
- {
+ if(nEditionEntry-- == 0) {
return id == 0 ? ee : ee->FindChapterAtom(id);
}
}
@@ -285,70 +333,155 @@ ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
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;
+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;
+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;
+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;
+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;
+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
}
@@ -358,32 +491,34 @@ static int cesort(const void* a, const void* b)
UINT64 ce2 = (static_cast<ContentEncoding*>(const_cast<void *>(b)))->ContentEncodingOrder;
return (int)ce1 - (int)ce2;
-//return static_cast<int>(ce1) - static_cast<int>(ce2);
+ //return static_cast<int>(ce1) - static_cast<int>(ce2);
}
bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
{
- if(ces.ce.GetCount() == 0) return(true);
+ if(ces.ce.GetCount() == 0) {
+ return(true);
+ }
CAtlArray<ContentEncoding*> cearray;
POSITION pos = ces.ce.GetHeadPosition();
- while(pos) cearray.Add(ces.ce.GetNext(pos));
+ while(pos) {
+ cearray.Add(ces.ce.GetNext(pos));
+ }
qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);
- for(int i = cearray.GetCount()-1; i >= 0; i--)
- {
+ for(int i = cearray.GetCount()-1; i >= 0; i--) {
ContentEncoding* ce = cearray[i];
- if(!(ce->ContentEncodingScope & Scope))
+ if(!(ce->ContentEncodingScope & Scope)) {
continue;
+ }
- if(ce->ContentEncodingType == ContentEncoding::Compression)
- {
- if(!data.Decompress(ce->cc))
+ if(ce->ContentEncodingType == ContentEncoding::Compression) {
+ if(!data.Decompress(ce->cc)) {
return(false);
- }
- else if(ce->ContentEncodingType == ContentEncoding::Encryption)
- {
+ }
+ } else if(ce->ContentEncodingType == ContentEncoding::Encryption) {
// TODO
return(false);
}
@@ -395,102 +530,200 @@ bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
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 0x2EB524: ColourSpace.Parse(pMN); break;
- case 0x2FB523: GammaValue.Parse(pMN); break;
- case 0x2383E3: FramePerSec.Parse(pMN); break;
+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 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;
+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;
+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;
+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;
+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;
+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;
+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;
+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;
+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
}
@@ -498,71 +731,75 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull)
{
pMN->SeekTo(pMN->m_start);
- TrackNumber.Parse(pMN);
- CShort s; s.Parse(pMN); TimeCode.Set(s);
+ TrackNumber.Parse(pMN);
+ CShort s;
+ s.Parse(pMN);
+ TimeCode.Set(s);
Lacing.Parse(pMN);
-
- if(!fFull) return S_OK;
+
+ if(!fFull) {
+ return S_OK;
+ }
CAtlList<MatroskaReader::QWORD> lens;
MatroskaReader::QWORD tlen = 0;
MatroskaReader::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;
- MatroskaReader::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;
+ 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;
+ MatroskaReader::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)
- {
+ while(pos) {
MatroskaReader::QWORD len = lens.GetNext(pos);
CAutoPtr<CBinary> p(DNew CBinary());
p->SetCount((INT_PTR)len);
@@ -576,119 +813,191 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull)
HRESULT BlockAdditions::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xA6: bm.Parse(pMN); break;
+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;
+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;
+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;
+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;
+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;
+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;
+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;
+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;
+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;
+case 0x45B9:
+ EditionEntries.Parse(pMN);
+ break;
EndChunk
}
HRESULT EditionEntry::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xB6: ChapterAtoms.Parse(pMN); break;
+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;
+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;
+case 0x85:
+ ChapString.Parse(pMN);
+ break;
+case 0x437C:
+ ChapLanguage.Parse(pMN);
+ break;
+case 0x437E:
+ ChapCountry.Parse(pMN);
+ break;
EndChunk
}
@@ -703,8 +1012,7 @@ HRESULT CBinary::Parse(CMatroskaNode* pMN)
bool CBinary::Compress(ContentCompression& cc)
{
- if(cc.ContentCompAlgo == ContentCompression::ZLIB)
- {
+ if(cc.ContentCompAlgo == ContentCompression::ZLIB) {
int res;
z_stream c_stream;
@@ -712,26 +1020,24 @@ bool CBinary::Compress(ContentCompression& cc)
c_stream.zfree = (free_func)0;
c_stream.opaque = (voidpf)0;
- if(Z_OK != (res = deflateInit(&c_stream, 9)))
+ if(Z_OK != (res = deflateInit(&c_stream, 9))) {
return(false);
+ }
c_stream.next_in = GetData();
c_stream.avail_in = GetCount();
BYTE* dst = NULL;
int n = 0;
- do
- {
+ do {
dst = (BYTE*)realloc(dst, ++n*10);
c_stream.next_out = &dst[(n-1)*10];
c_stream.avail_out = 10;
- if(Z_OK != (res = deflate(&c_stream, Z_FINISH)) && Z_STREAM_END != res)
- {
+ if(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);
+ } while(0 == c_stream.avail_out && Z_STREAM_END != res);
deflateEnd(&c_stream);
@@ -748,8 +1054,7 @@ bool CBinary::Compress(ContentCompression& cc)
bool CBinary::Decompress(ContentCompression& cc)
{
- if(cc.ContentCompAlgo == ContentCompression::ZLIB)
- {
+ if(cc.ContentCompAlgo == ContentCompression::ZLIB) {
int res;
z_stream d_stream;
@@ -757,26 +1062,24 @@ bool CBinary::Decompress(ContentCompression& cc)
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
- if(Z_OK != (res = inflateInit(&d_stream)))
+ if(Z_OK != (res = inflateInit(&d_stream))) {
return(false);
+ }
d_stream.next_in = GetData();
d_stream.avail_in = GetCount();
BYTE* dst = NULL;
int n = 0;
- do
- {
+ do {
dst = (unsigned char *)realloc(dst, ++n*1000);
d_stream.next_out = &dst[(n-1)*1000];
d_stream.avail_out = 1000;
- if(Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res)
- {
+ if(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);
+ } while(0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
inflateEnd(&d_stream);
@@ -786,9 +1089,7 @@ bool CBinary::Decompress(ContentCompression& cc)
free(dst);
return(true);
- }
- else if(cc.ContentCompAlgo == ContentCompression::HDRSTRIP)
- {
+ } else if(cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
InsertArrayAt(0, &cc.ContentCompSettings);
}
@@ -801,8 +1102,9 @@ HRESULT CANSI::Parse(CMatroskaNode* pMN)
MatroskaReader::QWORD len = pMN->m_len;
CHAR c;
- while(len-- > 0 && SUCCEEDED(pMN->Read(c)))
+ while(len-- > 0 && SUCCEEDED(pMN->Read(c))) {
*this += c;
+ }
return(len == -1 ? S_OK : E_FAIL);
}
@@ -811,8 +1113,9 @@ 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))
+ 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;
@@ -821,11 +1124,12 @@ HRESULT CUTF8::Parse(CMatroskaNode* pMN)
HRESULT CUInt::Parse(CMatroskaNode* pMN)
{
m_val = 0;
- for(int i = 0; i < (int)pMN->m_len; i++)
- {
+ 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;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
m_fValid = true;
return S_OK;
@@ -834,10 +1138,11 @@ HRESULT CUInt::Parse(CMatroskaNode* pMN)
HRESULT CInt::Parse(CMatroskaNode* pMN)
{
m_val = 0;
- for(int i = 0; i < (int)pMN->m_len; i++)
- {
+ for(int i = 0; i < (int)pMN->m_len; i++) {
HRESULT hr = pMN->Read(*((BYTE*)&m_val+7-i));
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
m_val >>= (8-pMN->m_len)*8;
m_fValid = true;
@@ -849,16 +1154,16 @@ HRESULT CFloat::Parse(CMatroskaNode* pMN)
HRESULT hr = E_FAIL;
m_val = 0;
- if(pMN->m_len == 4)
- {
+ 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))
+ if(SUCCEEDED(hr)) {
m_fValid = true;
+ }
return hr;
}
@@ -877,21 +1182,34 @@ HRESULT CID::Parse(CMatroskaNode* pMN)
BYTE b = 0;
HRESULT hr = pMN->Read(b);
- if(FAILED(hr)) return hr;
+ 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;
+ 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)
- {
+ while(nMoreBytes-- > 0) {
m_val <<= 8;
hr = pMN->Read(*(BYTE*)&m_val);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
m_fValid = true;
@@ -905,39 +1223,60 @@ HRESULT CLength::Parse(CMatroskaNode* pMN)
BYTE b = 0;
HRESULT hr = pMN->Read(b);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
int nMoreBytes = 0, nMoreBytesTmp = 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;
+ 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;
+ }
nMoreBytesTmp = nMoreBytes;
MatroskaReader::QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
- while(nMoreBytes-- > 0)
- {
+ while(nMoreBytes-- > 0) {
m_val <<= 8;
hr = pMN->Read(*(BYTE*)&m_val);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
- if(m_val == UnknownSize)
- {
+ 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)
+ if(m_fSigned) {
m_val -= (UnknownSize >> 1);
+ }
m_fValid = true;
@@ -996,7 +1335,9 @@ HRESULT CNode<T>::Parse(CMatroskaNode* pMN)
{
CAutoPtr<T> p(DNew T());
HRESULT hr = E_OUTOFMEMORY;
- if(!p || FAILED(hr = p->Parse(pMN))) return hr;
+ if(!p || FAILED(hr = p->Parse(pMN))) {
+ return hr;
+ }
AddTail(p);
return S_OK;
}
@@ -1005,7 +1346,9 @@ HRESULT CBlockGroupNode::Parse(CMatroskaNode* pMN, bool fFull)
{
CAutoPtr<BlockGroup> p(DNew BlockGroup());
HRESULT hr = E_OUTOFMEMORY;
- if(!p || FAILED(hr = p->Parse(pMN, fFull))) return hr;
+ if(!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ return hr;
+ }
AddTail(p);
return S_OK;
}
@@ -1014,7 +1357,9 @@ HRESULT CSimpleBlockNode::Parse(CMatroskaNode* pMN, bool fFull)
{
CAutoPtr<SimpleBlock> p(DNew SimpleBlock());
HRESULT hr = E_OUTOFMEMORY;
- if(!p || FAILED(hr = p->Parse(pMN, fFull))) return hr;
+ if(!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ return hr;
+ }
AddTail(p);
return S_OK;
}
@@ -1027,7 +1372,7 @@ CMatroskaNode::CMatroskaNode(CMatroskaFile* pMF)
{
ASSERT(m_pMF);
m_start = m_filepos = 0;
- m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
+ m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
}
CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent)
@@ -1040,40 +1385,46 @@ CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent)
HRESULT CMatroskaNode::Parse()
{
m_filepos = GetPos();
- if(FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this)))
+ 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>();
+ if(m_len == 0) {
+ return CAutoPtr<CMatroskaNode>();
+ }
SeekTo(m_start);
CAutoPtr<CMatroskaNode> pMN(DNew CMatroskaNode(this));
- if(id && !pMN->Find(id, fSearch)) pMN.Free();
+ if(id && !pMN->Find(id, fSearch)) {
+ pMN.Free();
+ }
return pMN;
}
bool CMatroskaNode::Next(bool fSame)
{
- if(!m_pParent)
+ if(!m_pParent) {
return(false);
+ }
CID id = m_id;
- while(m_start+m_len < m_pParent->m_start+m_pParent->m_len)
- {
+ while(m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
SeekTo(m_start+m_len);
- if(FAILED(Parse()))
- {
- if(!Resync())
+ if(FAILED(Parse())) {
+ if(!Resync()) {
return(false);
+ }
}
- if(!fSame || m_id == id)
+ if(!fSame || m_id == id) {
return(true);
+ }
}
return(false);
@@ -1081,45 +1432,58 @@ bool CMatroskaNode::Next(bool fSame)
bool CMatroskaNode::Find(DWORD id, bool fSearch)
{
- MatroskaReader::QWORD pos = m_pParent && m_pParent->m_id == 0x18538067 /*segment?*/
- ? FindPos(id)
- : 0;
+ MatroskaReader::QWORD pos = m_pParent && m_pParent->m_id == 0x18538067 /*segment?*/
+ ? FindPos(id)
+ : 0;
- if(pos)
- {
+ if(pos) {
SeekTo(pos);
Parse();
- }
- else if(fSearch)
- {
- while(m_id != id && Next());
+ } else if(fSearch) {
+ while(m_id != id && Next()) {
+ ;
+ }
}
return(m_id == id);
}
-void CMatroskaNode::SeekTo(MatroskaReader::QWORD pos) {m_pMF->Seek(pos);}
-MatroskaReader::QWORD CMatroskaNode::GetPos() {return m_pMF->GetPos();}
-MatroskaReader::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, MatroskaReader::QWORD len) {return m_pMF->ByteRead(pData, len);}
+void CMatroskaNode::SeekTo(MatroskaReader::QWORD pos)
+{
+ m_pMF->Seek(pos);
+}
+MatroskaReader::QWORD CMatroskaNode::GetPos()
+{
+ return m_pMF->GetPos();
+}
+MatroskaReader::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, MatroskaReader::QWORD len)
+{
+ return m_pMF->ByteRead(pData, len);
+}
MatroskaReader::QWORD CMatroskaNode::FindPos(DWORD id, MatroskaReader::QWORD start)
{
Segment& sm = m_pMF->m_segment;
POSITION pos = sm.MetaSeekInfo.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Seek* s = sm.MetaSeekInfo.GetNext(pos);
POSITION pos2 = s->SeekHeads.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
SeekHead* sh = s->SeekHeads.GetNext(pos2);
- if(sh->SeekID == id && sh->SeekPosition+sm.pos >= start)
+ if(sh->SeekID == id && sh->SeekPosition+sm.pos >= start) {
return sh->SeekPosition+sm.pos;
+ }
}
}
@@ -1140,30 +1504,34 @@ CAutoPtr<CMatroskaNode> CMatroskaNode::Copy()
CAutoPtr<CMatroskaNode> CMatroskaNode::GetFirstBlock()
{
CAutoPtr<CMatroskaNode> pNode = Child();
- do {if(pNode->m_id == 0xA0 || pNode->m_id == 0xA3) return pNode;}
- while(pNode->Next());
+ do {
+ if(pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
+ return pNode;
+ }
+ } while(pNode->Next());
return CAutoPtr<CMatroskaNode>();
}
bool CMatroskaNode::NextBlock()
{
- if(!m_pParent)
+ if(!m_pParent) {
return(false);
+ }
CID id = m_id;
- while(m_start+m_len < m_pParent->m_start+m_pParent->m_len)
- {
+ while(m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
SeekTo(m_start+m_len);
- if(FAILED(Parse()))
- {
- if(!Resync())
+ if(FAILED(Parse())) {
+ if(!Resync()) {
return(false);
+ }
}
- if(m_id == 0xA0 || m_id == 0xA3)
+ if(m_id == 0xA0 || m_id == 0xA3) {
return(true);
+ }
}
return(false);
@@ -1171,34 +1539,32 @@ bool CMatroskaNode::NextBlock()
bool CMatroskaNode::Resync()
{
- if(m_pParent->m_id == 0x18538067) /*segment?*/
- {
+ if(m_pParent->m_id == 0x18538067) { /*segment?*/
SeekTo(m_filepos);
- for(BYTE b = 0; S_OK == Read(b); b = 0)
- {
- if((b&0xf0) != 0x10)
+ for(BYTE b = 0; S_OK == Read(b); b = 0) {
+ if((b&0xf0) != 0x10) {
continue;
+ }
- DWORD dw = b;
+ 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;
+ 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;
}
}
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.h b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
index 183fca217..67c1a9b2c 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.h
+++ b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,8 +31,16 @@ namespace MatroskaReader
typedef unsigned __int64 QWORD;
- class CANSI : public CStringA {public: HRESULT Parse(CMatroskaNode* pMN);};
- class CUTF8 : public CStringW {public: HRESULT Parse(CMatroskaNode* pMN);};
+ 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
@@ -42,36 +50,86 @@ namespace MatroskaReader
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;}
+ 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 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 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(), GetCount());}
+ CBinary& operator = (const CBinary& b) {
+ Copy(b);
+ return(*this);
+ }
+ CStringA ToString() {
+ return CStringA((LPCSTR)GetData(), 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 CNode : public CAutoPtrList<T>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
class EBML
{
@@ -84,321 +142,378 @@ namespace MatroskaReader
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 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(rand());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 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 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(rand());
+ 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
{
@@ -419,7 +534,9 @@ namespace MatroskaReader
UINT64 GetMasterTrack();
- REFERENCE_TIME GetRefTime(INT64 t) const {return t*(REFERENCE_TIME)(SegmentInfo.TimeCodeScale)/100;}
+ REFERENCE_TIME GetRefTime(INT64 t) const {
+ return t*(REFERENCE_TIME)(SegmentInfo.TimeCodeScale)/100;
+ }
ChapterAtom* FindChapterAtom(UINT64 id, int nEditionEntry = 0);
};
@@ -459,7 +576,9 @@ namespace MatroskaReader
CMatroskaNode(CMatroskaFile* pMF); // creates the root
CMatroskaNode(CMatroskaNode* pParent);
- CMatroskaNode* Parent() {return m_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);
@@ -472,10 +591,12 @@ namespace MatroskaReader
HRESULT Read(BYTE* pData, QWORD len);
CAutoPtr<CMatroskaNode> Copy();
-
+
CAutoPtr<CMatroskaNode> GetFirstBlock();
bool NextBlock();
- bool IsRandomAccess() {return m_pMF->IsRandomAccess();}
+ bool IsRandomAccess() {
+ return m_pMF->IsRandomAccess();
+ }
};
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
index f9ded756e..78f1b6080 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
+++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,26 +31,22 @@ using namespace MatroskaReader;
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMatroskaSplitterFilter), L"MPC - Matroska Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMatroskaSourceFilter), L"MPC - Matroska Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMatroskaSourceFilter>, NULL, &sudFilter[1]},
};
@@ -60,9 +56,9 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
RegisterSourceFilter(
- __uuidof(CMatroskaSourceFilter),
- MEDIASUBTYPE_Matroska,
- _T("0,4,,1A45DFA3"),
+ __uuidof(CMatroskaSourceFilter),
+ MEDIASUBTYPE_Matroska,
+ _T("0,4,,1A45DFA3"),
_T(".mkv"), _T(".mka"), _T(".mks"), NULL);
return AMovieDllRegisterServer2(TRUE);
@@ -98,7 +94,7 @@ STDMETHODIMP CMatroskaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, v
{
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(ITrackInfo)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -119,8 +115,13 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAtlArray<TrackEntry*> pinOutTE;
m_pFile.Attach(DNew CMatroskaFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -128,19 +129,18 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
int iVideo = 1, iAudio = 1, iSubtitle = 1;
POSITION pos = m_pFile->m_segment.Tracks.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Track* pT = m_pFile->m_segment.Tracks.GetNext(pos);
POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
bool isSub = false;
- if(!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData))
+ if(!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
continue;
+ }
CStringA CodecID = pTE->CodecID.ToString();
@@ -152,82 +152,83 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mt.SetSampleSize(1);
- if(pTE->TrackType == TrackEntry::TypeVideo)
- {
+ if(pTE->TrackType == TrackEntry::TypeVideo) {
Name.Format(L"Video %d", iVideo++);
mt.majortype = MEDIATYPE_Video;
- if(CodecID == "V_MS/VFW/FOURCC")
- {
+ if(CodecID == "V_MS/VFW/FOURCC") {
mt.formattype = FORMAT_VideoInfo;
VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount() - sizeof(BITMAPINFOHEADER));
memset(mt.Format(), 0, 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;
+ 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;
}
mts.Add(mt);
- }
- else if(CodecID == "V_UNCOMPRESSED")
- {
- }
- else if(CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6)
- {
+ } 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(int i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++)
- avcC.push_back(pTE->CodecPrivate[i]);
+ std::vector<BYTE> avcC;
+ for(int i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
+ avcC.push_back(pTE->CodecPrivate[i]);
+ }
- std::vector<BYTE> sh;
+ std::vector<BYTE> sh;
- unsigned jj = 6;
+ 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;
- }
+ 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;
- }
+ 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;
+ goto avcsuccess;
avcfail:
- continue;
+ continue;
avcsuccess:
CAtlArray<BYTE> data;
@@ -251,9 +252,7 @@ avcsuccess:
memcpy(pSequenceHeader, data.GetData(), data.GetCount());
pm2vi->cbSequenceHeader = data.GetCount();
mts.Add(mt);
- }
- else if(CodecID.Find("V_MPEG4/") == 0)
- {
+ } 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());
@@ -268,9 +267,7 @@ avcsuccess:
memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
pm2vi->cbSequenceHeader = pTE->CodecPrivate.GetCount();
mts.Add(mt);
- }
- else if(CodecID.Find("V_REAL/RV") == 0)
- {
+ } 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());
@@ -281,9 +278,7 @@ avcsuccess:
pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
pvih->bmiHeader.biCompression = mt.subtype.Data1;
mts.Add(mt);
- }
- else if(CodecID == "V_DIRAC")
- {
+ } 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());
@@ -299,19 +294,16 @@ avcsuccess:
dvih->cbSequenceHeader = pTE->CodecPrivate.GetCount();
mts.Add(mt);
- }
- else if(CodecID == "V_MPEG2")
- {
+ } else if(CodecID == "V_MPEG2") {
BYTE* seqhdr = pTE->CodecPrivate.GetData();
DWORD len = pTE->CodecPrivate.GetCount();
int w = pTE->v.PixelWidth;
int h = pTE->v.PixelHeight;
- if(MakeMPEG2MediaType(mt, seqhdr, len, w, h))
+ if(MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
mts.Add(mt);
- }
- else if(CodecID == "V_THEORA")
- {
+ }
+ } else if(CodecID == "V_THEORA") {
BYTE* thdr = pTE->CodecPrivate.GetData() + 3;
mt.majortype = MEDIATYPE_Video;
@@ -327,7 +319,9 @@ avcsuccess:
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);
+ 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;
@@ -336,58 +330,51 @@ avcsuccess:
memcpy (&vih->dwSequenceHeader, pTE->CodecPrivate.GetData(), vih->cbSequenceHeader);
mts.Add(mt);
- }
- 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());
- memset(mt.Format(), 0, 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;
- mts.Add(mt);
- }
-/*
- else if(CodecID == "V_DSHOW/MPEG1VIDEO") // V_MPEG1
- {
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- mt.formattype = FORMAT_MPEGVideo;
- MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
- memcpy(pm1vi, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth*pm1vi->hdr.bmiHeader.biHeight*4);
+ } 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());
+ memset(mt.Format(), 0, 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;
mts.Add(mt);
}
-*/
+ /*
+ else if(CodecID == "V_DSHOW/MPEG1VIDEO") // V_MPEG1
+ {
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG1Payload;
+ mt.formattype = FORMAT_MPEGVideo;
+ MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
+ memcpy(pm1vi, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth*pm1vi->hdr.bmiHeader.biHeight*4);
+ mts.Add(mt);
+ }
+ */
REFERENCE_TIME AvgTimePerFrame = 0;
- if(pTE->v.FramePerSec > 0)
+ if(pTE->v.FramePerSec > 0) {
AvgTimePerFrame = (REFERENCE_TIME)(10000000i64 / pTE->v.FramePerSec);
- else if(pTE->DefaultDuration > 0)
+ } else if(pTE->DefaultDuration > 0) {
AvgTimePerFrame = (REFERENCE_TIME)pTE->DefaultDuration / 100;
+ }
- if(AvgTimePerFrame)
- {
- for(int i = 0; i < mts.GetCount(); i++)
- {
+ if(AvgTimePerFrame) {
+ for(int 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_VideoInfo2
+ || mts[i].formattype == FORMAT_MPEG2Video) {
((VIDEOINFOHEADER*)mts[i].Format())->AvgTimePerFrame = AvgTimePerFrame;
}
}
}
- if(pTE->v.DisplayWidth != 0 && pTE->v.DisplayHeight != 0)
- {
- for(int i = 0; i < mts.GetCount(); i++)
- {
- if(mts[i].formattype == FORMAT_VideoInfo)
- {
+ if(pTE->v.DisplayWidth != 0 && pTE->v.DisplayHeight != 0) {
+ for(int i = 0; i < mts.GetCount(); i++) {
+ if(mts[i].formattype == FORMAT_VideoInfo) {
DWORD vih1 = FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
DWORD vih2 = FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader);
DWORD bmi = mts[i].FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
@@ -399,17 +386,13 @@ avcsuccess:
((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioX = (DWORD)pTE->v.DisplayWidth;
((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioY = (DWORD)pTE->v.DisplayHeight;
mts.InsertAt(i++, mt);
- }
- else if(mts[i].formattype == FORMAT_MPEG2Video)
- {
+ } else if(mts[i].formattype == FORMAT_MPEG2Video) {
((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioX = (DWORD)pTE->v.DisplayWidth;
((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioY = (DWORD)pTE->v.DisplayHeight;
}
}
}
- }
- else if(pTE->TrackType == TrackEntry::TypeAudio)
- {
+ } else if(pTE->TrackType == TrackEntry::TypeAudio) {
Name.Format(L"Audio %d", iAudio++);
mt.majortype = MEDIATYPE_Audio;
@@ -425,8 +408,7 @@ avcsuccess:
static CAtlMap<CStringA, int, CStringElementTraits<CStringA> > id2ft;
- if(id2ft.IsEmpty())
- {
+ if(id2ft.IsEmpty()) {
id2ft["A_MPEG/L3"] = WAVE_FORMAT_MP3;
id2ft["A_MPEG/L2"] = WAVE_FORMAT_MPEG;
id2ft["A_MPEG/L1"] = WAVE_FORMAT_MPEG;
@@ -444,10 +426,8 @@ avcsuccess:
}
int wFormatTag;
- if(id2ft.Lookup(CodecID, wFormatTag))
- {
- if(wFormatTag < 0)
- {
+ if(id2ft.Lookup(CodecID, wFormatTag)) {
+ if(wFormatTag < 0) {
wFormatTag = -wFormatTag;
wfe->cbSize = pTE->CodecPrivate.GetCount();
wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
@@ -457,32 +437,30 @@ avcsuccess:
mt.subtype = FOURCCMap(wfe->wFormatTag = wFormatTag);
mts.Add(mt);
- if(wFormatTag == WAVE_FORMAT_FLAC)
- {
+ if(wFormatTag == WAVE_FORMAT_FLAC) {
mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
mts.InsertAt(0, mt);
}
- }
- else if(CodecID == "A_VORBIS")
- {
+ } else if(CodecID == "A_VORBIS") {
BYTE* p = pTE->CodecPrivate.GetData();
CAtlArray<int> sizes;
- for(BYTE n = *p++; n > 0; n--)
- {
+ for(BYTE n = *p++; n > 0; n--) {
int size = 0;
- do {size += *p;} while(*p++ == 0xff);
+ do {
+ size += *p;
+ } while(*p++ == 0xff);
sizes.Add(size);
}
int totalsize = 0;
- for(int i = 0; i < sizes.GetCount(); i++)
+ for(int i = 0; i < sizes.GetCount(); i++) {
totalsize += sizes[i];
+ }
sizes.Add(pTE->CodecPrivate.GetCount() - (p - pTE->CodecPrivate.GetData()) - totalsize);
totalsize += sizes[sizes.GetCount()-1];
- if(sizes.GetCount() == 3)
- {
+ if(sizes.GetCount() == 3) {
mt.subtype = MEDIASUBTYPE_Vorbis2;
mt.formattype = FORMAT_VorbisFormat2;
VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + totalsize);
@@ -491,8 +469,9 @@ avcsuccess:
pvf2->SamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
pvf2->BitsPerSample = (DWORD)pTE->a.BitDepth;
BYTE* p2 = mt.Format() + sizeof(VORBISFORMAT2);
- for(int i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++)
+ for(int i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);
+ }
mts.Add(mt);
}
@@ -505,44 +484,44 @@ avcsuccess:
vf->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
vf->nMinBitsPerSec = vf->nMaxBitsPerSec = vf->nAvgBitsPerSec = (DWORD)-1;
mts.Add(mt);
- }
- else if(CodecID == "A_MS/ACM")
- {
+ } else if(CodecID == "A_MS/ACM") {
wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
memcpy(wfe, (WAVEFORMATEX*)pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
mt.subtype = FOURCCMap(wfe->wFormatTag);
mts.Add(mt);
- }
- else if(CodecID.Find("A_AAC/") == 0)
- {
+ } 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;
+ 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, pTE->a.Channels);
mts.Add(mt);
- if(profile < 0)
- {
+ 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)
- {
+ } 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 = pTE->CodecPrivate.GetCount();
@@ -551,25 +530,22 @@ avcsuccess:
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(pTE->TrackType == TrackEntry::TypeSubtitle)
- {
- if(iSubtitle == 1) InstallFonts();
+ } else if(pTE->TrackType == TrackEntry::TypeSubtitle) {
+ if(iSubtitle == 1) {
+ InstallFonts();
+ }
Name.Format(L"Subtitle %d", iSubtitle++);
mt.SetSampleSize(1);
- if(CodecID == "S_TEXT/ASCII")
- {
+ if(CodecID == "S_TEXT/ASCII") {
mt.majortype = MEDIATYPE_Text;
mt.subtype = MEDIASUBTYPE_NULL;
mt.formattype = FORMAT_None;
mts.Add(mt);
isSub = true;
- }
- else
- {
+ } else {
mt.majortype = MEDIATYPE_Subtitle;
mt.formattype = FORMAT_SubtitleInfo;
SUBTITLEINFO* psi = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + pTE->CodecPrivate.GetCount());
@@ -578,7 +554,7 @@ avcsuccess:
wcsncpy(psi->TrackName, pTE->Name, countof(psi->TrackName)-1);
memcpy(mt.pbFormat + (psi->dwOffset = sizeof(SUBTITLEINFO)), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mt.subtype =
+ 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 :
@@ -595,22 +571,25 @@ avcsuccess:
}
}
- if(mts.IsEmpty())
- {
+ 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")");
+ + (pTE->Name.IsEmpty() ? L"" : L", " + pTE->Name)
+ + (L" (" + Name + L")");
HRESULT hr;
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMatroskaSplitterOutputPin((int)pTE->MinCache, pTE->DefaultDuration/100, mts, Name, this, this, &hr));
- if(!pTE->Name.IsEmpty()) pPinOut->SetProperty(L"NAME", pTE->Name);
- if(pTE->Language.GetLength() == 3) pPinOut->SetProperty(L"LANG", CStringW(CString(pTE->Language)));
-
+ 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),DNew CMatroskaSplitterOutputPin((int)pTE->MinCache, pTE->DefaultDuration/100, mts, Name, this, this, &hr),1);
pinOutTE.InsertAt((iVideo+iAudio-3),pTE,1);
@@ -627,20 +606,18 @@ avcsuccess:
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
pPinOut.Attach(pinOut[i]);
TrackEntry* pTE = pinOutTE[i];
-
- if (pTE != NULL)
- {
+
+ if (pTE != NULL) {
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())
- {
+ if(m_pFile->IsRandomAccess()) {
m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
}
@@ -666,32 +643,32 @@ avcsuccess:
{
POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
POSITION pos = pA->AttachedFiles.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
AttachedFile* pF = pA->AttachedFiles.GetNext(pos);
CAtlArray<BYTE> pData;
pData.SetCount(pF->FileDataLen);
m_pFile->Seek(pF->FileDataPos);
- if(SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount())))
+ if(SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
ResAppend(pF->FileName, pF->FileDescription, CStringW(pF->FileMimeType), pData.GetData(), pData.GetCount());
+ }
}
}
}
// chapters
- if(ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0))
- {
+ 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";
+ if(ChapLanguage.GetLength() < 3) {
+ ChapLanguage = "eng";
+ }
SetupChapters(ChapLanguage, caroot);
}
@@ -703,36 +680,38 @@ void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int
{
CStringW tabs('+', level);
- if(!tabs.IsEmpty()) tabs += ' ';
+ if(!tabs.IsEmpty()) {
+ tabs += ' ';
+ }
POSITION pos = parent->ChapterAtoms.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
// ChapUID zero not allow by Matroska specs
UINT64 ChapUID = parent->ChapterAtoms.GetNext(pos)->ChapterUID;
ChapterAtom* ca = (ChapUID == 0) ? NULL : m_pFile->m_segment.FindChapterAtom(ChapUID);
- if(ca)
- {
+ if(ca) {
CStringW name, first;
POSITION pos = ca->ChapterDisplays.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ChapterDisplay* cd = ca->ChapterDisplays.GetNext(pos);
- if(first.IsEmpty()) first = cd->ChapString;
- if(cd->ChapLanguage == lng) name = cd->ChapString;
+ 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())
- {
+ if(!ca->ChapterAtoms.IsEmpty()) {
SetupChapters(lng, ca, level+1);
}
- }
+ }
}
}
@@ -740,25 +719,22 @@ void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int
void CMatroskaSplitterFilter::InstallFonts()
{
POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
POSITION p2 = pA->AttachedFiles.GetHeadPosition();
- while(p2)
- {
+ while(p2) {
AttachedFile* pF = pA->AttachedFiles.GetNext(p2);
- if(pF->FileMimeType == "application/x-truetype-font")
- {
+ if(pF->FileMimeType == "application/x-truetype-font") {
// assume this is a font resource
- if(BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen])
- {
+ if(BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen]) {
m_pFile->Seek(pF->FileDataPos);
- if(SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen)))
+ if(SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
m_fontinst.InstallFont(pData, (UINT)pF->FileDataLen);
+ }
delete [] pData;
}
@@ -772,28 +748,28 @@ void CMatroskaSplitterFilter::SendVorbisHeaderSample()
HRESULT hr;
POSITION pos = m_pTrackEntryMap.GetStartPosition();
- while(pos)
- {
+ while(pos) {
DWORD TrackNumber = 0;
TrackEntry* pTE = NULL;
m_pTrackEntryMap.GetNextAssoc(pos, TrackNumber, pTE);
CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNumber);
- if(!(pTE && pPin && pPin->IsConnected()))
+ if(!(pTE && pPin && pPin->IsConnected())) {
continue;
+ }
if(pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
- && pTE->CodecPrivate.GetCount() > 0)
- {
+ && pTE->CodecPrivate.GetCount() > 0) {
BYTE* ptr = pTE->CodecPrivate.GetData();
CAtlList<int> sizes;
long last = 0;
- for(BYTE n = *ptr++; n > 0; n--)
- {
+ for(BYTE n = *ptr++; n > 0; n--) {
int size = 0;
- do {size += *ptr;} while(*ptr++ == 0xff);
+ do {
+ size += *ptr;
+ } while(*ptr++ == 0xff);
sizes.AddTail(size);
last += size;
}
@@ -802,23 +778,24 @@ void CMatroskaSplitterFilter::SendVorbisHeaderSample()
hr = S_OK;
POSITION pos = sizes.GetHeadPosition();
- while(pos && SUCCEEDED(hr))
- {
+ while(pos && SUCCEEDED(hr)) {
long len = sizes.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = (DWORD)pTE->TrackNumber;
- p->rtStart = 0; p->rtStop = 1;
+ p->rtStart = 0;
+ p->rtStop = 1;
p->bSyncPoint = FALSE;
-
+
p->SetData(ptr, len);
ptr += len;
-
+
hr = DeliverPacket(p);
}
- if(FAILED(hr))
+ if(FAILED(hr)) {
TRACE(_T("ERROR: Vorbis initialization failed for stream %I64d\n"), TrackNumber);
+ }
}
}
}
@@ -829,14 +806,14 @@ bool CMatroskaSplitterFilter::DemuxInit()
CMatroskaNode Root(m_pFile);
if(!m_pFile
- || !(m_pSegment = Root.Child(0x18538067))
- || !(m_pCluster = m_pSegment->Child(0x1F43B675)))
+ || !(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.GetCount() == 0)
- {
+ if(m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.GetCount() == 0) {
m_nOpenProgress = 0;
m_pFile->m_segment.SegmentInfo.Duration.Set(0);
@@ -844,8 +821,7 @@ bool CMatroskaSplitterFilter::DemuxInit()
CAutoPtr<Cue> pCue(DNew Cue());
- do
- {
+ do {
Cluster c;
c.ParseTimeCode(m_pCluster);
@@ -862,17 +838,20 @@ bool CMatroskaSplitterFilter::DemuxInit()
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);
+ if(CheckRequest(&cmd)) {
+ if(cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
}
- }
- while(!m_fAbort && m_pCluster->Next(true));
+ } while(!m_fAbort && m_pCluster->Next(true));
m_nOpenProgress = 100;
- if(!m_fAbort) m_pFile->m_segment.Cues.AddTail(pCue);
+ if(!m_fAbort) {
+ m_pFile->m_segment.Cues.AddTail(pCue);
+ }
m_fAbort = false;
}
@@ -888,8 +867,7 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
m_pCluster = m_pSegment->Child(0x1F43B675);
m_pBlock.Free();
- if(rt > 0)
- {
+ if(rt > 0) {
rt += m_pFile->m_rtOffset;
MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD)-1;
@@ -899,28 +877,28 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
UINT64 TrackNumber = s.GetMasterTrack();
POSITION pos1 = s.Cues.GetHeadPosition();
- while(pos1)
- {
+ while(pos1) {
Cue* pCue = s.Cues.GetNext(pos1);
POSITION pos2 = pCue->CuePoints.GetTailPosition();
- while(pos2)
- {
+ while(pos2) {
CuePoint* pCuePoint = pCue->CuePoints.GetPrev(pos2);
- if(rt < s.GetRefTime(pCuePoint->CueTime))
+ if(rt < s.GetRefTime(pCuePoint->CueTime)) {
continue;
+ }
POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while(pos3)
- {
+ while(pos3) {
CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
- if(TrackNumber != pCueTrackPositions->CueTrack)
+ if(TrackNumber != pCueTrackPositions->CueTrack) {
continue;
+ }
- if(lastCueClusterPosition == pCueTrackPositions->CueClusterPosition)
+ if(lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
continue;
+ }
lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
@@ -928,68 +906,60 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
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
-*/
+ /*
+ 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())
- {
+ if(CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
bool fPassedCueTime = false;
- do
- {
+ do {
CBlockGroupNode bgn;
- if(pBlock->m_id == 0xA0)
- {
+ if(pBlock->m_id == 0xA0) {
bgn.Parse(pBlock, true);
- }
- else if(pBlock->m_id == 0xA3)
- {
+ } else if(pBlock->m_id == 0xA3) {
CAutoPtr<BlockGroup> bg(DNew BlockGroup());
bg->Block.Parse(pBlock, true);
- if(!(bg->Block.Lacing & 0x80)) bg->ReferenceBlock.Set(0); // not a kf
+ if(!(bg->Block.Lacing & 0x80)) {
+ bg->ReferenceBlock.Set(0); // not a kf
+ }
bgn.AddTail(bg);
}
POSITION pos4 = bgn.GetHeadPosition();
- while(!fPassedCueTime && pos4)
- {
+ 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
- {
+ || 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())
- {
+ } else if(bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
fFoundKeyFrame = true;
m_pBlock = pBlock->Copy();
}
}
- }
- while(!fPassedCueTime && pBlock->NextBlock());
+ } while(!fPassedCueTime && pBlock->NextBlock());
}
}
- if(fFoundKeyFrame)
+ if(fFoundKeyFrame) {
pos1 = pos2 = pos3 = NULL;
+ }
}
}
}
- if(!m_pBlock)
- {
+ if(!m_pBlock) {
m_pCluster = m_pSegment->Child(0x1F43B675);
}
}
@@ -998,35 +968,35 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
bool CMatroskaSplitterFilter::DemuxLoop()
{
HRESULT hr = S_OK;
-
+
SendVorbisHeaderSample(); // HACK: init vorbis decoder with the headers
- do
- {
+ do {
Cluster c;
c.ParseTimeCode(m_pCluster);
- if(!m_pBlock) m_pBlock = m_pCluster->GetFirstBlock();
- if(!m_pBlock) continue;
+ if(!m_pBlock) {
+ m_pBlock = m_pCluster->GetFirstBlock();
+ }
+ if(!m_pBlock) {
+ continue;
+ }
- do
- {
+ do {
CBlockGroupNode bgn;
- if(m_pBlock->m_id == 0xA0)
- {
+ if(m_pBlock->m_id == 0xA0) {
bgn.Parse(m_pBlock, true);
- }
- else if(m_pBlock->m_id == 0xA3)
- {
+ } else if(m_pBlock->m_id == 0xA3) {
CAutoPtr<BlockGroup> bg(DNew BlockGroup());
bg->Block.Parse(m_pBlock, true);
- if(!(bg->Block.Lacing & 0x80)) bg->ReferenceBlock.Set(0); // not a kf
+ if(!(bg->Block.Lacing & 0x80)) {
+ bg->ReferenceBlock.Set(0); // not a kf
+ }
bgn.AddTail(bg);
}
- while(bgn.GetCount() && SUCCEEDED(hr))
- {
+ while(bgn.GetCount() && SUCCEEDED(hr)) {
CAutoPtr<MatroskaPacket> p(DNew MatroskaPacket());
p->bg = bgn.RemoveHead();
@@ -1034,22 +1004,22 @@ bool CMatroskaSplitterFilter::DemuxLoop()
p->TrackNumber = (DWORD)p->bg->Block.TrackNumber;
TrackEntry* pTE = NULL;
-
- if (!m_pTrackEntryMap.Lookup (p->TrackNumber, pTE) || !pTE) continue;
+
+ 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())
- {
+ 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)
- {
+ while(pos) {
CBinary* pb = p->bg->Block.BlockData.GetNext(pos);
pTE->Expand(*pb, ContentEncoding::AllFrameContents);
}
@@ -1060,13 +1030,11 @@ bool CMatroskaSplitterFilter::DemuxLoop()
hr = DeliverPacket(p);
}
- }
- while(m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
+ } while(m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
m_pBlock.Free();
- }
- while(m_pFile->GetPos() < m_pFile->m_segment.pos + m_pFile->m_segment.len
- && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
+ } while(m_pFile->GetPos() < m_pFile->m_segment.pos + m_pFile->m_segment.len
+ && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
m_pCluster.Free();
@@ -1077,14 +1045,18 @@ bool CMatroskaSplitterFilter::DemuxLoop()
STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
HRESULT hr = S_OK;
nKFs = 0;
POSITION pos = m_pFile->m_segment.Cues.GetHeadPosition();
- while(pos) nKFs += m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
+ while(pos) {
+ nKFs += m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
+ }
return hr;
}
@@ -1094,19 +1066,23 @@ STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENC
CheckPointer(pFormat, E_POINTER);
CheckPointer(pKFs, E_POINTER);
- if(!m_pFile) return E_UNEXPECTED;
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) return E_INVALIDARG;
+ 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)
- {
+ while(pos1 && nKFsTmp < nKFs) {
Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while(pos2 && nKFsTmp < nKFs)
+ while(pos2 && nKFsTmp < nKFs) {
pKFs[nKFsTmp++] = m_pFile->m_segment.GetRefTime(pCue->CuePoints.GetNext(pos2)->CueTime);
+ }
}
nKFs = nKFsTmp;
@@ -1130,8 +1106,8 @@ CMatroskaSourceFilter::CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CMatroskaSplitterOutputPin::CMatroskaSplitterOutputPin(
- int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
+ 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)
{
@@ -1160,22 +1136,23 @@ HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream()
// send out the last remaining packets from the queue
- while(m_rob.GetCount())
- {
+ while(m_rob.GetCount()) {
MatroskaPacket* mp = m_rob.RemoveHead();
- if(m_rob.GetCount() && !mp->bg->BlockDuration.IsValid())
+ if(m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
mp->rtStop = m_rob.GetHead()->rtStart;
- else if(m_rob.GetCount() == 0 && m_rtDefaultDuration > 0)
+ } else if(m_rob.GetCount() == 0 && m_rtDefaultDuration > 0) {
mp->rtStop = mp->rtStart + m_rtDefaultDuration;
+ }
timeoverride to = {mp->rtStart, mp->rtStop};
m_tos.AddTail(to);
}
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if(hr != S_OK) return hr;
+ if(hr != S_OK) {
+ return hr;
+ }
}
return __super::DeliverEndOfStream();
@@ -1184,7 +1161,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream()
HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
MatroskaPacket* mp = dynamic_cast<MatroskaPacket*>(p.m_p);
- if(!mp) return __super::DeliverPacket(p);
+ if(!mp) {
+ return __super::DeliverPacket(p);
+ }
// don't try to understand what's happening here, it's magic
@@ -1196,50 +1175,52 @@ HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_packets.AddTail(p2);
POSITION pos = m_rob.GetTailPosition();
- for(int i = m_nMinCache-1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; i--)
+ 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);
+ if(!pos) {
+ m_rob.AddHead(mp);
+ } else {
+ m_rob.InsertAfter(pos, mp);
+ }
mp = NULL;
- if(m_rob.GetCount() == m_nMinCache+1)
- {
+ 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())
- {
+ 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);
-*/
+ 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
- {
+ } else {
mp1->rtStop = mp2->rtStart;
}
}
}
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
mp = m_packets.GetHead();
- if(!mp->bg->BlockDuration.IsValid()) break;
-
+ 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;
+ if(hr != S_OK) {
+ return hr;
+ }
}
return S_OK;
@@ -1249,26 +1230,24 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
{
HRESULT hr = S_FALSE;
- if(m_tos.GetCount())
- {
+ if(m_tos.GetCount()) {
timeoverride to = m_tos.RemoveHead();
-// if(p->TrackNumber == 2)
- TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
- p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
- QueueCount());
-/**/
+ // if(p->TrackNumber == 2)
+ TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
+ p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
+ QueueCount());
+ /**/
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;
+
+ 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)
- {
+ while(pos) {
CAutoPtr<Packet> tmp(DNew Packet());
tmp->TrackNumber = p->TrackNumber;
tmp->bDiscontinuity = p->bDiscontinuity;
@@ -1276,7 +1255,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
tmp->rtStart = rtStart;
tmp->rtStop = rtStop;
tmp->Copy(*p->bg->Block.BlockData.GetNext(pos));
- if(S_OK != (hr = DeliverPacket(tmp))) break;
+ if(S_OK != (hr = DeliverPacket(tmp))) {
+ break;
+ }
rtStart += rtDelta;
rtStop += rtDelta;
@@ -1285,11 +1266,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
p->bDiscontinuity = false;
}
- if(m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4))
- {
+ if(m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
POSITION pos = p->bg->ba.bm.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const BlockMore* bm = p->bg->ba.bm.GetNext(pos);
CAutoPtr<Packet> tmp(DNew Packet());
tmp->TrackNumber = p->TrackNumber;
@@ -1298,7 +1277,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
tmp->rtStart = p->rtStart;
tmp->rtStop = p->rtStop;
tmp->Copy(bm->BlockAdditional);
- if(S_OK != (hr = DeliverPacket(tmp))) break;
+ if(S_OK != (hr = DeliverPacket(tmp))) {
+ break;
+ }
}
}
@@ -1309,28 +1290,31 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
TrackEntry* CMatroskaSplitterFilter::GetTrackEntryAt(UINT aTrackIdx)
{
- if(aTrackIdx < 0 || aTrackIdx >= m_pOrderedTrackArray.GetCount())
- return NULL;
+ if(aTrackIdx < 0 || aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
+ return NULL;
+ }
return m_pOrderedTrackArray[aTrackIdx];
}
STDMETHODIMP_(UINT) CMatroskaSplitterFilter::GetTrackCount()
-{
+{
return m_pTrackEntryMap.GetCount();
}
STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return FALSE;
+ }
pStructureToFill->FlagDefault = !!pTE->FlagDefault;
pStructureToFill->FlagForced = !!pTE->FlagForced;
pStructureToFill->FlagLacing = !!pTE->FlagLacing;
strncpy(pStructureToFill->Language, pTE->Language, 3);
- if(pStructureToFill->Language[0] == '\0')
+ if(pStructureToFill->Language[0] == '\0') {
strncpy(pStructureToFill->Language, "eng", 3);
+ }
pStructureToFill->Language[3] = '\0';
pStructureToFill->MaxCache = (UINT)pTE->MaxCache;
pStructureToFill->MinCache = (UINT)pTE->MinCache;
@@ -1341,15 +1325,15 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct
STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return FALSE;
+ }
- if(pTE->TrackType == TrackEntry::TypeVideo)
- {
+ if(pTE->TrackType == TrackEntry::TypeVideo) {
TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
- pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
+ pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
pTEIV->DisplayUnit = (BYTE)pTE->v.DisplayUnit;
- pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
+ pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
pTEIV->DisplayHeight = (UINT)pTE->v.DisplayHeight;
pTEIV->Interlaced = !!pTE->v.FlagInterlaced;
pTEIV->PixelWidth = (UINT)pTE->v.PixelWidth;
@@ -1363,46 +1347,51 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx
} else {
return FALSE;
}
-
+
return TRUE;
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackName(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->Name.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecID(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->CodecID.ToString().AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecName(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->CodecName.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecInfoURL(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->CodecInfoURL.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecDownloadURL(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->CodecDownloadURL.AllocSysString();
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
index ae47a7d83..a81b6d45a 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
+++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,11 +30,12 @@
class MatroskaPacket : public Packet
{
protected:
- int GetDataSize()
- {
+ int GetDataSize() {
int size = 0;
POSITION pos = bg->Block.BlockData.GetHeadPosition();
- while(pos) {size += bg->Block.BlockData.GetNext(pos)->GetCount();}
+ while(pos) {
+ size += bg->Block.BlockData.GetNext(pos)->GetCount();
+ }
return size;
}
public:
@@ -52,7 +53,9 @@ class CMatroskaSplitterOutputPin : public CBaseSplitterOutputPin
CAutoPtrList<MatroskaPacket> m_packets;
CAtlList<MatroskaPacket*> m_rob;
- typedef struct {REFERENCE_TIME rtStart, rtStop;} timeoverride;
+ typedef struct {
+ REFERENCE_TIME rtStart, rtStop;
+ } timeoverride;
CAtlList<timeoverride> m_tos;
protected:
@@ -60,7 +63,7 @@ protected:
public:
CMatroskaSplitterOutputPin(
- int nMinCache, REFERENCE_TIME rtDefaultDuration,
+ int nMinCache, REFERENCE_TIME rtDefaultDuration,
CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
virtual ~CMatroskaSplitterOutputPin();
@@ -69,7 +72,7 @@ public:
};
class __declspec(uuid("149D2E01-C32E-4939-80F6-C07B81015A7A"))
-CMatroskaSplitterFilter : public CBaseSplitterFilter, public ITrackInfo
+ CMatroskaSplitterFilter : public CBaseSplitterFilter, public ITrackInfo
{
void SetupChapters(LPCSTR lng, MatroskaReader::ChapterAtom* parent, int level = 0);
void InstallFonts();
@@ -83,7 +86,7 @@ protected:
CAtlMap<DWORD, MatroskaReader::TrackEntry*> m_pTrackEntryMap;
CAtlArray<MatroskaReader::TrackEntry* > m_pOrderedTrackArray;
- MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
+ MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
bool DemuxInit();
void DemuxSeek(REFERENCE_TIME rt);
@@ -94,7 +97,7 @@ public:
virtual ~CMatroskaSplitterFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IKeyFrameInfo
@@ -104,7 +107,7 @@ public:
// ITrackInfo
STDMETHODIMP_(UINT) GetTrackCount();
- STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
+ 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);
@@ -114,7 +117,7 @@ public:
};
class __declspec(uuid("0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4"))
-CMatroskaSourceFilter : public CMatroskaSplitterFilter
+ CMatroskaSourceFilter : public CMatroskaSplitterFilter
{
public:
CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.cpp b/src/filters/parser/MatroskaSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MatroskaSplitter/stdafx.cpp
+++ b/src/filters/parser/MatroskaSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.h b/src/filters/parser/MatroskaSplitter/stdafx.h
index 7e2652f5d..37bcea3a7 100644
--- a/src/filters/parser/MatroskaSplitter/stdafx.h
+++ b/src/filters/parser/MatroskaSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.cpp b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
index fef3f7d1a..11f7322c9 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitter.cpp
+++ b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,26 +27,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMpaSplitterFilter), L"MPC - Mpa Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMpaSourceFilter), L"MPC - Mpa Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpaSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpaSourceFilter>, NULL, &sudFilter[1]},
};
@@ -85,9 +81,9 @@ CMpaSplitterFilter::CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
STDMETHODIMP CMpaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -100,8 +96,13 @@ HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
CAtlArray<CMediaType> mts;
mts.Add(m_pFile->GetMediaType());
@@ -113,12 +114,24 @@ HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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);
+ 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.GetCount() > 0 ? S_OK : E_FAIL;
}
@@ -136,7 +149,9 @@ STDMETHODIMP CMpaSplitterFilter::GetDuration(LONGLONG* pDuration)
bool CMpaSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CMpaSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
// TODO
@@ -148,13 +163,10 @@ void CMpaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 startpos = m_pFile->GetStartPos();
__int64 endpos = m_pFile->GetEndPos();
- if(rt <= 0 || m_pFile->GetDuration() <= 0)
- {
+ if(rt <= 0 || m_pFile->GetDuration() <= 0) {
m_pFile->Seek(startpos);
m_rtStart = 0;
- }
- else
- {
+ } else {
m_pFile->Seek(startpos + (__int64)((1.0 * rt / m_pFile->GetDuration()) * (endpos - startpos)));
m_rtStart = rt;
}
@@ -168,9 +180,11 @@ bool CMpaSplitterFilter::DemuxLoop()
int FrameSize;
REFERENCE_TIME rtDuration;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9)
- {
- if(!m_pFile->Sync(FrameSize, rtDuration)) {Sleep(1); continue;}
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9) {
+ if(!m_pFile->Sync(FrameSize, rtDuration)) {
+ Sleep(1);
+ continue;
+ }
CAutoPtr<Packet> p(DNew Packet());
p->SetCount(FrameSize);
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.h b/src/filters/parser/MpaSplitter/MpaSplitter.h
index cae3c8b9a..064a91d36 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitter.h
+++ b/src/filters/parser/MpaSplitter/MpaSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,7 +25,7 @@
#include "MpaSplitterFile.h"
class __declspec(uuid("0E9D4BF7-CBCB-46C7-BD80-4EF223A3DC2B"))
-CMpaSplitterFilter : public CBaseSplitterFilter
+ CMpaSplitterFilter : public CBaseSplitterFilter
{
REFERENCE_TIME m_rtStart;
@@ -43,11 +43,11 @@ public:
CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
class __declspec(uuid("59A0DB73-0287-4C9A-9D3C-8CFF39F8E5DB"))
-CMpaSourceFilter : public CMpaSplitterFilter
+ CMpaSourceFilter : public CMpaSplitterFilter
{
public:
CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
index fc5f8399c..d26b70bb7 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
+++ b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,43 +28,42 @@
//
-static const LPCTSTR s_genre[] =
-{
+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("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("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("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("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("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("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("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("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("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("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"),
};
@@ -79,7 +78,9 @@ CMpaSplitterFile::CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr)
, m_endpos(0)
, m_totalbps(0)
{
- if(SUCCEEDED(hr)) hr = Init();
+ if(SUCCEEDED(hr)) {
+ hr = Init();
+ }
}
HRESULT CMpaSplitterFile::Init()
@@ -89,19 +90,18 @@ HRESULT CMpaSplitterFile::Init()
Seek(0);
- if(BitRead(24, true) == 0x000001)
+ if(BitRead(24, true) == 0x000001) {
return E_FAIL;
+ }
- if(m_endpos > 128 && IsRandomAccess())
- {
+ if(m_endpos > 128 && IsRandomAccess()) {
Seek(m_endpos - 128);
- if(BitRead(24) == 'TAG')
- {
+ if(BitRead(24) == 'TAG') {
m_endpos -= 128;
CStringA str;
-
+
// title
ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
m_tags['TIT2'] = CStringW(str).Trim();
@@ -120,17 +120,19 @@ HRESULT CMpaSplitterFile::Init()
// comment
ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['COMM'] = CStringW(str).Trim();
+ 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]);
+ 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))
+ if(genre < countof(s_genre)) {
m_tags['TCON'] = CStringW(s_genre[genre]);
+ }
}
}
@@ -138,8 +140,7 @@ HRESULT CMpaSplitterFile::Init()
bool MP3_find = false;
- while(BitRead(24, true) == 'ID3')
- {
+ while(BitRead(24, true) == 'ID3') {
MP3_find = true;
BitRead(24);
@@ -151,25 +152,31 @@ HRESULT CMpaSplitterFile::Init()
BYTE flags = (BYTE)BitRead(8);
UNUSED_ALWAYS(flags);
DWORD size = 0;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7) << 21;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7) << 14;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7) << 7;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7);
m_startpos = GetPos() + size;
// TODO: read extended header
- if(major <= 4)
- {
+ if(major <= 4) {
__int64 pos = GetPos();
- while(pos < m_startpos)
- {
+ while(pos < m_startpos) {
Seek(pos);
DWORD tag = (DWORD)BitRead(32);
@@ -183,16 +190,16 @@ HRESULT CMpaSplitterFile::Init()
pos += 4+4+2+size;
- if(!size || pos >= m_startpos)
+ if(!size || pos >= m_startpos) {
break;
+ }
if(tag == 'TIT2'
- || tag == 'TPE1'
- || tag == 'TALB'
- || tag == 'TYER'
- || tag == 'COMM'
- || tag == 'TRCK')
- {
+ || tag == 'TPE1'
+ || tag == 'TALB'
+ || tag == 'TYER'
+ || tag == 'COMM'
+ || tag == 'TRCK') {
BYTE encoding = (BYTE)BitRead(8);
size--;
@@ -201,45 +208,41 @@ HRESULT CMpaSplitterFile::Init()
CStringA str;
CStringW wstr;
- if(encoding > 0 && size >= 2 && bom == 0xfffe)
- {
- BitRead(16);
+ 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)
- {
+ } 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));
+ 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
- {
+ } 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++)
+ for(int i = 0; i < (1<<20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
BitRead(8), m_startpos++;
+ }
}
__int64 searchlen;
__int64 startpos;
__int64 syncpos;
- if(MP3_find)
- {
+ if(MP3_find) {
__int64 startpos_mp3 = m_startpos;
- while (m_mode == none)
- {
+ while (m_mode == none) {
searchlen = min(m_endpos - startpos_mp3, 0x200);
Seek(startpos_mp3);
@@ -247,45 +250,48 @@ HRESULT CMpaSplitterFile::Init()
syncpos = startpos_mp3 + searchlen;
// Check for a valid MPA header
- if(Read(m_mpahdr, searchlen, true, &m_mt))
- {
+ 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))
+ if(!Sync(4)) {
m_mode = none;
- else
+ } else {
break;
+ }
}
// If we have enough room to search for a valid header, then skip ahead and try again
- if (m_endpos - syncpos >= 8)
+ if (m_endpos - syncpos >= 8) {
startpos_mp3 = syncpos;
- else
+ } else {
break;
+ }
}
}
searchlen = min(m_endpos - m_startpos, m_startpos > 0 ? 0x200 : 7);
Seek(m_startpos);
- if(m_mode == none && Read(m_aachdr, searchlen, &m_mt))
- {
+ 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(!Sync(9)) {
+ m_mode = none;
+ }
}
- if(m_mode == none)
+ if(m_mode == none) {
return E_FAIL;
+ }
m_startpos = startpos;
@@ -293,12 +299,13 @@ HRESULT CMpaSplitterFile::Init()
REFERENCE_TIME rtFrameDur, rtPrevDur = -1;
clock_t start = clock();
int i = 0;
- while(Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC)
- {
+ 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;
+ if(i == 10) {
+ break;
+ }
rtPrevDur = m_rtDuration;
}
@@ -316,18 +323,14 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi
{
__int64 endpos = min(m_endpos, GetPos() + limit);
- if(m_mode == mpa)
- {
- while(GetPos() <= endpos - 4)
- {
+ if(m_mode == mpa) {
+ while(GetPos() <= endpos - 4) {
mpahdr h;
- if(Read(h, endpos - GetPos(), true))
- {
+ if(Read(h, endpos - GetPos(), true)) {
if (m_mpahdr.version == h.version
- && m_mpahdr.layer == h.layer
- && m_mpahdr.channels == h.channels)
- {
+ && m_mpahdr.layer == h.layer
+ && m_mpahdr.channels == h.channels) {
Seek(GetPos() - 4);
AdjustDuration(h.nBytesPerSec);
@@ -336,23 +339,18 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi
return true;
}
- }
- else
+ } else {
break;
+ }
}
- }
- else if(m_mode == mp4a)
- {
- while(GetPos() <= endpos - 9)
- {
+ } else if(m_mode == mp4a) {
+ while(GetPos() <= endpos - 9) {
aachdr h;
- if(Read(h, endpos - GetPos()))
- {
+ if(Read(h, endpos - GetPos())) {
if (m_aachdr.version == h.version
- && m_aachdr.layer == h.layer
- && m_aachdr.channels == h.channels)
- {
+ && 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));
@@ -362,9 +360,9 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi
return true;
}
- }
- else
+ } else {
break;
+ }
}
}
@@ -376,10 +374,11 @@ void CMpaSplitterFile::AdjustDuration(int nBytesPerSec)
ASSERT(nBytesPerSec);
int rValue;
- if(!m_pos2bps.Lookup(GetPos(), rValue))
- {
+ if(!m_pos2bps.Lookup(GetPos(), rValue)) {
m_totalbps += nBytesPerSec;
- if(!m_totalbps) return;
+ 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
index 2bd3a9a40..2c95f4af7 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.h
+++ b/src/filters/parser/MpaSplitter/MpaSplitterFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -45,11 +45,19 @@ public:
CAtlMap<DWORD, CStringW> m_tags;
- const CMediaType& GetMediaType() {return m_mt;}
- REFERENCE_TIME GetDuration() {return IsRandomAccess() ? m_rtDuration : 0;}
+ const CMediaType& GetMediaType() {
+ return m_mt;
+ }
+ REFERENCE_TIME GetDuration() {
+ return IsRandomAccess() ? m_rtDuration : 0;
+ }
- __int64 GetStartPos() {return m_startpos;}
- __int64 GetEndPos() {return m_endpos;}
+ __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/stdafx.cpp b/src/filters/parser/MpaSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MpaSplitter/stdafx.cpp
+++ b/src/filters/parser/MpaSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpaSplitter/stdafx.h b/src/filters/parser/MpaSplitter/stdafx.h
index 7fbf4d9ac..114712db9 100644
--- a/src/filters/parser/MpaSplitter/stdafx.h
+++ b/src/filters/parser/MpaSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
index 879a773de..9a29a446e 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp
+++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* (C) 2003-2006 Gabest
* (C) 2006-2010 see AUTHORS
* http://www.gabest.org
@@ -7,12 +7,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,30 +31,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System},
-// {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1VideoCD}, // cdxa filter should take care of this
+ // {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1VideoCD}, // cdxa filter should take care of this
{&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, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL},
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL},
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMpegSplitterFilter), L"MPC - Mpeg Splitter (Gabest)", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMpegSourceFilter), L"MPC - Mpeg Source (Gabest)", MERIT_UNLIKELY, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpegSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpegSourceFilter>, NULL, &sudFilter[1]},
};
@@ -73,15 +69,15 @@ STDAPI DllRegisterServer()
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, NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_TRANSPORT, chkbytes, NULL);
return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
-// UnRegisterSourceFilter(MEDIASUBTYPE_MPEG1System);
-// UnRegisterSourceFilter(MEDIASUBTYPE_MPEG2_PROGRAM);
+ // UnRegisterSourceFilter(MEDIASUBTYPE_MPEG1System);
+ // UnRegisterSourceFilter(MEDIASUBTYPE_MPEG2_PROGRAM);
return AMovieDllRegisterServer2(FALSE);
}
@@ -104,19 +100,21 @@ static int GetHighestBitSet32(unsigned long _Value)
{
unsigned long Ret;
unsigned char bNonZero = _BitScanReverse(&Ret, _Value);
- if (bNonZero)
+ if (bNonZero) {
return Ret;
- else
+ } else {
return -1;
+ }
}
CString FormatBitrate(double _Bitrate)
{
CString Temp;
- if (_Bitrate > 20000000) // More than 2 mbit
+ if (_Bitrate > 20000000) { // More than 2 mbit
Temp.Format(L"%.2f mbit/s", double(_Bitrate)/1000000.0);
- else
+ } else {
Temp.Format(L"%.1f kbit/s", double(_Bitrate)/1000.0);
+ }
return Temp;
}
@@ -138,55 +136,49 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
{
const WCHAR *pPresentationDesc = NULL;
- if (pClipInfo)
+ if (pClipInfo) {
pPresentationDesc = StreamTypeToName(pClipInfo->m_Type);
- else
+ } else {
pPresentationDesc = StreamTypeToName((PES_STREAM_TYPE)_PresentationType);
+ }
CString MajorType;
CAtlList<CString> Infos;
- if (_pMediaType->majortype == MEDIATYPE_Video)
- {
+ if (_pMediaType->majortype == MEDIATYPE_Video) {
MajorType = "Video";
- if (pClipInfo)
- {
+ if (pClipInfo) {
CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty())
+ if (!name.IsEmpty()) {
Infos.AddTail(name);
+ }
}
const VIDEOINFOHEADER *pVideoInfo = NULL;
const VIDEOINFOHEADER2 *pVideoInfo2 = NULL;
- if (_pMediaType->formattype == FORMAT_MPEGVideo)
- {
+ 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)
- {
+ } else if (_pMediaType->formattype == FORMAT_MPEG2_VIDEO) {
const MPEG2VIDEOINFO *pInfo = GetFormatHelper(pInfo, _pMediaType);
pVideoInfo2 = &pInfo->hdr;
bool bIsAVC = false;
- if (pInfo->hdr.bmiHeader.biCompression == '1CVA')
- {
+ if (pInfo->hdr.bmiHeader.biCompression == '1CVA') {
bIsAVC = true;
Infos.AddTail(L"AVC (H.264)");
- }
- else if (pInfo->hdr.bmiHeader.biCompression == 0)
+ } else if (pInfo->hdr.bmiHeader.biCompression == 0) {
Infos.AddTail(L"MPEG2");
- else
- {
+ } else {
WCHAR Temp[5];
memset(Temp, 0, sizeof(Temp));
Temp[0] = (pInfo->hdr.bmiHeader.biCompression >> 0) & 0xFF;
@@ -196,70 +188,96 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
Infos.AddTail(Temp);
}
- switch (pInfo->dwProfile)
- {
- case AM_MPEG2Profile_Simple: Infos.AddTail(L"Simple Profile"); break;
- case AM_MPEG2Profile_Main: Infos.AddTail(L"Main Profile"); break;
- case AM_MPEG2Profile_SNRScalable: Infos.AddTail(L"SNR Scalable Profile"); break;
- case AM_MPEG2Profile_SpatiallyScalable: Infos.AddTail(L"Spatially Scalable Profile"); break;
- case AM_MPEG2Profile_High: Infos.AddTail(L"High Profile"); break;
- default:
- 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 122: Infos.AddTail(L"High 4:2:2 Profile"); break;
- case 244: Infos.AddTail(L"High 4:4:4 Profile"); break;
-
- default: Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile)); break;
+ switch (pInfo->dwProfile) {
+ case AM_MPEG2Profile_Simple:
+ Infos.AddTail(L"Simple Profile");
+ break;
+ case AM_MPEG2Profile_Main:
+ Infos.AddTail(L"Main Profile");
+ break;
+ case AM_MPEG2Profile_SNRScalable:
+ Infos.AddTail(L"SNR Scalable Profile");
+ break;
+ case AM_MPEG2Profile_SpatiallyScalable:
+ Infos.AddTail(L"Spatially Scalable Profile");
+ break;
+ case AM_MPEG2Profile_High:
+ Infos.AddTail(L"High Profile");
+ break;
+ default:
+ 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 122:
+ Infos.AddTail(L"High 4:2:2 Profile");
+ break;
+ case 244:
+ Infos.AddTail(L"High 4:4:4 Profile");
+ break;
+
+ default:
+ Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
+ break;
+ }
+ } else {
+ Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
}
}
- else
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- }
- break;
+ break;
}
- switch (pInfo->dwLevel)
- {
- case AM_MPEG2Level_Low: Infos.AddTail(L"Low Level"); break;
- case AM_MPEG2Level_Main: Infos.AddTail(L"Main Level"); break;
- case AM_MPEG2Level_High1440: Infos.AddTail(L"High1440 Level"); break;
- case AM_MPEG2Level_High: Infos.AddTail(L"High Level"); break;
- default:
- 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));
- }
- break;
+ switch (pInfo->dwLevel) {
+ case AM_MPEG2Level_Low:
+ Infos.AddTail(L"Low Level");
+ break;
+ case AM_MPEG2Level_Main:
+ Infos.AddTail(L"Main Level");
+ break;
+ case AM_MPEG2Level_High1440:
+ Infos.AddTail(L"High1440 Level");
+ break;
+ case AM_MPEG2Level_High:
+ Infos.AddTail(L"High Level");
+ break;
+ default:
+ 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));
+ }
+ }
+ break;
}
- }
- else if (_pMediaType->formattype == FORMAT_VIDEOINFO2)
- {
+ } 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')
- {
+ if (CodecType == '1CVW') {
bIsVC1 = true;
Infos.AddTail(L"VC-1");
- }
- else if (CodecType)
- {
+ } else if (CodecType) {
WCHAR Temp[5];
memset(Temp, 0, sizeof(Temp));
Temp[0] = (CodecType >> 0) & 0xFF;
@@ -268,109 +286,91 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
Temp[3] = (CodecType >> 24) & 0xFF;
Infos.AddTail(Temp);
}
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
Infos.AddTail(L"DVD Sub Picture");
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
Infos.AddTail(L"SVCD Sub Picture");
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
Infos.AddTail(L"CVD Sub Picture");
}
- if (pVideoInfo2)
- {
- if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight)
+ if (pVideoInfo2) {
+ if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) {
Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight));
- if (pVideoInfo2->AvgTimePerFrame)
+ }
+ if (pVideoInfo2->AvgTimePerFrame) {
Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo2->AvgTimePerFrame)));
- if (pVideoInfo2->dwBitRate)
+ }
+ if (pVideoInfo2->dwBitRate) {
Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate));
- }
- else if (pVideoInfo)
- {
- if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight)
+ }
+ } 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)
+ }
+ if (pVideoInfo->AvgTimePerFrame) {
Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo->AvgTimePerFrame)));
- if (pVideoInfo->dwBitRate)
+ }
+ if (pVideoInfo->dwBitRate) {
Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate));
+ }
}
-
- }
- else if (_pMediaType->majortype == MEDIATYPE_Audio)
- {
+
+ } else if (_pMediaType->majortype == MEDIATYPE_Audio) {
MajorType = "Audio";
- if (pClipInfo)
- {
+ if (pClipInfo) {
CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty())
+ if (!name.IsEmpty()) {
Infos.AddTail(name);
+ }
}
- if (_pMediaType->formattype == FORMAT_WaveFormatEx)
- {
+ if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
const WAVEFORMATEX *pInfo = GetFormatHelper(pInfo, _pMediaType);
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)
- {
+ if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
Infos.AddTail(L"DVD LPCM");
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
const WAVEFORMATEX_HDMV_LPCM *pInfoHDMV = GetFormatHelper(pInfoHDMV, _pMediaType);
UNUSED_ALWAYS(pInfoHDMV);
Infos.AddTail(L"HDMV LPCM");
}
- if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS)
- {
+ if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
Infos.AddTail(L"Dolby Digital Plus");
- }
- else
- {
- switch (pInfo->wFormatTag)
- {
- case WAVE_FORMAT_PS2_PCM:
- {
+ } else {
+ switch (pInfo->wFormatTag) {
+ case WAVE_FORMAT_PS2_PCM: {
Infos.AddTail(L"PS2 PCM");
}
break;
- case WAVE_FORMAT_PS2_ADPCM:
- {
+ case WAVE_FORMAT_PS2_ADPCM: {
Infos.AddTail(L"PS2 ADPCM");
}
break;
- case WAVE_FORMAT_DVD_DTS:
- {
- if (pPresentationDesc)
+ case WAVE_FORMAT_DVD_DTS: {
+ if (pPresentationDesc) {
Infos.AddTail(pPresentationDesc);
- else
+ } else {
Infos.AddTail(L"DTS");
+ }
}
break;
- case WAVE_FORMAT_DOLBY_AC3:
- {
- if (pPresentationDesc)
+ case WAVE_FORMAT_DOLBY_AC3: {
+ if (pPresentationDesc) {
Infos.AddTail(pPresentationDesc);
- else
+ } else {
Infos.AddTail(L"Dolby Digital");
+ }
}
break;
- case WAVE_FORMAT_AAC:
- {
+ case WAVE_FORMAT_AAC: {
Infos.AddTail(L"AAC");
}
break;
- case WAVE_FORMAT_MP3:
- {
+ case WAVE_FORMAT_MP3: {
Infos.AddTail(L"MP3");
}
break;
- case WAVE_FORMAT_MPEG:
- {
+ case WAVE_FORMAT_MPEG: {
const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, _pMediaType);
int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
@@ -380,59 +380,57 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
}
}
- 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;
+ 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)
+ } else if (pInfo->nSamplesPerSec) {
Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0));
- if (pInfo->nChannels)
+ }
+ if (pInfo->nChannels) {
Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
- if (pInfo->wBitsPerSample)
+ }
+ if (pInfo->wBitsPerSample) {
Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
- if (pInfo->nAvgBytesPerSec)
+ }
+ if (pInfo->nAvgBytesPerSec) {
Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
+ }
}
- }
- else if (_pMediaType->majortype == MEDIATYPE_Subtitle)
- {
+ } else if (_pMediaType->majortype == MEDIATYPE_Subtitle) {
MajorType = "Subtitle";
- if (pPresentationDesc)
+ if (pPresentationDesc) {
Infos.AddTail(pPresentationDesc);
+ }
- if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO))
- {
+ if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO)) {
const SUBTITLEINFO *pInfo = GetFormatHelper(pInfo, _pMediaType);
CString name = ISO6392ToLanguage(pInfo->IsoLang);
- if (pInfo->TrackName[0])
+ if (pInfo->TrackName[0]) {
Infos.AddHead(pInfo->TrackName);
- if (!name.IsEmpty())
+ }
+ if (!name.IsEmpty()) {
Infos.AddHead(name);
- }
- else
- {
- if (pClipInfo)
- {
+ }
+ } else {
+ if (pClipInfo) {
CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty())
+ if (!name.IsEmpty()) {
Infos.AddHead(name);
+ }
}
}
}
- if (!Infos.IsEmpty())
- {
+ if (!Infos.IsEmpty()) {
CString Ret;
Ret += MajorType;
@@ -440,14 +438,14 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
bool bFirst = true;
- for(POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos))
- {
+ for(POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
CString& String = Infos.GetAt(pos);
- if (bFirst)
+ if (bFirst) {
Ret += String;
- else
+ } else {
Ret += L", " + String;
+ }
bFirst = false;
}
@@ -470,9 +468,9 @@ CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLS
STDMETHODIMP CMpegSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IAMStreamSelect)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -481,32 +479,30 @@ STDMETHODIMP CMpegSplitterFilter::GetClassID(CLSID* pClsID)
{
CheckPointer (pClsID, E_POINTER);
- if (m_pPipoBimbo)
- {
+ if (m_pPipoBimbo) {
memcpy (pClsID, &CLSID_WMAsfReader, sizeof (GUID));
return S_OK;
- }
- else
+ } else {
return __super::GetClassID(pClsID);
+ }
}
void CMpegSplitterFilter::ReadClipInfo(LPCOLESTR pszFileName)
{
- if (wcslen (pszFileName) > 0)
- {
+ 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)
- {
+
+ if (_wsplitpath_s (pszFileName, Drive, countof(Drive), Dir, countof(Dir), Filename, countof(Filename), Ext, countof(Ext)) == 0) {
CString strClipInfo;
- if (Drive[0])
+ if (Drive[0]) {
strClipInfo.Format (_T("%s\\%s\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- else
+ } else {
strClipInfo.Format (_T("%s\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
+ }
m_ClipInfo.ReadInfo (strClipInfo);
}
@@ -516,7 +512,7 @@ void CMpegSplitterFilter::ReadClipInfo(LPCOLESTR pszFileName)
STDMETHODIMP CMpegSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
HRESULT hr;
-
+
return __super::Load (pszFileName, pmt);
}
@@ -526,22 +522,21 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
HRESULT hr;
BYTE b;
- if(m_pFile->m_type == CMpegSplitterFile::ps || m_pFile->m_type == CMpegSplitterFile::es)
- {
- if(!m_pFile->NextMpegStartCode(b))
+ if(m_pFile->m_type == CMpegSplitterFile::ps || m_pFile->m_type == CMpegSplitterFile::es) {
+ if(!m_pFile->NextMpegStartCode(b)) {
return S_FALSE;
+ }
- if(b == 0xba) // program stream header
- {
+ if(b == 0xba) { // program stream header
CMpegSplitterFile::pshdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
- }
- else if(b == 0xbb) // program stream system header
- {
+ }
+ } else if(b == 0xbb) { // program stream system header
CMpegSplitterFile::pssyshdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
+ }
}
#if (EVO_SUPPORT == 0)
else if(b >= 0xbd && b < 0xf0) // pes packet
@@ -551,10 +546,11 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
{
CMpegSplitterFile::peshdr h;
- if(!m_pFile->Read(h, b) || !h.len) return S_FALSE;
+ if(!m_pFile->Read(h, b) || !h.len) {
+ return S_FALSE;
+ }
- if(h.type == CMpegSplitterFile::mpeg2 && h.scrambling)
- {
+ if(h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
ASSERT(0);
return E_FAIL;
}
@@ -563,8 +559,7 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
DWORD TrackNumber = m_pFile->AddStream(0, b, h.len);
- if(GetOutputPin(TrackNumber))
- {
+ if(GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
@@ -580,52 +575,46 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
}
m_pFile->Seek(pos + h.len);
}
- }
- else if(m_pFile->m_type == CMpegSplitterFile::ts)
- {
+ } else if(m_pFile->m_type == CMpegSplitterFile::ts) {
CMpegSplitterFile::trhdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
+ }
__int64 pos = m_pFile->GetPos();
- if(h.payload && h.payloadstart)
+ if(h.payload && h.payloadstart) {
m_pFile->UpdatePrograms(h);
+ }
- if(h.payload && h.pid >= 16 && h.pid < 0x1fff && !h.scrambling)
- {
+ if(h.payload && h.pid >= 16 && h.pid < 0x1fff && !h.scrambling) {
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)
- {
+ 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, h.bytes - (DWORD)(m_pFile->GetPos() - pos));
}
- if(GetOutputPin(TrackNumber))
- {
+ if(GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
p->bSyncPoint = !!h2.fpts;
p->bAppendable = !h2.fpts;
- if (h.fPCR)
- {
+ if (h.fPCR) {
CRefTime rtNow;
StreamTime(rtNow);
TRACE ("Now=%S PCR=%S\n", ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
}
- if (h2.fpts && h.pid == 241)
- {
+ if (h2.fpts && h.pid == 241) {
TRACE ("Sub=%S\n", ReftimeToString(h2.pts - rtStartOffset));
}
@@ -641,19 +630,17 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
}
m_pFile->Seek(h.next);
- }
- else if(m_pFile->m_type == CMpegSplitterFile::pva)
- {
+ } else if(m_pFile->m_type == CMpegSplitterFile::pva) {
CMpegSplitterFile::pvahdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
+ }
DWORD TrackNumber = h.streamid;
__int64 pos = m_pFile->GetPos();
- if(GetOutputPin(TrackNumber))
- {
+ if(GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
@@ -686,22 +673,20 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
ReadClipInfo (GetPartFilename(pAsyncReader));
m_pFile.Attach(DNew CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo));
- if(!m_pFile) return E_OUTOFMEMORY;
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
m_pFile.Free();
return hr;
}
// Create
- if (m_ClipInfo.IsHdmv())
- {
- for (int i=0; i<m_ClipInfo.GetStreamNumber(); i++)
- {
+ if (m_ClipInfo.IsHdmv()) {
+ for (int i=0; i<m_ClipInfo.GetStreamNumber(); i++) {
CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex (i);
- if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM)
- {
+ if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM) {
m_pFile->AddHdmvPGStream (stream->m_PID, stream->m_LanguageCode);
}
}
@@ -710,24 +695,19 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = 0;
- for(int i = 0; i < countof(m_pFile->m_streams); i++)
- {
+ for(int i = 0; i < countof(m_pFile->m_streams); i++) {
POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos)
- {
+ 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)
- {
+ if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
str = _T("No subtitles");
- }
- else
- {
+ } else {
int iProgram;
const CHdmvClipInfo::Stream *pClipInfo;
const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
@@ -737,28 +717,28 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType);
- 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 (!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(DNew CMpegSplitterOutputPin(mts, str, this, this, &hr));
- if (i == CMpegSplitterFile::subpic)
+ if (i == CMpegSplitterFile::subpic) {
(static_cast<CMpegSplitterOutputPin*>(pPinOut.m_p))->SetMaxShift (_I64_MAX);
- if(S_OK == AddOutputPin(s, pPinOut))
+ }
+ if(S_OK == AddOutputPin(s, pPinOut)) {
break;
+ }
}
}
- if(m_rtPlaylistDuration)
- {
+ if(m_rtPlaylistDuration) {
m_rtNewStop = m_rtStop = m_rtDuration = m_rtPlaylistDuration;
- }
- else if(m_pFile->IsRandomAccess() && m_pFile->m_rate)
- {
+ } else if(m_pFile->IsRandomAccess() && m_pFile->m_rate) {
m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_pFile->GetLength() / m_pFile->m_rate;
}
@@ -768,7 +748,9 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool CMpegSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CMpegSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
m_rtStartOffset = 0;
@@ -779,27 +761,22 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
CAtlList<CMpegSplitterFile::stream>* pMasterStream = m_pFile->GetMasterStream();
- if(!pMasterStream)
- {
+ if(!pMasterStream) {
ASSERT(0);
return;
}
- if(m_pFile->IsStreaming())
- {
+ 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)
- {
+
+ if(rt <= rtPreroll || m_rtDuration <= 0) {
m_pFile->Seek(0);
- }
- else
- {
+ } else {
__int64 len = m_pFile->GetLength();
__int64 seekpos = (__int64)(1.0*rt/m_rtDuration*len);
__int64 minseekpos = _I64_MAX;
@@ -808,50 +785,46 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
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);
+ 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);
+ CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNum);
+ if(pPin && pPin->IsConnected()) {
+ m_pFile->Seek(seekpos);
- REFERENCE_TIME pdt = _I64_MIN;
+ REFERENCE_TIME pdt = _I64_MIN;
- for(int j = 0; j < 10; j++)
- {
- REFERENCE_TIME rt = m_pFile->NextPTS(TrackNum);
+ for(int j = 0; j < 10; j++) {
+ REFERENCE_TIME rt = m_pFile->NextPTS(TrackNum);
- if(rt < 0) break;
+ if(rt < 0) {
+ break;
+ }
- REFERENCE_TIME dt = rt - rtmax;
- if(dt > 0 && dt == pdt) dt = 10000000i64;
+ REFERENCE_TIME dt = rt - rtmax;
+ if(dt > 0 && dt == pdt) {
+ dt = 10000000i64;
+ }
- if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0)
- {
- minseekpos = min(minseekpos, m_pFile->GetPos());
- break;
- }
+ if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
+ minseekpos = min(minseekpos, m_pFile->GetPos());
+ break;
+ }
+
+ m_pFile->Seek(m_pFile->GetPos() - (__int64)(1.0*dt/m_rtDuration*len));
- m_pFile->Seek(m_pFile->GetPos() - (__int64)(1.0*dt/m_rtDuration*len));
-
- pdt = dt;
+ //pdt = dt;
+ }
}
}
}
- }
- if(minseekpos != _I64_MAX)
- {
+ if(minseekpos != _I64_MAX) {
seekpos = minseekpos;
- }
- else
- {
+ } else {
// this file is probably screwed up, try plan B, seek simply by bitrate
rt -= rtPreroll;
@@ -869,11 +842,11 @@ bool CMpegSplitterFilter::DemuxLoop()
REFERENCE_TIME rtStartOffset = m_rtStartOffset ? m_rtStartOffset : m_pFile->m_rtMin;
HRESULT hr = S_OK;
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
if((hr = m_pFile->HasMoreData(1024*500)) == S_OK)
- if((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE)
+ if((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
Sleep(1);
+ }
}
return(true);
@@ -893,63 +866,67 @@ STDMETHODIMP CMpegSplitterFilter::Count(DWORD* pcStreams)
*pcStreams = 0;
- for(int i = 0; i < countof(m_pFile->m_streams); i++)
+ 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))
+ if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
return E_NOTIMPL;
+ }
- for(int i = 0, j = 0; i < countof(m_pFile->m_streams); i++)
- {
+ for(int i = 0, j = 0; i < countof(m_pFile->m_streams); i++) {
int cnt = m_pFile->m_streams[i].GetCount();
-
- if(lIndex >= j && lIndex < j+cnt)
- {
+
+ if(lIndex >= j && lIndex < j+cnt) {
lIndex -= j;
POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if(!pos) return E_UNEXPECTED;
+ if(!pos) {
+ return E_UNEXPECTED;
+ }
CMpegSplitterFile::stream& to = m_pFile->m_streams[i].GetAt(pos);
pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CMpegSplitterFile::stream& from = m_pFile->m_streams[i].GetNext(pos);
- if(!GetOutputPin(from)) continue;
+ if(!GetOutputPin(from)) {
+ continue;
+ }
HRESULT hr;
- if(FAILED(hr = RenameOutputPin(from, to, &to.mt)))
+ if(FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
return hr;
+ }
// 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!=NULL && !m_ClipInfo.IsHdmv() && !m_pFile->IsHdmv())
- {
- for(int k = 0; k < countof(m_pFile->m_streams); k++)
- {
- if(k == i) continue;
+ if(p!=NULL && !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)
- {
+ while(pos) {
CMpegSplitterFile::stream& from = m_pFile->m_streams[k].GetNext(pos);
- if(!GetOutputPin(from)) continue;
+ 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)
+ 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;
}
}
@@ -969,67 +946,52 @@ STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags)
LONGLONG GetMediaTypeQuality(const CMediaType *_pMediaType, int _PresentationFormat)
{
- if (_pMediaType->formattype == FORMAT_WaveFormatEx)
- {
+ 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)
- {
+ if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
TypePriority = 12;
- }
- else
- {
- if (_PresentationFormat == AUDIO_STREAM_DTS_HD_MASTER_AUDIO)
+ } 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)
+ } else if (_PresentationFormat == AUDIO_STREAM_DTS_HD) {
TypePriority = 11;
- else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD)
+ } else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD) {
TypePriority = 12;
- else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS)
+ } else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS) {
TypePriority = 10;
- else
- {
- switch (pInfo->wFormatTag)
- {
- case WAVE_FORMAT_PS2_PCM:
- {
+ } else {
+ switch (pInfo->wFormatTag) {
+ case WAVE_FORMAT_PS2_PCM: {
TypePriority = 12;
}
break;
- case WAVE_FORMAT_PS2_ADPCM:
- {
+ case WAVE_FORMAT_PS2_ADPCM: {
TypePriority = 4;
}
break;
- case WAVE_FORMAT_DVD_DTS:
- {
+ case WAVE_FORMAT_DVD_DTS: {
TypePriority = 9;
}
break;
- case WAVE_FORMAT_DOLBY_AC3:
- {
+ case WAVE_FORMAT_DOLBY_AC3: {
TypePriority = 8;
}
break;
- case WAVE_FORMAT_AAC:
- {
+ case WAVE_FORMAT_AAC: {
TypePriority = 7;
}
break;
- case WAVE_FORMAT_MP3:
- {
+ case WAVE_FORMAT_MP3: {
TypePriority = 6;
}
break;
- case WAVE_FORMAT_MPEG:
- {
+ case WAVE_FORMAT_MPEG: {
TypePriority = 5;
}
break;
@@ -1053,8 +1015,7 @@ LONGLONG GetMediaTypeQuality(const CMediaType *_pMediaType, int _PresentationFor
bool CMpegSplitterFile::stream::operator < (const stream &_Other) const
{
- if (mt.majortype == MEDIATYPE_Audio && _Other.mt.majortype == MEDIATYPE_Audio)
- {
+ if (mt.majortype == MEDIATYPE_Audio && _Other.mt.majortype == MEDIATYPE_Audio) {
int iProgram0;
const CHdmvClipInfo::Stream *pClipInfo0;
const CMpegSplitterFile::program * pProgram0 = m_pFile->FindProgram(pid, iProgram0, pClipInfo0);
@@ -1063,18 +1024,22 @@ bool CMpegSplitterFile::stream::operator < (const stream &_Other) const
const CHdmvClipInfo::Stream *pClipInfo1;
const CMpegSplitterFile::program * pProgram1 = m_pFile->FindProgram(_Other.pid, iProgram1, pClipInfo1);
int StreamType1 = pClipInfo1 ? pClipInfo1->m_Type : pProgram1 ? pProgram1->streams[iProgram1].type : 0;
-
- if (mt.formattype == FORMAT_WaveFormatEx && _Other.mt.formattype != FORMAT_WaveFormatEx)
+
+ if (mt.formattype == FORMAT_WaveFormatEx && _Other.mt.formattype != FORMAT_WaveFormatEx) {
return true;
- if (mt.formattype != FORMAT_WaveFormatEx && _Other.mt.formattype == FORMAT_WaveFormatEx)
+ }
+ if (mt.formattype != FORMAT_WaveFormatEx && _Other.mt.formattype == FORMAT_WaveFormatEx) {
return false;
+ }
LONGLONG Quality0 = GetMediaTypeQuality(&mt, StreamType0);
LONGLONG Quality1 = GetMediaTypeQuality(&_Other.mt, StreamType1);
- if (Quality0 > Quality1)
+ if (Quality0 > Quality1) {
return true;
- if (Quality0 < Quality1)
+ }
+ if (Quality0 < Quality1) {
return false;
+ }
}
DWORD DefaultFirst = *this;
DWORD DefaultSecond = _Other;
@@ -1083,41 +1048,49 @@ bool CMpegSplitterFile::stream::operator < (const stream &_Other) const
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++)
- {
+ for(int i = 0, j = 0; i < countof(m_pFile->m_streams); i++) {
int cnt = m_pFile->m_streams[i].GetCount();
-
- if(lIndex >= j && lIndex < j+cnt)
- {
+
+ if(lIndex >= j && lIndex < j+cnt) {
lIndex -= j;
-
+
POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if(!pos) return E_UNEXPECTED;
+ if(!pos) {
+ return E_UNEXPECTED;
+ }
CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetAt(pos);
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 = NULL;
- if(ppUnk) *ppUnk = NULL;
+ 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 = NULL;
+ }
+ if(ppUnk) {
+ *ppUnk = NULL;
+ }
+
-
- if(ppszName)
- {
+ if(ppszName) {
CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
CStringW str;
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID)
- {
+ if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
str = _T("No subtitles");
*plcid = (LCID)LCID_NOSUBTITLES;
- }
- else
- {
+ } else {
int iProgram;
const CHdmvClipInfo::Stream *pClipInfo;
const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
@@ -1127,16 +1100,19 @@ STDMETHODIMP CMpegSplitterFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD*
CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType);
- 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 (!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 == NULL) return E_OUTOFMEMORY;
+ if(*ppszName == NULL) {
+ return E_OUTOFMEMORY;
+ }
wcscpy_s(*ppszName, str.GetLength()+1, str);
}
@@ -1200,14 +1176,14 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
CAutoLock cAutoLock(this);
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ 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;
+ if(_abs64(rt - m_rtPrev) > m_rtMaxShift) {
+ m_rtOffset += m_rtPrev - rt;
+ }
p->rtStart += m_rtOffset;
p->rtStop += m_rtOffset;
@@ -1215,60 +1191,57 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_rtPrev = p->rtStart;
}
-
- if (p->pmt)
- {
- if (*((CMediaType *)p->pmt) != m_mt)
+
+ 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))
+ 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)
- {
+ if(!m_p) {
BYTE* base = p->GetData();
BYTE* s = base;
BYTE* e = s + p->GetCount();
- for(; s < e; s++)
- {
- if(*s != 0xff) continue;
+ for(; s < e; s++) {
+ if(*s != 0xff) {
+ continue;
+ }
- if(s == e-1 || (s[1]&0xf6) == 0xf0)
- {
+ if(s == e-1 || (s[1]&0xf6) == 0xf0) {
memmove(base, s, e - s);
p->SetCount(e - s);
m_p = p;
break;
}
}
- }
- else
- {
+ } else {
m_p->Append(*p);
}
- while(m_p && m_p->GetCount() > 9)
- {
+ 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;
+ s += 7;
+ len -= 7;
+ if(crc) {
+ s += 2, len -= 2;
+ }
- if(e - s < len)
- {
+ if(e - s < len) {
break;
}
- if(len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len+1]&0xf6) != 0xf0))
- {
+ if(len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len+1]&0xf6) != 0xf0)) {
m_p.Free();
break;
}
@@ -1285,7 +1258,8 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p2->rtStop = m_p->rtStop;
m_p->rtStop = Packet::INVALID_TIME;
- p2->pmt = m_p->pmt; m_p->pmt = NULL;
+ p2->pmt = m_p->pmt;
+ m_p->pmt = NULL;
p2->SetData(s, len);
s += len;
@@ -1293,26 +1267,32 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_p->SetCount(e - s);
HRESULT hr = __super::DeliverPacket(p2);
- if(hr != S_OK) return hr;
+ 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);
-
+ 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 = NULL;
}
return S_OK;
- }
- else if(m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva')) // just like aac, this has to be starting nalus, more can be packed together
- {
- if(!m_p)
- {
+ } else if(m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva')) { // just like aac, this has to be starting nalus, more can be packed together
+ if(!m_p) {
m_p.Attach(DNew Packet());
m_p->TrackNumber = p->TrackNumber;
m_p->bDiscontinuity = p->bDiscontinuity;
@@ -1333,15 +1313,20 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
BYTE* start = m_p->GetData();
BYTE* end = start + m_p->GetCount();
- while(start <= end-4 && *(DWORD*)start != 0x01000000) start++;
+ while(start <= end-4 && *(DWORD*)start != 0x01000000) {
+ start++;
+ }
- while(start <= end-4)
- {
+ while(start <= end-4) {
BYTE* next = start+1;
- while(next <= end-4 && *(DWORD*)next != 0x01000000) next++;
+ while(next <= end-4 && *(DWORD*)next != 0x01000000) {
+ next++;
+ }
- if(next >= end-4) break;
+ if(next >= end-4) {
+ break;
+ }
int size = next - start;
@@ -1350,24 +1335,24 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
CAutoPtr<Packet> p2;
- while (Nalu.ReadNext())
- {
- DWORD dwNalLength =
+ while (Nalu.ReadNext()) {
+ DWORD dwNalLength =
((Nalu.GetDataLength() >> 24) & 0x000000ff) |
((Nalu.GetDataLength() >> 8) & 0x0000ff00) |
((Nalu.GetDataLength() << 8) & 0x00ff0000) |
((Nalu.GetDataLength() << 24) & 0xff000000);
CAutoPtr<Packet> p3(DNew Packet());
-
+
p3->SetCount (Nalu.GetDataLength()+sizeof(dwNalLength));
memcpy (p3->GetData(), &dwNalLength, sizeof(dwNalLength));
memcpy (p3->GetData()+sizeof(dwNalLength), Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- if (p2 == NULL)
+
+ if (p2 == NULL) {
p2 = p3;
- else
+ } else {
p2->Append(*p3);
+ }
}
p2->TrackNumber = m_p->TrackNumber;
@@ -1377,74 +1362,72 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p2->bSyncPoint = m_p->bSyncPoint;
m_p->bSyncPoint = FALSE;
- p2->rtStart = m_p->rtStart; 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 = NULL;
+ p2->pmt = m_p->pmt;
+ m_p->pmt = NULL;
m_pl.AddTail(p2);
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ if(p->rtStart != Packet::INVALID_TIME) {
m_p->rtStart = p->rtStart;
m_p->rtStop = p->rtStop;
p->rtStart = Packet::INVALID_TIME;
}
- if(p->bDiscontinuity)
- {
+ if(p->bDiscontinuity) {
m_p->bDiscontinuity = p->bDiscontinuity;
p->bDiscontinuity = FALSE;
}
- if(p->bSyncPoint)
- {
+ if(p->bSyncPoint) {
m_p->bSyncPoint = p->bSyncPoint;
p->bSyncPoint = FALSE;
}
- if(m_p->pmt)
+ if(m_p->pmt) {
DeleteMediaType(m_p->pmt);
-
+ }
+
m_p->pmt = p->pmt;
p->pmt = NULL;
start = next;
}
- if(start > m_p->GetData())
- {
+ if(start > m_p->GetData()) {
m_p->RemoveAt(0, start - m_p->GetData());
}
- for(POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos))
- {
- if(pos == m_pl.GetHeadPosition())
+ 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 = true;
+ }
- if((pData[4]&0x1f) == 0x09 || !m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)
- {
+ if((pData[4]&0x1f) == 0x09 || !m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME) {
p = m_pl.RemoveHead();
- while(pos != m_pl.GetHeadPosition())
- {
+ 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;
+ if(hr != S_OK) {
+ return hr;
+ }
}
}
return S_OK;
- }
- else if(m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw')) // just like aac, this has to be starting nalus, more can be packed together
- {
- if(!m_p)
- {
+ } else if(m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw')) { // just like aac, this has to be starting nalus, more can be packed together
+ if(!m_p) {
m_p.Attach(DNew Packet());
m_p->TrackNumber = p->TrackNumber;
m_p->bDiscontinuity = p->bDiscontinuity;
@@ -1466,35 +1449,34 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
BYTE* end = start + m_p->GetCount();
bool bSeqFound = false;
- while(start <= end-4)
- {
- if (*(DWORD*)start == 0x0D010000)
- {
+ while(start <= end-4) {
+ if (*(DWORD*)start == 0x0D010000) {
bSeqFound = true;
break;
- }
- else if (*(DWORD*)start == 0x0F010000)
+ } else if (*(DWORD*)start == 0x0F010000) {
break;
+ }
start++;
}
- while(start <= end-4)
- {
+ while(start <= end-4) {
BYTE* next = start+1;
- while(next <= end-4)
- {
- if (*(DWORD*)next == 0x0D010000)
- {
- if (bSeqFound) break;
+ while(next <= end-4) {
+ if (*(DWORD*)next == 0x0D010000) {
+ if (bSeqFound) {
+ break;
+ }
bSeqFound = true;
- }
- else if (*(DWORD*)next == 0x0F010000)
+ } else if (*(DWORD*)next == 0x0F010000) {
break;
+ }
next++;
}
- if(next >= end-4) break;
+ if(next >= end-4) {
+ break;
+ }
int size = next - start - 4;
UNUSED_ALWAYS(size);
@@ -1519,27 +1501,27 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p2->SetData(start, next - start);
HRESULT hr = __super::DeliverPacket(p2);
- if(hr != S_OK) return hr;
+ if(hr != S_OK) {
+ return hr;
+ }
- if(p->rtStart != Packet::INVALID_TIME)
- {
- m_p->rtStart = p->rtStart;
+ 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)
- {
+ if(p->bDiscontinuity) {
m_p->bDiscontinuity = p->bDiscontinuity;
p->bDiscontinuity = FALSE;
}
- if(p->bSyncPoint)
- {
+ if(p->bSyncPoint) {
m_p->bSyncPoint = p->bSyncPoint;
p->bSyncPoint = FALSE;
}
- if(m_p->pmt)
+ if(m_p->pmt) {
DeleteMediaType(m_p->pmt);
-
+ }
+
m_p->pmt = p->pmt;
p->pmt = NULL;
@@ -1547,60 +1529,58 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
bSeqFound = (*(DWORD*)start == 0x0D010000);
}
- if(start > m_p->GetData())
- {
+ 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)))
- {
+ else if (m_bFilterDTSMA && ((m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS))) {
BYTE* start = p->GetData();
BYTE* end = start + p->GetCount();
- if (end - start < 4 && !p->pmt)
- return S_OK; // Should be invalid packet
+ if (end - start < 4 && !p->pmt) {
+ return S_OK; // Should be invalid packet
+ }
BYTE* hdr = start;
int Type;
- // 16 bits big endian bitstream
- if (hdr[0] == 0x7f && hdr[1] == 0xfe &&
- hdr[2] == 0x80 && hdr[3] == 0x01)
+ // 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)
+ // 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)
+ // 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)
+ // 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;
- }
- }
- else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)
- {
+ // no sync
+ else if (!p->pmt) {
+ return S_OK;
+ }
+ } else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
BYTE* start = p->GetData();
p->SetData(start + 4, p->GetCount() - 4);
- }
- else
- {
+ } else {
m_p.Free();
m_pl.RemoveAll();
}
@@ -1615,15 +1595,15 @@ STDMETHODIMP CMpegSplitterOutputPin::Connect(IPin* pReceivePin, const AM_MEDIA_T
PIN_INFO PinInfo;
GUID FilterClsid;
- if (SUCCEEDED (pReceivePin->QueryPinInfo (&PinInfo)))
- {
- if (SUCCEEDED (PinInfo.pFilter->GetClassID(&FilterClsid)))
- {
- if (FilterClsid == CLSID_DMOWrapperFilter)
+ 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)
+ else if (FilterClsid == CLSID_AC3Filter) {
m_bFilterDTSMA = true;
+ }
}
PinInfo.pFilter->Release();
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.h b/src/filters/parser/MpegSplitter/MpegSplitter.h
index a5155fa8c..abceb4cd9 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitter.h
+++ b/src/filters/parser/MpegSplitter/MpegSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,7 +25,7 @@
#include "MpegSplitterFile.h"
class __declspec(uuid("DC257063-045F-4BE2-BD5B-E12279C464F0"))
-CMpegSplitterFilter : public CBaseSplitterFilter, public IAMStreamSelect
+ CMpegSplitterFilter : public CBaseSplitterFilter, public IAMStreamSelect
{
REFERENCE_TIME m_rtStartOffset;
bool m_pPipoBimbo;
@@ -47,22 +47,24 @@ protected:
public:
CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSplitterFilter));
- void SetPipo(bool bPipo) { m_pPipoBimbo = bPipo; };
+ void SetPipo(bool bPipo) {
+ m_pPipoBimbo = bPipo;
+ };
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
STDMETHODIMP GetClassID(CLSID* pClsID);
STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
// 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);
+ 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);
};
class __declspec(uuid("1365BE7A-C86A-473C-9A41-C0A6E82C9FA3"))
-CMpegSourceFilter : public CMpegSplitterFilter
+ CMpegSourceFilter : public CMpegSplitterFilter
{
public:
CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSourceFilter));
@@ -85,5 +87,7 @@ public:
CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
virtual ~CMpegSplitterOutputPin();
STDMETHODIMP Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt);
- void SetMaxShift(REFERENCE_TIME rtMaxShift) { m_rtMaxShift = rtMaxShift; };
+ void SetMaxShift(REFERENCE_TIME rtMaxShift) {
+ m_rtMaxShift = rtMaxShift;
+ };
};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
index 5200baec4..5624d1a2b 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
+++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -39,10 +39,12 @@ CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bo
, m_ClipInfo(ClipInfo)
{
- if(SUCCEEDED(hr)) hr = Init();
+ if(SUCCEEDED(hr)) {
+ hr = Init(pAsyncReader);
+ }
}
-HRESULT CMpegSplitterFile::Init()
+HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader)
{
HRESULT hr;
@@ -52,104 +54,109 @@ HRESULT CMpegSplitterFile::Init()
Seek(0);
- if(m_type == us)
- {
- if(BitRead(32, true) == 'TFrc') Seek(0x67c);
+ if(m_type == us) {
+ if(BitRead(32, true) == 'TFrc') {
+ Seek(0x67c);
+ }
int cnt = 0, limit = 4;
- for(trhdr h; cnt < limit && Read(h); cnt++) Seek(h.next);
- if(cnt >= limit) m_type = ts;
+ for(trhdr h; cnt < limit && Read(h); cnt++) {
+ Seek(h.next);
+ }
+ if(cnt >= limit) {
+ m_type = ts;
+ }
}
Seek(0);
- if(m_type == us)
- {
+ if(m_type == us) {
int cnt = 0, limit = 4;
- for(pvahdr h; cnt < limit && Read(h); cnt++) Seek(GetPos() + h.length);
- if(cnt >= limit) m_type = pva;
+ for(pvahdr h; cnt < limit && Read(h); cnt++) {
+ Seek(GetPos() + h.length);
+ }
+ if(cnt >= limit) {
+ m_type = pva;
+ }
}
Seek(0);
- if(m_type == us)
- {
+ if(m_type == us) {
BYTE b;
- for(int i = 0; (i < 4 || GetPos() < 65536) && m_type == us && NextMpegStartCode(b); i++)
- {
- if(b == 0xba)
- {
+ for(int i = 0; (i < 4 || GetPos() < 65536) && m_type == us && NextMpegStartCode(b); i++) {
+ if(b == 0xba) {
pshdr h;
- if(Read(h))
- {
+ if(Read(h)) {
m_type = 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
- {
+ } 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)
+ if(Read(h, b) && BitRead(24, true) == 0x000001) {
m_type = es;
+ }
}
}
}
Seek(0);
- if(m_type == us)
+ if(m_type == us) {
return E_FAIL;
+ }
// min/max pts & bitrate
m_rtMin = m_posMin = _I64_MAX;
m_rtMax = m_posMax = 0;
- if(IsRandomAccess() || IsStreaming())
- {
- if(IsStreaming())
- {
- for(int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++);
+ if(IsRandomAccess() || IsStreaming()) {
+ if(IsStreaming()) {
+ for(int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++) {
+ ;
+ }
}
CAtlList<__int64> fps;
- for(int i = 0, j = 5; i <= j; i++)
+ for(int i = 0, j = 5; i <= j; i++) {
fps.AddTail(i*GetLength()/j);
+ }
- for(__int64 pfp = 0; fps.GetCount(); )
- {
+ for(__int64 pfp = 0; fps.GetCount(); ) {
__int64 fp = fps.RemoveHead();
fp = min(GetLength() - MEGABYTE/8, fp);
fp = max(pfp, fp);
__int64 nfp = fp + (pfp == 0 ? 5*MEGABYTE : MEGABYTE/8);
- if(FAILED(hr = SearchStreams(fp, nfp)))
+ if(FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
return hr;
+ }
pfp = nfp;
}
- }
- else
- {
- if(FAILED(hr = SearchStreams(0, MEGABYTE/8)))
+ } else {
+ if(FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader))) {
return hr;
+ }
}
- if(m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0)
+ if(m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0) {
return E_FAIL;
+ }
int indicated_rate = m_rate;
int detected_rate = int(10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin));
// 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)
+ 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...
+ } else {
+ ; // TODO: in this case disable seeking, or try doing something less drastical...
+ }
- if(m_streams[video].GetCount())
- {
- if (!m_bIsHdmv && m_streams[subpic].GetCount())
- {
+ if(m_streams[video].GetCount()) {
+ if (!m_bIsHdmv && m_streams[subpic].GetCount()) {
#ifndef DEBUG
stream s;
s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
@@ -157,11 +164,9 @@ HRESULT CMpegSplitterFile::Init()
s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
m_streams[subpic].Insert(s, this);
#endif
- }
- else
- {
+ } else {
// Add fake stream for "No subtitle"
- //AddHdmvPGStream (NO_SUBTITLE_PID, "---");
+ AddHdmvPGStream (NO_SUBTITLE_PID, "---");
}
}
@@ -170,19 +175,20 @@ HRESULT CMpegSplitterFile::Init()
return S_OK;
}
-void CMpegSplitterFile::OnComplete()
+void CMpegSplitterFile::OnComplete(IAsyncReader* pAsyncReader)
{
__int64 pos = GetPos();
- if(SUCCEEDED(SearchStreams(GetLength() - 500*1024, GetLength())))
- {
+ if(SUCCEEDED(SearchStreams(GetLength() - 500*1024, GetLength(), pAsyncReader))) {
int indicated_rate = m_rate;
int detected_rate = int(m_rtMax > m_rtMin ? 10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin) : 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)
+ 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...
+ } else {
+ ; // TODO: in this case disable seeking, or try doing something less drastical...
+ }
}
Seek(pos);
@@ -195,12 +201,9 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
BYTE b;
- while(GetRemaining())
- {
- if(m_type == ps || m_type == es)
- {
- if(!NextMpegStartCode(b)) // continue;
- {
+ while(GetRemaining()) {
+ if(m_type == ps || m_type == es) {
+ if(!NextMpegStartCode(b)) { // continue;
ASSERT(0);
break;
}
@@ -214,12 +217,13 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
#endif
{
peshdr h;
- if(!Read(h, b) || !h.len) continue;
+ if(!Read(h, b) || !h.len) {
+ continue;
+ }
__int64 pos = GetPos();
- if(h.fpts && AddStream(0, b, h.len) == TrackNum)
- {
+ if(h.fpts && AddStream(0, b, h.len) == TrackNum) {
ASSERT(h.pts >= m_rtMin && h.pts <= m_rtMax);
rt = h.pts;
break;
@@ -227,21 +231,18 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
Seek(pos + h.len);
}
- }
- else if(m_type == ts)
- {
+ } else if(m_type == ts) {
trhdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
rtpos = GetPos()-4;
- if(h.payload && h.payloadstart && ISVALIDPID(h.pid))
- {
+ 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, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum))
- {
+ if(NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
+ if(h2.fpts && AddStream(h.pid, b, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
ASSERT(h2.pts >= m_rtMin && h2.pts <= m_rtMax);
rt = h2.pts;
break;
@@ -250,48 +251,52 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
}
Seek(h.next);
- }
- else if(m_type == pva)
- {
+ } else if(m_type == pva) {
pvahdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
- if(h.fpts)
- {
+ if(h.fpts) {
rt = h.pts;
break;
}
}
}
- if(rtpos >= 0) Seek(rtpos);
- if(rt >= 0) rt -= m_rtMin;
+ if(rtpos >= 0) {
+ Seek(rtpos);
+ }
+ if(rt >= 0) {
+ rt -= m_rtMin;
+ }
return rt;
}
-HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
+HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader)
{
Seek(start);
stop = min(stop, GetLength());
- while(GetPos() < stop)
- {
+ while(GetPos() < stop) {
BYTE b;
- if(m_type == ps || m_type == es)
- {
- if(!NextMpegStartCode(b)) continue;
+ if(m_type == ps || m_type == es) {
+ if(!NextMpegStartCode(b)) {
+ continue;
+ }
- if(b == 0xba) // program stream header
- {
+ if(b == 0xba) { // program stream header
pshdr h;
- if(!Read(h)) continue;
- }
- else if(b == 0xbb) // program stream system header
- {
+ if(!Read(h)) {
+ continue;
+ }
+ } else if(b == 0xbb) { // program stream system header
pssyshdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
}
#if (EVO_SUPPORT == 0)
else if(b >= 0xbd && b < 0xf0) // pes packet
@@ -300,80 +305,103 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
#endif
{
peshdr h;
- if(!Read(h, b)) continue;
+ if(!Read(h, b)) {
+ continue;
+ }
- if(h.type == mpeg2 && h.scrambling) {ASSERT(0); return E_FAIL;}
+ 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();}
- if(m_rtMin < h.pts && m_rtMax < h.pts) {m_rtMax = h.pts; m_posMax = GetPos();}
+ 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();
AddStream(0, b, h.len);
- if(h.len) Seek(pos + h.len);
+ if(h.len) {
+ Seek(pos + h.len);
+ }
}
- }
- else if(m_type == ts)
- {
+ } else if(m_type == ts) {
trhdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
__int64 pos = GetPos();
- if(h.payload && h.payloadstart)
+ if(h.payload && h.payloadstart) {
UpdatePrograms(h);
-
- if(h.payload && ISVALIDPID(h.pid))
- {
+ }
+
+ 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)
- {
+ 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)
- {
- if(m_rtMin == _I64_MAX)
- {
+ if(h2.fpts) {
+ if(m_rtMin == _I64_MAX) {
m_rtMin = h2.pts;
m_posMin = GetPos();
+ //TRACE ("m_rtMin(SearchStreams)=%S\n", ReftimeToString(m_rtMin));
}
-
- if(m_rtMin < h2.pts && m_rtMax < h2.pts)
- {
+
+ if(m_rtMin < h2.pts && m_rtMax < h2.pts) {
m_rtMax = h2.pts;
m_posMax = GetPos();
+ // 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 (int i=0; i<m_ClipInfo.GetStreamNumber(); i++) {
+ 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 ("UPDATE m_rtPTSOffset(SearchStreams)=%S\n", ReftimeToString(m_rtPTSOffset));
+ //TRACE ("m_rtMin(Boucle)=%S\n", ReftimeToString(m_rtMin));
+ //TRACE ("stream=%d\n", stream->m_Type);
+ //TRACE ("m_rtMax(Boucle)=%S\n", ReftimeToString(m_rtMax));
+ //TRACE ("m_rtMax - m_rtMin(Boucle)=%S\n", ReftimeToString(m_rtMax - m_rtMin));
+ }
+ }
+ }
+ //TRACE ("m_rtMax(SearchStreams)=%S\n", ReftimeToString(m_rtMax));
}
}
- }
- else
+ } else {
b = 0;
+ }
AddStream(h.pid, b, DWORD(h.bytes - (GetPos() - pos)));
}
Seek(h.next);
- }
- else if(m_type == pva)
- {
+ } else if(m_type == pva) {
pvahdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
- if(h.fpts)
- {
- if(m_rtMin == _I64_MAX)
- {
+ if(h.fpts) {
+ if(m_rtMin == _I64_MAX) {
m_rtMin = h.pts;
m_posMin = GetPos();
}
- if(m_rtMin < h.pts && m_rtMax < h.pts)
- {
+ if(m_rtMin < h.pts && m_rtMax < h.pts) {
m_rtMax = h.pts;
m_posMax = GetPos();
}
@@ -381,13 +409,15 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
__int64 pos = GetPos();
- if(h.streamid == 1)
+ if(h.streamid == 1) {
AddStream(h.streamid, 0xe0, h.length);
- else if(h.streamid == 2)
+ } else if(h.streamid == 2) {
AddStream(h.streamid, 0xc0, h.length);
+ }
- if(h.length)
+ if(h.length) {
Seek(pos + h.length);
+ }
}
}
@@ -396,10 +426,12 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len)
{
- if(pid)
- {
- if(pesid) m_pid2pes[pid] = pesid;
- else m_pid2pes.Lookup(pid, pesid);
+ if(pid) {
+ if(pesid) {
+ m_pid2pes[pid] = pesid;
+ } else {
+ m_pid2pes.Lookup(pid, pesid);
+ }
}
stream s;
@@ -408,113 +440,102 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len)
int type = unknown;
- if(pesid >= 0xe0 && pesid < 0xf0) // mpeg video
- {
+ if(pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
__int64 pos = GetPos();
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::seqhdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = video;
+ }
}
Seek(pos);
- if(type == unknown)
- {
-// CMpegSplitterFile::avchdr h; <= PPS and SPS can be present on differents packets !
- if(!m_streams[video].Find(s) && Read(avch, len, &s.mt))
+ if(type == unknown) {
+ // CMpegSplitterFile::avchdr h; <= PPS and SPS can be present on differents packets !
+ if(!m_streams[video].Find(s) && Read(avch, len, &s.mt)) {
type = video;
+ }
}
- }
- else if(pesid >= 0xc0 && pesid < 0xe0) // mpeg audio
- {
+ } else if(pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
__int64 pos = GetPos();
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::mpahdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, false, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
type = audio;
+ }
}
Seek(pos);
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::aachdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
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))
- {
+ } else if(pesid == 0xbd || pesid == 0xfd) { // private stream 1
+ if(s.pid) {
+ if(!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
__int64 pos = GetPos();
// AC3
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::ac3hdr h;
- if(Read(h, len, &s.mt))
+ if(Read(h, len, &s.mt)) {
type = audio;
+ }
}
// DTS
Seek(pos);
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::dtshdr h;
- if(Read(h, len, &s.mt))
+ if(Read(h, len, &s.mt)) {
type = audio;
+ }
}
// VC1
- Seek(pos);
- if(type == unknown)
- {
+ Seek(pos);
+ if(type == unknown) {
CMpegSplitterFile::vc1hdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = video;
+ }
}
// DVB subtitles
- Seek(pos);
- if(type == unknown)
- {
+ Seek(pos);
+ if(type == unknown) {
CMpegSplitterFile::dvbsub h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ 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 != NULL))
- {
+ if((type == unknown) && (pProgram != NULL)) {
PES_STREAM_TYPE StreamType = INVALID;
-
+
Seek(pos);
StreamType = pProgram->streams[iProgram].type;
- switch (StreamType)
- {
- case AUDIO_STREAM_LPCM :
- {
+ switch (StreamType) {
+ case AUDIO_STREAM_LPCM : {
CMpegSplitterFile::hdmvlpcmhdr h;
- if(!m_streams[audio].Find(s) && Read(h, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, &s.mt)) {
type = audio;
+ }
}
break;
- case PRESENTATION_GRAPHICS_STREAM :
- {
+ case PRESENTATION_GRAPHICS_STREAM : {
CMpegSplitterFile::hdmvsubhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL))
- {
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL)) {
m_bIsHdmv = true;
type = subpic;
}
@@ -525,129 +546,110 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len)
}
}
#if (EVO_SUPPORT != 0)
- else if (pesid == 0xfd) // TODO EVO SUPPORT
- {
+ else if (pesid == 0xfd) { // TODO EVO SUPPORT
CMpegSplitterFile::vc1hdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = video;
+ }
}
#endif
- else
- {
+ 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
- {
+ 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))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
- }
- else if(b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) // dts
- {
+ }
+ } 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))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
- }
- else if(b >= 0xa0 && b < 0xa8) // lpcm
- {
+ }
+ } else if(b >= 0xa0 && b < 0xa8) { // lpcm
s.ps1id = (b >= 0xa0 && b < 0xa8) ? (BYTE)(BitRead(32) >> 24) : 0xa0;
-
+
CMpegSplitterFile::lpcmhdr h;
- if(Read(h, &s.mt) && !m_streams[audio].Find(s)) // note the reversed order, the header should be stripped always even if it's not a new stream
+ if(Read(h, &s.mt) && !m_streams[audio].Find(s)) { // note the reversed order, the header should be stripped always even if it's not a new stream
type = audio;
- }
- else if(b >= 0x20 && b < 0x40) // DVD subpic
- {
+ }
+ } 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))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
- }
- else if(b >= 0x70 && b < 0x80) // SVCD 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))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
- }
- else if(b >= 0x00 && b < 0x10) // CVD 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))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
- }
- else if(w == 0xffa0 || w == 0xffa1) // ps2-mpg audio
- {
+ }
+ } 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))
+ if(!m_streams[audio].Find(s) && Read(h, &s.mt)) {
type = audio;
- }
- else if(w == 0xff90) // ps2-mpg ac3 or subtitles
- {
+ }
+ } 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)
- {
+ if(w == 0x0b77) {
CMpegSplitterFile::ac3hdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
- }
- else if(w == 0x0000) // usually zero...
- {
+ }
+ } else if(w == 0x0000) { // usually zero...
CMpegSplitterFile::ps2subhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
+ }
}
}
#if (EVO_SUPPORT != 0)
- else if(b >= 0xc0 && b < 0xc8) // dolby digital +
- {
+ else if(b >= 0xc0 && b < 0xc8) { // dolby digital +
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)
- {
+ if(w == 0x0b77) {
CMpegSplitterFile::ac3hdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
+ }
}
}
#endif
}
- }
- else if(pesid == 0xbe) // padding
- {
- }
- else if(pesid == 0xbf) // private stream 2
- {
+ } 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))
- {
+ if(type != unknown && !m_streams[type].Find(s)) {
+ if(s.pid) {
+ for(int i = 0; i < unknown; i++) {
+ if(m_streams[i].Find(s)) {
/*ASSERT(0);*/
return s;
}
@@ -669,8 +671,7 @@ void CMpegSplitterFile::AddHdmvPGStream(WORD pid, const char* language_code)
s.pesid = 0xbd;
CMpegSplitterFile::hdmvsubhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code))
- {
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
m_streams[subpic].Insert(s, this);
}
}
@@ -690,46 +691,37 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h)
{
CAutoLock cAutoLock(&m_csProps);
- if(h.pid == 0)
- {
+ if(h.pid == 0) {
trsechdr h2;
- if(Read(h2) && h2.table_id == 0)
- {
+ 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--)
- {
+ for(int i = len/4; i > 0; i--) {
WORD program_number = (WORD)BitRead(16);
BYTE reserved = (BYTE)BitRead(3);
WORD pid = (WORD)BitRead(13);
UNUSED_ALWAYS(reserved);
- if(program_number != 0)
- {
+ if(program_number != 0) {
m_programs[pid].program_number = program_number;
newprograms[program_number] = true;
}
}
POSITION pos = m_programs.GetStartPosition();
- while(pos)
- {
+ while(pos) {
const CAtlMap<WORD, program>::CPair* pPair = m_programs.GetNext(pos);
- if(!newprograms.Lookup(pPair->m_value.program_number))
- {
+ 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))
- {
+ } else if(CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
trsechdr h2;
- if(Read(h2) && h2.table_id == 2)
- {
+ if(Read(h2) && h2.table_id == 2) {
memset(pPair->m_value.streams, 0, sizeof(pPair->m_value.streams));
int len = h2.section_length;
@@ -745,11 +737,11 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h)
len -= 4+program_info_length;
- while(program_info_length-- > 0)
+ while(program_info_length-- > 0) {
BitRead(8);
+ }
- for(int i = 0; i < countof(pPair->m_value.streams) && len >= 5; i++)
- {
+ for(int i = 0; i < countof(pPair->m_value.streams) && len >= 5; i++) {
BYTE stream_type = (BYTE)BitRead(8);
BYTE nreserved1 = (BYTE)BitRead(3);
WORD pid = (WORD)BitRead(13);
@@ -760,8 +752,9 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h)
len -= 5+ES_info_length;
- while(ES_info_length-- > 0)
+ while(ES_info_length-- > 0) {
BitRead(8);
+ }
pPair->m_value.streams[i].pid = pid;
pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
@@ -789,14 +782,11 @@ const CMpegSplitterFile::program* CMpegSplitterFile::FindProgram(WORD pid, int &
POSITION pos = m_programs.GetStartPosition();
- while(pos)
- {
+ while(pos) {
program* p = &m_programs.GetNextValue(pos);
- for(int i = 0; i < countof(p->streams); i++)
- {
- if(p->streams[i].pid == pid)
- {
+ for(int i = 0; i < countof(p->streams); i++) {
+ if(p->streams[i].pid == pid) {
iStream = i;
return p;
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
index 1e52ea697..62c2caf05 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h
+++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -35,9 +35,9 @@ class CMpegSplitterFile : public CBaseSplitterFileEx
bool m_bIsHdmv;
- HRESULT Init();
+ HRESULT Init(IAsyncReader* pAsyncReader);
- void OnComplete();
+ void OnComplete(IAsyncReader* pAsyncReader);
public:
CHdmvClipInfo &m_ClipInfo;
@@ -53,16 +53,21 @@ public:
__int64 m_posMin, m_posMax;
int m_rate; // byte/sec
- struct stream
- {
+ struct stream {
CMpegSplitterFile *m_pFile;
CMediaType mt;
WORD pid;
BYTE pesid, ps1id;
bool operator < (const stream &_Other) const;
- struct stream() {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;}
+ struct stream() {
+ 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, unknown};
@@ -70,33 +75,33 @@ public:
class CStreamList : public CAtlList<stream>
{
public:
- void Insert(stream& s, CMpegSplitterFile *_pFile)
- {
+ void Insert(stream& s, CMpegSplitterFile *_pFile) {
s.m_pFile = _pFile;
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos))
- {
+ for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
stream& s2 = GetAt(pos);
- if(s < s2) {InsertBefore(pos, s); return;}
+ if(s < s2) {
+ InsertBefore(pos, s);
+ return;
+ }
}
AddTail(s);
}
- static CStringW ToString(int type)
- {
- return
- type == video ? L"Video" :
- type == audio ? L"Audio" :
- type == subpic ? L"Subtitle" :
+ static CStringW ToString(int type) {
+ return
+ type == video ? L"Video" :
+ type == audio ? L"Audio" :
+ type == subpic ? L"Subtitle" :
L"Unknown";
}
- const stream* FindStream(int pid)
- {
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos))
- {
+ const stream* FindStream(int pid) {
+ for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
const stream& s = GetAt(pos);
- if(s.pid == pid) return &s;
+ if(s.pid == pid) {
+ return &s;
+ }
}
return NULL;
@@ -104,23 +109,25 @@ public:
} m_streams[unknown];
- HRESULT SearchStreams(__int64 start, __int64 stop);
+ HRESULT SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader);
DWORD AddStream(WORD pid, BYTE pesid, DWORD len);
void AddHdmvPGStream(WORD pid, const char* language_code);
CAtlList<stream>* GetMasterStream();
- bool IsHdmv() { return m_bIsHdmv; };
+ bool IsHdmv() {
+ return m_bIsHdmv;
+ };
- struct program
- {
+ struct program {
WORD program_number;
- struct stream
- {
+ struct stream {
WORD pid;
PES_STREAM_TYPE type;
};
stream streams[64];
- struct program() {memset(this, 0, sizeof(*this));}
+ struct program() {
+ memset(this, 0, sizeof(*this));
+ }
};
CAtlMap<WORD, program> m_programs;
@@ -128,5 +135,5 @@ public:
void UpdatePrograms(const trhdr& h);
const program* FindProgram(WORD pid, int &iStream, const CHdmvClipInfo::Stream * &_pClipInfo);
-
+
};
diff --git a/src/filters/parser/MpegSplitter/stdafx.cpp b/src/filters/parser/MpegSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MpegSplitter/stdafx.cpp
+++ b/src/filters/parser/MpegSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpegSplitter/stdafx.h b/src/filters/parser/MpegSplitter/stdafx.h
index a72e6f179..5560c6425 100644
--- a/src/filters/parser/MpegSplitter/stdafx.h
+++ b/src/filters/parser/MpegSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/NutSplitter/NutFile.cpp b/src/filters/parser/NutSplitter/NutFile.cpp
index dc72f1de8..9a5eae7ed 100644
--- a/src/filters/parser/NutSplitter/NutFile.cpp
+++ b/src/filters/parser/NutSplitter/NutFile.cpp
@@ -4,7 +4,9 @@
CNutFile::CNutFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
@@ -12,58 +14,52 @@ HRESULT CNutFile::Init()
{
Seek(0);
- if(BitRead(64) != NUTM)
+ if(BitRead(64) != NUTM) {
return E_FAIL;
+ }
m_streams.RemoveAll();
Seek(0);
- while(GetRemaining())
- {
+ while(GetRemaining()) {
frame_header fh;
fh.checksum_flag = 1;
UINT64 id = 0;
if(BitRead(1, true) == 0
- || (id = BitRead(64)) == NUTK)
+ || (id = BitRead(64)) == NUTK) {
break;
+ }
packet_header ph;
Read(ph);
- if(id == NUTM)
- {
+ if(id == NUTM) {
Read(m_mh);
- }
- else if(id == NUTS)
- {
+ } else if(id == NUTS) {
CAutoPtr<stream_header> sh(DNew stream_header());
Read(*sh);
- if(sh->stream_class == SC_VIDEO) Read(sh->vsh);
- else if(sh->stream_class == SC_AUDIO) Read(sh->ash);
+ if(sh->stream_class == SC_VIDEO) {
+ Read(sh->vsh);
+ } else if(sh->stream_class == SC_AUDIO) {
+ Read(sh->ash);
+ }
// else if(sh->stream_class == SC_SUBTITLE) ; // nothing to do
m_streams.AddTail(sh);
- }
- else if(id == NUTX)
- {
+ } else if(id == NUTX) {
index_header ih;
Read(ih);
- }
- else if(id == NUTI)
- {
+ } else if(id == NUTI) {
info_header ih;
Read(ih);
- }
- else if(id == 0) // frame
- {
+ } else if(id == 0) { // frame
ASSERT(0);
break;
}
- if(fh.checksum_flag)
- {
+ if(fh.checksum_flag) {
Seek(ph.pos + ph.fptr - 4);
ph.checksum = (UINT32)BitRead(32);
}
@@ -80,8 +76,10 @@ void CNutFile::Read(vint& vi)
{
vi = 0;
bool more;
- do {more = !!BitRead(1); vi = (vi << 7) | BitRead(7);}
- while(more);
+ do {
+ more = !!BitRead(1);
+ vi = (vi << 7) | BitRead(7);
+ } while(more);
}
void CNutFile::Read(svint& svi)
@@ -89,8 +87,11 @@ void CNutFile::Read(svint& svi)
vint vi;
Read(vi);
vi++;
- if(vi&1) svi = -((svint)vi>>1);
- else svi = ((svint)vi>>1);
+ if(vi&1) {
+ svi = -((svint)vi>>1);
+ } else {
+ svi = ((svint)vi>>1);
+ }
}
void CNutFile::Read(binary& b)
@@ -98,7 +99,9 @@ void CNutFile::Read(binary& b)
vint len;
Read(len);
b.SetCount((INT_PTR)len);
- for(BYTE* buff = b.GetData(); len-- > 0; *buff++ = (BYTE)BitRead(8));
+ for(BYTE* buff = b.GetData(); len-- > 0; *buff++ = (BYTE)BitRead(8)) {
+ ;
+ }
}
void CNutFile::Read(packet_header& ph)
@@ -118,21 +121,22 @@ void CNutFile::Read(stream_header& sh)
{
Read(sh.stream_id);
Read(sh.stream_class);
- Read(sh.fourcc);
- Read(sh.average_bitrate);
- Read(sh.language_code);
- Read(sh.time_base_nom);
- Read(sh.time_base_denom);
- Read(sh.msb_timestamp_shift);
- Read(sh.shuffle_type);
- sh.fixed_fps = BitRead(1);
- sh.index_flag = BitRead(1);
- sh.reserved = BitRead(6);
- while(1)
- {
+ Read(sh.fourcc);
+ Read(sh.average_bitrate);
+ Read(sh.language_code);
+ Read(sh.time_base_nom);
+ Read(sh.time_base_denom);
+ Read(sh.msb_timestamp_shift);
+ Read(sh.shuffle_type);
+ sh.fixed_fps = BitRead(1);
+ sh.index_flag = BitRead(1);
+ sh.reserved = BitRead(6);
+ while(1) {
CAutoPtr<codec_specific> p(DNew codec_specific());
Read(p->type);
- if(p->type == 0) break;
+ if(p->type == 0) {
+ break;
+ }
Read(p->data);
sh.cs.AddTail(p);
}
@@ -160,8 +164,7 @@ void CNutFile::Read(index_header& ih)
vint len;
Read(len);
ih.ie.SetCount((INT_PTR)len);
- for(index_entry* p = ih.ie.GetData(); len-- > 0;)
- {
+ for(index_entry* p = ih.ie.GetData(); len-- > 0;) {
Read(p->timestamp);
Read(p->position);
}
@@ -170,22 +173,22 @@ void CNutFile::Read(index_header& ih)
void CNutFile::Read(info_header& ih)
{
// TODO
-/*
- for(;;){
- id v
- if(id==0) break
- name= info_table[id][0]
- type= info_table[id][1]
- if(type==NULL)
- type b
- if(name==NULL)
- name b
- if(type=="v")
- value v
- else if(type=="s")
- value s
- else
- value b
- }
-*/
+ /*
+ for(;;){
+ id v
+ if(id==0) break
+ name= info_table[id][0]
+ type= info_table[id][1]
+ if(type==NULL)
+ type b
+ if(name==NULL)
+ name b
+ if(type=="v")
+ value v
+ else if(type=="s")
+ value s
+ else
+ value b
+ }
+ */
}
diff --git a/src/filters/parser/NutSplitter/NutFile.h b/src/filters/parser/NutSplitter/NutFile.h
index ab2a0a7e1..2221daa0d 100644
--- a/src/filters/parser/NutSplitter/NutFile.h
+++ b/src/filters/parser/NutSplitter/NutFile.h
@@ -15,40 +15,34 @@ public:
typedef CAtlArray<BYTE> binary;
typedef CAtlArray<BYTE> string;
- struct packet_header
- {
+ struct packet_header {
__int64 pos;
vint fptr, bptr;
UINT32 checksum;
};
- struct main_header
- {
+ struct main_header {
vint version;
vint stream_count;
};
- struct codec_specific
- {
+ struct codec_specific {
vint type;
binary data;
};
- struct video_stream_header
- {
+ struct video_stream_header {
vint width, height;
vint sample_width, sample_height;
vint colorspace_type;
};
- struct audio_stream_header
- {
+ struct audio_stream_header {
vint samplerate_mul;
vint channel_count;
};
- struct stream_header
- {
+ struct stream_header {
vint stream_id;
vint stream_class;
string fourcc;
@@ -62,12 +56,14 @@ public:
int index_flag:1;
int reserved:6;
CAutoPtrList<codec_specific> cs;
- union {video_stream_header vsh; audio_stream_header ash;};
+ union {
+ video_stream_header vsh;
+ audio_stream_header ash;
+ };
vint msb_timestamp;
};
- struct frame_header
- {
+ struct frame_header {
BYTE zero_bit:1;
BYTE priority:2;
BYTE checksum_flag:1;
@@ -76,31 +72,28 @@ public:
BYTE reserved:1;
};
- struct index_entry
- {
+ struct index_entry {
vint timestamp;
vint position;
};
- struct index_header
- {
- vint stream_id;
+ struct index_header {
+ vint stream_id;
CAtlArray<index_entry> ie;
};
- struct info_header
- {
+ struct info_header {
// TODO
vint dummy;
};
#pragma pack(pop)
- #define NUTM 0xF9526A624E55544Dui64
- #define NUTS 0xD667773F4E555453ui64
- #define NUTK 0xCB8630874E55544Bui64
- #define NUTX 0xEBFCDE0E4E555458ui64
- #define NUTI 0xA37B64354E555449ui64
+#define NUTM 0xF9526A624E55544Dui64
+#define NUTS 0xD667773F4E555453ui64
+#define NUTK 0xCB8630874E55544Bui64
+#define NUTX 0xEBFCDE0E4E555458ui64
+#define NUTI 0xA37B64354E555449ui64
enum {SC_VIDEO = 0, SC_AUDIO = 32, SC_SUBTITLE = 64};
diff --git a/src/filters/parser/NutSplitter/NutSplitter.cpp b/src/filters/parser/NutSplitter/NutSplitter.cpp
index 3edb5a328..5e86c76d2 100644
--- a/src/filters/parser/NutSplitter/NutSplitter.cpp
+++ b/src/filters/parser/NutSplitter/NutSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,26 +26,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_Nut},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CNutSplitterFilter), L"MPC - Nut Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CNutSourceFilter), L"MPC - Nut Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CNutSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CNutSourceFilter>, NULL, &sudFilter[1]},
};
@@ -90,8 +86,13 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CNutFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -99,15 +100,13 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
// pins
POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CNutFile::stream_header* sh = m_pFile->m_streams.GetNext(pos);
CAtlArray<CMediaType> mts;
CMediaType mt;
- if(sh->stream_class == CNutFile::SC_VIDEO)
- {
+ if(sh->stream_class == CNutFile::SC_VIDEO) {
CNutFile::video_stream_header& vsh = sh->vsh;
mt.majortype = MEDIATYPE_Video;
@@ -126,8 +125,7 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.Add(mt);
- if(vsh.sample_width && vsh.sample_height)
- {
+ if(vsh.sample_width && vsh.sample_height) {
VIDEOINFOHEADER2 vih2;
memset(&vih2, 0, sizeof(vih2));
vih2.dwBitRate = vih.dwBitRate;
@@ -139,20 +137,15 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.InsertAt(0, mt);
}
- }
- else if(sh->stream_class == CNutFile::SC_AUDIO)
- {
+ } else if(sh->stream_class == CNutFile::SC_AUDIO) {
CNutFile::audio_stream_header& ash = sh->ash;
UNUSED_ALWAYS(ash);
// TODO
- }
- else if(sh->stream_class == CNutFile::SC_SUBTITLE)
- {
+ } else if(sh->stream_class == CNutFile::SC_SUBTITLE) {
// TODO
}
- if(mts.GetCount() > 0)
- {
+ if(mts.GetCount() > 0) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
AddOutputPin((DWORD)sh->stream_id, pPinOut);
}
@@ -167,7 +160,9 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool CNutSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CNutSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
m_pFile->Seek(0);
return(true);
}
@@ -175,14 +170,13 @@ bool CNutSplitterFilter::DemuxInit()
void CNutSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos) m_pFile->m_streams.GetNext(pos)->msb_timestamp = 0;
+ while(pos) {
+ m_pFile->m_streams.GetNext(pos)->msb_timestamp = 0;
+ }
- if(rt <= 0)
- {
+ if(rt <= 0) {
m_pFile->Seek(0);
- }
- else
- {
+ } else {
m_pFile->Seek(0);
// TODO
}
@@ -192,26 +186,21 @@ bool CNutSplitterFilter::DemuxLoop()
{
bool fKeyFrame = false;
- while(!CheckRequest(NULL) && m_pFile->GetRemaining())
- {
+ while(!CheckRequest(NULL) && m_pFile->GetRemaining()) {
CNutFile::frame_header fh;
fh.checksum_flag = 1;
UINT64 id = 0;
- if(m_pFile->BitRead(1, true) == 0)
- {
+ if(m_pFile->BitRead(1, true) == 0) {
fh.zero_bit = m_pFile->BitRead(1);
fh.priority = m_pFile->BitRead(2);
- fh.checksum_flag = m_pFile->BitRead(1);
+ fh.checksum_flag = m_pFile->BitRead(1);
fh.msb_timestamp_flag = m_pFile->BitRead(1);
fh.subpacket_type = m_pFile->BitRead(2);
fh.reserved = m_pFile->BitRead(1);
- }
- else
- {
- if((id = m_pFile->BitRead(64)) == NUTK)
- {
+ } else {
+ if((id = m_pFile->BitRead(64)) == NUTK) {
fKeyFrame = true;
continue;
}
@@ -220,95 +209,95 @@ bool CNutSplitterFilter::DemuxLoop()
CNutFile::packet_header ph;
m_pFile->Read(ph);
- if(id == 0)
- {
+ if(id == 0) {
CNutFile::vint stream_id;
m_pFile->Read(stream_id);
CNutFile::stream_header* sh = NULL;
POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CNutFile::stream_header* tmp = m_pFile->m_streams.GetNext(pos);
- if(tmp->stream_id == stream_id) {sh = tmp; break;}
+ if(tmp->stream_id == stream_id) {
+ sh = tmp;
+ break;
+ }
}
- if(sh)
- {
- if(fh.msb_timestamp_flag)
+ if(sh) {
+ if(fh.msb_timestamp_flag) {
m_pFile->Read(sh->msb_timestamp);
+ }
CNutFile::svint lsb_timestamp = 0;
m_pFile->Read(lsb_timestamp);
-TRACE(_T("[%I64d]: %I64d:%I64d\n"), stream_id, sh->msb_timestamp, lsb_timestamp);
+ TRACE(_T("[%I64d]: %I64d:%I64d\n"), stream_id, sh->msb_timestamp, lsb_timestamp);
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = (DWORD)stream_id;
p->bSyncPoint = fKeyFrame;
- p->rtStart = 10000i64 * ((sh->msb_timestamp << sh->msb_timestamp_shift) + lsb_timestamp)
- * sh->time_base_nom / sh->time_base_denom;
+ p->rtStart = 10000i64 * ((sh->msb_timestamp << sh->msb_timestamp_shift) + lsb_timestamp)
+ * sh->time_base_nom / sh->time_base_denom;
p->rtStop = p->rtStart+1;
fKeyFrame = false;
CNutFile::vint len = ph.fptr - (m_pFile->GetPos() - ph.pos);
- if(fh.checksum_flag) len -= 4;
+ if(fh.checksum_flag) {
+ len -= 4;
+ }
- if(fh.subpacket_type == 1)
- {
+ if(fh.subpacket_type == 1) {
p->SetCount(len);
m_pFile->ByteRead(p->GetData(), p->GetCount());
- if(FAILED(DeliverPacket(p)))
+ if(FAILED(DeliverPacket(p))) {
break;
- }
- else
- {
- // TODO
-/*
- vint subpacket_count;
- Read(subpacket_count);
-
- if(fh.subpacket_type & 1)
- {
- CArray<vint> keyframe_run;
- keyframe_run.SetSize(subpacket_count);
- for(int i = 0; i < subpacket_count; i++)
- Read(keyframe_run[i]);
}
-
- CArray<vint> timestamp_diff;
- timestamp_diff.SetSize(subpacket_count);
- CArray<vint> timestamp_diff_run;
- timestamp_diff_run.SetSize(subpacket_count);
- for(int i = 0; i < subpacket_count; i++)
- {
- Read(timestamp_diff[i]);
- if(timestamp_diff[i] & 1)
- Read(timestamp_diff_run[i]);
- }
-
- if(fh.subpacket_type & 2)
- {
- CArray<string> subpacket_size_diff;
- for(int i = 0; i < subpacket_count-1; i++)
- {
- Read(subpacket_size_diff[i]);
- }
- }
-
- for(int i = 0; i < subpacket_count; i++)
- {
- }
-*/
+ } else {
+ // TODO
+ /*
+ vint subpacket_count;
+ Read(subpacket_count);
+
+ if(fh.subpacket_type & 1)
+ {
+ CArray<vint> keyframe_run;
+ keyframe_run.SetSize(subpacket_count);
+ for(int i = 0; i < subpacket_count; i++)
+ Read(keyframe_run[i]);
+ }
+
+ CArray<vint> timestamp_diff;
+ timestamp_diff.SetSize(subpacket_count);
+ CArray<vint> timestamp_diff_run;
+ timestamp_diff_run.SetSize(subpacket_count);
+ for(int i = 0; i < subpacket_count; i++)
+ {
+ Read(timestamp_diff[i]);
+ if(timestamp_diff[i] & 1)
+ Read(timestamp_diff_run[i]);
+ }
+
+ if(fh.subpacket_type & 2)
+ {
+ CArray<string> subpacket_size_diff;
+ for(int i = 0; i < subpacket_count-1; i++)
+ {
+ Read(subpacket_size_diff[i]);
+ }
+ }
+
+ for(int i = 0; i < subpacket_count; i++)
+ {
+ }
+ */
}
}
}
- if(fh.checksum_flag)
- {
+ if(fh.checksum_flag) {
m_pFile->Seek(ph.pos + ph.fptr - 4);
ph.checksum = (UINT32)m_pFile->BitRead(32);
}
diff --git a/src/filters/parser/NutSplitter/NutSplitter.h b/src/filters/parser/NutSplitter/NutSplitter.h
index 5d447d3d8..82e820905 100644
--- a/src/filters/parser/NutSplitter/NutSplitter.h
+++ b/src/filters/parser/NutSplitter/NutSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -25,11 +25,11 @@
#include "NutFile.h"
// {5EB7173E-AA71-4a54-BDD1-1CA57D20405F}
-DEFINE_GUID(MEDIASUBTYPE_Nut,
-0x5eb7173e, 0xaa71, 0x4a54, 0xbd, 0xd1, 0x1c, 0xa5, 0x7d, 0x20, 0x40, 0x5f);
+DEFINE_GUID(MEDIASUBTYPE_Nut,
+ 0x5eb7173e, 0xaa71, 0x4a54, 0xbd, 0xd1, 0x1c, 0xa5, 0x7d, 0x20, 0x40, 0x5f);
class __declspec(uuid("90514D6A-76B7-4405-88A8-B4B1EF6061C6"))
-CNutSplitterFilter : public CBaseSplitterFilter
+ CNutSplitterFilter : public CBaseSplitterFilter
{
CAutoPtr<CNutFile> m_pFile;
@@ -48,7 +48,7 @@ public:
};
class __declspec(uuid("918B5A9F-DFED-4532-83A9-9B16D83ED73F"))
-CNutSourceFilter : public CNutSplitterFilter
+ CNutSourceFilter : public CNutSplitterFilter
{
public:
CNutSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/NutSplitter/stdafx.cpp b/src/filters/parser/NutSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/NutSplitter/stdafx.cpp
+++ b/src/filters/parser/NutSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/NutSplitter/stdafx.h b/src/filters/parser/NutSplitter/stdafx.h
index dcc6b12a6..8f287fec1 100644
--- a/src/filters/parser/NutSplitter/stdafx.h
+++ b/src/filters/parser/NutSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/OggSplitter/OggFile.cpp b/src/filters/parser/OggSplitter/OggFile.cpp
index e8a3a6d1f..d90237a22 100644
--- a/src/filters/parser/OggSplitter/OggFile.cpp
+++ b/src/filters/parser/OggSplitter/OggFile.cpp
@@ -4,14 +4,18 @@
COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
HRESULT COggFile::Init()
{
Seek(0);
- if(!Sync()) return E_FAIL;
+ if(!Sync()) {
+ return E_FAIL;
+ }
return S_OK;
}
@@ -22,12 +26,10 @@ bool COggFile::Sync(HANDLE hBreak)
DWORD dw;
for(__int64 i = 0, j = hBreak ? GetLength() - start : 65536;
- 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')
- {
+ 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);
}
@@ -49,26 +51,30 @@ bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak)
page.m_lens.RemoveAll();
page.SetCount(0);
- if(!Read(page.m_hdr, hBreak))
+ 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++)
- {
+ for(BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
BYTE b;
- if(S_OK != ByteRead(&b, 1)) return(false);
+ if(S_OK != ByteRead(&b, 1)) {
+ return(false);
+ }
packetlen += b;
- if(1/*b < 0xff*/) {page.m_lens.AddTail(packetlen); pagelen += packetlen; packetlen = 0;}
+ if(1/*b < 0xff*/) {
+ page.m_lens.AddTail(packetlen);
+ pagelen += packetlen;
+ packetlen = 0;
+ }
}
- if(fFull)
- {
+ if(fFull) {
page.SetCount(pagelen);
- if(S_OK != ByteRead(page.GetData(), page.GetCount()))
+ if(S_OK != ByteRead(page.GetData(), page.GetCount())) {
return(false);
- }
- else
- {
+ }
+ } else {
Seek(GetPos() + pagelen);
page.m_lens.RemoveAll();
}
diff --git a/src/filters/parser/OggSplitter/OggFile.h b/src/filters/parser/OggSplitter/OggFile.h
index f37f01c0c..204013ddc 100644
--- a/src/filters/parser/OggSplitter/OggFile.h
+++ b/src/filters/parser/OggSplitter/OggFile.h
@@ -4,11 +4,11 @@
#pragma pack(push, 1)
-struct OggPageHeader
-{
+struct OggPageHeader {
DWORD capture_pattern;
BYTE stream_structure_version;
- BYTE header_type_flag; enum {continued=1, first=2, last=4};
+ BYTE header_type_flag;
+ enum {continued=1, first=2, last=4};
__int64 granule_position;
DWORD bitstream_serial_number;
DWORD page_sequence_number;
@@ -16,8 +16,7 @@ struct OggPageHeader
BYTE number_page_segments;
};
-struct OggVorbisIdHeader
-{
+struct OggVorbisIdHeader {
DWORD vorbis_version;
BYTE audio_channels;
DWORD audio_sample_rate;
@@ -29,27 +28,27 @@ struct OggVorbisIdHeader
BYTE framing_flag;
};
-struct OggVideoHeader
-{
+struct OggVideoHeader {
DWORD w, h;
};
-struct OggAudioHeader
-{
+struct OggAudioHeader {
WORD nChannels, nBlockAlign;
DWORD nAvgBytesPerSec;
};
-struct OggStreamHeader
-{
+struct OggStreamHeader {
char streamtype[8], subtype[4];
DWORD size;
__int64 time_unit, samples_per_unit;
DWORD default_len;
- DWORD buffersize;
+ DWORD buffersize;
WORD bps;
WORD alignmentfix1;
- union {OggVideoHeader v; OggAudioHeader a;};
+ union {
+ OggVideoHeader v;
+ OggAudioHeader a;
+ };
DWORD alignmentfix2;
};
#pragma pack(pop)
@@ -59,7 +58,9 @@ class OggPage : public CAtlArray<BYTE>
public:
OggPageHeader m_hdr;
CAtlList<int> m_lens;
- OggPage() {memset(&m_hdr, 0, sizeof(m_hdr));}
+ OggPage() {
+ memset(&m_hdr, 0, sizeof(m_hdr));
+ }
};
class COggFile : public CBaseSplitterFile
diff --git a/src/filters/parser/OggSplitter/OggSplitter.cpp b/src/filters/parser/OggSplitter/OggSplitter.cpp
index fa348c31f..7a341b12b 100644
--- a/src/filters/parser/OggSplitter/OggSplitter.cpp
+++ b/src/filters/parser/OggSplitter/OggSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -38,25 +38,21 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(COggSplitterFilter), L"MPC - Ogg Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(COggSourceFilter), L"MPC - Ogg Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<COggSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<COggSourceFilter>, NULL, &sudFilter[1]},
};
@@ -66,8 +62,8 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Ogg,
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Ogg,
_T("0,4,,4F676753"), // OggS
_T(".ogg"), _T(".ogm"), NULL);
@@ -96,35 +92,42 @@ 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)
- {
+ 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 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)
- {
+ 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
- {
+ 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;
+ 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;
}
- while(cnt > 0) {ret |= (*p++&((1<<min(cnt,8))-1)) << off; off += 8; cnt -= 8;}
return ret;
}
- unsigned int getbits(int cnt)
- {
+ unsigned int getbits(int cnt) {
unsigned int ret = showbits(cnt);
m_pos += cnt;
return ret;
@@ -153,8 +156,13 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew COggFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -163,12 +171,10 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile->Seek(0);
OggPage page;
- for(int i = 0, nWaitForMore = 0; m_pFile->Read(page); i++)
- {
+ for(int i = 0, nWaitForMore = 0; m_pFile->Read(page); i++) {
BYTE* p = page.GetData();
- if(!(page.m_hdr.header_type_flag & OggPageHeader::continued))
- {
+ if(!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
BYTE type = *p++;
CStringW name;
@@ -176,110 +182,90 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
HRESULT hr;
- if(type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6))
- {
- if(type == 0x80)
- {
+ if(type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
+ if(type == 0x80) {
name.Format(L"Theora %d", i);
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
pPinOut.Attach(DNew COggTheoraOutputPin(page.GetData(), name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
nWaitForMore++;
}
- }
- else if(type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first))
- {
+ } else if(type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- if(!memcmp(p, "vorbis", 6))
- {
+ if(!memcmp(p, "vorbis", 6)) {
name.Format(L"Vorbis %d", i);
pPinOut.Attach(DNew COggVorbisOutputPin((OggVorbisIdHeader*)(p+6), name, this, this, &hr));
nWaitForMore++;
- }
- else if(!memcmp(p, "video", 5))
- {
+ } else if(!memcmp(p, "video", 5)) {
name.Format(L"Video %d", i);
pPinOut.Attach(DNew COggVideoOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- }
- else if(!memcmp(p, "audio", 5))
- {
+ } else if(!memcmp(p, "audio", 5)) {
name.Format(L"Audio %d", i);
pPinOut.Attach(DNew COggAudioOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- }
- else if(!memcmp(p, "text", 4))
- {
+ } else if(!memcmp(p, "text", 4)) {
name.Format(L"Text %d", i);
pPinOut.Attach(DNew COggTextOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- }
- else if(!memcmp(p, "Direct Show Samples embedded in Ogg", 35))
- {
+ } else if(!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
name.Format(L"DirectShow %d", i);
pPinOut.Attach(DNew COggDirectShowOutputPin((AM_MEDIA_TYPE*)(p+35+sizeof(GUID)), name, this, this, &hr));
}
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)))
- {
+ } 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, page.GetCount()-6-1);
}
- }
- else if(type == 0x7F && page.GetCount()>12 && *(long*)(p+8) == 0x43614C66) // Flac
- {
+ } 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(DNew COggFlacOutputPin(p+12, page.GetCount()-14, name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- }
- else if (*(long*)(p-1) == 0x43614C66)
- {
+ } else if (*(long*)(p-1) == 0x43614C66) {
//bFlac = true;
//nWaitForMore++;
- if (m_pFile->Read(page))
- {
+ if (m_pFile->Read(page)) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
name.Format(L"Flac %d", i);
p = page.GetData();
pPinOut.Attach(DNew COggFlacOutputPin(p, page.GetCount(), name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
}
- }
- else if(!(type&1) && nWaitForMore == 0)
- {
+ } else if(!(type&1) && nWaitForMore == 0) {
break;
}
}
- if(COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
- {
+ if(COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) nWaitForMore--;
+ if(p->IsInitialized()) {
+ nWaitForMore--;
+ }
}
- if(COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
- {
+ if(COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) nWaitForMore--;
+ if(p->IsInitialized()) {
+ nWaitForMore--;
+ }
}
}
- if(m_pOutputs.IsEmpty())
+ if(m_pOutputs.IsEmpty()) {
return E_FAIL;
+ }
- if(m_pFile->IsRandomAccess())
- {
+ if(m_pFile->IsRandomAccess()) {
m_pFile->Seek(max(m_pFile->GetLength()-65536, 0));
OggPage page;
- while(m_pFile->Read(page))
- {
+ while(m_pFile->Read(page)) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if(!pOggPin || page.m_hdr.granule_position == -1) continue;
+ if(!pOggPin || page.m_hdr.granule_position == -1) {
+ continue;
+ }
REFERENCE_TIME rt = pOggPin->GetRefTime(page.m_hdr.granule_position);
m_rtDuration = max(rt, m_rtDuration);
}
@@ -298,20 +284,19 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
tagmap[L"DESCRIPTION"] = L"DESC";
POSITION pos2 = tagmap.GetStartPosition();
- while(pos2)
- {
+ while(pos2) {
CStringW oggtag, dsmtag;
tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) continue;
+ if(!pOggPin) {
+ continue;
+ }
CStringW value = pOggPin->GetComment(oggtag);
- if(!value.IsEmpty())
- {
+ if(!value.IsEmpty()) {
SetProperty(dsmtag, value);
break;
}
@@ -319,23 +304,29 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !ChapGetCount())
- {
+ while(pos && !ChapGetCount()) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) continue;
+ if(!pOggPin) {
+ continue;
+ }
- for(int i = 1; pOggPin; i++)
- {
- CStringW key;
+ for(int i = 1; pOggPin; i++) {
+ CStringW key;
key.Format(L"CHAPTER%02d", i);
CStringW time = pOggPin->GetComment(key);
- if(time.IsEmpty()) break;
+ if(time.IsEmpty()) {
+ break;
+ }
key.Format(L"CHAPTER%02dNAME", i);
CStringW name = pOggPin->GetComment(key);
- if(name.IsEmpty()) name.Format(L"Chapter %d", i);
+ if(name.IsEmpty()) {
+ name.Format(L"Chapter %d", i);
+ }
int h, m, s, ms;
WCHAR c;
- if(7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) break;
+ if(7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
+ break;
+ }
REFERENCE_TIME rt = ((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000;
ChapAppend(rt, name);
}
@@ -348,19 +339,18 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool COggSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "COggSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
return(true);
}
void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0 )
- {
+ if(rt <= 0 ) {
m_pFile->Seek(0);
- }
- else if(m_rtDuration > 0)
- {
+ } else if(m_rtDuration > 0) {
// oh, the horror...
__int64 len = m_pFile->GetLength();
@@ -369,19 +359,22 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
REFERENCE_TIME rtMinDiff = _I64_MAX;
- while(1)
- {
+ while(1) {
__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;
+ 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;}
+ if(!pOggPin) {
+ ASSERT(0);
+ continue;
+ }
rtPos = pOggPin->GetRefTime(page.m_hdr.granule_position);
endpos = m_pFile->GetPos();
@@ -391,12 +384,10 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 rtDiff = rtPos - rt;
- if(rtDiff < 0)
- {
+ if(rtDiff < 0) {
rtDiff = -rtDiff;
- if(rtDiff < 1000000 || rtDiff >= rtMinDiff)
- {
+ if(rtDiff < 1000000 || rtDiff >= rtMinDiff) {
m_pFile->Seek(startpos);
break;
}
@@ -406,23 +397,20 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 newpos = startpos;
- if(rtPos < rt && rtPos < m_rtDuration)
- {
+ 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)
- {
+ 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)
- {
+ if(newpos >= startpos) {
+ newpos = startpos - 1024;
+ }
+ } else if(rtPos == rt) {
m_pFile->Seek(startpos);
break;
- }
- else
- {
+ } else {
ASSERT(0);
m_pFile->Seek(0);
break;
@@ -436,55 +424,51 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
m_pFile->Seek(startpos);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
- if(!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin))
+ if(!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
continue;
+ }
bool fKeyFrameFound = false, fSkipKeyFrame = true;
__int64 endpos = _I64_MAX;
- while(!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0)
- {
+ 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)
+ 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)))
+ if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
continue;
+ }
- if(pPin->GetRefTime(page.m_hdr.granule_position) > rt)
+ if(pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
break;
+ }
- if(!fKeyFrameFound)
- {
+ if(!fKeyFrameFound) {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(p->bSyncPoint)
- {
+ while(p = pPin->GetPacket()) {
+ if(p->bSyncPoint) {
fKeyFrameFound = true;
fSkipKeyFrame = p->fSkip;
}
}
- if(fKeyFrameFound) break;
- }
- else
- {
+ if(fKeyFrameFound) {
+ break;
+ }
+ } else {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(!p->fSkip)
- {
+ while(p = pPin->GetPacket()) {
+ if(!p->fSkip) {
fSkipKeyFrame = false;
break;
}
@@ -492,7 +476,10 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
}
}
- if(!(fKeyFrameFound && !fSkipKeyFrame)) {endpos = startpos; startpos = max(startpos - 10*65536, 0);}
+ if(!(fKeyFrameFound && !fSkipKeyFrame)) {
+ endpos = startpos;
+ startpos = max(startpos - 10*65536, 0);
+ }
m_pFile->Seek(startpos);
}
@@ -504,24 +491,25 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
fKeyFrameFound = false;
OggPage page;
- while(!fKeyFrameFound && m_pFile->Read(page))
- {
- if(page.m_hdr.granule_position == -1) continue;
+ 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)))
+ 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)
+ if(rtPos > rt) {
break;
+ }
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(p->bSyncPoint)
- {
+ while(p = pPin->GetPacket()) {
+ if(p->bSyncPoint) {
fKeyFrameFound = true;
break;
}
@@ -543,17 +531,24 @@ bool COggSplitterFilter::DemuxLoop()
HRESULT hr = S_OK;
OggPage page;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle()))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && 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;}
+ if(!pOggPin) {
+ ASSERT(0);
+ continue;
+ }
+ if(!pOggPin->IsConnected()) {
+ continue;
+ }
+ if(FAILED(hr = pOggPin->UnpackPage(page))) {
+ ASSERT(0);
+ break;
+ }
CAutoPtr<OggPacket> p;
- while(!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket()))
- {
- if(!p->fSkip)
+ while(!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
+ if(!p->fSkip) {
hr = DeliverPacket(p);
+ }
}
}
@@ -585,34 +580,27 @@ 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; )
- {
+ for(int n = bs.getbits(32); n-- > 0; ) {
CStringA str;
- for(int len = bs.getbits(32); len-- > 0; )
+ for(int len = bs.getbits(32); len-- > 0; ) {
str += (CHAR)bs.getbits(8);
+ }
CAtlList<CStringA> sl;
Explode(str, sl, '=', 2);
- if(sl.GetCount() == 2)
- {
+ if(sl.GetCount() == 2) {
CAutoPtr<CComment> p(DNew CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
- if(p->m_key == L"LANGUAGE")
- {
+ if(p->m_key == L"LANGUAGE") {
CString lang = ISO6392ToLanguage(sl.GetTail()), iso6392 = LanguageToISO6392(CString(p->m_value));
- if(p->m_value.GetLength() == 3 && !lang.IsEmpty())
- {
+ if(p->m_value.GetLength() == 3 && !lang.IsEmpty()) {
SetName(CStringW(lang));
SetProperty(L"LANG", p->m_value);
- }
- else if(!iso6392.IsEmpty())
- {
+ } else if(!iso6392.IsEmpty()) {
SetName(p->m_value);
SetProperty(L"LANG", CStringW(iso6392));
- }
- else
- {
+ } else {
SetName(p->m_value);
SetProperty(L"NAME", p->m_value);
}
@@ -629,10 +617,11 @@ CStringW COggSplitterOutputPin::GetComment(CStringW key)
key.MakeUpper();
CAtlList<CStringW> sl;
POSITION pos = m_pComments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComment* p = m_pComments.GetNext(pos);
- if(key == p->m_key) sl.AddTail(p->m_value);
+ if(key == p->m_key) {
+ sl.AddTail(p->m_value);
+ }
}
return Implode(sl, ';');
}
@@ -649,87 +638,88 @@ void COggSplitterOutputPin::ResetState(DWORD seqnum)
HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page)
{
- if(m_lastseqnum != page.m_hdr.page_sequence_number-1)
- {
+ if(m_lastseqnum != page.m_hdr.page_sequence_number-1) {
ResetState(page.m_hdr.page_sequence_number);
return S_FALSE; // FIXME
- }
- else
- {
+ } 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();
+ 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();
+ 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))
- {
+ 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(len < 255 || pos == page.m_lens.GetTailPosition()) {
+ if(first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
+ // ASSERT(m_lastpacket);
- if(m_lastpacket)
- {
+ if(m_lastpacket) {
int 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);
+ if(len < 255) {
+ m_packets.AddTail(m_lastpacket);
+ }
}
- }
- else
- {
+ } else {
CAutoPtr<OggPacket> p(DNew OggPacket());
- if(last == pos && page.m_hdr.granule_position != -1)
- {
+ if(last == pos && page.m_hdr.granule_position != -1) {
p->bDiscontinuity = m_fSkip;
-REFERENCE_TIME rtLast = m_rtLast;
+ 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
+ // 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(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)
- {
+ 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
- {
+ if(len < 255) {
+ m_packets.AddTail(p);
+ } else {
+ m_lastpacket = p;
+ }
+ } else {
ASSERT(0);
}
}
@@ -746,7 +736,9 @@ CAutoPtr<OggPacket> COggSplitterOutputPin::GetPacket()
{
CAutoPtr<OggPacket> p;
CAutoLock csAutoLock(&m_csPackets);
- if(m_packets.GetCount()) p = m_packets.RemoveHead();
+ if(m_packets.GetCount()) {
+ p = m_packets.RemoveHead();
+ }
return p;
}
@@ -807,17 +799,16 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
{
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
Packet* p = m_packets.GetHead();
- if(p->GetCount() >= 6 && p->GetAt(0) == 0x05)
- {
+ if(p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
// yeah, right, we are going to be parsing this backwards! :P
bitstream bs(p->GetData(), p->GetCount(), true);
- while(bs.hasbits(-1) && bs.getbits(-1) != 1);
- for(int cnt = 0; bs.hasbits(-8-16-16-1-6); cnt++)
- {
+ 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);
@@ -826,8 +817,7 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
unsigned int blockflag = bs.getbits(-1);
UNUSED_ALWAYS(mapping);
- if(transformtype != 0 || windowtype != 0)
- {
+ if(transformtype != 0 || windowtype != 0) {
ASSERT(modes == cnt);
break;
}
@@ -837,14 +827,13 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
}
int cnt = m_initpackets.GetCount();
- if(cnt <= 3)
- {
+ if(cnt <= 3) {
ASSERT(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,
+ m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len,
p->GetData(), p->GetCount());
}
@@ -862,15 +851,18 @@ REFERENCE_TIME COggVorbisOutputPin::GetRefTime(__int64 granule_position)
HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if(len > 0 && m_blockflags.GetCount())
- {
+ if(len > 0 && m_blockflags.GetCount()) {
bitstream bs(pData, len);
- if(bs.getbits(1) == 0)
- {
+ if(bs.getbits(1) == 0) {
int x = m_blockflags.GetCount()-1, n = 0;
- while(x) {n++; x >>= 1;}
+ 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);
+ if(m_lastblocksize) {
+ m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
+ }
m_lastblocksize = blocksize;
}
}
@@ -885,8 +877,9 @@ HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
HRESULT COggVorbisOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1))
+ if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
+ }
return __super::DeliverPacket(p);
}
@@ -897,11 +890,9 @@ HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_
m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_Vorbis) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -926,9 +917,10 @@ COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFi
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;
+ if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
+ if(phr) {
+ *phr = VFW_E_INVALID_FILE_FORMAT;
+ }
return;
}
@@ -941,7 +933,7 @@ COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFi
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;
+ m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
CMediaType mt;
@@ -971,8 +963,7 @@ REFERENCE_TIME COggFlacOutputPin::GetRefTime(__int64 granule_position)
HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8)
- {
+ if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8) {
return S_FALSE;
}
@@ -986,8 +977,9 @@ HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int
HRESULT COggFlacOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1))
+ if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
+ }
return __super::DeliverPacket(p);
}
@@ -998,11 +990,9 @@ HRESULT COggFlacOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TI
m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -1026,20 +1016,18 @@ COggDirectShowOutputPin::COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pNa
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...
+ 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)
- {
+ if(m_mt.majortype == MEDIATYPE_Video) {
rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
- }
- else if(m_mt.majortype == MEDIATYPE_Audio)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Audio) {
rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
}
@@ -1052,15 +1040,18 @@ HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pDat
BYTE hdr = pData[i++];
- if(!(hdr&1))
- {
+ 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++)
+ for(int j = 0; j < nLenBytes; j++) {
Length |= (__int64)pData[i++] << (j << 3);
+ }
- if(len < i) {ASSERT(0); return E_FAIL;}
+ if(len < i) {
+ ASSERT(0);
+ return E_FAIL;
+ }
p->bSyncPoint = !!(hdr&8);
p->rtStart = m_rtLast;
@@ -1096,14 +1087,17 @@ HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
BYTE hdr = pData[i++];
- if(!(hdr&1))
- {
+ if(!(hdr&1)) {
BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
__int64 Length = 0;
- for(int j = 0; j < nLenBytes; j++)
+ for(int j = 0; j < nLenBytes; j++) {
Length |= (__int64)pData[i++] << (j << 3);
+ }
- if(len < i) {ASSERT(0); return E_FAIL;}
+ if(len < i) {
+ ASSERT(0);
+ return E_FAIL;
+ }
p->bSyncPoint = !!(hdr&8);
p->rtStart = m_rtLast;
@@ -1124,7 +1118,7 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
: COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
+ extra = max(extra, 0);
CMediaType mt;
mt.majortype = MEDIATYPE_Video;
@@ -1138,19 +1132,24 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
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;
+ 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);
@@ -1164,7 +1163,7 @@ COggAudioOutputPin::COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
: COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
+ extra = max(extra, 0);
CMediaType mt;
mt.majortype = MEDIATYPE_Audio;
@@ -1218,18 +1217,19 @@ COggTheoraOutputPin::COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pF
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)
- {
+ 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 ?
+
+ if (m_KfgShift == 0) {
+ m_KfgShift = 6; // Is it really default value ?
+ }
mt.bFixedSizeSamples = 0;
m_mts.Add(mt);
@@ -1239,17 +1239,16 @@ HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
{
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
Packet* p = m_packets.GetHead();
CMediaType& mt = m_mts[0];
int size = p->GetCount();
ASSERT(size <= 0xffff);
MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.ReallocFormatBuffer(
- FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) +
- ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader +
- 2 + size);
+ 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;
@@ -1262,15 +1261,15 @@ HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
REFERENCE_TIME COggTheoraOutputPin::GetRefTime(__int64 granule_position)
{
- LONGLONG iframe;
- LONGLONG pframe;
+ 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.*/
+ 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 = 0;
rt = (iframe+pframe-m_nIndexOffset) * m_rtAvgTimePerFrame;
@@ -1284,8 +1283,9 @@ HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
p->rtStop = m_rtLast+1;
p->SetData(pData, len);
- if(!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video)
+ 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.h b/src/filters/parser/OggSplitter/OggSplitter.h
index 5790ccad0..3d7ae5975 100644
--- a/src/filters/parser/OggSplitter/OggSplitter.h
+++ b/src/filters/parser/OggSplitter/OggSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -29,7 +29,9 @@
class OggPacket : public Packet
{
public:
- OggPacket() {fSkip = false;}
+ OggPacket() {
+ fSkip = false;
+ }
bool fSkip;
};
@@ -37,9 +39,11 @@ 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();}
+ public:
+ CStringW m_key, m_value;
+ CComment(CStringW key, CStringW value) : m_key(key), m_value(value) {
+ m_key.MakeUpper();
+ }
};
CAutoPtrList<CComment> m_pComments;
@@ -64,9 +68,9 @@ public:
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);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
class COggVorbisOutputPin : public COggSplitterOutputPin
@@ -81,13 +85,15 @@ class COggVorbisOutputPin : public COggSplitterOutputPin
virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ 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;}
+ bool IsInitialized() {
+ return m_initpackets.GetCount() >= 3;
+ }
};
class COggFlacOutputPin : public COggSplitterOutputPin
@@ -106,12 +112,14 @@ class COggFlacOutputPin : public COggSplitterOutputPin
virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ 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;}
+ bool IsInitialized() {
+ return m_initpackets.GetCount() >= 3;
+ }
};
class COggDirectShowOutputPin : public COggSplitterOutputPin
@@ -169,11 +177,13 @@ public:
COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() {return m_initpackets.GetCount() >= 3;}
+ bool IsInitialized() {
+ return m_initpackets.GetCount() >= 3;
+ }
};
class __declspec(uuid("9FF48807-E133-40AA-826F-9B2959E5232D"))
-COggSplitterFilter : public CBaseSplitterFilter
+ COggSplitterFilter : public CBaseSplitterFilter
{
protected:
CAutoPtr<COggFile> m_pFile;
@@ -189,7 +199,7 @@ public:
};
class __declspec(uuid("6D3688CE-3E9D-42F4-92CA-8A11119D25CD"))
-COggSourceFilter : public COggSplitterFilter
+ COggSourceFilter : public COggSplitterFilter
{
public:
COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/OggSplitter/stdafx.cpp b/src/filters/parser/OggSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/OggSplitter/stdafx.cpp
+++ b/src/filters/parser/OggSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/OggSplitter/stdafx.h b/src/filters/parser/OggSplitter/stdafx.h
index 01aef1f91..f8e9cd301 100644
--- a/src/filters/parser/OggSplitter/stdafx.h
+++ b/src/filters/parser/OggSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
index a3da7019f..50b9c752b 100644
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
+++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
@@ -38,8 +38,9 @@ template<typename T>
static void bswap(T& var)
{
BYTE* s = (BYTE*)&var;
- for(BYTE* d = s + sizeof(var)-1; s < d; s++, d--)
+ for(BYTE* d = s + sizeof(var)-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
void rvinfo::bswap()
@@ -86,38 +87,32 @@ using namespace RMFF;
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV20},
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV30},
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV40},
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV41},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins2[] =
-{
+const AMOVIESETUP_PIN sudpPins2[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut2), sudPinTypesOut2}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
@@ -129,27 +124,23 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] =
{&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
};
-const AMOVIESETUP_PIN sudpPins3[] =
-{
+const AMOVIESETUP_PIN sudpPins3[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn3), sudPinTypesIn3},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut3), sudPinTypesOut3}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CRealMediaSplitterFilter), L"MPC - RealMedia Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRealMediaSourceFilter), L"MPC - RealMedia Source", MERIT_NORMAL, 0, NULL, 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[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CRealMediaSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CRealMediaSourceFilter>, NULL, &sudFilter[1]},
{sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRealVideoDecoder>, NULL, &sudFilter[2]},
@@ -197,8 +188,9 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
DWORD dw;
- if(FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.')
+ if(FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
return E_FAIL;
+ }
}
HRESULT hr = E_FAIL;
@@ -206,7 +198,9 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CRMFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
if(FAILED(hr)) {
m_pFile.Free();
return hr;
@@ -218,21 +212,21 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_rtStop = 10000i64*m_pFile->m_p.tDuration;
POSITION pos = m_pFile->m_mps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
MediaProperies* pmp = m_pFile->m_mps.GetNext(pos);
CStringW name;
name.Format(L"Output %02d", pmp->stream);
- if(!pmp->name.IsEmpty()) name += L" (" + CStringW(pmp->name) + L")";
+ 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")
- {
+ if(pmp->mime == "video/x-pn-realvideo") {
mt.majortype = MEDIATYPE_Video;
mt.formattype = FORMAT_VideoInfo;
@@ -247,7 +241,9 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
ASSERT(rvi.fcc1 == 'ODIV');
mt.subtype = FOURCCMap(rvi.fcc2);
- if(rvi.fps > 0x10000) pvih->AvgTimePerFrame = REFERENCE_TIME(10000000i64 / ((float)rvi.fps/0x10000));
+ 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;
@@ -259,8 +255,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.Add(mt);
- if(pmp->width > 0 && pmp->height > 0)
- {
+ if(pmp->width > 0 && pmp->height > 0) {
BITMAPINFOHEADER bmi = pvih->bmiHeader;
mt.formattype = FORMAT_VideoInfo2;
VIDEOINFOHEADER2* pvih2 = (VIDEOINFOHEADER2*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + pmp->typeSpecData.GetCount());
@@ -274,9 +269,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.InsertAt(0, mt);
}
- }
- else if(pmp->mime == "audio/x-pn-realaudio")
- {
+ } else if(pmp->mime == "audio/x-pn-realaudio") {
mt.majortype = MEDIATYPE_Audio;
mt.formattype = FORMAT_WaveFormatEx;
mt.bTemporalCompression = 1;
@@ -294,10 +287,10 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
fccstr[4] = 0;
BYTE* fmt = pmp->typeSpecData.GetData();
- for(int i = 0; i < pmp->typeSpecData.GetCount()-4; i++, fmt++)
- {
- if(fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a')
+ for(int i = 0; i < pmp->typeSpecData.GetCount()-4; i++, fmt++) {
+ if(fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
break;
+ }
}
rainfo rai = *(rainfo*)fmt;
@@ -305,8 +298,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
BYTE* extra = NULL;
- if(rai.version2 == 4)
- {
+ if(rai.version2 == 4) {
rainfo4 rai4 = *(rainfo4*)fmt;
rai4.bswap();
pwfe->nChannels = rai4.channels;
@@ -318,12 +310,11 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
p += len;
len = *p++;
ASSERT(len == 4);
- if(len == 4)
+ if(len == 4) {
fcc = MAKEFOURCC(p[0],p[1],p[2],p[3]);
+ }
extra = p + len + 3;
- }
- else if(rai.version2 == 5)
- {
+ } else if(rai.version2 == 5) {
rainfo5 rai5 = *(rainfo5*)fmt;
rai5.bswap();
pwfe->nChannels = rai5.channels;
@@ -332,9 +323,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
pwfe->nBlockAlign = rai5.frame_size;
fcc = rai5.fourcc3;
extra = fmt + sizeof(rainfo5) + 4;
- }
- else
- {
+ } else {
continue;
}
@@ -344,69 +333,59 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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;
+ 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)
- {
+ if(pwfe->wFormatTag) {
mts.Add(mt);
- if(fcc == 'DNET')
- {
+ if(fcc == 'DNET') {
mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
mts.InsertAt(0, mt);
- }
- else if(fcc == 'RAAC' || fcc == 'RACP')
- {
+ } else if(fcc == 'RAAC' || fcc == 'RACP') {
mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_AAC);
int extralen = *(DWORD*)extra;
extra += 4;
::bswap(extralen);
ASSERT(*extra == 2); // always 2? why? what does it mean?
- if(*extra == 2)
- {
+ if(*extra == 2) {
extra++;
extralen--;
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extralen);
pwfe->cbSize = extralen;
memcpy(pwfe + 1, extra, extralen);
- }
- else
- {
+ } 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")
- {
+ } else if(pmp->mime == "logical-fileinfo") {
CAtlMap<CStringA, CStringA, CStringElementTraits<CStringA> > lfi;
CStringA key, value;
@@ -418,21 +397,21 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bswap(cnt);
p += 4;
- if(cnt > 0xffff) // different format?
- {
+ if(cnt > 0xffff) { // different format?
p += 2;
cnt = p <= end-4 ? *(DWORD*)p : 0;
bswap(cnt);
p += 4;
}
- while(p < end-4 && cnt-- > 0)
- {
+ while(p < end-4 && cnt-- > 0) {
BYTE* base = p;
DWORD len = *(DWORD*)p;
bswap(len);
p += 4;
- if(base + len > end) break;
+ if(base + len > end) {
+ break;
+ }
p++;
WORD keylen = *(WORD*)p;
@@ -455,22 +434,22 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
POSITION pos = lfi.GetStartPosition();
- while(pos)
- {
+ 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), NULL, 10)) > 0)
- {
+ && (n = strtol(key.Mid(7), NULL, 10)) > 0) {
int h, m, s, ms;
char c;
- if(7 != sscanf(value, "%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms))
+ if(7 != sscanf(value, "%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
continue;
+ }
key.Format("CHAPTER%02dNAME", n);
- if(!lfi.Lookup(key, value) || value.IsEmpty())
+ if(!lfi.Lookup(key, value) || value.IsEmpty()) {
value.Format("Chapter %d", n);
+ }
ChapAppend(
((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000,
@@ -479,8 +458,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
}
- if(mts.IsEmpty())
- {
+ if(mts.IsEmpty()) {
TRACE(_T("Unsupported RealMedia stream (%d): %s\n"), pmp->stream, CString(pmp->mime));
continue;
}
@@ -488,21 +466,22 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
HRESULT hr;
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CRealMediaSplitterOutputPin(mts, name, this, this, &hr));
- if(SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut)))
- {
- if(!m_rtStop)
+ 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++)
- {
+ for(DWORD stream = 0; pos; stream++) {
CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
CStringW name;
name.Format(L"Subtitle %02d", stream);
- if(!s.name.IsEmpty()) name += L" (" + CStringW(CString(s.name)) + L")";
+ if(!s.name.IsEmpty()) {
+ name += L" (" + CStringW(CString(s.name)) + L")";
+ }
CMediaType mt;
mt.SetSampleSize(1);
@@ -531,12 +510,13 @@ bool CRealMediaSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CRealMediaSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
// reindex if needed
- if(m_pFile->m_irs.GetCount() == 0)
- {
+ if(m_pFile->m_irs.GetCount() == 0) {
m_nOpenProgress = 0;
m_rtDuration = 0;
@@ -546,26 +526,24 @@ bool CRealMediaSplitterFilter::DemuxInit()
UINT32 nPacket = 0;
POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while(pos && !m_fAbort)
- {
+ 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++)
- {
+ 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)))
+ 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)
- {
+ if(mph.stream == stream && (mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart) {
CAutoPtr<IndexRecord> pir(DNew IndexRecord);
pir->tStart = mph.tStart;
pir->ptrFilePos = (UINT32)filepos;
@@ -578,17 +556,21 @@ bool CRealMediaSplitterFilter::DemuxInit()
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);
+ 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();
+ if(m_fAbort) {
+ m_pFile->m_irs.RemoveAll();
+ }
m_fAbort = false;
}
@@ -602,83 +584,74 @@ bool CRealMediaSplitterFilter::DemuxInit()
void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0)
- {
+ if(rt <= 0) {
m_seekpos = m_pFile->m_dcs.GetHeadPosition();
m_seekpacket = 0;
m_seekfilepos = m_pFile->m_dcs.GetHead()->pos;
- }
- else
- {
+ } else {
m_seekpos = NULL;
POSITION pos = m_pFile->m_irs.GetTailPosition();
- while(pos && !m_seekpos)
- {
+ while(pos && !m_seekpos) {
IndexRecord* pir = m_pFile->m_irs.GetPrev(pos);
- if(pir->tStart <= rt/10000)
- {
+ if(pir->tStart <= rt/10000) {
m_seekpacket = pir->packet;
pos = m_pFile->m_dcs.GetTailPosition();
- while(pos && !m_seekpos)
- {
+ while(pos && !m_seekpos) {
POSITION tmp = pos;
DataChunk* pdc = m_pFile->m_dcs.GetPrev(pos);
- if(pdc->pos <= pir->ptrFilePos)
- {
+ if(pdc->pos <= pir->ptrFilePos) {
m_seekpos = tmp;
m_seekfilepos = pir->ptrFilePos;
POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while(pos != m_seekpos)
- {
+ 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)
+ {
+ 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)
- {
+ if(!m_seekpos) {
m_seekpos = m_pFile->m_dcs.GetHeadPosition();
m_seekpacket = 0;
m_seekfilepos = m_pFile->m_dcs.GetAt(m_seekpos)->pos;
@@ -692,8 +665,7 @@ bool CRealMediaSplitterFilter::DemuxLoop()
POSITION pos;
pos = m_pFile->m_subs.GetHeadPosition();
- for(DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++)
- {
+ for(DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++) {
CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet);
@@ -727,17 +699,16 @@ bool CRealMediaSplitterFilter::DemuxLoop()
}
pos = m_seekpos;
- while(pos && SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
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(NULL); i++)
- {
+ for(UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(NULL); i++) {
MediaPacketHeader mph;
- if(S_OK != (hr = m_pFile->Read(mph)))
+ if(S_OK != (hr = m_pFile->Read(mph))) {
break;
+ }
CAutoPtr<Packet> p(DNew Packet);
p->TrackNumber = mph.stream;
@@ -759,7 +730,9 @@ bool CRealMediaSplitterFilter::DemuxLoop()
STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
nKFs = m_pFile->m_irs.GetCount();
return S_OK;
}
@@ -769,13 +742,18 @@ STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFEREN
CheckPointer(pFormat, E_POINTER);
CheckPointer(pKFs, E_POINTER);
- if(!m_pFile) return E_UNEXPECTED;
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) return E_INVALIDARG;
+ 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++)
+ for(int i = 0; pos && nKFsTmp < nKFs; i++) {
pKFs[nKFsTmp++] = 10000i64*m_pFile->m_irs.GetNext(pos)->tStart;
+ }
nKFs = nKFsTmp;
return S_OK;
@@ -808,8 +786,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
{
HRESULT hr;
- if(m_segments.GetCount() == 0)
- {
+ if(m_segments.GetCount() == 0) {
m_segments.Clear();
return S_OK;
}
@@ -824,8 +801,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
DWORD len = 0, total = 0;
POSITION pos = m_segments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
segment* s = m_segments.GetNext(pos);
len = max(len, s->offset + s->data.GetCount());
total += s->data.GetCount();
@@ -839,18 +815,14 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
*pData++ = m_segments.fMerged ? 0 : m_segments.GetCount()-1;
- if(m_segments.fMerged)
- {
+ if(m_segments.fMerged) {
*((DWORD*)pData) = 1;
pData += 4;
*((DWORD*)pData) = 0;
pData += 4;
- }
- else
- {
+ } else {
pos = m_segments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
*((DWORD*)pData) = 1;
pData += 4;
*((DWORD*)pData) = m_segments.GetNext(pos)->offset;
@@ -859,8 +831,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
}
pos = m_segments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
segment* s = m_segments.GetNext(pos);
memcpy(pData + s->offset, s->data.GetData(), s->data.GetCount());
}
@@ -878,74 +849,77 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
ASSERT(p->rtStart < p->rtStop);
- if(m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
WORD* s = (WORD*)p->GetData();
WORD* e = s + p->GetCount()/2;
- while(s < e) bswap(*s++);
+ 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)
- {
+ || m_mt.subtype == MEDIASUBTYPE_RV41) {
CAutoLock cAutoLock(&m_csQueue);
int len = p->GetCount();
BYTE* pIn = p->GetData();
BYTE* pInOrg = pIn;
- if(m_segments.rtStart != p->rtStart)
- {
- if(S_OK != (hr = DeliverSegments()))
+ if(m_segments.rtStart != p->rtStart) {
+ if(S_OK != (hr = DeliverSegments())) {
return hr;
+ }
}
- if(!m_segments.fDiscontinuity && p->bDiscontinuity)
+ if(!m_segments.fDiscontinuity && p->bDiscontinuity) {
m_segments.fDiscontinuity = true;
+ }
m_segments.fSyncPoint = !!p->bSyncPoint;
m_segments.rtStart = p->rtStart;
- while(pIn - pInOrg < len)
- {
+ while(pIn - pInOrg < len) {
BYTE hdr = *pIn++, subseq = 0, seqnum = 0;
DWORD packetlen = 0, packetoffset = 0;
- if((hdr&0xc0) == 0x40)
- {
+ if((hdr&0xc0) == 0x40) {
pIn++;
packetlen = len - (pIn - pInOrg);
- }
- else
- {
- if((hdr&0x40) == 0)
+ } else {
+ if((hdr&0x40) == 0) {
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&0x8000) {
+ m_segments.fMerged = true;
+ }
if((packetlen&0x4000) == 0) {
GetWORD(packetlen);
packetlen &= 0x3fffffff;
+ } else {
+ packetlen &= 0x3fff;
}
- else packetlen &= 0x3fff;
GetWORD(packetoffset);
if((packetoffset&0x4000) == 0) {
GetWORD(packetoffset);
packetoffset &= 0x3fffffff;
+ } else {
+ packetoffset &= 0x3fff;
}
- else packetoffset &= 0x3fff;
#undef GetWORD
- if((hdr&0xc0) == 0xc0)
+ if((hdr&0xc0) == 0xc0) {
m_segments.rtStart = 10000i64*packetoffset - m_rtStart, packetoffset = 0;
- else if((hdr&0xc0) == 0x80)
+ } else if((hdr&0xc0) == 0x80) {
packetoffset = packetlen - packetoffset;
+ }
seqnum = *pIn++;
}
@@ -960,16 +934,14 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
pIn += len2;
- if((hdr&0x80) || packetoffset+len2 >= packetlen)
- {
- if(S_OK != (hr = DeliverSegments()))
+ 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)
- {
+ } 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;
@@ -977,8 +949,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
int remaining = p->GetCount()-2;
int expected = *(ptr-1)>>4;
- while(total < remaining)
- {
+ while(total < remaining) {
int size = (ptr[0]<<8)|(ptr[1]);
sizes.AddTail(size);
total += size;
@@ -996,8 +967,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
BOOL bDiscontinuity = p->bDiscontinuity;
POSITION pos = sizes.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
WORD size = sizes.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet);
@@ -1008,12 +978,11 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p->SetData(ptr, size);
ptr += size;
bDiscontinuity = false;
- if(S_OK != (hr = __super::DeliverPacket(p)))
+ if(S_OK != (hr = __super::DeliverPacket(p))) {
break;
+ }
}
- }
- else
- {
+ } else {
hr = __super::DeliverPacket(p);
}
@@ -1038,7 +1007,9 @@ CRealMediaSourceFilter::CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
CRMFile::CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
@@ -1056,8 +1027,9 @@ HRESULT CRMFile::Read(ChunkHdr& hdr)
HRESULT hr;
if(S_OK != (hr = Read(hdr.object_id))
|| S_OK != (hr = Read(hdr.size))
- || S_OK != (hr = Read(hdr.object_version)))
+ || S_OK != (hr = Read(hdr.object_version))) {
return hr;
+ }
return S_OK;
}
@@ -1069,16 +1041,21 @@ HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull)
HRESULT hr;
UINT16 object_version;
- if(S_OK != (hr = Read(object_version))) return hr;
- if(object_version != 0 && object_version != 1) return S_OK;
+ 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)))
+ || S_OK != (hr = Read(flags))) {
return hr;
+ }
mph.flags = (MediaPacketHeader::flag_t)flags;
LONG len = mph.len;
@@ -1088,14 +1065,12 @@ HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull)
ASSERT(len >= 0);
len = max(len, 0);
- if(fFull)
- {
+ if(fFull) {
mph.pData.SetCount(len);
- if(mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len)))
+ if(mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
return hr;
- }
- else
- {
+ }
+ } else {
Seek(GetPos() + len);
}
@@ -1112,143 +1087,230 @@ HRESULT CRMFile::Init()
HRESULT hr;
ChunkHdr hdr;
- while(GetRemaining() && S_OK == (hr = Read(hdr)))
- {
+ while(GetRemaining() && S_OK == (hr = Read(hdr))) {
__int64 pos = GetPos() - sizeof(hdr);
- if(fFirstChunk && hdr.object_id != '.RMF')
+ if(fFirstChunk && hdr.object_id != '.RMF') {
return E_FAIL;
+ }
fFirstChunk = false;
- if(pos + hdr.size > GetLength() && hdr.object_id != 'DATA') // truncated?
+ if(pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
break;
+ }
- if(hdr.object_id == 0x2E7261FD) // '.ra+0xFD'
+ 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;
+ 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(DNew 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 slen;
+ if(S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(slen), slen))) {
+ return hr;
+ }
+ if(S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(slen), slen))) {
+ 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;
}
- 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(DNew 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 slen;
- if(S_OK != (hr = Read(slen))) return hr;
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(slen), slen))) return hr;
- if(S_OK != (hr = Read(slen))) return hr;
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(slen), slen))) 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(DNew 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(DNew 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);
+ case 'DATA': {
+ CAutoPtr<DataChunk> dc(DNew 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;
}
- 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, NULL, 10));
- p += s.data.GetLength();
- m_subs.AddTail(s);
+ 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(DNew 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;
}
- 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, NULL, 10));
+ p += s.data.GetLength();
+ m_subs.AddTail(s);
+ }
+ }
+ break;
}
}
- if(hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA')
- {
+ if(hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
hdr.size = GetPos() - pos;
}
@@ -1257,8 +1319,9 @@ HRESULT CRMFile::Init()
|| GetPos() == pos + sizeof(hdr));
pos += hdr.size;
- if(pos > GetPos())
+ if(pos > GetPos()) {
Seek(pos);
+ }
}
return S_OK;
@@ -1272,8 +1335,7 @@ unsigned int GetBits2(int n, unsigned char*& p, unsigned int& bit_offset, unsign
bit_offset += n;
bit_buffer <<= n;
- if(bit_offset > (32-16))
- {
+ if(bit_offset > (32-16)) {
p += bit_offset >> 3;
bit_offset &= 7;
bit_buffer = (unsigned int)p[0] << 24;
@@ -1303,32 +1365,25 @@ void GetDimensions(unsigned char* p, unsigned int* wi, unsigned int* hi)
GetBits(13);
w = cw[GetBits(3)];
- if(w == 0)
- {
- do
- {
+ if(w == 0) {
+ do {
c = GetBits(8);
w += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
c = GetBits(3);
h = ch1[c];
- if(h == 0)
- {
+ if(h == 0) {
c = ((c << 1) | GetBits(1)) & 3;
h = ch2[c];
- if(h == 0)
- {
- do
- {
+ if(h == 0) {
+ do {
c = GetBits(8);
h += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
}
@@ -1355,53 +1410,49 @@ void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi,
*top_field_first = false;
*repeat_field = false;
c = GetBits(1);
- if (c)
- {
+ if (c) {
c = GetBits(1);
- if (c)
+ if (c) {
*interlaced = true;
+ }
c = GetBits(1);
- if (c)
+ if (c) {
*top_field_first = true;
+ }
c = GetBits(1);
- if (c)
+ if (c) {
*repeat_field = true;
+ }
c = GetBits(1);
c = GetBits(1);
- if (c)
+ if (c) {
GetBits(2);
+ }
}
GetBits(16);
w = cw[GetBits(3)];
- if(w == 0)
- {
- do
- {
+ if(w == 0) {
+ do {
c = GetBits(8);
w += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
c = GetBits(3);
h = ch1[c];
- if(h == 0)
- {
+ if(h == 0) {
c = ((c << 1) | GetBits(1)) & 3;
h = ch2[c];
- if(h == 0)
- {
- do
- {
+ if(h == 0) {
+ do {
c = GetBits(8);
h += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
}
@@ -1412,27 +1463,26 @@ void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi,
void CRMFile::GetDimensions()
{
POSITION pos = m_mps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
UINT64 filepos = GetPos();
MediaProperies* pmp = m_mps.GetNext(pos);
- if(pmp->mime == "video/x-pn-realvideo")
- {
+ 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')
+ if(rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
continue;
+ }
MediaPacketHeader mph;
- while(S_OK == Read(mph))
- {
+ while(S_OK == Read(mph)) {
if(mph.stream != pmp->stream || mph.len == 0
- || !(mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG))
+ || !(mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG)) {
continue;
+ }
BYTE* p = mph.pData.GetData();
BYTE* p0 = p;
@@ -1441,13 +1491,12 @@ void CRMFile::GetDimensions()
BYTE hdr = *p++;
DWORD packetlen = 0, packetoffset = 0;
- if((hdr&0xc0) == 0x40)
- {
+ if((hdr&0xc0) == 0x40) {
packetlen = len - (++p - p0);
- }
- else
- {
- if((hdr&0x40) == 0) p++;
+ } else {
+ if((hdr&0x40) == 0) {
+ p++;
+ }
#define GetWORD(var) \
var = (var<<8)|(*p++); \
@@ -1457,34 +1506,42 @@ void CRMFile::GetDimensions()
if((packetlen&0x4000) == 0) {
GetWORD(packetlen);
packetlen &= 0x3fffffff;
+ } else {
+ packetlen &= 0x3fff;
}
- else packetlen &= 0x3fff;
GetWORD(packetoffset);
if((packetoffset&0x4000) == 0) {
GetWORD(packetoffset);
packetoffset &= 0x3fffffff;
+ } else {
+ packetoffset &= 0x3fff;
}
- else packetoffset &= 0x3fff;
#undef GetWORD
- if((hdr&0xc0) == 0xc0) packetoffset = 0;
- else if((hdr&0xc0) == 0x80) packetoffset = packetlen - packetoffset;
+ if((hdr&0xc0) == 0xc0) {
+ packetoffset = 0;
+ } else if((hdr&0xc0) == 0x80) {
+ packetoffset = packetlen - packetoffset;
+ }
p++;
}
len = min(len - (p - p0), packetlen - packetoffset);
- if(len > 0)
- {
+ 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.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)
+ if(rvi.w == pmp->width && rvi.h == pmp->height) {
pmp->width = pmp->height = 0;
+ }
break;
}
@@ -1500,18 +1557,19 @@ int CRMFile::GetMasterStream()
int s1 = -1, s2 = -1;
POSITION pos = m_mps.GetHeadPosition();
- while(pos)
- {
+ 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;
}
- else if(pmp->mime == "audio/x-pn-realaudio" && s2 == -1) s2 = pmp->stream;
}
- if(s1 == -1)
+ if(s1 == -1) {
s1 = s2;
+ }
return s1;
}
@@ -1533,7 +1591,9 @@ CRealVideoDecoder::CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
CRealVideoDecoder::~CRealVideoDecoder()
{
- if(m_hDrvDll) FreeLibrary(m_hDrvDll);
+ if(m_hDrvDll) {
+ FreeLibrary(m_hDrvDll);
+ }
}
HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
@@ -1553,17 +1613,18 @@ HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
{11, rvi.w, rvi.h, 0, 0, rvi.type1, 1, rvi.type2};
#pragma pack(pop)
- if(FAILED(hr = RVInit(&i, &m_dwCookie)))
+ if(FAILED(hr = RVInit(&i, &m_dwCookie))) {
return hr;
+ }
- if(rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002)
- {
+ if(rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002) {
int nWidthHeight = (1+((rvi.type1>>16)&7));
UINT32* pWH = DNew UINT32[nWidthHeight*2];
pWH[0] = rvi.w;
pWH[1] = rvi.h;
- for(int i = 2; i < nWidthHeight*2; i++)
+ for(int i = 2; i < nWidthHeight*2; i++) {
pWH[i] = rvi.morewh[i-2]*4;
+ }
#pragma pack(push, 1)
struct {
UINT32 data1;
@@ -1581,8 +1642,7 @@ HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
void CRealVideoDecoder::FreeRV()
{
- if(m_dwCookie)
- {
+ if(m_dwCookie) {
RVFree(m_dwCookie);
m_dwCookie = 0;
}
@@ -1595,11 +1655,14 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
HRESULT hr;
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK; // nothing to do
+ if(len <= 0) {
+ return S_OK; // nothing to do
+ }
REFERENCE_TIME rtStart, rtStop;
pIn->GetTime(&rtStart, &rtStop);
@@ -1623,8 +1686,7 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
pDataIn += offset;
- if(m_fDropFrames && m_timestamp+1 == transform_in.timestamp)
- {
+ if(m_fDropFrames && m_timestamp+1 == transform_in.timestamp) {
m_timestamp = transform_in.timestamp;
return S_OK;
}
@@ -1635,36 +1697,29 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
::GetDimensions_X10(pDataIn, &tmp1, &tmp2, &interlaced, &tmp3, &tmp4);
int size = tmp1*tmp2;
- if( m_lastBuffSizeDim < size )
- {
+ if( m_lastBuffSizeDim < size ) {
_aligned_free(m_pI420);
_aligned_free(m_pI420Tmp);
m_lastBuffSizeDim = size;
ATLTRACE("resize out put buff %d" ,size);
- if ( m_pI420 = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16)))
- {
+ if ( m_pI420 = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16))) {
ATLTRACE(" m_pI420.Allocated 1" );
memset(m_pI420, 0, size);
ATLTRACE(" m_pI420.Allocated 2" );
memset(m_pI420 + size, 0x80, size/2);
ATLTRACE(" m_pI420.Allocated 3" );
- }
- else
- {
+ } else {
ATLTRACE(" m_pI420.Allocate fail %d" ,size*3/2);
return S_OK;
}
- if( m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16)))
- {
+ if( m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16))) {
ATLTRACE(" m_pI420Tmp.Allocated 1" );
memset(m_pI420Tmp, 0, size);
ATLTRACE(" m_pI420Tmp.Allocated 2" );
memset(m_pI420Tmp + size, 0x80, size/2);
ATLTRACE(" m_pI420Tmp.Allocated 3" );
- }
- else
- {
+ } else {
ATLTRACE(" m_pI420Tmp.Allocate fail %d" ,size*3/2);
return S_OK;
}
@@ -1674,27 +1729,27 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
m_timestamp = transform_in.timestamp;
- if(FAILED(hr))
- {
+ 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;
+ // return hr;
}
- if(pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1&1))
+ if(pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1&1)) {
return S_OK;
+ }
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
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)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
BYTE* pI420[3] = {m_pI420, m_pI420Tmp, NULL};
- if(interlaced)
- {
+ if(interlaced) {
int size = m_w*m_h;
DeinterlaceBlend(pI420[1], pI420[0], m_w, m_h, m_w, m_w);
DeinterlaceBlend(pI420[1]+size, pI420[0]+size, m_w/2, m_h/2, m_w/2, m_w/2);
@@ -1702,12 +1757,12 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
}
- if(transform_out.w != m_w || transform_out.h != m_h)
- {
+ 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)
+ 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;
@@ -1719,7 +1774,7 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
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));
+ rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
return m_pOutput->Deliver(pOut);
}
@@ -1729,22 +1784,23 @@ void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD
int si = wi*hi, so = wo*ho;
ASSERT(((si*so)&3) == 0);
- if(wi < wo)
- {
+ 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;
+ 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)
- {
+ } 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;
+ 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);
@@ -1754,23 +1810,23 @@ void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD
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);
+ 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)
- {
+ if(hi == ho) {
memcpy(pOut, pIn, wo*ho);
- }
- else
- {
- for(DWORD x = 0; x < wo; x++, pIn++, pOut++)
+ } else {
+ for(DWORD x = 0; x < wo; x++, pIn++, pOut++) {
ResizeRow(pIn, hi, wo, pOut, ho, wo);
+ }
}
}
@@ -1778,10 +1834,9 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW
{
ASSERT(wi < wo);
- if(dpo == 1)
- {
+ 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];
+ // pOut[i] = pIn[j>>16];
{
BYTE* p = &pIn[j>>16];
DWORD jf = j&0xffff;
@@ -1789,11 +1844,9 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW
}
*pOut = pIn[wi-1];
- }
- else
- {
+ } else {
for(DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut += dpo, j += dj)
-// *pOut = pIn[dpi*(j>>16)];
+ // *pOut = pIn[dpi*(j>>16)];
{
BYTE* p = &pIn[dpi*(j>>16)];
DWORD jf = j&0xffff;
@@ -1807,22 +1860,22 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW
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)
+ || 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)
- {
+ if(mtIn->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mtIn->Format();
if(vih2->dwPictAspectRatioX < vih2->bmiHeader.biWidth
- || vih2->dwPictAspectRatioY < vih2->bmiHeader.biHeight)
+ || vih2->dwPictAspectRatioY < vih2->bmiHeader.biHeight) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
- if(!m_pInput->IsConnected())
- {
+ if(!m_pInput->IsConnected()) {
if(m_hDrvDll) {
FreeLibrary(m_hDrvDll);
m_hDrvDll = NULL;
@@ -1833,65 +1886,88 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
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");
+ 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(NULL, buff, &len) && _tcslen(buff) > 0)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
oldpath = buff;
TCHAR c = oldpath[oldpath.GetLength()-1];
- if(c != '\\' && c != '/') oldpath += '\\';
+ 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(NULL, buff, &len) && _tcslen(buff) > 0)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
newpath = buff;
TCHAR c = newpath[newpath.GetLength()-1];
- if(c != '\\' && c != '/') newpath += '\\';
+ if(c != '\\' && c != '/') {
+ newpath += '\\';
+ }
key.Close();
}
- if(!newpath.IsEmpty()) paths.AddTail(newpath + newdll);
- if(!oldpath.IsEmpty()) paths.AddTail(oldpath + newdll);
+ 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);
+ 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));
+ if (pos) {
+ m_hDrvDll = LoadLibrary(paths.GetNext(pos));
+ }
} while(pos && !m_hDrvDll);
- if(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(!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)
+ || !RVFree || !RVHiveMessage
+ || !RVInit || !RVTransform) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(FAILED(InitRV(mtIn)))
+ if(FAILED(InitRV(mtIn))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return S_OK;
@@ -1899,12 +1975,12 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if(m_pOutput && m_pOutput->IsConnected())
- {
+ if(m_pOutput && m_pOutput->IsConnected()) {
BITMAPINFOHEADER bih1, bih2;
if(ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
- && abs(bih1.biHeight) != abs(bih2.biHeight))
+ && abs(bih1.biHeight) != abs(bih2.biHeight)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return __super::CheckTransform(mtIn, mtOut);
@@ -1913,8 +1989,9 @@ HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaTy
HRESULT CRealVideoDecoder::StartStreaming()
{
const CMediaType& mt = m_pInput->CurrentMediaType();
- if(FAILED(InitRV(&mt)))
+ if(FAILED(InitRV(&mt))) {
return E_FAIL;
+ }
int size = m_w*m_h;
m_lastBuffSizeDim = size;
@@ -1954,9 +2031,13 @@ HRESULT CRealVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tSto
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);
+ 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;
}
@@ -1971,13 +2052,17 @@ CRealAudioDecoder::CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr)
, m_hDrvDll(NULL)
, m_dwCookie(0)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CRealAudioDecoder::~CRealAudioDecoder()
{
-// FreeRA();
- if(m_hDrvDll) FreeLibrary(m_hDrvDll);
+ // FreeRA();
+ if(m_hDrvDll) {
+ FreeLibrary(m_hDrvDll);
+ }
}
HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
@@ -1987,8 +2072,9 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
HRESULT hr;
if(RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
- || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie)))
+ || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->Format();
@@ -2002,7 +2088,9 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
}
WORD wBitsPerSample = pwfe->wBitsPerSample;
- if(!wBitsPerSample) wBitsPerSample = 16;
+ if(!wBitsPerSample) {
+ wBitsPerSample = 16;
+ }
#pragma pack(push, 1)
struct {
@@ -2010,33 +2098,31 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
WORD bpsample, channels, quality;
DWORD bpframe, packetsize, extralen;
void* extra;
- } initdata =
- { pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
+ } initdata = {
+ pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
0, 0, 0, NULL
};
#pragma pack(pop)
CAutoVectorPtr<BYTE> pBuff;
- if(pmt->subtype == MEDIASUBTYPE_AAC)
- {
+ 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
+ } 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')
+ 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;
@@ -2044,26 +2130,23 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
BYTE* p;
- if(m_rai.version2 == 4)
- {
+ 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)
- {
+ } else if(m_rai.version2 == 5) {
p = (BYTE*)((rainfo5*)fmt+1);
- }
- else
- {
+ } else {
return VFW_E_TYPE_NOT_ACCEPTED;
}
p += 3;
- if(m_rai.version2 == 5) p++;
+ if(m_rai.version2 == 5) {
+ p++;
+ }
initdata.bpframe = m_rai.sub_packet_size;
initdata.packetsize = m_rai.coded_frame_size;
@@ -2071,22 +2154,24 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
initdata.extra = p + 4;
}
- if(FAILED(hr = RAInitDecoder(m_dwCookie, &initdata)))
+ if(FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(RASetPwd)
+ if(RASetPwd) {
RASetPwd(m_dwCookie, "Ardubancel Quazanga");
+ }
- if(RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor)))
+ 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)
- {
+ if(m_dwCookie) {
RAFreeDecoder(m_dwCookie);
RACloseCodec(m_dwCookie);
m_dwCookie = 0;
@@ -2100,26 +2185,30 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ if(pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
+ }
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
BYTE* pDataInOrg = pDataIn;
UNUSED_ALWAYS(pDataInOrg);
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK;
+ 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(pIn->IsPreroll() == S_OK || rtStart < 0)
+ return S_OK;
+ */
- if(S_OK == pIn->IsSyncPoint())
- {
+ if(S_OK == pIn->IsSyncPoint()) {
m_bufflen = 0;
m_rtBuffStart = rtStart;
m_fBuffDiscontinuity = pIn->IsDiscontinuity() == S_OK;
@@ -2134,21 +2223,17 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
if(m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
|| m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RACP
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC)
- {
+ || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC) {
src = pDataIn;
dst = pDataIn + len;
w = len;
- }
- else
- {
+ } else {
memcpy(&m_buff[m_bufflen], pDataIn, len);
m_bufflen += len;
len = w*h;
- if(m_bufflen >= len)
- {
+ if(m_bufflen >= len) {
ASSERT(m_bufflen == len);
src = m_buff;
@@ -2156,12 +2241,9 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
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++)
- {
+ || 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;
@@ -2170,9 +2252,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
src = m_buff + len;
dst = m_buff + len*2;
- }
- else if(m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR)
- {
+ } 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]= {
@@ -2191,10 +2271,16 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
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;
+ 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;
}
@@ -2207,17 +2293,16 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
rtStart = m_rtBuffStart;
- for(; src < dst; src += w)
- {
+ for(; src < dst; src += w) {
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
if(FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -2225,11 +2310,10 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
hr = RADecode(m_dwCookie, src, w, pDataOut, &len, -1);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
TRACE(_T("RA returned an error code!!!\n"));
continue;
-// return hr;
+ // return hr;
}
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
@@ -2247,8 +2331,9 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
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)))
+ if(rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
return hr;
+ }
rtStart = rtStop;
}
@@ -2269,11 +2354,11 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
&& mtIn->subtype != MEDIASUBTYPE_SIPR
&& mtIn->subtype != MEDIASUBTYPE_RAAC
&& mtIn->subtype != MEDIASUBTYPE_RACP
- && mtIn->subtype != MEDIASUBTYPE_AAC)
+ && mtIn->subtype != MEDIASUBTYPE_AAC) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(!m_pInput->IsConnected())
- {
+ if(!m_pInput->IsConnected()) {
if(m_hDrvDll) {
FreeLibrary(m_hDrvDll);
m_hDrvDll = NULL;
@@ -2282,8 +2367,7 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
CAtlList<CString> paths;
CString olddll, newdll, oldpath, newpath;
- TCHAR fourcc[5] =
- {
+ TCHAR fourcc[5] = {
(TCHAR)((mtIn->subtype.Data1>>0)&0xff),
(TCHAR)((mtIn->subtype.Data1>>8)&0xff),
(TCHAR)((mtIn->subtype.Data1>>16)&0xff),
@@ -2291,8 +2375,9 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
0
};
- if(!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc))
+ if(!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
_tcscpy(fourcc, _T("RAAC"));
+ }
olddll.Format(_T("%s3260.dll"), fourcc);
newdll.Format(_T("%s.dll"), fourcc);
@@ -2301,37 +2386,48 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
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(NULL, buff, &len) && _tcslen(buff) > 0)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
oldpath = buff;
TCHAR c = oldpath[oldpath.GetLength()-1];
- if(c != '\\' && c != '/') oldpath += '\\';
+ 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(NULL, buff, &len) && _tcslen(buff) > 0)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
newpath = buff;
TCHAR c = newpath[newpath.GetLength()-1];
- if(c != '\\' && c != '/') newpath += '\\';
+ if(c != '\\' && c != '/') {
+ newpath += '\\';
+ }
key.Close();
}
- if(!newpath.IsEmpty()) paths.AddTail(newpath + newdll);
- if(!oldpath.IsEmpty()) paths.AddTail(oldpath + newdll);
+ 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);
+ 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));
+ if (pos) {
+ m_hDrvDll = LoadLibrary(paths.GetNext(pos));
+ }
} while(pos && !m_hDrvDll);
- if(m_hDrvDll)
- {
+ if(m_hDrvDll) {
RACloseCodec = (PCloseCodec)GetProcAddress(m_hDrvDll, "RACloseCodec");
RADecode = (PDecode)GetProcAddress(m_hDrvDll, "RADecode");
RAFlush = (PFlush)GetProcAddress(m_hDrvDll, "RAFlush");
@@ -2347,23 +2443,25 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
if(!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
|| !RAFreeDecoder || !RAGetFlavorProperty || !RAInitDecoder
- || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/)
+ || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(m_hDrvDll)
- {
+ if(m_hDrvDll) {
char buff[_MAX_PATH];
GetModuleFileNameA(m_hDrvDll, buff, MAX_PATH);
CPathA p(buff);
p.RemoveFileSpec();
p.AddBackslash();
m_dllpath = p.m_strPath;
- if(RASetDLLAccessPath)
+ if(RASetDLLAccessPath) {
RASetDLLAccessPath("DT_Codecs=" + m_dllpath);
+ }
}
- if(FAILED(InitRA(mtIn)))
+ if(FAILED(InitRA(mtIn))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return S_OK;
@@ -2387,16 +2485,22 @@ HRESULT CRealAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaTy
HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
WORD wBitsPerSample = pwfe->wBitsPerSample;
- if(!wBitsPerSample) wBitsPerSample = 16;
+ if(!wBitsPerSample) {
+ wBitsPerSample = 16;
+ }
// ok, maybe this is too much...
pProperties->cBuffers = 8;
@@ -2406,8 +2510,9 @@ HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
@@ -2416,26 +2521,32 @@ HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR
HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ 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(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;
+ 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[] =
- {
+ if(iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
+ static DWORD chmask[] = {
KSAUDIO_SPEAKER_DIRECTOUT,
KSAUDIO_SPEAKER_MONO,
KSAUDIO_SPEAKER_STEREO,
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
index b97121801..89f2e0b59 100644
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
+++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
@@ -30,64 +30,60 @@
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;
+ 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
-{
+struct rvinfo {
DWORD dwSize, fcc1, fcc2;
WORD w, h, bpp;
DWORD unk1, fps, type1, type2;
@@ -95,8 +91,7 @@ struct rvinfo
void bswap();
};
-struct rainfo
-{
+struct rainfo {
DWORD fourcc1; // '.', 'r', 'a', 0xfd
WORD version1; // 4 or 5
WORD unknown1; // 00 000
@@ -116,8 +111,7 @@ struct rainfo
void bswap();
};
-struct rainfo4 : rainfo
-{
+struct rainfo4 : rainfo {
WORD sample_rate;
WORD unknown8; // 0
WORD sample_size;
@@ -125,8 +119,7 @@ struct rainfo4 : rainfo
void bswap();
};
-struct rainfo5 : rainfo
-{
+struct rainfo5 : rainfo {
BYTE unknown7[6]; // 0, srate, 0
WORD sample_rate;
WORD unknown8; // 0
@@ -181,8 +174,7 @@ private:
public:
REFERENCE_TIME rtStart;
bool fDiscontinuity, fSyncPoint, fMerged;
- void Clear()
- {
+ void Clear() {
CAutoLock cAutoLock(this);
rtStart = 0;
fDiscontinuity = fSyncPoint = fMerged = false;
diff --git a/src/filters/parser/RoQSplitter/RoQSplitter.cpp b/src/filters/parser/RoQSplitter/RoQSplitter.cpp
index 71c7c4e8d..d87c8a3d6 100644
--- a/src/filters/parser/RoQSplitter/RoQSplitter.cpp
+++ b/src/filters/parser/RoQSplitter/RoQSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,64 +26,54 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_RoQ},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_RoQV},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins2[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut2), sudPinTypesOut2}
+const AMOVIESETUP_PIN sudpPins2[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut2), sudPinTypesOut2}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_RoQA},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
};
-const AMOVIESETUP_PIN sudpPins3[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn3), sudPinTypesIn3},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut3), sudPinTypesOut3}
+const AMOVIESETUP_PIN sudpPins3[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn3), sudPinTypesIn3},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut3), sudPinTypesOut3}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CRoQSplitterFilter), L"MPC - RoQ Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRoQSourceFilter), L"MPC - RoQ Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRoQVideoDecoder), L"MPC - RoQ Video Decoder", MERIT_NORMAL, countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRoQAudioDecoder), L"MPC - RoQ Audio Decoder", MERIT_NORMAL, countof(sudpPins3), sudpPins3, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CRoQSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CRoQSourceFilter>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRoQVideoDecoder>, NULL, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRoQAudioDecoder>, NULL, &sudFilter[3]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRoQVideoDecoder>, NULL, &sudFilter[2]},
+ {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRoQAudioDecoder>, NULL, &sudFilter[3]},
};
int g_cTemplates = countof(g_Templates);
@@ -127,7 +117,9 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
UINT64 hdr = 0, hdrchk = 0x001effffffff1084;
m_pAsyncReader->SyncRead(0, 8, (BYTE*)&hdr);
- if(hdr != hdrchk) return E_FAIL;
+ if(hdr != hdrchk) {
+ return E_FAIL;
+ }
//
@@ -152,19 +144,15 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
UINT64 pos = 8;
- while(S_OK == m_pAsyncReader->SyncRead(pos, sizeof(rc), (BYTE*)&rc))
- {
+ while(S_OK == m_pAsyncReader->SyncRead(pos, sizeof(rc), (BYTE*)&rc)) {
pos += sizeof(rc);
- if(rc.id == 0x1001)
- {
- if(S_OK != m_pAsyncReader->SyncRead(pos, sizeof(ri), (BYTE*)&ri) || ri.w == 0 || ri.h == 0)
+ if(rc.id == 0x1001) {
+ if(S_OK != m_pAsyncReader->SyncRead(pos, sizeof(ri), (BYTE*)&ri) || ri.w == 0 || ri.h == 0) {
break;
- }
- else if(rc.id == 0x1002 || rc.id == 0x1011)
- {
- if(!iHasVideo && ri.w > 0 && ri.h > 0)
- {
+ }
+ } else if(rc.id == 0x1002 || rc.id == 0x1011) {
+ if(!iHasVideo && ri.w > 0 && ri.h > 0) {
mts.RemoveAll();
mt.InitMediaType();
@@ -187,8 +175,7 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
AddOutputPin(0, pPinOut);
}
- if(rc.id == 0x1002)
- {
+ if(rc.id == 0x1002) {
iHasVideo++;
index i;
@@ -197,11 +184,8 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
i.fp = pos - sizeof(rc);
m_index.AddTail(i);
}
- }
- else if(rc.id == 0x1020 || rc.id == 0x1021)
- {
- if(!iHasAudio)
- {
+ } else if(rc.id == 0x1020 || rc.id == 0x1021) {
+ if(!iHasAudio) {
mts.RemoveAll();
mt.InitMediaType();
@@ -247,20 +231,21 @@ bool CRoQSplitterFilter::DemuxInit()
void CRoQSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0)
- {
+ if(rt <= 0) {
m_indexpos = m_index.GetHeadPosition();
- }
- else
- {
+ } else {
m_indexpos = m_index.GetTailPosition();
- while(m_indexpos && m_index.GetPrev(m_indexpos).rtv > rt);
+ while(m_indexpos && m_index.GetPrev(m_indexpos).rtv > rt) {
+ ;
+ }
}
}
bool CRoQSplitterFilter::DemuxLoop()
{
- if(!m_indexpos) return(true);
+ if(!m_indexpos) {
+ return(true);
+ }
index& i = m_index.GetAt(m_indexpos);
@@ -272,30 +257,26 @@ bool CRoQSplitterFilter::DemuxLoop()
roq_chunk rc;
while(S_OK == (hr = m_pAsyncReader->SyncRead(pos, sizeof(rc), (BYTE*)&rc))
- && !CheckRequest(NULL))
- {
+ && !CheckRequest(NULL)) {
pos += sizeof(rc);
CAutoPtr<Packet> p(DNew Packet());
- if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021)
- {
+ if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021) {
p->SetCount(sizeof(rc) + rc.size);
memcpy(p->GetData(), &rc, sizeof(rc));
- if(S_OK != (hr = m_pAsyncReader->SyncRead(pos, rc.size, p->GetData() + sizeof(rc))))
+ if(S_OK != (hr = m_pAsyncReader->SyncRead(pos, rc.size, p->GetData() + sizeof(rc)))) {
break;
+ }
}
- if(rc.id == 0x1002 || rc.id == 0x1011)
- {
+ if(rc.id == 0x1002 || rc.id == 0x1011) {
p->TrackNumber = 0;
p->bSyncPoint = rtVideo == 0;
p->rtStart = rtVideo;
p->rtStop = rtVideo += (rc.id == 0x1011 ? 10000000i64/30 : 0);
TRACE(_T("v: %I64d - %I64d (%d)\n"), p->rtStart/10000, p->rtStop/10000, p->GetCount());
- }
- else if(rc.id == 0x1020 || rc.id == 0x1021)
- {
+ } else if(rc.id == 0x1020 || rc.id == 0x1021) {
int nChannels = (rc.id&1)+1;
p->TrackNumber = 1;
@@ -305,8 +286,7 @@ bool CRoQSplitterFilter::DemuxLoop()
TRACE(_T("a: %I64d - %I64d (%d)\n"), p->rtStart/10000, p->rtStop/10000, p->GetCount());
}
- if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021)
- {
+ if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021) {
hr = DeliverPacket(p);
}
@@ -334,7 +314,9 @@ CRoQSourceFilter::CRoQSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
CRoQVideoDecoder::CRoQVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CRoQVideoDecoder"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CRoQVideoDecoder::~CRoQVideoDecoder()
@@ -366,9 +348,13 @@ void CRoQVideoDecoder::apply_vector_4x4(int x, int y, roq_cell* cell)
row_inc = m_pitch - 4;
c_row_inc = (m_pitch/2) - 2;
- *yptr++ = y0 = cell->y0; *uptr++ = u = cell->u; *vptr++ = v = cell->v;
+ *yptr++ = y0 = cell->y0;
+ *uptr++ = u = cell->u;
+ *vptr++ = v = cell->v;
*yptr++ = y0;
- *yptr++ = y1 = cell->y1; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y1 = cell->y1;
+ *uptr++ = u;
+ *vptr++ = v;
*yptr++ = y1;
yptr += row_inc;
@@ -378,11 +364,17 @@ void CRoQVideoDecoder::apply_vector_4x4(int x, int y, roq_cell* cell)
*yptr++ = y1;
*yptr++ = y1;
- yptr += row_inc; uptr += c_row_inc; vptr += c_row_inc;
+ yptr += row_inc;
+ uptr += c_row_inc;
+ vptr += c_row_inc;
- *yptr++ = y0 = cell->y2; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y0 = cell->y2;
+ *uptr++ = u;
+ *vptr++ = v;
*yptr++ = y0;
- *yptr++ = y1 = cell->y3; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y1 = cell->y3;
+ *uptr++ = u;
+ *vptr++ = v;
*yptr++ = y1;
yptr += row_inc;
@@ -403,8 +395,7 @@ void CRoQVideoDecoder::apply_motion_4x4(int x, int y, unsigned char mv, char mea
pa = m_y[0] + (y * m_pitch) + x;
pb = m_y[1] + (my * m_pitch) + mx;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -415,8 +406,7 @@ void CRoQVideoDecoder::apply_motion_4x4(int x, int y, unsigned char mv, char mea
pa = m_u[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_u[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 2; i++)
- {
+ for(i = 0; i < 2; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa += m_pitch/2;
@@ -425,8 +415,7 @@ void CRoQVideoDecoder::apply_motion_4x4(int x, int y, unsigned char mv, char mea
pa = m_v[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_v[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 2; i++)
- {
+ for(i = 0; i < 2; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa += m_pitch/2;
@@ -444,8 +433,7 @@ void CRoQVideoDecoder::apply_motion_8x8(int x, int y, unsigned char mv, char mea
pa = m_y[0] + (y * m_pitch) + x;
pb = m_y[1] + (my * m_pitch) + mx;
- for(i = 0; i < 8; i++)
- {
+ for(i = 0; i < 8; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -460,8 +448,7 @@ void CRoQVideoDecoder::apply_motion_8x8(int x, int y, unsigned char mv, char mea
pa = m_u[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_u[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -472,8 +459,7 @@ void CRoQVideoDecoder::apply_motion_8x8(int x, int y, unsigned char mv, char mea
pa = m_v[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_v[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -509,28 +495,33 @@ HRESULT CRoQVideoDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT hr;
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK; // nothing to do
+ if(len <= 0) {
+ return S_OK; // nothing to do
+ }
REFERENCE_TIME rtStart = 0, rtStop = 0;
pIn->GetTime(&rtStart, &rtStop);
- if(pIn->IsPreroll() == S_OK || rtStart < 0)
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
return S_OK;
+ }
BYTE* pDataOut = NULL;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)))
+ if(FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
@@ -543,39 +534,37 @@ HRESULT CRoQVideoDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
pDataIn += sizeof(roq_chunk);
- if(rc->id == 0x1002)
- {
+ if(rc->id == 0x1002) {
DWORD nv1 = rc->arg>>8;
- if(nv1 == 0) nv1 = 256;
+ if(nv1 == 0) {
+ nv1 = 256;
+ }
DWORD nv2 = rc->arg&0xff;
- if(nv2 == 0 && nv1 * 6 < rc->size) nv2 = 256;
+ if(nv2 == 0 && nv1 * 6 < rc->size) {
+ nv2 = 256;
+ }
memcpy(m_cells, pDataIn, sizeof(m_cells[0])*nv1);
pDataIn += sizeof(m_cells[0])*nv1;
for(int i = 0; i < (int)nv2; i++)
- for(int j = 0; j < 4; j++)
+ for(int j = 0; j < 4; j++) {
m_qcells[i].idx[j] = &m_cells[*pDataIn++];
+ }
return S_FALSE;
- }
- else if(rc->id == 0x1011)
- {
+ } else if(rc->id == 0x1011) {
int bpos = 0, xpos = 0, ypos = 0;
int vqflg = 0, vqflg_pos = -1, vqid;
roq_qcell* qcell = NULL;
BYTE* buf = pDataIn;
- while(bpos < (int)rc->size && ypos < h)
- {
- for(int yp = ypos; yp < ypos + 16; yp += 8)
- {
- for(int xp = xpos; xp < xpos + 16; xp += 8)
- {
- if(vqflg_pos < 0)
- {
+ while(bpos < (int)rc->size && ypos < h) {
+ for(int yp = ypos; yp < ypos + 16; yp += 8) {
+ for(int xp = xpos; xp < xpos + 16; xp += 8) {
+ if(vqflg_pos < 0) {
vqflg = buf[bpos++];
vqflg |= buf[bpos++]<<8;
vqflg_pos = 7;
@@ -584,87 +573,92 @@ HRESULT CRoQVideoDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
vqid = (vqflg >> (vqflg_pos * 2)) & 3;
vqflg_pos--;
- switch(vqid)
- {
- case 0:
- break;
- case 1:
- apply_motion_8x8(xp, yp, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
- break;
- case 2:
- qcell = m_qcells + buf[bpos++];
- apply_vector_4x4(xp, yp, qcell->idx[0]);
- apply_vector_4x4(xp+4, yp, qcell->idx[1]);
- apply_vector_4x4(xp, yp+4, qcell->idx[2]);
- apply_vector_4x4(xp+4, yp+4, qcell->idx[3]);
- break;
- case 3:
- for(int k = 0; k < 4; k++)
- {
- int x = xp, y = yp;
- if(k&1) x += 4;
- if(k&2) y += 4;
-
- if(vqflg_pos < 0)
- {
- vqflg = buf[bpos++];
- vqflg |= buf[bpos++]<<8;
- vqflg_pos = 7;
- }
-
- vqid = (vqflg >> (vqflg_pos * 2)) & 3;
- vqflg_pos--;
-
- switch(vqid)
- {
- case 0:
- break;
- case 1:
- apply_motion_4x4(x, y, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
- break;
- case 2:
- qcell = m_qcells + buf[bpos++];
- apply_vector_2x2(x, y, qcell->idx[0]);
- apply_vector_2x2(x+2, y, qcell->idx[1]);
- apply_vector_2x2(x, y+2, qcell->idx[2]);
- apply_vector_2x2(x+2, y+2, qcell->idx[3]);
- break;
- case 3:
- apply_vector_2x2(x, y, &m_cells[buf[bpos++]]);
- apply_vector_2x2(x+2, y, &m_cells[buf[bpos++]]);
- apply_vector_2x2(x, y+2, &m_cells[buf[bpos++]]);
- apply_vector_2x2(x+2, y+2, &m_cells[buf[bpos++]]);
- break;
+ switch(vqid) {
+ case 0:
+ break;
+ case 1:
+ apply_motion_8x8(xp, yp, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
+ break;
+ case 2:
+ qcell = m_qcells + buf[bpos++];
+ apply_vector_4x4(xp, yp, qcell->idx[0]);
+ apply_vector_4x4(xp+4, yp, qcell->idx[1]);
+ apply_vector_4x4(xp, yp+4, qcell->idx[2]);
+ apply_vector_4x4(xp+4, yp+4, qcell->idx[3]);
+ break;
+ case 3:
+ for(int k = 0; k < 4; k++) {
+ int x = xp, y = yp;
+ if(k&1) {
+ x += 4;
+ }
+ if(k&2) {
+ y += 4;
+ }
+
+ if(vqflg_pos < 0) {
+ vqflg = buf[bpos++];
+ vqflg |= buf[bpos++]<<8;
+ vqflg_pos = 7;
+ }
+
+ vqid = (vqflg >> (vqflg_pos * 2)) & 3;
+ vqflg_pos--;
+
+ switch(vqid) {
+ case 0:
+ break;
+ case 1:
+ apply_motion_4x4(x, y, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
+ break;
+ case 2:
+ qcell = m_qcells + buf[bpos++];
+ apply_vector_2x2(x, y, qcell->idx[0]);
+ apply_vector_2x2(x+2, y, qcell->idx[1]);
+ apply_vector_2x2(x, y+2, qcell->idx[2]);
+ apply_vector_2x2(x+2, y+2, qcell->idx[3]);
+ break;
+ case 3:
+ apply_vector_2x2(x, y, &m_cells[buf[bpos++]]);
+ apply_vector_2x2(x+2, y, &m_cells[buf[bpos++]]);
+ apply_vector_2x2(x, y+2, &m_cells[buf[bpos++]]);
+ apply_vector_2x2(x+2, y+2, &m_cells[buf[bpos++]]);
+ break;
+ }
}
- }
- break;
+ break;
}
}
}
xpos += 16;
- if(xpos >= w) {xpos -= w; ypos += 16;}
+ if(xpos >= w) {
+ xpos -= w;
+ ypos += 16;
+ }
}
- if(m_rtStart+rtStart == 0)
- {
+ if(m_rtStart+rtStart == 0) {
memcpy(m_y[1], m_y[0], w*h*3/2);
- }
- else
- {
+ } else {
BYTE* tmp;
- tmp = m_y[0]; m_y[0] = m_y[1]; m_y[1] = tmp;
- tmp = m_u[0]; m_u[0] = m_u[1]; m_u[1] = tmp;
- tmp = m_v[0]; m_v[0] = m_v[1]; m_v[1] = tmp;
+ tmp = m_y[0];
+ m_y[0] = m_y[1];
+ m_y[1] = tmp;
+ tmp = m_u[0];
+ m_u[0] = m_u[1];
+ m_u[1] = tmp;
+ tmp = m_v[0];
+ m_v[0] = m_v[1];
+ m_v[1] = tmp;
}
- }
- else
- {
+ } else {
return E_UNEXPECTED;
}
- if(rtStart < 0)
+ if(rtStart < 0) {
return S_FALSE;
+ }
Copy(pDataOut, m_y[1], w, h);
@@ -683,32 +677,24 @@ void CRoQVideoDecoder::Copy(BYTE* pOut, BYTE* pIn, DWORD w, DWORD h)
BYTE* pInU = pIn + pitchIn*h;
BYTE* pInV = pInU + pitchInUV*h/2;
- if(bihOut.biCompression == '2YUY')
- {
+ if(bihOut.biCompression == '2YUY') {
BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI')
- {
+ } else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI') {
BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h, pOut + bihOut.biWidth*h*5/4, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == '21VY')
- {
+ } else if(bihOut.biCompression == '21VY') {
BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h*5/4, pOut + bihOut.biWidth*h, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
int pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
- if(bihOut.biHeight > 0)
- {
+ if(bihOut.biHeight > 0) {
pOut += pitchOut*(h-1);
pitchOut = -pitchOut;
}
- if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn))
- {
- for(DWORD y = 0; y < h; y++, pIn += pitchIn, pOut += pitchOut)
+ if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
+ for(DWORD y = 0; y < h; y++, pIn += pitchIn, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
+ }
}
}
}
@@ -716,37 +702,39 @@ void CRoQVideoDecoder::Copy(BYTE* pOut, BYTE* pIn, DWORD w, DWORD h)
HRESULT CRoQVideoDecoder::CheckInputType(const CMediaType* mtIn)
{
return mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_RoQV
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if(m_pOutput && m_pOutput->IsConnected())
- {
+ if(m_pOutput && m_pOutput->IsConnected()) {
BITMAPINFOHEADER bih1, bih2;
if(ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
- && abs(bih1.biHeight) != abs(bih2.biHeight))
+ && abs(bih1.biHeight) != abs(bih2.biHeight)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
- || mtOut->subtype == MEDIASUBTYPE_YV12
- || mtOut->subtype == MEDIASUBTYPE_I420
- || mtOut->subtype == MEDIASUBTYPE_IYUV
- || mtOut->subtype == MEDIASUBTYPE_ARGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB24
- || mtOut->subtype == MEDIASUBTYPE_RGB565
- || mtOut->subtype == MEDIASUBTYPE_RGB555)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
+ || mtOut->subtype == MEDIASUBTYPE_YV12
+ || mtOut->subtype == MEDIASUBTYPE_I420
+ || mtOut->subtype == MEDIASUBTYPE_IYUV
+ || mtOut->subtype == MEDIASUBTYPE_ARGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB24
+ || mtOut->subtype == MEDIASUBTYPE_RGB565
+ || mtOut->subtype == MEDIASUBTYPE_RGB555)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQVideoDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
@@ -758,20 +746,26 @@ HRESULT CRoQVideoDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
- return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CRoQVideoDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- struct {const GUID* subtype; WORD biPlanes, biBitCount; DWORD biCompression;} fmts[] =
- {
+ struct {
+ const GUID* subtype;
+ WORD biPlanes, biBitCount;
+ DWORD biCompression;
+ } fmts[] = {
{&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
{&MEDIASUBTYPE_I420, 3, 12, '024I'},
{&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
@@ -788,8 +782,12 @@ HRESULT CRoQVideoDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{&MEDIASUBTYPE_RGB555, 1, 16, BI_BITFIELDS},
};
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= countof(fmts)) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= countof(fmts)) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
@@ -838,8 +836,10 @@ HRESULT CRoQVideoDecoder::StartStreaming()
HRESULT CRoQVideoDecoder::StopStreaming()
{
- delete [] m_y[0]; m_y[0] = NULL;
- delete [] m_y[1]; m_y[1] = NULL;
+ delete [] m_y[0];
+ m_y[0] = NULL;
+ delete [] m_y[1];
+ m_y[1] = NULL;
return __super::StopStreaming();
}
@@ -851,7 +851,9 @@ HRESULT CRoQVideoDecoder::StopStreaming()
CRoQAudioDecoder::CRoQAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CRoQAudioDecoder"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CRoQAudioDecoder::~CRoQAudioDecoder()
@@ -863,8 +865,7 @@ HRESULT CRoQAudioDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT hr;
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -874,68 +875,74 @@ HRESULT CRoQAudioDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
UNUSED_ALWAYS(pwfe);
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK;
+ if(len <= 0) {
+ return S_OK;
+ }
REFERENCE_TIME rtStart, rtStop;
pIn->GetTime(&rtStart, &rtStop);
- if(pIn->IsPreroll() == S_OK || rtStart < 0)
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
return S_OK;
+ }
BYTE* pDataOut = NULL;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)))
+ if(FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
long size = pOut->GetSize();
- if(size <= 0)
+ if(size <= 0) {
return E_FAIL;
+ }
roq_chunk* rc = (roq_chunk*)pDataIn;
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
- if(wfe->nChannels == 1)
- {
+ if(wfe->nChannels == 1) {
int mono = (short)rc->arg;
unsigned char* src = pDataIn + sizeof(roq_chunk);
short* dst = (short*)pDataOut;
- for(int i = sizeof(roq_chunk); i < len; i++, src++, dst++)
- {
+ for(int i = sizeof(roq_chunk); i < len; i++, src++, dst++) {
short diff = (*src&0x7f)*(*src&0x7f);
- if(*src&0x80) diff = -diff;
+ if(*src&0x80) {
+ diff = -diff;
+ }
mono += diff;
*dst = (short)mono;
}
- }
- else if(wfe->nChannels == 2)
- {
+ } else if(wfe->nChannels == 2) {
int left = (char)(rc->arg>>8)<<8;
int right = (char)(rc->arg)<<8;
unsigned char* src = pDataIn + sizeof(roq_chunk);
short* dst = (short*)pDataOut;
- for(int i = sizeof(roq_chunk); i < len; i+=2, src++, dst++)
- {
+ for(int i = sizeof(roq_chunk); i < len; i+=2, src++, dst++) {
short diff = (*src&0x7f)*(*src&0x7f);
- if(*src&0x80) diff = -diff;
+ if(*src&0x80) {
+ diff = -diff;
+ }
ASSERT((int)left + diff <= SHRT_MAX && (int)left + diff >= SHRT_MIN);
left += diff;
*dst = (short)left;
- src++; dst++;
+ src++;
+ dst++;
diff = (*src&0x7f)*(*src&0x7f);
- if(*src&0x80) diff = -diff;
+ if(*src&0x80) {
+ diff = -diff;
+ }
ASSERT((int)right + diff <= SHRT_MAX && (int)right + diff >= SHRT_MIN);
right += diff;
*dst = (short)right;
}
- }
- else
- {
+ } else {
return E_UNEXPECTED;
}
@@ -949,25 +956,29 @@ HRESULT CRoQAudioDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT CRoQAudioDecoder::CheckInputType(const CMediaType* mtIn)
{
return mtIn->majortype == MEDIATYPE_Audio && mtIn->subtype == MEDIASUBTYPE_RoQA
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
@@ -979,20 +990,27 @@ HRESULT CRoQAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
}
HRESULT CRoQAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
*pmt = m_pInput->CurrentMediaType();
pmt->subtype = MEDIASUBTYPE_PCM;
diff --git a/src/filters/parser/RoQSplitter/RoQSplitter.h b/src/filters/parser/RoQSplitter/RoQSplitter.h
index e8b57a0ae..88e43dfc2 100644
--- a/src/filters/parser/RoQSplitter/RoQSplitter.h
+++ b/src/filters/parser/RoQSplitter/RoQSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,30 +24,39 @@
#include "../BaseSplitter/BaseSplitter.h"
// {48B93619-A959-45d9-B5FD-E12A67A96CF1}
-DEFINE_GUID(MEDIASUBTYPE_RoQ,
-0x48b93619, 0xa959, 0x45d9, 0xb5, 0xfd, 0xe1, 0x2a, 0x67, 0xa9, 0x6c, 0xf1);
+DEFINE_GUID(MEDIASUBTYPE_RoQ,
+ 0x48b93619, 0xa959, 0x45d9, 0xb5, 0xfd, 0xe1, 0x2a, 0x67, 0xa9, 0x6c, 0xf1);
// 56516F52-0000-0010-8000-00AA00389B71 'RoQV' == MEDIASUBTYPE_RoQV
DEFINE_GUID(MEDIASUBTYPE_RoQV,
-0x56516F52, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x56516F52, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_RoQA 0x41516F52
// 41516F52-0000-0010-8000-00AA00389B71 'RoQA' == MEDIASUBTYPE_RoQA
DEFINE_GUID(MEDIASUBTYPE_RoQA,
-WAVE_FORMAT_RoQA, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_RoQA, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#pragma pack(push, 1)
-struct roq_chunk {WORD id; DWORD size; WORD arg;};
-struct roq_info {WORD w, h, unk1, unk2;};
+struct roq_chunk {
+ WORD id;
+ DWORD size;
+ WORD arg;
+};
+struct roq_info {
+ WORD w, h, unk1, unk2;
+};
#pragma pack(pop)
class __declspec(uuid("C73DF7C1-21F2-44C7-A430-D35FB9BB298F"))
-CRoQSplitterFilter : public CBaseSplitterFilter
+ CRoQSplitterFilter : public CBaseSplitterFilter
{
CComPtr<IAsyncReader> m_pAsyncReader;
- struct index {REFERENCE_TIME rtv, rta; __int64 fp;};
+ struct index {
+ REFERENCE_TIME rtv, rta;
+ __int64 fp;
+ };
CAtlList<index> m_index;
POSITION m_indexpos;
@@ -63,14 +72,14 @@ public:
};
class __declspec(uuid("02B8E5C2-4E1F-45D3-9A8E-B8F1EDE6DE09"))
-CRoQSourceFilter : public CRoQSplitterFilter
+ CRoQSourceFilter : public CRoQSplitterFilter
{
public:
CRoQSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("FBEFC5EC-ABA0-4E6C-ACA3-D05FDFEFB853"))
-CRoQVideoDecoder : public CTransformFilter
+ CRoQVideoDecoder : public CTransformFilter
{
CCritSec m_csReceive;
@@ -83,10 +92,14 @@ CRoQVideoDecoder : public CTransformFilter
void Copy(BYTE* pOut, BYTE* pIn, DWORD w, DWORD h);
- #pragma pack(push, 1)
- struct roq_cell {BYTE y0, y1, y2, y3, u, v;} m_cells[256];
- struct roq_qcell {roq_cell* idx[4];} m_qcells[256];
- #pragma pack(pop)
+#pragma pack(push, 1)
+ struct roq_cell {
+ BYTE y0, y1, y2, y3, u, v;
+ } m_cells[256];
+ struct roq_qcell {
+ roq_cell* idx[4];
+ } m_qcells[256];
+#pragma pack(pop)
void apply_vector_2x2(int x, int y, roq_cell* cell);
void apply_vector_4x4(int x, int y, roq_cell* cell);
void apply_motion_4x4(int x, int y, unsigned char mv, char mean_x, char mean_y);
@@ -96,7 +109,7 @@ public:
CRoQVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr);
virtual ~CRoQVideoDecoder();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
HRESULT CheckInputType(const CMediaType* mtIn);
@@ -109,7 +122,7 @@ public:
};
class __declspec(uuid("226FAF85-E358-4502-8C98-F4224BE76953"))
-CRoQAudioDecoder : public CTransformFilter
+ CRoQAudioDecoder : public CTransformFilter
{
public:
CRoQAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr);
diff --git a/src/filters/parser/RoQSplitter/stdafx.cpp b/src/filters/parser/RoQSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/RoQSplitter/stdafx.cpp
+++ b/src/filters/parser/RoQSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/RoQSplitter/stdafx.h b/src/filters/parser/RoQSplitter/stdafx.h
index 0ddde4f7d..bf58d6fb9 100644
--- a/src/filters/parser/RoQSplitter/stdafx.h
+++ b/src/filters/parser/RoQSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.cpp b/src/filters/parser/SSFSplitter/SSFSplitter.cpp
index 917e35cc0..e581a8a62 100644
--- a/src/filters/parser/SSFSplitter/SSFSplitter.cpp
+++ b/src/filters/parser/SSFSplitter/SSFSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,26 +26,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_SSF},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CSSFSplitterFilter), L"MPC - SSF Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CSSFSourceFilter), L"MPC - SSF Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSSFSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSSFSourceFilter>, NULL, &sudFilter[1]},
};
@@ -79,16 +75,18 @@ namespace ssf
CBaseSplitterFile* m_pFile;
public:
- InputStreamBSF(CBaseSplitterFile* pFile)
- : m_pFile(pFile)
- {
+ InputStreamBSF(CBaseSplitterFile* pFile)
+ : m_pFile(pFile) {
ASSERT(m_pFile);
}
- int InputStreamBSF::NextByte()
- {
- if(!m_pFile) ThrowError(_T("m_pFile is NULL"));
- if(!m_pFile->GetRemaining()) return EOS;
+ int InputStreamBSF::NextByte() {
+ if(!m_pFile) {
+ ThrowError(_T("m_pFile is NULL"));
+ }
+ if(!m_pFile->GetRemaining()) {
+ return EOS;
+ }
return (int)m_pFile->BitRead(8);
}
};
@@ -98,8 +96,12 @@ int CSSFSplitterFilter::SegmentItemEx::Compare(const void* a, const void* b)
{
const SegmentItemEx* si1 = (const SegmentItemEx*)a;
const SegmentItemEx* si2 = (const SegmentItemEx*)b;
- if(si1->start < si2->start) return -1;
- if(si2->start < si1->start) return +1;
+ if(si1->start < si2->start) {
+ return -1;
+ }
+ if(si2->start < si1->start) {
+ return +1;
+ }
return 0;
}
@@ -120,33 +122,36 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ try {
+ m_ssf.Parse(ssf::InputStreamBSF(m_pFile));
+ } catch(ssf::Exception&) {
+ return E_FAIL;
+ }
- try {m_ssf.Parse(ssf::InputStreamBSF(m_pFile));}
- catch(ssf::Exception&) {return E_FAIL;}
-
//
m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = 0;
- if(ssf::Reference* pRootRef = m_ssf.GetRootRef())
- {
+ if(ssf::Reference* pRootRef = m_ssf.GetRootRef()) {
ssf::WCharOutputStream s;
ssf::StringMapW<float> offset;
POSITION pos = pRootRef->m_nodes.GetHeadPosition();
- while(pos)
- {
- if(ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos)))
- {
- try
- {
+ while(pos) {
+ if(ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos))) {
+ try {
ssf::Definition::Time time;
- if(pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue())
- {
+ if(pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue()) {
SegmentItemEx si;
si.pDef = pDef;
si.start = time.start.value;
@@ -157,12 +162,10 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
continue;
}
- }
- catch(ssf::Exception&)
- {
+ } catch(ssf::Exception&) {
}
- pDef->Dump(s);
+ pDef->Dump(s);
}
}
@@ -178,7 +181,9 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
memset(si, 0, sizeof(*si));
si->dwOffset = sizeof(*si);
BYTE* p = (BYTE*)(si+1);
- p[0] = 0xef; p[1] = 0xbb; p[2] = 0xbf;
+ p[0] = 0xef;
+ p[1] = 0xbb;
+ p[2] = 0xbf;
memcpy(&p[3], (LPCSTR)hdr, hdr.GetLength());
mts.Add(mt);
@@ -188,13 +193,16 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAtlArray<SegmentItemEx> subs;
subs.SetCount(m_subs.GetCount());
pos = m_subs.GetHeadPosition();
- for(size_t i = 0; pos; i++) subs.SetAt(i, m_subs.GetNext(pos));
+ for(size_t i = 0; pos; i++) {
+ subs.SetAt(i, m_subs.GetNext(pos));
+ }
qsort(subs.GetData(), subs.GetCount(), sizeof(SegmentItemEx), SegmentItemEx::Compare);
m_subs.RemoveAll();
- for(size_t i = 0; i < subs.GetCount(); i++) m_subs.AddTail(subs[i]);
+ for(size_t i = 0; i < subs.GetCount(); i++) {
+ m_subs.AddTail(subs[i]);
+ }
- if(!m_ssf.m_segments.IsEmpty())
- {
+ if(!m_ssf.m_segments.IsEmpty()) {
m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64*m_ssf.m_segments.GetTail().m_stop;
}
}
@@ -210,11 +218,8 @@ bool CSSFSplitterFilter::DemuxInit()
void CSSFSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0)
- {
- }
- else
- {
+ if(rt <= 0) {
+ } else {
// TODO
}
}
@@ -225,8 +230,7 @@ bool CSSFSplitterFilter::DemuxLoop()
POSITION pos = m_subs.GetHeadPosition();
- while(pos && SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
SegmentItemEx& si = m_subs.GetNext(pos);
ssf::WCharOutputStream s;
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.h b/src/filters/parser/SSFSplitter/SSFSplitter.h
index 35f95c507..de76e1211 100644
--- a/src/filters/parser/SSFSplitter/SSFSplitter.h
+++ b/src/filters/parser/SSFSplitter/SSFSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,14 +25,13 @@
#include "../../../Subtitles/libssf/SubtitleFile.h"
class __declspec(uuid("95C3F9F6-1E05-4C34-8122-504476EACB51"))
-CSSFSplitterFilter : public CBaseSplitterFilter
+ CSSFSplitterFilter : public CBaseSplitterFilter
{
CAutoPtr<CBaseSplitterFile> m_pFile;
ssf::SubtitleFile m_ssf;
- struct SegmentItemEx : public ssf::SubtitleFile::SegmentItem
- {
+ struct SegmentItemEx : public ssf::SubtitleFile::SegmentItem {
static int Compare(const void* a, const void* b);
};
@@ -50,7 +49,7 @@ public:
};
class __declspec(uuid("57F46A2A-6DC9-4A9F-B5FA-DFDD62B8BAFB"))
-CSSFSourceFilter : public CSSFSplitterFilter
+ CSSFSourceFilter : public CSSFSplitterFilter
{
public:
CSSFSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/SSFSplitter/stdafx.cpp b/src/filters/parser/SSFSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/SSFSplitter/stdafx.cpp
+++ b/src/filters/parser/SSFSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/SSFSplitter/stdafx.h b/src/filters/parser/SSFSplitter/stdafx.h
index 55763f8a3..432a74d80 100644
--- a/src/filters/parser/SSFSplitter/stdafx.h
+++ b/src/filters/parser/SSFSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
index f4003196c..3ca6b5489 100644
--- a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
+++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,29 +25,24 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CStreamDriveThruFilter), L"MPC - StreamDriveThru", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CStreamDriveThruFilter>, NULL, &sudFilter[0]}
};
@@ -77,7 +72,9 @@ CStreamDriveThruFilter::CStreamDriveThruFilter(LPUNKNOWN pUnk, HRESULT* phr)
: CBaseFilter(NAME("CStreamDriveThruFilter"), pUnk, &m_csLock, __uuidof(this))
, m_position(0)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput = DNew CStreamDriveThruInputPin(NAME("CStreamDriveThruInputPin"), this, &m_csLock, phr);
m_pOutput = DNew CStreamDriveThruOutputPin(NAME("CStreamDriveThruOutputPin"), this, &m_csLock, phr);
@@ -100,7 +97,7 @@ STDMETHODIMP CStreamDriveThruFilter::NonDelegatingQueryInterface(REFIID riid, vo
{
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IMediaSeeking)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -109,107 +106,98 @@ STDMETHODIMP CStreamDriveThruFilter::NonDelegatingQueryInterface(REFIID riid, vo
DWORD CStreamDriveThruFilter::ThreadProc()
{
- while(1)
- {
+ while(1) {
DWORD cmd = GetRequest();
- switch(cmd)
- {
- default:
- case CMD_EXIT:
- Reply(S_OK);
- return 0;
- case CMD_STOP:
- Reply(S_OK);
- break;
- case CMD_PAUSE:
- Reply(S_OK);
- break;
- case CMD_RUN:
- Reply(S_OK);
-
- do
- {
- CComPtr<IAsyncReader> pAsyncReader;
- CComPtr<IStream> pStream;
-
- if(!m_pInput || !m_pInput->IsConnected() || FAILED(m_pInput->GetAsyncReader(&pAsyncReader))
- || !m_pOutput || !m_pOutput->IsConnected() || FAILED(m_pOutput->GetStream(&pStream)))
- break;
-
- LARGE_INTEGER li = {0};
- ULARGE_INTEGER uli = {0};
-
- if(FAILED(pStream->Seek(li, STREAM_SEEK_SET, NULL))
- || FAILED(pStream->SetSize(uli)))
- break;
-
- if(CComQIPtr<IFileSinkFilter2> pFSF = GetFilterFromPin(m_pOutput->GetConnected()))
- {
- pFSF->SetMode(AM_FILE_OVERWRITE);
-
- LPOLESTR pfn;
- if(SUCCEEDED(pFSF->GetCurFile(&pfn, NULL)))
- {
- pFSF->SetFileName(pfn, NULL);
- CoTaskMemFree(pfn);
+ switch(cmd) {
+ default:
+ case CMD_EXIT:
+ Reply(S_OK);
+ return 0;
+ case CMD_STOP:
+ Reply(S_OK);
+ break;
+ case CMD_PAUSE:
+ Reply(S_OK);
+ break;
+ case CMD_RUN:
+ Reply(S_OK);
+
+ do {
+ CComPtr<IAsyncReader> pAsyncReader;
+ CComPtr<IStream> pStream;
+
+ if(!m_pInput || !m_pInput->IsConnected() || FAILED(m_pInput->GetAsyncReader(&pAsyncReader))
+ || !m_pOutput || !m_pOutput->IsConnected() || FAILED(m_pOutput->GetStream(&pStream))) {
+ break;
}
- }
-
- m_position = 0;
- BYTE buff[PACKETSIZE];
-
- do
- {
- while(!CheckRequest(&cmd))
- {
- CAutoLock csAutoLock(&m_csLock);
-
- LONGLONG total = 0, available = 0;
- if(FAILED(pAsyncReader->Length(&total, &available)) || m_position >= total)
- {
- cmd = CMD_STOP;
- break;
- }
- LONG size = (LONG)min(PACKETSIZE, total - m_position);
- if(FAILED(pAsyncReader->SyncRead(m_position, size, buff)))
- {
- cmd = CMD_STOP;
- break;
- }
+ LARGE_INTEGER li = {0};
+ ULARGE_INTEGER uli = {0};
- ULONG written = 0;
- if(FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written)
- {
- cmd = CMD_STOP;
- break;
- }
+ if(FAILED(pStream->Seek(li, STREAM_SEEK_SET, NULL))
+ || FAILED(pStream->SetSize(uli))) {
+ break;
+ }
- m_position += size;
+ if(CComQIPtr<IFileSinkFilter2> pFSF = GetFilterFromPin(m_pOutput->GetConnected())) {
+ pFSF->SetMode(AM_FILE_OVERWRITE);
+
+ LPOLESTR pfn;
+ if(SUCCEEDED(pFSF->GetCurFile(&pfn, NULL))) {
+ pFSF->SetFileName(pfn, NULL);
+ CoTaskMemFree(pfn);
+ }
}
- if(cmd == CMD_PAUSE)
- {
- Reply(S_OK); // reply to CMD_PAUSE
+ m_position = 0;
+ BYTE buff[PACKETSIZE];
- while(!CheckRequest(&cmd))
- Sleep(50);
+ do {
+ while(!CheckRequest(&cmd)) {
+ CAutoLock csAutoLock(&m_csLock);
- Reply(S_OK); // reply to something
- }
- }
- while(cmd == CMD_RUN);
+ LONGLONG total = 0, available = 0;
+ if(FAILED(pAsyncReader->Length(&total, &available)) || m_position >= total) {
+ cmd = CMD_STOP;
+ break;
+ }
+
+ LONG size = (LONG)min(PACKETSIZE, total - m_position);
+ if(FAILED(pAsyncReader->SyncRead(m_position, size, buff))) {
+ cmd = CMD_STOP;
+ break;
+ }
- uli.QuadPart = m_position;
- pStream->SetSize(uli);
+ ULONG written = 0;
+ if(FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written) {
+ cmd = CMD_STOP;
+ break;
+ }
- if(CComPtr<IPin> pPin = m_pOutput->GetConnected())
- pPin->EndOfStream();
- }
- while(false);
+ m_position += size;
+ }
+
+ if(cmd == CMD_PAUSE) {
+ Reply(S_OK); // reply to CMD_PAUSE
+
+ while(!CheckRequest(&cmd)) {
+ Sleep(50);
+ }
+
+ Reply(S_OK); // reply to something
+ }
+ } while(cmd == CMD_RUN);
+
+ uli.QuadPart = m_position;
+ pStream->SetSize(uli);
+
+ if(CComPtr<IPin> pPin = m_pOutput->GetConnected()) {
+ pPin->EndOfStream();
+ }
+ } while(false);
- break;
+ break;
}
}
@@ -223,20 +211,24 @@ int CStreamDriveThruFilter::GetPinCount()
CBasePin* CStreamDriveThruFilter::GetPin(int n)
{
- CAutoLock csAutoLock(&m_csLock);
+ CAutoLock csAutoLock(&m_csLock);
- if(n == 0) return m_pInput;
- else if(n == 1) return m_pOutput;
+ if(n == 0) {
+ return m_pInput;
+ } else if(n == 1) {
+ return m_pOutput;
+ }
- return NULL;
+ return NULL;
}
STDMETHODIMP CStreamDriveThruFilter::Stop()
{
HRESULT hr;
-
- if(FAILED(hr = __super::Stop()))
+
+ if(FAILED(hr = __super::Stop())) {
return hr;
+ }
CallWorker(CMD_STOP);
@@ -246,9 +238,10 @@ STDMETHODIMP CStreamDriveThruFilter::Stop()
STDMETHODIMP CStreamDriveThruFilter::Pause()
{
HRESULT hr;
-
- if(FAILED(hr = __super::Pause()))
+
+ if(FAILED(hr = __super::Pause())) {
return hr;
+ }
CallWorker(CMD_PAUSE);
@@ -258,9 +251,10 @@ STDMETHODIMP CStreamDriveThruFilter::Pause()
STDMETHODIMP CStreamDriveThruFilter::Run(REFERENCE_TIME tStart)
{
HRESULT hr;
-
- if(FAILED(hr = __super::Run(tStart)))
+
+ if(FAILED(hr = __super::Run(tStart))) {
return hr;
+ }
CallWorker(CMD_RUN);
@@ -277,7 +271,9 @@ STDMETHODIMP CStreamDriveThruFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ if(*pCapabilities == 0) {
+ return S_OK;
+ }
DWORD caps;
GetCapabilities(&caps);
@@ -311,11 +307,9 @@ STDMETHODIMP CStreamDriveThruFilter::GetDuration(LONGLONG* pDuration)
CheckPointer(pDuration, E_POINTER);
CheckPointer(m_pInput, VFW_E_NOT_CONNECTED);
- if(CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected())
- {
+ if(CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected()) {
LONGLONG total, available;
- if(SUCCEEDED(pAsyncReader->Length(&total, &available)))
- {
+ if(SUCCEEDED(pAsyncReader->Length(&total, &available))) {
*pDuration = total;
return S_OK;
}
@@ -331,12 +325,30 @@ STDMETHODIMP CStreamDriveThruFilter::GetCurrentPosition(LONGLONG* pCurrent)
{
return pCurrent ? *pCurrent = m_position, S_OK : E_POINTER;
}
-STDMETHODIMP CStreamDriveThruFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::SetRate(double dRate) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::GetRate(double* pdRate) {return E_NOTIMPL;}
+STDMETHODIMP CStreamDriveThruFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::SetRate(double dRate)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::GetRate(double* pdRate)
+{
+ return E_NOTIMPL;
+}
STDMETHODIMP CStreamDriveThruFilter::GetPreroll(LONGLONG* pllPreroll)
{
return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
@@ -372,26 +384,28 @@ STDMETHODIMP CStreamDriveThruInputPin::NonDelegatingQueryInterface(REFIID riid,
{
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CStreamDriveThruInputPin::CheckMediaType(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CStreamDriveThruInputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin)))
+ if(FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
+ }
- if(!CComQIPtr<IAsyncReader>(pPin))
+ if(!CComQIPtr<IAsyncReader>(pPin)) {
return E_NOINTERFACE;
+ }
return S_OK;
}
@@ -400,8 +414,9 @@ HRESULT CStreamDriveThruInputPin::BreakConnect()
{
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
m_pAsyncReader.Release();
@@ -412,8 +427,9 @@ HRESULT CStreamDriveThruInputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
CheckPointer(pPin, E_POINTER);
m_pAsyncReader = pPin;
@@ -462,42 +478,50 @@ STDMETHODIMP CStreamDriveThruOutputPin::NonDelegatingQueryInterface(REFIID riid,
{
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CStreamDriveThruOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
pProperties->cBuffers = 1;
pProperties->cbBuffer = PACKETSIZE;
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if(Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CStreamDriveThruOutputPin::CheckMediaType(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CStreamDriveThruOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
pmt->majortype = MEDIATYPE_Stream;
pmt->subtype = GUID_NULL;
@@ -511,11 +535,13 @@ HRESULT CStreamDriveThruOutputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin)))
+ if(FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
+ }
- if(!CComQIPtr<IStream>(pPin))
+ if(!CComQIPtr<IStream>(pPin)) {
return E_NOINTERFACE;
+ }
return S_OK;
}
@@ -524,8 +550,9 @@ HRESULT CStreamDriveThruOutputPin::BreakConnect()
{
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
m_pStream.Release();
@@ -536,8 +563,9 @@ HRESULT CStreamDriveThruOutputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
CheckPointer(pPin, E_POINTER);
m_pStream = pPin;
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.h b/src/filters/parser/StreamDriveThru/StreamDriveThru.h
index d55b7aeca..62bd97bcd 100644
--- a/src/filters/parser/StreamDriveThru/StreamDriveThru.h
+++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -36,12 +36,12 @@ public:
HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
HRESULT CompleteConnect(IPin* pPin);
STDMETHODIMP BeginFlush();
@@ -59,16 +59,16 @@ public:
HRESULT GetStream(IStream** ppStream);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pPin);
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pPin);
STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush();
@@ -77,7 +77,7 @@ public:
};
class __declspec(uuid("534FE6FD-F1F0-4aec-9F45-FF397320CE33"))
-CStreamDriveThruFilter : public CBaseFilter, protected CAMThread, public IMediaSeeking
+ CStreamDriveThruFilter : public CBaseFilter, protected CAMThread, public IMediaSeeking
{
CCritSec m_csLock;
@@ -86,7 +86,7 @@ CStreamDriveThruFilter : public CBaseFilter, protected CAMThread, public IMediaS
protected:
enum {CMD_EXIT, CMD_STOP, CMD_PAUSE, CMD_RUN};
- DWORD ThreadProc();
+ DWORD ThreadProc();
LONGLONG m_position;
@@ -95,7 +95,7 @@ public:
virtual ~CStreamDriveThruFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
int GetPinCount();
CBasePin* GetPin(int n);
diff --git a/src/filters/parser/StreamDriveThru/stdafx.cpp b/src/filters/parser/StreamDriveThru/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/StreamDriveThru/stdafx.cpp
+++ b/src/filters/parser/StreamDriveThru/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/StreamDriveThru/stdafx.h b/src/filters/parser/StreamDriveThru/stdafx.h
index b55bcba79..a8c9e282b 100644
--- a/src/filters/parser/StreamDriveThru/stdafx.h
+++ b/src/filters/parser/StreamDriveThru/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.