diff options
author | v0lt <v0lt@users.sourceforge.net> | 2012-06-01 12:02:47 +0400 |
---|---|---|
committer | v0lt <v0lt@users.sourceforge.net> | 2012-06-01 12:02:47 +0400 |
commit | cda94f2497ce1b3c17ea4b1926b871626c834e6e (patch) | |
tree | 347705caf32590114f905c9673986cef9f77ef1a /src/filters/parser/BaseSplitter | |
parent | 61b60fb29e946fb233565bbea5a58fafe16c2beb (diff) |
MpegSplitter: improved support for MLP in .aob files (ticket #1866)
DTSAC3Source: MLP header size is not less than 20 bytes (needed for ffmpeg decoder)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4960 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/BaseSplitter')
-rw-r--r-- | src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp | 54 | ||||
-rw-r--r-- | src/filters/parser/BaseSplitter/BaseSplitterFileEx.h | 12 |
2 files changed, 65 insertions, 1 deletions
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp index decdad87e..170811d1e 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp +++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp @@ -2100,6 +2100,60 @@ 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) {
+ if (!pmt) {
+ return true;
+ }
+
+ h.size = fsize;
+
+ 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 ba32723e7..42a5d2c82 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h +++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h @@ -254,6 +254,14 @@ public: BYTE bitpersample:2;
};
+ struct mlphdr
+ {
+ DWORD size;
+ //DWORD samplerate;
+ //WORD bitdepth;
+ //WORD channels;
+ };
+
struct dvdspuhdr
{
// nothing ;)
@@ -441,6 +449,8 @@ public: bool Read(dvbsub& h, int len, CMediaType* pmt = NULL);
bool Read(avchdr& h, spsppsindex index);
- int HrdParameters(CGolombBuffer& gb);
+ bool Find(mlphdr& h, int len, CMediaType* pmt = NULL);
+
+ int HrdParameters(CGolombBuffer& gb);
void RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length);
};
|