diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2011-08-14 15:34:02 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2011-08-14 15:34:02 +0400 |
commit | cf8773d177cee41a1496565c3c6f41400d9d7843 (patch) | |
tree | 1bd0a0e0a2b8a91bb2a053a2d087dc6a315692bb /src/filters/transform/Mpeg2DecFilter | |
parent | c9ea1a526e493a08ea5261a478010ab590c4bbae (diff) |
Fix : MPEG2 Software Decoder support only 4:2:0 profile.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3660 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/Mpeg2DecFilter')
-rw-r--r-- | src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp index 83c86401c..f64407448 100644 --- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp +++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp @@ -32,6 +32,7 @@ #include "../../../DSUtil/DSUtil.h"
#include "../../../DSUtil/MediaTypes.h"
+#include "../../../DSUtil/GolombBuffer.h"
#include <InitGuid.h>
#include <moreuuids.h>
@@ -949,6 +950,20 @@ HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin) return __super::CheckConnect(dir, pPin);
}
+int NextMpegStartCode(CGolombBuffer& gb, BYTE& code, __int64 len)
+{
+ gb.BitByteAlign();
+ DWORD dw = (DWORD)-1;
+ do {
+ if(len-- == 0) {
+ return false;
+ }
+ dw = (dw << 8) | (BYTE)gb.BitRead(8);
+ } while((dw&0xffffff00) != 0x00000100);
+ code = (BYTE)(dw&0xff);
+ return true;
+}
+
HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
{
if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
@@ -956,6 +971,27 @@ HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn) if(vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
+ BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
+ DWORD cbSequenceHeader = vih->cbSequenceHeader;
+
+ BYTE id = 0;
+ CGolombBuffer gb(pSequenceHeader, cbSequenceHeader);
+ while(gb.GetPos() < gb.GetSize() && id != 0xb5) {
+ if(!NextMpegStartCode(gb, id, cbSequenceHeader)) {
+ break;
+ }
+ }
+ if(id == 0xb5) {
+ gb.BitRead(4); // startcodeid
+ gb.BitRead(1); // profile_levelescape
+ gb.BitRead(3); // profile
+ gb.BitRead(4); // level
+ gb.BitRead(1); // interlaced
+ BYTE chroma = gb.BitRead(2);
+ if(chroma >= 2) {// current support only 4:2:0 profile
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
}
return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
|