diff options
author | v0lt <v0lt@users.sourceforge.net> | 2012-06-01 15:27:18 +0400 |
---|---|---|
committer | v0lt <v0lt@users.sourceforge.net> | 2012-06-01 15:27:18 +0400 |
commit | a8a052655daeb1c36daab5317534ee7e44a3c0b6 (patch) | |
tree | 6efed1057c47f0fa2b5de9c5a555d8b8bf5de3f9 /src/filters/parser/BaseSplitter | |
parent | 90117056d24b2860cf7ec1438901c40c9fb6b54e (diff) |
cleaning and cosmetics
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4966 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/BaseSplitter')
-rw-r--r-- | src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp | 109 | ||||
-rw-r--r-- | src/filters/parser/BaseSplitter/BaseSplitterFileEx.h | 3 |
2 files changed, 56 insertions, 56 deletions
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp index 989dba529..c84751383 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp +++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp @@ -1085,6 +1085,61 @@ bool CBaseSplitterFileEx::Read(hdmvlpcmhdr& h, CMediaType* pmt) return true;
}
+bool CBaseSplitterFileEx::Read(mlphdr& h, int len, CMediaType* pmt, bool find_sync)
+{
+ memset(&h, 0, sizeof(h));
+ if (len < 20) return false;
+
+ __int64 startpos = GetPos();
+
+ int samplerate, channels, framelength;
+ WORD bitdepth;
+ bool isTrueHD;
+ int fsize = 0;
+
+ BYTE buf[20];
+ int k = find_sync ? len - 20 : 1;
+ int i = 0;
+ while (i < k) {
+ Seek(startpos+i);
+ ByteRead(buf, 20);
+ if (GetMLPFrameSize(buf)) {
+ fsize = ParseMLPHeader(buf, &samplerate, &channels, &framelength, &bitdepth, &isTrueHD);
+ break;
+ }
+ ++i;
+ }
+
+ if (fsize && !isTrueHD) {
+ h.size = fsize;
+
+ if (!pmt) {
+ return true;
+ }
+
+ int bitrate = (int)(fsize * 8i64 * samplerate / framelength); // inaccurate, because fsize is not constant
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_MLP;
+ pmt->formattype = FORMAT_WaveFormatEx;
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
+ wfe->nChannels = channels;
+ wfe->nSamplesPerSec = samplerate;
+ wfe->nAvgBytesPerSec = (bitrate + 4) /8;
+ wfe->nBlockAlign = fsize < WORD_MAX ? fsize : WORD_MAX;
+ wfe->wBitsPerSample = bitdepth;
+ wfe->cbSize = 0;
+
+ pmt->SetSampleSize(0);
+
+ Seek(startpos+i);
+ return true;
+ }
+
+ return false;
+}
+
bool CBaseSplitterFileEx::Read(dvdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
@@ -2100,60 +2155,6 @@ bool CBaseSplitterFileEx::Read(dvbsub& h, int len, CMediaType* pmt) return false;
}
-bool CBaseSplitterFileEx::Find(mlphdr& h, int len, CMediaType* pmt)
-{
- memset(&h, 0, sizeof(h));
- if (len < 20) return false;
-
- __int64 startpos = GetPos();
-
- int samplerate, channels, framelength;
- WORD bitdepth;
- bool isTrueHD;
- int fsize = 0;
-
- BYTE buf[20];
- int i = 0;
- while (i+20 < len) {
- Seek(startpos+i);
- ByteRead(buf, 20);
- if (GetMLPFrameSize(buf)) {
- fsize = ParseMLPHeader(buf, &samplerate, &channels, &framelength, &bitdepth, &isTrueHD);
- break;
- }
- ++i;
- }
-
- if (fsize && !isTrueHD) {
- h.size = fsize;
-
- if (!pmt) {
- return true;
- }
-
- int bitrate = (int)(fsize * 8i64 * samplerate / framelength); // inaccurate, because fsize is not constant
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_MLP;
- pmt->formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
- wfe->nChannels = channels;
- wfe->nSamplesPerSec = samplerate;
- wfe->nAvgBytesPerSec = (bitrate + 4) /8;
- wfe->nBlockAlign = fsize < WORD_MAX ? fsize : WORD_MAX;
- wfe->wBitsPerSample = bitdepth;
- wfe->cbSize = 0;
-
- pmt->SetSampleSize(0);
-
- Seek(startpos+i);
- return true;
- }
-
- return false;
-}
-
/*
To see working buffer in debugger, look :
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h index 42a5d2c82..6b3a21171 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h +++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h @@ -435,6 +435,7 @@ public: bool Read(lpcmhdr& h, CMediaType* pmt = NULL);
bool Read(dvdalpcmhdr& h, int len, CMediaType* pmt = NULL);
bool Read(hdmvlpcmhdr& h, CMediaType* pmt = NULL);
+ bool Read(mlphdr& h, int len, CMediaType* pmt = NULL, bool find_sync = false);
bool Read(dvdspuhdr& h, CMediaType* pmt = NULL);
bool Read(hdmvsubhdr& h, CMediaType* pmt = NULL, const char* language_code = NULL);
bool Read(svcdspuhdr& h, CMediaType* pmt = NULL);
@@ -449,8 +450,6 @@ public: bool Read(dvbsub& h, int len, CMediaType* pmt = NULL);
bool Read(avchdr& h, spsppsindex index);
- bool Find(mlphdr& h, int len, CMediaType* pmt = NULL);
-
int HrdParameters(CGolombBuffer& gb);
void RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length);
};
|