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>2010-04-09 18:12:59 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
commitefbc9d9043ff8ff92716ddd00a5f61412d535593 (patch)
tree8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/filters/parser/NutSplitter
parentdf6b139a6d9027156f614b68687e039e3a5854db (diff)
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/NutSplitter')
-rw-r--r--src/filters/parser/NutSplitter/NutFile.cpp266
-rw-r--r--src/filters/parser/NutSplitter/NutFile.h210
-rw-r--r--src/filters/parser/NutSplitter/NutSplitter.cpp486
-rw-r--r--src/filters/parser/NutSplitter/NutSplitter.h30
-rw-r--r--src/filters/parser/NutSplitter/resource.h2
-rw-r--r--src/filters/parser/NutSplitter/stdafx.cpp8
-rw-r--r--src/filters/parser/NutSplitter/stdafx.h8
7 files changed, 497 insertions, 513 deletions
diff --git a/src/filters/parser/NutSplitter/NutFile.cpp b/src/filters/parser/NutSplitter/NutFile.cpp
index 519558e33..dc72f1de8 100644
--- a/src/filters/parser/NutSplitter/NutFile.cpp
+++ b/src/filters/parser/NutSplitter/NutFile.cpp
@@ -2,126 +2,122 @@
#include "NutFile.h"
CNutFile::CNutFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
+ : CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) return;
- hr = Init();
+ if(FAILED(hr)) return;
+ hr = Init();
}
HRESULT CNutFile::Init()
{
- Seek(0);
-
- if(BitRead(64) != NUTM)
- return E_FAIL;
-
- m_streams.RemoveAll();
-
- Seek(0);
-
- while(GetRemaining())
- {
- frame_header fh;
- fh.checksum_flag = 1;
-
- UINT64 id = 0;
-
- if(BitRead(1, true) == 0
- || (id = BitRead(64)) == NUTK)
- break;
-
- packet_header ph;
- Read(ph);
-
- if(id == NUTM)
- {
- Read(m_mh);
- }
- 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);
- // else if(sh->stream_class == SC_SUBTITLE) ; // nothing to do
- m_streams.AddTail(sh);
- }
- else if(id == NUTX)
- {
- index_header ih;
- Read(ih);
- }
- else if(id == NUTI)
- {
- info_header ih;
- Read(ih);
- }
- else if(id == 0) // frame
- {
- ASSERT(0);
- break;
- }
-
- if(fh.checksum_flag)
- {
- Seek(ph.pos + ph.fptr - 4);
- ph.checksum = (UINT32)BitRead(32);
- }
-
- Seek(ph.pos + ph.fptr);
- }
-
- Seek(0);
-
- return m_streams.GetCount() ? S_OK : E_FAIL;
+ Seek(0);
+
+ if(BitRead(64) != NUTM)
+ return E_FAIL;
+
+ m_streams.RemoveAll();
+
+ Seek(0);
+
+ while(GetRemaining())
+ {
+ frame_header fh;
+ fh.checksum_flag = 1;
+
+ UINT64 id = 0;
+
+ if(BitRead(1, true) == 0
+ || (id = BitRead(64)) == NUTK)
+ break;
+
+ packet_header ph;
+ Read(ph);
+
+ if(id == NUTM)
+ {
+ Read(m_mh);
+ }
+ 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);
+ // else if(sh->stream_class == SC_SUBTITLE) ; // nothing to do
+ m_streams.AddTail(sh);
+ }
+ else if(id == NUTX)
+ {
+ index_header ih;
+ Read(ih);
+ }
+ else if(id == NUTI)
+ {
+ info_header ih;
+ Read(ih);
+ }
+ else if(id == 0) // frame
+ {
+ ASSERT(0);
+ break;
+ }
+
+ if(fh.checksum_flag)
+ {
+ Seek(ph.pos + ph.fptr - 4);
+ ph.checksum = (UINT32)BitRead(32);
+ }
+
+ Seek(ph.pos + ph.fptr);
+ }
+
+ Seek(0);
+
+ return m_streams.GetCount() ? S_OK : E_FAIL;
}
void CNutFile::Read(vint& vi)
{
- vi = 0;
- bool more;
- do
- {
- more = !!BitRead(1);
- vi = (vi << 7) | BitRead(7);
- }
- while(more);
+ vi = 0;
+ bool more;
+ do {more = !!BitRead(1); vi = (vi << 7) | BitRead(7);}
+ while(more);
}
void CNutFile::Read(svint& svi)
{
- vint vi;
- Read(vi);
- vi++;
- if(vi & 1) svi = -((svint)vi >> 1);
- else svi = ((svint)vi >> 1);
+ vint vi;
+ Read(vi);
+ vi++;
+ if(vi&1) svi = -((svint)vi>>1);
+ else svi = ((svint)vi>>1);
}
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));
+ vint len;
+ Read(len);
+ b.SetCount((INT_PTR)len);
+ for(BYTE* buff = b.GetData(); len-- > 0; *buff++ = (BYTE)BitRead(8));
}
void CNutFile::Read(packet_header& ph)
{
- ph.pos = GetPos();
- Read(ph.fptr);
- Read(ph.bptr);
+ ph.pos = GetPos();
+ Read(ph.fptr);
+ Read(ph.bptr);
}
void CNutFile::Read(main_header& mh)
{
- Read(mh.version);
- Read(mh.stream_count);
+ Read(mh.version);
+ Read(mh.stream_count);
}
void CNutFile::Read(stream_header& sh)
{
- Read(sh.stream_id);
- Read(sh.stream_class);
+ Read(sh.stream_id);
+ Read(sh.stream_class);
Read(sh.fourcc);
Read(sh.average_bitrate);
Read(sh.language_code);
@@ -132,64 +128,64 @@ void CNutFile::Read(stream_header& sh)
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;
- Read(p->data);
- sh.cs.AddTail(p);
- }
+ while(1)
+ {
+ CAutoPtr<codec_specific> p(DNew codec_specific());
+ Read(p->type);
+ if(p->type == 0) break;
+ Read(p->data);
+ sh.cs.AddTail(p);
+ }
}
void CNutFile::Read(video_stream_header& vsh)
{
- Read(vsh.width);
- Read(vsh.height);
- Read(vsh.sample_width);
- Read(vsh.sample_height);
- Read(vsh.colorspace_type);
+ Read(vsh.width);
+ Read(vsh.height);
+ Read(vsh.sample_width);
+ Read(vsh.sample_height);
+ Read(vsh.colorspace_type);
}
void CNutFile::Read(audio_stream_header& ash)
{
- Read(ash.samplerate_mul);
- Read(ash.channel_count);
+ Read(ash.samplerate_mul);
+ Read(ash.channel_count);
}
void CNutFile::Read(index_header& ih)
{
- Read(ih.stream_id);
-
- vint len;
- Read(len);
- ih.ie.SetCount((INT_PTR)len);
- for(index_entry* p = ih.ie.GetData(); len-- > 0;)
- {
- Read(p->timestamp);
- Read(p->position);
- }
+ Read(ih.stream_id);
+
+ vint len;
+ Read(len);
+ ih.ie.SetCount((INT_PTR)len);
+ for(index_entry* p = ih.ie.GetData(); len-- > 0;)
+ {
+ Read(p->timestamp);
+ Read(p->position);
+ }
}
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
- }
- */
+ // 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
+ }
+*/
}
diff --git a/src/filters/parser/NutSplitter/NutFile.h b/src/filters/parser/NutSplitter/NutFile.h
index a3c5d163d..ab2a0a7e1 100644
--- a/src/filters/parser/NutSplitter/NutFile.h
+++ b/src/filters/parser/NutSplitter/NutFile.h
@@ -4,125 +4,121 @@
class CNutFile : public CBaseSplitterFile
{
- HRESULT Init();
+ HRESULT Init();
public:
#pragma pack(push, 1)
- typedef UINT64 vint;
- typedef INT64 svint;
- typedef CAtlArray<BYTE> binary;
- typedef CAtlArray<BYTE> string;
-
- struct packet_header
- {
- __int64 pos;
- vint fptr, bptr;
- UINT32 checksum;
- };
-
- struct main_header
- {
- vint version;
- vint stream_count;
- };
-
- struct codec_specific
- {
- vint type;
- binary data;
- };
-
- struct video_stream_header
- {
- vint width, height;
- vint sample_width, sample_height;
- vint colorspace_type;
- };
-
- struct audio_stream_header
- {
- vint samplerate_mul;
- vint channel_count;
- };
-
- struct stream_header
- {
+ typedef UINT64 vint;
+ typedef INT64 svint;
+ typedef CAtlArray<BYTE> binary;
+ typedef CAtlArray<BYTE> string;
+
+ struct packet_header
+ {
+ __int64 pos;
+ vint fptr, bptr;
+ UINT32 checksum;
+ };
+
+ struct main_header
+ {
+ vint version;
+ vint stream_count;
+ };
+
+ struct codec_specific
+ {
+ vint type;
+ binary data;
+ };
+
+ struct video_stream_header
+ {
+ vint width, height;
+ vint sample_width, sample_height;
+ vint colorspace_type;
+ };
+
+ struct audio_stream_header
+ {
+ vint samplerate_mul;
+ vint channel_count;
+ };
+
+ struct stream_header
+ {
+ vint stream_id;
+ vint stream_class;
+ string fourcc;
+ vint average_bitrate;
+ string language_code;
+ vint time_base_nom;
+ vint time_base_denom;
+ vint msb_timestamp_shift;
+ vint shuffle_type;
+ int fixed_fps:1;
+ int index_flag:1;
+ int reserved:6;
+ CAutoPtrList<codec_specific> cs;
+ union {video_stream_header vsh; audio_stream_header ash;};
+ vint msb_timestamp;
+ };
+
+ struct frame_header
+ {
+ BYTE zero_bit:1;
+ BYTE priority:2;
+ BYTE checksum_flag:1;
+ BYTE msb_timestamp_flag:2;
+ BYTE subpacket_type:2;
+ BYTE reserved:1;
+ };
+
+ struct index_entry
+ {
+ vint timestamp;
+ vint position;
+ };
+
+ struct index_header
+ {
vint stream_id;
- vint stream_class;
- string fourcc;
- vint average_bitrate;
- string language_code;
- vint time_base_nom;
- vint time_base_denom;
- vint msb_timestamp_shift;
- vint shuffle_type;
- int fixed_fps: 1;
- int index_flag: 1;
- int reserved: 6;
- CAutoPtrList<codec_specific> cs;
- union
- {
- video_stream_header vsh;
- audio_stream_header ash;
- };
- vint msb_timestamp;
- };
-
- struct frame_header
- {
- BYTE zero_bit: 1;
- BYTE priority: 2;
- BYTE checksum_flag: 1;
- BYTE msb_timestamp_flag: 2;
- BYTE subpacket_type: 2;
- BYTE reserved: 1;
- };
-
- struct index_entry
- {
- vint timestamp;
- vint position;
- };
-
- struct index_header
- {
- vint stream_id;
- CAtlArray<index_entry> ie;
- };
+ CAtlArray<index_entry> ie;
+ };
- struct info_header
- {
- // TODO
- vint dummy;
- };
+ struct info_header
+ {
+ // TODO
+ vint dummy;
+ };
#pragma pack(pop)
-#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};
-
- void Read(vint& v);
- void Read(svint& sv);
- void Read(binary& b);
- void Read(packet_header& ph);
- void Read(main_header& mh);
- void Read(stream_header& sh);
- void Read(video_stream_header& vsh);
- void Read(audio_stream_header& ash);
- void Read(index_header& ih);
- void Read(info_header& ih);
+ #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};
+
+ void Read(vint& v);
+ void Read(svint& sv);
+ void Read(binary& b);
+ void Read(packet_header& ph);
+ void Read(main_header& mh);
+ void Read(stream_header& sh);
+ void Read(video_stream_header& vsh);
+ void Read(audio_stream_header& ash);
+ void Read(index_header& ih);
+ void Read(info_header& ih);
public:
- CNutFile(IAsyncReader* pAsyncReader, HRESULT& hr);
+ CNutFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- main_header m_mh;
- CAutoPtrList<stream_header> m_streams;
+ main_header m_mh;
+ CAutoPtrList<stream_header> m_streams;
};
diff --git a/src/filters/parser/NutSplitter/NutSplitter.cpp b/src/filters/parser/NutSplitter/NutSplitter.cpp
index 723c38d3b..56b1f81c1 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,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
*
*/
@@ -28,8 +28,8 @@
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Nut},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_Nut},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] =
@@ -40,30 +40,30 @@ const AMOVIESETUP_PIN sudpPins[] =
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},
+ {&__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[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CNutSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CNutSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CNutSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CNutSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_Nut, _T("0,8,,F9526A624E55544D"), _T(".nut"), NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_Nut, _T("0,8,,F9526A624E55544D"), _T(".nut"), NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_Nut);
+ UnRegisterSourceFilter(MEDIASUBTYPE_Nut);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -77,261 +77,253 @@ CFilterApp theApp;
//
CNutSplitterFilter::CNutSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CNutSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CNutSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DNew CNutFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr))
- {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- // pins
-
- POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos)
- {
- CNutFile::stream_header* sh = m_pFile->m_streams.GetNext(pos);
-
- CAtlArray<CMediaType> mts;
- CMediaType mt;
-
- if(sh->stream_class == CNutFile::SC_VIDEO)
- {
- CNutFile::video_stream_header& vsh = sh->vsh;
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap(*(DWORD*)sh->fourcc.GetData());
- mt.formattype = FORMAT_VideoInfo;
-
- VIDEOINFOHEADER vih;
- memset(&vih, 0, sizeof(vih));
- vih.dwBitRate = (DWORD)sh->average_bitrate;
- vih.AvgTimePerFrame = 10000000i64 * sh->time_base_nom / sh->time_base_denom;
- vih.bmiHeader.biSize = sizeof(vih.bmiHeader);
- vih.bmiHeader.biCompression = mt.subtype.Data1;
- vih.bmiHeader.biWidth = (LONG)vsh.width;
- vih.bmiHeader.biHeight = (LONG)vsh.height;
- mt.SetFormat((BYTE*)&vih, sizeof(vih));
-
- mts.Add(mt);
-
- if(vsh.sample_width && vsh.sample_height)
- {
- VIDEOINFOHEADER2 vih2;
- memset(&vih2, 0, sizeof(vih2));
- vih2.dwBitRate = vih.dwBitRate;
- vih2.AvgTimePerFrame = vih.AvgTimePerFrame;
- vih2.dwPictAspectRatioX = (DWORD)vsh.sample_width;
- vih2.dwPictAspectRatioY = (DWORD)vsh.sample_height;
- vih2.bmiHeader = vih.bmiHeader;
- mt.SetFormat((BYTE*)&vih2, sizeof(vih2));
-
- mts.InsertAt(0, mt);
- }
- }
- else if(sh->stream_class == CNutFile::SC_AUDIO)
- {
- CNutFile::audio_stream_header& ash = sh->ash;
- // TODO
- }
- else if(sh->stream_class == CNutFile::SC_SUBTITLE)
- {
- // TODO
- }
-
- if(mts.GetCount() > 0)
- {
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
- AddOutputPin((DWORD)sh->stream_id, pPinOut);
- }
- }
-
- // TODO
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+
+ m_pFile.Attach(DNew CNutFile(pAsyncReader, hr));
+ if(!m_pFile) return E_OUTOFMEMORY;
+ if(FAILED(hr)) {m_pFile.Free(); return hr;}
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+
+ // pins
+
+ POSITION pos = m_pFile->m_streams.GetHeadPosition();
+ while(pos)
+ {
+ CNutFile::stream_header* sh = m_pFile->m_streams.GetNext(pos);
+
+ CAtlArray<CMediaType> mts;
+ CMediaType mt;
+
+ if(sh->stream_class == CNutFile::SC_VIDEO)
+ {
+ CNutFile::video_stream_header& vsh = sh->vsh;
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = FOURCCMap(*(DWORD*)sh->fourcc.GetData());
+ mt.formattype = FORMAT_VideoInfo;
+
+ VIDEOINFOHEADER vih;
+ memset(&vih, 0, sizeof(vih));
+ vih.dwBitRate = (DWORD)sh->average_bitrate;
+ vih.AvgTimePerFrame = 10000000i64 * sh->time_base_nom / sh->time_base_denom;
+ vih.bmiHeader.biSize = sizeof(vih.bmiHeader);
+ vih.bmiHeader.biCompression = mt.subtype.Data1;
+ vih.bmiHeader.biWidth = (LONG)vsh.width;
+ vih.bmiHeader.biHeight = (LONG)vsh.height;
+ mt.SetFormat((BYTE*)&vih, sizeof(vih));
+
+ mts.Add(mt);
+
+ if(vsh.sample_width && vsh.sample_height)
+ {
+ VIDEOINFOHEADER2 vih2;
+ memset(&vih2, 0, sizeof(vih2));
+ vih2.dwBitRate = vih.dwBitRate;
+ vih2.AvgTimePerFrame = vih.AvgTimePerFrame;
+ vih2.dwPictAspectRatioX = (DWORD)vsh.sample_width;
+ vih2.dwPictAspectRatioY = (DWORD)vsh.sample_height;
+ vih2.bmiHeader = vih.bmiHeader;
+ mt.SetFormat((BYTE*)&vih2, sizeof(vih2));
+
+ mts.InsertAt(0, mt);
+ }
+ }
+ else if(sh->stream_class == CNutFile::SC_AUDIO)
+ {
+ CNutFile::audio_stream_header& ash = sh->ash;
+ // TODO
+ }
+ else if(sh->stream_class == CNutFile::SC_SUBTITLE)
+ {
+ // TODO
+ }
+
+ if(mts.GetCount() > 0)
+ {
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
+ AddOutputPin((DWORD)sh->stream_id, pPinOut);
+ }
+ }
+
+ // TODO
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CNutSplitterFilter::DemuxInit()
{
- if(!m_pFile) return(false);
- m_pFile->Seek(0);
- return(true);
+ if(!m_pFile) return(false);
+ m_pFile->Seek(0);
+ return(true);
}
void CNutSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos) m_pFile->m_streams.GetNext(pos)->msb_timestamp = 0;
+ POSITION pos = m_pFile->m_streams.GetHeadPosition();
+ while(pos) m_pFile->m_streams.GetNext(pos)->msb_timestamp = 0;
if(rt <= 0)
- {
- m_pFile->Seek(0);
- }
- else
- {
- m_pFile->Seek(0);
- // TODO
- }
+ {
+ m_pFile->Seek(0);
+ }
+ else
+ {
+ m_pFile->Seek(0);
+ // TODO
+ }
}
bool CNutSplitterFilter::DemuxLoop()
{
- bool fKeyFrame = false;
-
- while(!CheckRequest(NULL) && m_pFile->GetRemaining())
- {
- CNutFile::frame_header fh;
- fh.checksum_flag = 1;
-
- UINT64 id = 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.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)
- {
- fKeyFrame = true;
- continue;
- }
- }
-
- CNutFile::packet_header ph;
- m_pFile->Read(ph);
-
- 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)
- {
- CNutFile::stream_header* tmp = m_pFile->m_streams.GetNext(pos);
- if(tmp->stream_id == stream_id)
- {
- sh = tmp;
- break;
- }
- }
-
- 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);
-
- 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->rtStop = p->rtStart + 1;
-
- fKeyFrame = false;
-
- CNutFile::vint len = ph.fptr - (m_pFile->GetPos() - ph.pos);
- if(fh.checksum_flag) len -= 4;
-
- if(fh.subpacket_type == 1)
- {
- p->SetCount(len);
- m_pFile->ByteRead(p->GetData(), p->GetCount());
-
- 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++)
- {
- }
- */
- }
- }
- }
-
- if(fh.checksum_flag)
- {
- m_pFile->Seek(ph.pos + ph.fptr - 4);
- ph.checksum = (UINT32)m_pFile->BitRead(32);
- }
-
- m_pFile->Seek(ph.pos + ph.fptr);
- }
-
- return(true);
+ bool fKeyFrame = false;
+
+ while(!CheckRequest(NULL) && m_pFile->GetRemaining())
+ {
+ CNutFile::frame_header fh;
+ fh.checksum_flag = 1;
+
+ UINT64 id = 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.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)
+ {
+ fKeyFrame = true;
+ continue;
+ }
+ }
+
+ CNutFile::packet_header ph;
+ m_pFile->Read(ph);
+
+ 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)
+ {
+ CNutFile::stream_header* tmp = m_pFile->m_streams.GetNext(pos);
+ if(tmp->stream_id == stream_id) {sh = tmp; break;}
+ }
+
+ 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);
+
+ 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->rtStop = p->rtStart+1;
+
+ fKeyFrame = false;
+
+ CNutFile::vint len = ph.fptr - (m_pFile->GetPos() - ph.pos);
+ if(fh.checksum_flag) len -= 4;
+
+ if(fh.subpacket_type == 1)
+ {
+ p->SetCount(len);
+ m_pFile->ByteRead(p->GetData(), p->GetCount());
+
+ 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++)
+ {
+ }
+*/
+ }
+ }
+ }
+
+ if(fh.checksum_flag)
+ {
+ m_pFile->Seek(ph.pos + ph.fptr - 4);
+ ph.checksum = (UINT32)m_pFile->BitRead(32);
+ }
+
+ m_pFile->Seek(ph.pos + ph.fptr);
+ }
+
+ return(true);
}
// IMediaSeeking
STDMETHODIMP CNutSplitterFilter::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- *pDuration = m_rtDuration;
- return S_OK;
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = m_rtDuration;
+ return S_OK;
}
//
@@ -339,8 +331,8 @@ STDMETHODIMP CNutSplitterFilter::GetDuration(LONGLONG* pDuration)
//
CNutSourceFilter::CNutSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CNutSplitterFilter(pUnk, phr)
+ : CNutSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
diff --git a/src/filters/parser/NutSplitter/NutSplitter.h b/src/filters/parser/NutSplitter/NutSplitter.h
index 14d6ac51e..3eb99904d 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,31 +25,31 @@
#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);
[uuid("90514D6A-76B7-4405-88A8-B4B1EF6061C6")]
class CNutSplitterFilter : public CBaseSplitterFilter
{
- CAutoPtr<CNutFile> m_pFile;
+ CAutoPtr<CNutFile> m_pFile;
protected:
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CNutSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CNutSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- // IMediaSeeking
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ // IMediaSeeking
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
};
[uuid("918B5A9F-DFED-4532-83A9-9B16D83ED73F")]
class CNutSourceFilter : public CNutSplitterFilter
{
public:
- CNutSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CNutSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
diff --git a/src/filters/parser/NutSplitter/resource.h b/src/filters/parser/NutSplitter/resource.h
index 02fc84368..80ef35412 100644
--- a/src/filters/parser/NutSplitter/resource.h
+++ b/src/filters/parser/NutSplitter/resource.h
@@ -3,7 +3,7 @@
// Used by NutSplitter.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/parser/NutSplitter/stdafx.cpp b/src/filters/parser/NutSplitter/stdafx.cpp
index e1ec5adac..4284c08d9 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,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
*
*/
diff --git a/src/filters/parser/NutSplitter/stdafx.h b/src/filters/parser/NutSplitter/stdafx.h
index 0c8bbfda0..e3ebbbb58 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,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
*
*/