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:
Diffstat (limited to 'src/filters/transform/Mpeg2DecFilter')
-rw-r--r--src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h61
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp3144
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h402
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp286
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h104
-rw-r--r--src/filters/transform/Mpeg2DecFilter/attributes.h8
-rw-r--r--src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp382
-rw-r--r--src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp4113
-rw-r--r--src/filters/transform/Mpeg2DecFilter/libmpeg2.h222
-rw-r--r--src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp782
-rw-r--r--src/filters/transform/Mpeg2DecFilter/resource.h2
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.cpp8
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.h8
13 files changed, 4664 insertions, 4858 deletions
diff --git a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
index a2b62a8e6..c4112dcc1 100644
--- a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
+++ b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.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
*
*/
@@ -24,33 +24,32 @@
typedef enum {DIAuto, DIWeave, DIBlend, DIBob, DIFieldShift} ditype;
[uuid("0ABEAA65-0317-47B9-AE1D-D9EA905AFD25")]
-interface IMpeg2DecFilter :
-public IUnknown
+interface IMpeg2DecFilter : public IUnknown
{
- STDMETHOD(SetDeinterlaceMethod(ditype di)) = 0;
- STDMETHOD_(ditype, GetDeinterlaceMethod()) = 0;
-
- // Brightness: -255.0 to 255.0, default 0.0
- // Contrast: 0.0 to 10.0, default 1.0
- // Hue: -180.0 to +180.0, default 0.0
- // Saturation: 0.0 to 10.0, default 1.0
-
- STDMETHOD(SetBrightness(float brightness)) = 0;
- STDMETHOD(SetContrast(float contrast)) = 0;
- STDMETHOD(SetHue(float hue)) = 0;
- STDMETHOD(SetSaturation(float saturation)) = 0;
- STDMETHOD_(float, GetBrightness()) = 0;
- STDMETHOD_(float, GetContrast()) = 0;
- STDMETHOD_(float, GetHue()) = 0;
- STDMETHOD_(float, GetSaturation()) = 0;
-
- STDMETHOD(EnableForcedSubtitles(bool fEnable)) = 0;
- STDMETHOD_(bool, IsForcedSubtitlesEnabled()) = 0;
-
- STDMETHOD(EnablePlanarYUV(bool fEnable)) = 0;
- STDMETHOD_(bool, IsPlanarYUVEnabled()) = 0;
-
- STDMETHOD(EnableInterlaced(bool fEnable)) = 0;
- STDMETHOD_(bool, IsInterlacedEnabled()) = 0;
+ STDMETHOD(SetDeinterlaceMethod(ditype di)) = 0;
+ STDMETHOD_(ditype, GetDeinterlaceMethod()) = 0;
+
+ // Brightness: -255.0 to 255.0, default 0.0
+ // Contrast: 0.0 to 10.0, default 1.0
+ // Hue: -180.0 to +180.0, default 0.0
+ // Saturation: 0.0 to 10.0, default 1.0
+
+ STDMETHOD(SetBrightness(float brightness)) = 0;
+ STDMETHOD(SetContrast(float contrast)) = 0;
+ STDMETHOD(SetHue(float hue)) = 0;
+ STDMETHOD(SetSaturation(float saturation)) = 0;
+ STDMETHOD_(float, GetBrightness()) = 0;
+ STDMETHOD_(float, GetContrast()) = 0;
+ STDMETHOD_(float, GetHue()) = 0;
+ STDMETHOD_(float, GetSaturation()) = 0;
+
+ STDMETHOD(EnableForcedSubtitles(bool fEnable)) = 0;
+ STDMETHOD_(bool, IsForcedSubtitlesEnabled()) = 0;
+
+ STDMETHOD(EnablePlanarYUV(bool fEnable)) = 0;
+ STDMETHOD_(bool, IsPlanarYUVEnabled()) = 0;
+
+ STDMETHOD(EnableInterlaced(bool fEnable)) = 0;
+ STDMETHOD_(bool, IsInterlacedEnabled()) = 0;
};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
index d50bf0804..7eb4f94b5 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.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
*
*/
@@ -42,19 +42,19 @@
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
{
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO},
#ifndef MPEG2ONLY
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Packet},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Payload},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Packet},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Payload},
#endif
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
};
const AMOVIESETUP_PIN sudpPins[] =
@@ -65,29 +65,29 @@ const AMOVIESETUP_PIN sudpPins[] =
const AMOVIESETUP_FILTER sudFilter[] =
{
-#ifdef MPEG2ONLY
- {&__uuidof(CMpeg2DecFilter), L"MPC - MPEG-2 Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
-#else
- {&__uuidof(CMpeg2DecFilter), L"MPC - MPEG Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
-#endif
+ #ifdef MPEG2ONLY
+ {&__uuidof(CMpeg2DecFilter), L"MPC - MPEG-2 Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ #else
+ {&__uuidof(CMpeg2DecFilter), L"MPC - MPEG Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ #endif
};
CFactoryTemplate g_Templates[] =
{
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, NULL, &sudFilter[0]},
- {L"CMpeg2DecPropertyPage", &__uuidof(CMpeg2DecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpeg2DecSettingsWnd> >},
+ {L"CMpeg2DecPropertyPage", &__uuidof(CMpeg2DecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpeg2DecSettingsWnd> >},
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
//
@@ -95,63 +95,63 @@ STDAPI DllUnregisterServer()
#include <detours/detours.h>
BOOL (__stdcall * Real_IsDebuggerPresent)(void)
-= IsDebuggerPresent;
+ = IsDebuggerPresent;
-LONG(__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
- LPDEVMODEA a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
-= ChangeDisplaySettingsExA;
+LONG (__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
+ LPDEVMODEA a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExA;
-LONG(__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
- LPDEVMODEW a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
-= ChangeDisplaySettingsExW;
+LONG (__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
+ LPDEVMODEW a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExW;
BOOL WINAPI Mine_IsDebuggerPresent()
{
- TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
- return FALSE;
+ TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
+ return FALSE;
}
LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
{
- if(dwFlags & CDS_VIDEOPARAMETERS)
- {
- VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
-
- if(vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
- && (vp->dwFlags & VP_FLAGS_COPYPROTECT))
- {
- if(vp->dwCommand == VP_COMMAND_GET)
- {
- if((vp->dwTVStandard & VP_TV_STANDARD_WIN_VGA) && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA)
- {
- TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
- vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
- }
- }
- else if(vp->dwCommand == VP_COMMAND_SET)
- {
- TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
- return 0;
- }
- }
- }
-
- return ret;
+ if(dwFlags&CDS_VIDEOPARAMETERS)
+ {
+ VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
+
+ if(vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
+ && (vp->dwFlags&VP_FLAGS_COPYPROTECT))
+ {
+ if(vp->dwCommand == VP_COMMAND_GET)
+ {
+ if((vp->dwTVStandard&VP_TV_STANDARD_WIN_VGA) && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA)
+ {
+ TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
+ vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
+ }
+ }
+ else if(vp->dwCommand == VP_COMMAND_SET)
+ {
+ TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
+ return 0;
+ }
+ }
+ }
+
+ return ret;
}
LONG WINAPI Mine_ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
+ return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
}
LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
+ return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
}
//
@@ -161,25 +161,25 @@ LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpD
class CMpeg2DecFilterApp : public CFilterApp
{
public:
- BOOL InitInstance()
- {
- long lError;
+ BOOL InitInstance()
+ {
+ long lError;
- if(!__super::InitInstance()) return FALSE;
+ if(!__super::InitInstance()) return FALSE;
- DetourRestoreAfterWith();
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
+ DetourRestoreAfterWith();
+ DetourTransactionBegin();
+ DetourUpdateThread(GetCurrentThread());
- DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
+ DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
- lError = DetourTransactionCommit();
- ASSERT(lError == NOERROR);
+ lError = DetourTransactionCommit();
+ ASSERT (lError == NOERROR);
- return TRUE;
- }
+ return TRUE;
+ }
};
CMpeg2DecFilterApp theApp;
@@ -190,989 +190,975 @@ CMpeg2DecFilterApp theApp;
// CMpeg2DecFilter
//
-CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(NAME("CMpeg2DecFilter"), lpunk, phr, __uuidof(this), 1)
- , m_fWaitForKeyFrame(true)
+CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
+ : CBaseVideoFilter(NAME("CMpeg2DecFilter"), lpunk, phr, __uuidof(this), 1)
+ , m_fWaitForKeyFrame(true)
{
- delete m_pInput;
+ delete m_pInput;
// delete m_pOutput;
- if(FAILED(*phr)) return;
+ if(FAILED(*phr)) return;
- if(!(m_pInput = DNew CMpeg2DecInputPin(this, phr, L"Video"))) * phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!(m_pInput = DNew CMpeg2DecInputPin(this, phr, L"Video"))) *phr = E_OUTOFMEMORY;
+ if(FAILED(*phr)) return;
// if(!(m_pOutput = DNew CMpeg2DecOutputPin(this, phr, L"Output"))) *phr = E_OUTOFMEMORY;
// if(FAILED(*phr)) return;
- if(!(m_pSubpicInput = DNew CSubpicInputPin(this, phr))) * phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
-
- if(!(m_pClosedCaptionOutput = DNew CClosedCaptionOutputPin(this, m_pLock, phr))) * phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
-
- SetDeinterlaceMethod(DIAuto);
- SetBrightness(0.0f);
- SetContrast(1.0f);
- SetHue(0.0f);
- SetSaturation(1.0f);
- EnableForcedSubtitles(true);
- EnablePlanarYUV(true);
- EnableInterlaced(false);
-
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ))
- {
- DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DeinterlaceMethod"), dw)) SetDeinterlaceMethod((ditype)dw);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Brightness"), dw)) SetBrightness(*(float*)&dw);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Contrast"), dw)) SetContrast(*(float*)&dw);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Hue"), dw)) SetHue(*(float*)&dw);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Saturation"), dw)) SetSaturation(*(float*)&dw);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSubtitles"), dw)) EnableForcedSubtitles(!!dw);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("PlanarYUV"), dw)) EnablePlanarYUV(!!dw);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Interlaced"), dw)) EnableInterlaced(!!dw);
- }
-
- m_rate.Rate = 10000;
- m_rate.StartTime = 0;
+ if(!(m_pSubpicInput = DNew CSubpicInputPin(this, phr))) *phr = E_OUTOFMEMORY;
+ if(FAILED(*phr)) return;
+
+ if(!(m_pClosedCaptionOutput = DNew CClosedCaptionOutputPin(this, m_pLock, phr))) *phr = E_OUTOFMEMORY;
+ if(FAILED(*phr)) return;
+
+ SetDeinterlaceMethod(DIAuto);
+ SetBrightness(0.0f);
+ SetContrast(1.0f);
+ SetHue(0.0f);
+ SetSaturation(1.0f);
+ EnableForcedSubtitles(true);
+ EnablePlanarYUV(true);
+ EnableInterlaced(false);
+
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ))
+ {
+ DWORD dw;
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DeinterlaceMethod"), dw)) SetDeinterlaceMethod((ditype)dw);
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Brightness"), dw)) SetBrightness(*(float*)&dw);
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Contrast"), dw)) SetContrast(*(float*)&dw);
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Hue"), dw)) SetHue(*(float*)&dw);
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Saturation"), dw)) SetSaturation(*(float*)&dw);
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSubtitles"), dw)) EnableForcedSubtitles(!!dw);
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("PlanarYUV"), dw)) EnablePlanarYUV(!!dw);
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Interlaced"), dw)) EnableInterlaced(!!dw);
+ }
+
+ m_rate.Rate = 10000;
+ m_rate.StartTime = 0;
}
CMpeg2DecFilter::~CMpeg2DecFilter()
{
- CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder")))
- {
- key.SetDWORDValue(_T("DeinterlaceMethod"), m_ditype);
- key.SetDWORDValue(_T("Brightness"), *(DWORD*)&m_bright);
- key.SetDWORDValue(_T("Contrast"), *(DWORD*)&m_cont);
- key.SetDWORDValue(_T("Hue"), *(DWORD*)&m_hue);
- key.SetDWORDValue(_T("Saturation"), *(DWORD*)&m_sat);
- key.SetDWORDValue(_T("ForcedSubtitles"), m_fForcedSubs);
- key.SetDWORDValue(_T("PlanarYUV"), m_fPlanarYUV);
- key.SetDWORDValue(_T("Interlaced"), m_fInterlaced);
- }
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder")))
+ {
+ key.SetDWORDValue(_T("DeinterlaceMethod"), m_ditype);
+ key.SetDWORDValue(_T("Brightness"), *(DWORD*)&m_bright);
+ key.SetDWORDValue(_T("Contrast"), *(DWORD*)&m_cont);
+ key.SetDWORDValue(_T("Hue"), *(DWORD*)&m_hue);
+ key.SetDWORDValue(_T("Saturation"), *(DWORD*)&m_sat);
+ key.SetDWORDValue(_T("ForcedSubtitles"), m_fForcedSubs);
+ key.SetDWORDValue(_T("PlanarYUV"), m_fPlanarYUV);
+ key.SetDWORDValue(_T("Interlaced"), m_fInterlaced);
+ }
- delete m_pSubpicInput;
- delete m_pClosedCaptionOutput;
+ delete m_pSubpicInput;
+ delete m_pClosedCaptionOutput;
}
STDMETHODIMP CMpeg2DecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IMpeg2DecFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IMpeg2DecFilter)
+ QI(ISpecifyPropertyPages)
+ QI(ISpecifyPropertyPages2)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
int CMpeg2DecFilter::GetPinCount()
{
- return 4;
+ return 4;
}
CBasePin* CMpeg2DecFilter::GetPin(int n)
{
- switch(n)
- {
- case 0:
- return m_pInput;
- case 1:
- return m_pOutput;
- case 2:
- return m_pSubpicInput;
- case 3:
- return m_pClosedCaptionOutput;
- }
- return NULL;
+ switch(n)
+ {
+ case 0: return m_pInput;
+ case 1: return m_pOutput;
+ case 2: return m_pSubpicInput;
+ case 3: return m_pClosedCaptionOutput;
+ }
+ return NULL;
}
HRESULT CMpeg2DecFilter::EndOfStream()
{
- CAutoLock cAutoLock(&m_csReceive);
- m_pClosedCaptionOutput->EndOfStream();
- return __super::EndOfStream();
+ CAutoLock cAutoLock(&m_csReceive);
+ m_pClosedCaptionOutput->EndOfStream();
+ return __super::EndOfStream();
}
HRESULT CMpeg2DecFilter::BeginFlush()
{
- m_pClosedCaptionOutput->DeliverBeginFlush();
- return __super::BeginFlush();
+ m_pClosedCaptionOutput->DeliverBeginFlush();
+ return __super::BeginFlush();
}
HRESULT CMpeg2DecFilter::EndFlush()
{
- m_pClosedCaptionOutput->DeliverEndFlush();
- return __super::EndFlush();
+ m_pClosedCaptionOutput->DeliverEndFlush();
+ return __super::EndFlush();
}
HRESULT CMpeg2DecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
- m_pClosedCaptionOutput->DeliverNewSegment(tStart, tStop, dRate);
- m_fDropFrames = false;
- return __super::NewSegment(tStart, tStop, dRate);
+ CAutoLock cAutoLock(&m_csReceive);
+ m_pClosedCaptionOutput->DeliverNewSegment(tStart, tStop, dRate);
+ m_fDropFrames = false;
+ return __super::NewSegment(tStart, tStop, dRate);
}
void CMpeg2DecFilter::InputTypeChanged()
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
+
+ TRACE(_T("ResetMpeg2Decoder()\n"));
- TRACE(_T("ResetMpeg2Decoder()\n"));
+ for(int i = 0; i < countof(m_dec->m_pictures); i++)
+ {
+ m_dec->m_pictures[i].rtStart = m_dec->m_pictures[i].rtStop = _I64_MIN+1;
+ m_dec->m_pictures[i].fDelivered = false;
+ m_dec->m_pictures[i].flags &= ~PIC_MASK_CODING_TYPE;
+ }
- for(int i = 0; i < countof(m_dec->m_pictures); i++)
- {
- m_dec->m_pictures[i].rtStart = m_dec->m_pictures[i].rtStop = _I64_MIN + 1;
- m_dec->m_pictures[i].fDelivered = false;
- m_dec->m_pictures[i].flags &= ~PIC_MASK_CODING_TYPE;
- }
-
- const CMediaType& mt = m_pInput->CurrentMediaType();
+ const CMediaType& mt = m_pInput->CurrentMediaType();
- BYTE* pSequenceHeader = NULL;
- DWORD cbSequenceHeader = 0;
+ BYTE* pSequenceHeader = NULL;
+ DWORD cbSequenceHeader = 0;
- if(mt.formattype == FORMAT_MPEGVideo)
- {
- pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
- cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
- }
- else if(mt.formattype == FORMAT_MPEG2_VIDEO)
- {
- pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
- cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
- }
+ if(mt.formattype == FORMAT_MPEGVideo)
+ {
+ pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
+ cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
+ }
+ else if(mt.formattype == FORMAT_MPEG2_VIDEO)
+ {
+ pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
+ cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
+ }
- m_dec->mpeg2_close();
- m_dec->mpeg2_init();
+ m_dec->mpeg2_close();
+ m_dec->mpeg2_init();
- m_dec->mpeg2_buffer(pSequenceHeader, pSequenceHeader + cbSequenceHeader);
+ m_dec->mpeg2_buffer(pSequenceHeader, pSequenceHeader + cbSequenceHeader);
- m_fWaitForKeyFrame = true;
+ m_fWaitForKeyFrame = true;
- m_fFilm = false;
- m_fb.flags = 0;
+ m_fFilm = false;
+ m_fb.flags = 0;
}
void CMpeg2DecFilter::SetDeinterlaceMethod()
{
- ASSERT(m_dec->m_info.m_sequence);
- ASSERT(m_dec->m_info.m_display_picture);
-
- DWORD seqflags = m_dec->m_info.m_sequence->flags;
- DWORD oldflags = m_fb.flags;
- DWORD newflags = m_dec->m_info.m_display_picture->flags;
-
- if(!(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
- && !(oldflags & PIC_FLAG_REPEAT_FIRST_FIELD)
- && (newflags & PIC_FLAG_PROGRESSIVE_FRAME))
- {
- if(!m_fFilm && (newflags & PIC_FLAG_REPEAT_FIRST_FIELD))
- {
- TRACE(_T("m_fFilm = true\n"));
- m_fFilm = true;
- }
- else if(m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD))
- {
- TRACE(_T("m_fFilm = false\n"));
- m_fFilm = false;
- }
- }
-
- const CMediaType& mt = m_pOutput->CurrentMediaType();
-
- if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
- {
- m_fb.di = DIWeave;
- }
- else
- {
- m_fb.di = GetDeinterlaceMethod();
-
- if(m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift)
- {
- if(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
- m_fb.di = DIWeave; // hurray!
- else if(m_fFilm)
- m_fb.di = DIWeave; // we are lucky
- else if(!(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME))
- m_fb.di = DIBlend; // ok, clear thing
- else
- // big trouble here, the progressive_frame bit is not reliable :'(
- // frames without temporal field diffs can be only detected when ntsc
- // uses the repeat field flag (signaled with m_fFilm), if it's not set
- // or we have pal then we might end up blending the fields unnecessarily...
- m_fb.di = DIBlend;
- }
- }
-
- m_fb.flags = newflags;
+ ASSERT(m_dec->m_info.m_sequence);
+ ASSERT(m_dec->m_info.m_display_picture);
+
+ DWORD seqflags = m_dec->m_info.m_sequence->flags;
+ DWORD oldflags = m_fb.flags;
+ DWORD newflags = m_dec->m_info.m_display_picture->flags;
+
+ if(!(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
+ && !(oldflags & PIC_FLAG_REPEAT_FIRST_FIELD)
+ && (newflags & PIC_FLAG_PROGRESSIVE_FRAME))
+ {
+ if(!m_fFilm && (newflags & PIC_FLAG_REPEAT_FIRST_FIELD))
+ {
+ TRACE(_T("m_fFilm = true\n"));
+ m_fFilm = true;
+ }
+ else if(m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD))
+ {
+ TRACE(_T("m_fFilm = false\n"));
+ m_fFilm = false;
+ }
+ }
+
+ const CMediaType& mt = m_pOutput->CurrentMediaType();
+
+ if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
+ {
+ m_fb.di = DIWeave;
+ }
+ else
+ {
+ m_fb.di = GetDeinterlaceMethod();
+
+ if(m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift)
+ {
+ if(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
+ m_fb.di = DIWeave; // hurray!
+ else if(m_fFilm)
+ m_fb.di = DIWeave; // we are lucky
+ else if(!(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME))
+ m_fb.di = DIBlend; // ok, clear thing
+ else
+ // big trouble here, the progressive_frame bit is not reliable :'(
+ // frames without temporal field diffs can be only detected when ntsc
+ // uses the repeat field flag (signaled with m_fFilm), if it's not set
+ // or we have pal then we might end up blending the fields unnecessarily...
+ m_fb.di = DIBlend;
+ }
+ }
+
+ m_fb.flags = newflags;
}
void CMpeg2DecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS)
- {
- AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props)))
- {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- const CMediaType& mt = m_pOutput->CurrentMediaType();
- if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
- {
- // props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
-
- if(m_dec->m_info.m_sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
-
- if(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST)
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- if(m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD)
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
-
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P)
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B)
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
+ if(CComQIPtr<IMediaSample2> pMS2 = pMS)
+ {
+ AM_SAMPLE2_PROPERTIES props;
+ if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props)))
+ {
+ props.dwTypeSpecificFlags &= ~0x7f;
+
+ const CMediaType& mt = m_pOutput->CurrentMediaType();
+ if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
+ {
+ // props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
+
+ if(m_dec->m_info.m_sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
+
+ if(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST)
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ if(m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD)
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
+
+ if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
+ if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P)
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
+ if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B)
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
+ }
+
+ pMS2->SetProperties(sizeof(props), (BYTE*)&props);
+ }
+ }
}
HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
{
- HRESULT hr;
+ HRESULT hr;
- BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
- return hr;
+ BYTE* pDataIn = NULL;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ return hr;
- long len = pIn->GetActualDataLength();
+ long len = pIn->GetActualDataLength();
- (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
+ (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
- if(pIn->IsDiscontinuity() == S_OK)
- {
- InputTypeChanged();
- }
+ if(pIn->IsDiscontinuity() == S_OK)
+ {
+ InputTypeChanged();
+ }
- REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
- hr = pIn->GetTime(&rtStart, &rtStop);
- if(FAILED(hr)) rtStart = rtStop = _I64_MIN;
+ REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
+ hr = pIn->GetTime(&rtStart, &rtStop);
+ if(FAILED(hr)) rtStart = rtStop = _I64_MIN;
- while(len >= 0)
- {
- mpeg2_state_t state = m_dec->mpeg2_parse();
+ while(len >= 0)
+ {
+ mpeg2_state_t state = m_dec->mpeg2_parse();
#ifndef _WIN64
- __asm emms; // this one is missing somewhere in the precompiled mmx obj files
+ __asm emms; // this one is missing somewhere in the precompiled mmx obj files
#endif
- switch(state)
- {
- case STATE_BUFFER:
- if(len > 0)
- {
- m_dec->mpeg2_buffer(pDataIn, pDataIn + len);
- len = 0;
- }
- else len = -1;
- break;
- case STATE_INVALID:
- TRACE(_T("*** STATE_INVALID\n"));
- break;
- case STATE_GOP:
- m_pClosedCaptionOutput->Deliver(m_dec->m_info.m_user_data, m_dec->m_info.m_user_data_len);
- break;
- case STATE_SEQUENCE:
- m_AvgTimePerFrame = m_dec->m_info.m_sequence->frame_period
- ? 10i64 * m_dec->m_info.m_sequence->frame_period / 27
- : ((VIDEOINFOHEADER*)m_pInput->CurrentMediaType().Format())->AvgTimePerFrame;
- break;
- case STATE_PICTURE:
- m_dec->m_picture->rtStart = rtStart;
- rtStart = _I64_MIN;
- m_dec->m_picture->fDelivered = false;
- m_dec->mpeg2_skip(m_fDropFrames && (m_dec->m_picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B);
- break;
- case STATE_SLICE:
- case STATE_END:
- {
- mpeg2_picture_t* picture = m_dec->m_info.m_display_picture;
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
-
- if(picture && !(picture->flags & PIC_FLAG_SKIP) && fbuf)
- {
- ASSERT(!picture->fDelivered);
-
- picture->fDelivered = true;
-
- // frame buffer
-
- int w = m_dec->m_info.m_sequence->picture_width;
- int h = m_dec->m_info.m_sequence->picture_height;
- int pitch = (m_dec->m_info.m_sequence->width + 31) & ~31;
-
- if(m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch)
- m_fb.Alloc(w, h, pitch);
-
- // start - end
-
- m_fb.rtStart = picture->rtStart;
- if(m_fb.rtStart == _I64_MIN) m_fb.rtStart = m_fb.rtStop;
- m_fb.rtStop = m_fb.rtStart + m_AvgTimePerFrame * picture->nb_fields / (m_dec->m_info.m_display_picture_2nd ? 1 : 2);
-
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
-
- //
-
- SetDeinterlaceMethod();
-
- if(S_OK != (hr = DeliverFast())
- && S_OK != (hr = DeliverNormal()))
- return hr;
- }
- }
- break;
- default:
- break;
- }
- }
-
- return S_OK;
+ switch(state)
+ {
+ case STATE_BUFFER:
+ if(len > 0) {m_dec->mpeg2_buffer(pDataIn, pDataIn + len); len = 0;}
+ else len = -1;
+ break;
+ case STATE_INVALID:
+ TRACE(_T("*** STATE_INVALID\n"));
+ break;
+ case STATE_GOP:
+ m_pClosedCaptionOutput->Deliver(m_dec->m_info.m_user_data, m_dec->m_info.m_user_data_len);
+ break;
+ case STATE_SEQUENCE:
+ m_AvgTimePerFrame = m_dec->m_info.m_sequence->frame_period
+ ? 10i64 * m_dec->m_info.m_sequence->frame_period / 27
+ : ((VIDEOINFOHEADER*)m_pInput->CurrentMediaType().Format())->AvgTimePerFrame;
+ break;
+ case STATE_PICTURE:
+ m_dec->m_picture->rtStart = rtStart; rtStart = _I64_MIN;
+ m_dec->m_picture->fDelivered = false;
+ m_dec->mpeg2_skip(m_fDropFrames && (m_dec->m_picture->flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B);
+ break;
+ case STATE_SLICE:
+ case STATE_END:
+ {
+ mpeg2_picture_t* picture = m_dec->m_info.m_display_picture;
+ mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
+
+ if(picture && !(picture->flags&PIC_FLAG_SKIP) && fbuf)
+ {
+ ASSERT(!picture->fDelivered);
+
+ picture->fDelivered = true;
+
+ // frame buffer
+
+ int w = m_dec->m_info.m_sequence->picture_width;
+ int h = m_dec->m_info.m_sequence->picture_height;
+ int pitch = (m_dec->m_info.m_sequence->width + 31) & ~31;
+
+ if(m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch)
+ m_fb.Alloc(w, h, pitch);
+
+ // start - end
+
+ m_fb.rtStart = picture->rtStart;
+ if(m_fb.rtStart == _I64_MIN) m_fb.rtStart = m_fb.rtStop;
+ m_fb.rtStop = m_fb.rtStart + m_AvgTimePerFrame * picture->nb_fields / (m_dec->m_info.m_display_picture_2nd ? 1 : 2);
+
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
+
+ //
+
+ SetDeinterlaceMethod();
+
+ if(S_OK != (hr = DeliverFast())
+ && S_OK != (hr = DeliverNormal()))
+ return hr;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return S_OK;
}
bool CMpeg2DecFilter::IsVideoInterlaced()
{
- return IsInterlacedEnabled();
+ return IsInterlacedEnabled();
}
HRESULT CMpeg2DecFilter::DeliverFast()
{
- HRESULT hr;
+ HRESULT hr;
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) return S_FALSE;
+ mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
+ if(!fbuf) return S_FALSE;
- {
+ {
- CAutoLock cAutoLock2(&m_csProps);
+ CAutoLock cAutoLock2(&m_csProps);
- if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator
- || m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)
- || fabs(m_bright) > EPSILON || fabs(m_cont - 1.0) > EPSILON
- || fabs(m_hue) > EPSILON || fabs(m_sat - 1.0) > EPSILON)
- return S_FALSE;
- }
-
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
- m_fWaitForKeyFrame = false;
+ if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator
+ || m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)
+ || fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON
+ || fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON)
+ return S_FALSE;
+ }
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
- return S_OK;
+ if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
+ m_fWaitForKeyFrame = false;
- const CMediaType& mt = m_pOutput->CurrentMediaType();
+ if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
+ return S_OK;
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
- return S_FALSE;
+ const CMediaType& mt = m_pOutput->CurrentMediaType();
+
+ if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
+ return S_FALSE;
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
- return hr;
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
+ || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ return hr;
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
- return S_FALSE;
+ if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
+ return S_FALSE;
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&mt, &bihOut);
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&mt, &bihOut);
- int w = bihOut.biWidth;
- int h = abs(bihOut.biHeight);
- int srcpitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
- int dstpitch = bihOut.biWidth;
+ int w = bihOut.biWidth;
+ int h = abs(bihOut.biHeight);
+ int srcpitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
+ int dstpitch = bihOut.biWidth;
- BYTE* y = pDataOut;
- BYTE* u = y + dstpitch * h;
- BYTE* v = y + dstpitch * h * 5 / 4;
+ BYTE* y = pDataOut;
+ BYTE* u = y + dstpitch*h;
+ BYTE* v = y + dstpitch*h*5/4;
- if(bihOut.biCompression == '21VY')
- {
- BYTE* tmp = u;
- u = v;
- v = tmp;
- }
+ if(bihOut.biCompression == '21VY') {BYTE* tmp = u; u = v; v = tmp;}
- if(m_fb.di == DIWeave)
- {
- BitBltFromI420ToI420(w, h, y, u, v, dstpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], srcpitch);
- }
- else if(m_fb.di == DIBlend)
- {
- DeinterlaceBlend(y, fbuf->buf[0], w, h, dstpitch, srcpitch);
- DeinterlaceBlend(u, fbuf->buf[1], w / 2, h / 2, dstpitch / 2, srcpitch / 2);
- DeinterlaceBlend(v, fbuf->buf[2], w / 2, h / 2, dstpitch / 2, srcpitch / 2);
- }
- else // TODO
- {
- return S_FALSE;
- }
+ if(m_fb.di == DIWeave)
+ {
+ BitBltFromI420ToI420(w, h, y, u, v, dstpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], srcpitch);
+ }
+ else if(m_fb.di == DIBlend)
+ {
+ DeinterlaceBlend(y, fbuf->buf[0], w, h, dstpitch, srcpitch);
+ DeinterlaceBlend(u, fbuf->buf[1], w/2, h/2, dstpitch/2, srcpitch/2);
+ DeinterlaceBlend(v, fbuf->buf[2], w/2, h/2, dstpitch/2, srcpitch/2);
+ }
+ else // TODO
+ {
+ return S_FALSE;
+ }
- if(h == 1088)
- {
- memset(y + dstpitch*(h - 8), 0xff, dstpitch * 8);
- memset(u + dstpitch*(h - 8) / 4, 0x80, dstpitch * 8 / 4);
- memset(v + dstpitch*(h - 8) / 4, 0x80, dstpitch * 8 / 4);
- }
+ if(h == 1088)
+ {
+ memset(y + dstpitch*(h-8), 0xff, dstpitch*8);
+ memset(u + dstpitch*(h-8)/4, 0x80, dstpitch*8/4);
+ memset(v + dstpitch*(h-8)/4, 0x80, dstpitch*8/4);
+ }
- if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput))
- {
- CAutoLock cAutoLock(&pPin->m_csRateLock);
+ if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput))
+ {
+ CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate)
- {
- m_rate.Rate = pPin->m_ratechange.Rate;
- m_rate.StartTime = m_fb.rtStart;
- }
- }
+ if(m_rate.Rate != pPin->m_ratechange.Rate)
+ {
+ m_rate.Rate = pPin->m_ratechange.Rate;
+ m_rate.StartTime = m_fb.rtStart;
+ }
+ }
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
- rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
- rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- //
+ //
- SetTypeSpecificFlags(pOut);
+ SetTypeSpecificFlags(pOut);
- //
+ //
- return m_pOutput->Deliver(pOut);
+ return m_pOutput->Deliver(pOut);
}
HRESULT CMpeg2DecFilter::DeliverNormal()
{
- HRESULT hr;
+ HRESULT hr;
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) return S_FALSE;
+ mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
+ if(!fbuf) return S_FALSE;
- int w = m_fb.w;
- int h = m_fb.h;
- int spitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
- int dpitch = m_fb.pitch;
+ int w = m_fb.w;
+ int h = m_fb.h;
+ int spitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
+ int dpitch = m_fb.pitch;
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
- bool tff = !!(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST);
+ bool tff = !!(m_fb.flags&PIC_FLAG_TOP_FIELD_FIRST);
- // deinterlace
+ // deinterlace
- if(m_fb.di == DIWeave)
- {
- BitBltFromI420ToI420(w, h, m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], dpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], spitch);
- }
- else if(m_fb.di == DIBlend)
- {
- DeinterlaceBlend(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch);
- DeinterlaceBlend(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2);
- DeinterlaceBlend(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2);
- }
- else if(m_fb.di == DIBob)
- {
- DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
- DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
- DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
-
- m_fb.rtStart = rtStart;
- m_fb.rtStop = (rtStart + rtStop) / 2;
- }
- else if(m_fb.di == DIFieldShift)
- {
- int soffset = tff ? 0 : spitch;
- int doffset = tff ? 0 : dpitch;
- BitBltFromRGBToRGB(w, h / 2, m_fb.buf[0] + doffset, dpitch * 2, 8, fbuf->buf[0] + soffset, spitch * 2, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[1] + doffset / 2, dpitch, 8, fbuf->buf[1] + soffset / 2, spitch, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[2] + doffset / 2, dpitch, 8, fbuf->buf[2] + soffset / 2, spitch, 8);
- }
+ if(m_fb.di == DIWeave)
+ {
+ BitBltFromI420ToI420(w, h, m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], dpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], spitch);
+ }
+ else if(m_fb.di == DIBlend)
+ {
+ DeinterlaceBlend(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch);
+ DeinterlaceBlend(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2);
+ DeinterlaceBlend(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2);
+ }
+ else if(m_fb.di == DIBob)
+ {
+ DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
+ DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, tff);
+ DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, tff);
- // postproc
+ m_fb.rtStart = rtStart;
+ m_fb.rtStop = (rtStart + rtStop) / 2;
+ }
+ else if(m_fb.di == DIFieldShift)
+ {
+ int soffset = tff ? 0 : spitch;
+ int doffset = tff ? 0 : dpitch;
+ BitBltFromRGBToRGB(w, h/2, m_fb.buf[0] + doffset, dpitch*2, 8, fbuf->buf[0] + soffset, spitch*2, 8);
+ BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[1] + doffset/2, dpitch, 8, fbuf->buf[1] + soffset/2, spitch, 8);
+ BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[2] + doffset/2, dpitch, 8, fbuf->buf[2] + soffset/2, spitch, 8);
+ }
- ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
+ // postproc
- // deliver
+ ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
- if(FAILED(hr = Deliver(false)))
- return hr;
+ // deliver
- if(m_fb.di == DIBob)
- {
- DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
- DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
- DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
+ if(FAILED(hr = Deliver(false)))
+ return hr;
- m_fb.rtStart = (rtStart + rtStop) / 2;
- m_fb.rtStop = rtStop;
+ if(m_fb.di == DIBob)
+ {
+ DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
+ DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, !tff);
+ DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, !tff);
- // postproc
+ m_fb.rtStart = (rtStart + rtStop) / 2;
+ m_fb.rtStop = rtStop;
- ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
+ // postproc
- // deliver
+ ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
- if(FAILED(hr = Deliver(false)))
- return hr;
- }
- else if(m_fb.di == DIFieldShift)
- {
- int soffset = !tff ? 0 : spitch;
- int doffset = !tff ? 0 : dpitch;
- BitBltFromRGBToRGB(w, h / 2, m_fb.buf[0] + doffset, dpitch * 2, 8, fbuf->buf[0] + soffset, spitch * 2, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[1] + doffset / 2, dpitch, 8, fbuf->buf[1] + soffset / 2, spitch, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[2] + doffset / 2, dpitch, 8, fbuf->buf[2] + soffset / 2, spitch, 8);
- }
+ // deliver
- return S_OK;
+ if(FAILED(hr = Deliver(false)))
+ return hr;
+ }
+ else if(m_fb.di == DIFieldShift)
+ {
+ int soffset = !tff ? 0 : spitch;
+ int doffset = !tff ? 0 : dpitch;
+ BitBltFromRGBToRGB(w, h/2, m_fb.buf[0] + doffset, dpitch*2, 8, fbuf->buf[0] + soffset, spitch*2, 8);
+ BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[1] + doffset/2, dpitch, 8, fbuf->buf[1] + soffset/2, spitch, 8);
+ BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[2] + doffset/2, dpitch, 8, fbuf->buf[2] + soffset/2, spitch, 8);
+ }
+
+ return S_OK;
}
HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
- m_fWaitForKeyFrame = false;
+ if((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
+ m_fWaitForKeyFrame = false;
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
- return S_OK;
+ if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
+ return S_OK;
- HRESULT hr;
+ HRESULT hr;
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
- return hr;
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
+ || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ return hr;
- if(m_fb.h == 1088)
- {
- memset(m_fb.buf[0] + m_fb.w*(m_fb.h - 8), 0xff, m_fb.pitch * 8);
- memset(m_fb.buf[1] + m_fb.w*(m_fb.h - 8) / 4, 0x80, m_fb.pitch * 8 / 4);
- memset(m_fb.buf[2] + m_fb.w*(m_fb.h - 8) / 4, 0x80, m_fb.pitch * 8 / 4);
- }
+ if(m_fb.h == 1088)
+ {
+ memset(m_fb.buf[0] + m_fb.w*(m_fb.h-8), 0xff, m_fb.pitch*8);
+ memset(m_fb.buf[1] + m_fb.w*(m_fb.h-8)/4, 0x80, m_fb.pitch*8/4);
+ memset(m_fb.buf[2] + m_fb.w*(m_fb.h-8)/4, 0x80, m_fb.pitch*8/4);
+ }
- BYTE** buf = &m_fb.buf[0];
+ BYTE** buf = &m_fb.buf[0];
- if(m_pSubpicInput->HasAnythingToRender(m_fb.rtStart))
- {
- BitBltFromI420ToI420(m_fb.w, m_fb.h,
- m_fb.buf[3], m_fb.buf[4], m_fb.buf[5], m_fb.pitch,
- m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], m_fb.pitch);
+ if(m_pSubpicInput->HasAnythingToRender(m_fb.rtStart))
+ {
+ BitBltFromI420ToI420(m_fb.w, m_fb.h,
+ m_fb.buf[3], m_fb.buf[4], m_fb.buf[5], m_fb.pitch,
+ m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], m_fb.pitch);
- buf = &m_fb.buf[3];
+ buf = &m_fb.buf[3];
- m_pSubpicInput->RenderSubpics(m_fb.rtStart, buf, m_fb.pitch, m_fb.h);
- }
+ m_pSubpicInput->RenderSubpics(m_fb.rtStart, buf, m_fb.pitch, m_fb.h);
+ }
- CopyBuffer(pDataOut, buf, (m_fb.w + 7)&~7, m_fb.h, m_fb.pitch, MEDIASUBTYPE_I420, !(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME));
+ CopyBuffer(pDataOut, buf, (m_fb.w+7)&~7, m_fb.h, m_fb.pitch, MEDIASUBTYPE_I420, !(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME));
- //
+ //
- if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput))
- {
- CAutoLock cAutoLock(&pPin->m_csRateLock);
+ if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput))
+ {
+ CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate)
- {
- m_rate.Rate = pPin->m_ratechange.Rate;
- m_rate.StartTime = m_fb.rtStart;
- }
- }
+ if(m_rate.Rate != pPin->m_ratechange.Rate)
+ {
+ m_rate.Rate = pPin->m_ratechange.Rate;
+ m_rate.StartTime = m_fb.rtStart;
+ }
+ }
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
- rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
- rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- //
+ //
- SetTypeSpecificFlags(pOut);
+ SetTypeSpecificFlags(pOut);
- //
+ //
- hr = m_pOutput->Deliver(pOut);
+ hr = m_pOutput->Deliver(pOut);
- return hr;
+ return hr;
}
#include <IFilterVersion.h>
HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if(dir == PINDIR_OUTPUT)
- {
- if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator)
- {
- // one of these needed for dynamic format changes
-
- CLSID clsid = GetCLSID(pPin);
-
- DWORD ver = 0;
- if(CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin))
- ver = pFV->GetFilterVersion();
-
- if(clsid != CLSID_OverlayMixer
- /*&& clsid != CLSID_OverlayMixer2*/
- && clsid != CLSID_VideoMixingRenderer
- && clsid != CLSID_VideoMixingRenderer9
- && clsid != GUIDFromCString(_T("{FA10746C-9B63-4b6c-BC49-FC300EA5F256}")) // EVR
- && clsid != GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}")) // ffdshow
- && (clsid != GUIDFromCString(_T("{93A22E7A-5091-45ef-BA61-6DA26156A5D0}")) || ver < 0x0234) // dvobsub
- && (clsid != GUIDFromCString(_T("{9852A670-F845-491b-9BE6-EBD841B8A613}")) || ver < 0x0234) // dvobsub auto
- && clsid != CLSID_madVR
- && clsid != CLSID_DXR) // Haali's video renderer
- return E_FAIL;
- }
- }
+ if(dir == PINDIR_OUTPUT)
+ {
+ if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator)
+ {
+ // one of these needed for dynamic format changes
+
+ CLSID clsid = GetCLSID(pPin);
- return __super::CheckConnect(dir, pPin);
+ DWORD ver = 0;
+ if(CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin))
+ ver = pFV->GetFilterVersion();
+
+ if(clsid != CLSID_OverlayMixer
+ /*&& clsid != CLSID_OverlayMixer2*/
+ && clsid != CLSID_VideoMixingRenderer
+ && clsid != CLSID_VideoMixingRenderer9
+ && clsid != GUIDFromCString(_T("{FA10746C-9B63-4b6c-BC49-FC300EA5F256}")) // EVR
+ && clsid != GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}")) // ffdshow
+ && (clsid != GUIDFromCString(_T("{93A22E7A-5091-45ef-BA61-6DA26156A5D0}")) || ver < 0x0234) // dvobsub
+ && (clsid != GUIDFromCString(_T("{9852A670-F845-491b-9BE6-EBD841B8A613}")) || ver < 0x0234) // dvobsub auto
+ && clsid != CLSID_madVR
+ && clsid != CLSID_DXR) // Haali's video renderer
+ return E_FAIL;
+ }
+ }
+
+ return __super::CheckConnect(dir, pPin);
}
HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
{
- if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat)
- {
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
- if(vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000)
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
+ if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat)
+ {
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
+ if(vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000)
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_MPEG2_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_MPEG2_PES && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Packet
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Payload)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_MPEG2_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_MPEG2_PES && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Packet
+ || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Payload)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CMpeg2DecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- bool fPlanarYUV = mtOut->subtype == MEDIASUBTYPE_YV12
- || mtOut->subtype == MEDIASUBTYPE_I420
- || mtOut->subtype == MEDIASUBTYPE_IYUV;
+ bool fPlanarYUV = mtOut->subtype == MEDIASUBTYPE_YV12
+ || mtOut->subtype == MEDIASUBTYPE_I420
+ || mtOut->subtype == MEDIASUBTYPE_IYUV;
- return SUCCEEDED(__super::CheckTransform(mtIn, mtOut))
- && (!fPlanarYUV || IsPlanarYUVEnabled())
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return SUCCEEDED(__super::CheckTransform(mtIn, mtOut))
+ && (!fPlanarYUV || IsPlanarYUVEnabled())
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
DWORD g_clock;
HRESULT CMpeg2DecFilter::StartStreaming()
{
- HRESULT hr = __super::StartStreaming();
- if(FAILED(hr)) return hr;
+ HRESULT hr = __super::StartStreaming();
+ if(FAILED(hr)) return hr;
- m_dec.Attach(DNew CMpeg2Dec());
- if(!m_dec) return E_OUTOFMEMORY;
+ m_dec.Attach(DNew CMpeg2Dec());
+ if(!m_dec) return E_OUTOFMEMORY;
- InputTypeChanged();
+ InputTypeChanged();
// g_clock = clock();
- return S_OK;
+ return S_OK;
}
HRESULT CMpeg2DecFilter::StopStreaming()
{
- /*
- CString str;
- str.Format(_T("%d"), clock()-g_clock);
- AfxMessageBox(str);
- */
- m_dec.Free();
+/*
+ CString str;
+ str.Format(_T("%d"), clock()-g_clock);
+ AfxMessageBox(str);
+*/
+ m_dec.Free();
- return __super::StopStreaming();
+ return __super::StopStreaming();
}
HRESULT CMpeg2DecFilter::AlterQuality(Quality q)
{
- if(q.Late > 100 * 10000i64) m_fDropFrames = true;
- else if(q.Late <= 0) m_fDropFrames = false;
+ if(q.Late > 100*10000i64) m_fDropFrames = true;
+ else if(q.Late <= 0) m_fDropFrames = false;
// TRACE(_T("CMpeg2DecFilter::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
- return S_OK;
+ return S_OK;
}
// ISpecifyPropertyPages2
STDMETHODIMP CMpeg2DecFilter::GetPages(CAUUID* pPages)
{
- CheckPointer(pPages, E_POINTER);
+ CheckPointer(pPages, E_POINTER);
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- pPages->pElems[0] = __uuidof(CMpeg2DecSettingsWnd);
+ pPages->cElems = 1;
+ pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
+ pPages->pElems[0] = __uuidof(CMpeg2DecSettingsWnd);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
- CheckPointer(ppPage, E_POINTER);
+ CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) return E_INVALIDARG;
- HRESULT hr;
+ HRESULT hr;
- if(guid == __uuidof(CMpeg2DecSettingsWnd))
- {
- (*ppPage = DNew CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(NULL, &hr))->AddRef();
- }
+ if(guid == __uuidof(CMpeg2DecSettingsWnd))
+ {
+ (*ppPage = DNew CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(NULL, &hr))->AddRef();
+ }
- return *ppPage ? S_OK : E_FAIL;
+ return *ppPage ? S_OK : E_FAIL;
}
// IMpeg2DecFilter
STDMETHODIMP CMpeg2DecFilter::SetDeinterlaceMethod(ditype di)
{
- CAutoLock cAutoLock(&m_csProps);
- m_ditype = di;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_ditype = di;
+ return S_OK;
}
STDMETHODIMP_(ditype) CMpeg2DecFilter::GetDeinterlaceMethod()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_ditype;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_ditype;
}
void CMpeg2DecFilter::CalcBrCont(BYTE* YTbl, float bright, float cont)
{
- int Cont = (int)(cont * 512);
- int Bright = (int)bright;
+ int Cont = (int)(cont * 512);
+ int Bright = (int)bright;
- for(int i = 0; i < 256; i++)
- {
- int y = ((Cont * (i - 16)) >> 9) + Bright + 16;
- YTbl[i] = min(max(y, 0), 255);
+ for(int i = 0; i < 256; i++)
+ {
+ int y = ((Cont * (i - 16)) >> 9) + Bright + 16;
+ YTbl[i] = min(max(y, 0), 255);
// YTbl[i] = min(max(y, 16), 235);
- }
+ }
}
void CMpeg2DecFilter::CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat)
{
- int Sat = (int)(sat * 512);
- double Hue = (hue * 3.1415926) / 180.0;
- int Sin = (int)(sin(Hue) * 4096);
- int Cos = (int)(cos(Hue) * 4096);
-
- for(int y = 0; y < 256; y++)
- {
- for(int x = 0; x < 256; x++)
- {
- int u = x - 128;
- int v = y - 128;
- int ux = (u * Cos + v * Sin) >> 12;
- v = (v * Cos - u * Sin) >> 12;
- u = ((ux * Sat) >> 9) + 128;
- v = ((v * Sat) >> 9) + 128;
- u = min(max(u, 16), 235);
- v = min(max(v, 16), 235);
- UTbl[(y << 8) | x] = u;
- VTbl[(y << 8) | x] = v;
- }
- }
+ int Sat = (int)(sat * 512);
+ double Hue = (hue * 3.1415926) / 180.0;
+ int Sin = (int)(sin(Hue) * 4096);
+ int Cos = (int)(cos(Hue) * 4096);
+
+ for(int y = 0; y < 256; y++)
+ {
+ for(int x = 0; x < 256; x++)
+ {
+ int u = x - 128;
+ int v = y - 128;
+ int ux = (u * Cos + v * Sin) >> 12;
+ v = (v * Cos - u * Sin) >> 12;
+ u = ((ux * Sat) >> 9) + 128;
+ v = ((v * Sat) >> 9) + 128;
+ u = min(max(u, 16), 235);
+ v = min(max(v, 16), 235);
+ UTbl[(y << 8) | x] = u;
+ VTbl[(y << 8) | x] = v;
+ }
+ }
}
void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch)
{
- CAutoLock cAutoLock(&m_csProps);
+ CAutoLock cAutoLock(&m_csProps);
- if(fabs(m_bright) > EPSILON || fabs(m_cont - 1.0) > EPSILON)
- {
- int size = pitch * h;
+ if(fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON)
+ {
+ int size = pitch*h;
- if((g_cpuid.m_flags & CCpuID::sse2) && ((DWORD_PTR)srcy & 15) == 0)
- {
- short Cont = (short)(min(max(m_cont, 0) * 512, (1 << 16) - 1));
- short Bright = (short)(m_bright + 16);
+ if((g_cpuid.m_flags&CCpuID::sse2) && ((DWORD_PTR)srcy & 15) == 0)
+ {
+ short Cont = (short)(min(max(m_cont, 0) * 512, (1<<16)-1));
+ short Bright = (short)(m_bright + 16);
- __m128i bc = _mm_set_epi16(Bright, Cont, Bright, Cont, Bright, Cont, Bright, Cont);
+ __m128i bc = _mm_set_epi16(Bright, Cont, Bright, Cont, Bright, Cont, Bright, Cont);
- __m128i zero = _mm_setzero_si128();
- __m128i _16 = _mm_set1_epi16(16);
- __m128i _512 = _mm_set1_epi16(512);
+ __m128i zero = _mm_setzero_si128();
+ __m128i _16 = _mm_set1_epi16(16);
+ __m128i _512 = _mm_set1_epi16(512);
- for(int i = 0, j = size >> 4; i < j; i++)
- {
- __m128i r = _mm_load_si128((__m128i*)&srcy[i*16]);
+ for(int i = 0, j = size>>4; i < j; i++)
+ {
+ __m128i r = _mm_load_si128((__m128i*)&srcy[i*16]);
- __m128i rl = _mm_unpacklo_epi8(r, zero);
- __m128i rh = _mm_unpackhi_epi8(r, zero);
+ __m128i rl = _mm_unpacklo_epi8(r, zero);
+ __m128i rh = _mm_unpackhi_epi8(r, zero);
- rl = _mm_subs_epi16(rl, _16);
- rh = _mm_subs_epi16(rh, _16);
+ rl = _mm_subs_epi16(rl, _16);
+ rh = _mm_subs_epi16(rh, _16);
- __m128i rll = _mm_unpacklo_epi16(rl, _512);
- __m128i rlh = _mm_unpackhi_epi16(rl, _512);
- __m128i rhl = _mm_unpacklo_epi16(rh, _512);
- __m128i rhh = _mm_unpackhi_epi16(rh, _512);
+ __m128i rll = _mm_unpacklo_epi16(rl, _512);
+ __m128i rlh = _mm_unpackhi_epi16(rl, _512);
+ __m128i rhl = _mm_unpacklo_epi16(rh, _512);
+ __m128i rhh = _mm_unpackhi_epi16(rh, _512);
- rll = _mm_madd_epi16(rll, bc);
- rlh = _mm_madd_epi16(rlh, bc);
- rhl = _mm_madd_epi16(rhl, bc);
- rhh = _mm_madd_epi16(rhh, bc);
+ rll = _mm_madd_epi16(rll, bc);
+ rlh = _mm_madd_epi16(rlh, bc);
+ rhl = _mm_madd_epi16(rhl, bc);
+ rhh = _mm_madd_epi16(rhh, bc);
- rll = _mm_srai_epi32(rll, 9);
- rlh = _mm_srai_epi32(rlh, 9);
- rhl = _mm_srai_epi32(rhl, 9);
- rhh = _mm_srai_epi32(rhh, 9);
+ rll = _mm_srai_epi32(rll, 9);
+ rlh = _mm_srai_epi32(rlh, 9);
+ rhl = _mm_srai_epi32(rhl, 9);
+ rhh = _mm_srai_epi32(rhh, 9);
- rl = _mm_packs_epi32(rll, rlh);
- rh = _mm_packs_epi32(rhl, rhh);
+ rl = _mm_packs_epi32(rll, rlh);
+ rh = _mm_packs_epi32(rhl, rhh);
- r = _mm_packus_epi16(rl, rh);
+ r = _mm_packus_epi16(rl, rh);
- _mm_store_si128((__m128i*)&srcy[i*16], r);
- }
+ _mm_store_si128((__m128i*)&srcy[i*16], r);
+ }
- srcy += size >> 4;
- size &= 15;
- }
+ srcy += size>>4;
+ size &= 15;
+ }
- for(; size > 0; size--)
- {
- *srcy++ = m_YTbl[*srcy];
- }
- }
+ for(; size > 0; size--)
+ {
+ *srcy++ = m_YTbl[*srcy];
+ }
+ }
- pitch /= 2;
- w /= 2;
- h /= 2;
-
- if(fabs(m_hue) > EPSILON || fabs(m_sat - 1.0) > EPSILON)
- {
- for(int size = pitch * h; size > 0; size--)
- {
- WORD uv = (*srcv << 8) | *srcu;
- *srcu++ = m_UTbl[uv];
- *srcv++ = m_VTbl[uv];
- }
- }
+ pitch /= 2;
+ w /= 2;
+ h /= 2;
+
+ if(fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON)
+ {
+ for(int size = pitch*h; size > 0; size--)
+ {
+ WORD uv = (*srcv<<8)|*srcu;
+ *srcu++ = m_UTbl[uv];
+ *srcv++ = m_VTbl[uv];
+ }
+ }
}
STDMETHODIMP CMpeg2DecFilter::SetBrightness(float bright)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcBrCont(m_YTbl, m_bright = bright, m_cont);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcBrCont(m_YTbl, m_bright = bright, m_cont);
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::SetContrast(float cont)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcBrCont(m_YTbl, m_bright, m_cont = cont);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcBrCont(m_YTbl, m_bright, m_cont = cont);
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::SetHue(float hue)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcHueSat(m_UTbl, m_VTbl, m_hue = hue, m_sat);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcHueSat(m_UTbl, m_VTbl, m_hue = hue, m_sat);
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::SetSaturation(float sat)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcHueSat(m_UTbl, m_VTbl, m_hue, m_sat = sat);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcHueSat(m_UTbl, m_VTbl, m_hue, m_sat = sat);
+ return S_OK;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetBrightness()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_bright;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_bright;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetContrast()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_cont;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_cont;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetHue()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_hue;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_hue;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetSaturation()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_sat;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_sat;
}
STDMETHODIMP CMpeg2DecFilter::EnableForcedSubtitles(bool fEnable)
{
- CAutoLock cAutoLock(&m_csProps);
- m_fForcedSubs = fEnable;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_fForcedSubs = fEnable;
+ return S_OK;
}
STDMETHODIMP_(bool) CMpeg2DecFilter::IsForcedSubtitlesEnabled()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_fForcedSubs;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_fForcedSubs;
}
STDMETHODIMP CMpeg2DecFilter::EnablePlanarYUV(bool fEnable)
{
- CAutoLock cAutoLock(&m_csProps);
- m_fPlanarYUV = fEnable;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_fPlanarYUV = fEnable;
+ return S_OK;
}
STDMETHODIMP_(bool) CMpeg2DecFilter::IsPlanarYUVEnabled()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_fPlanarYUV;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_fPlanarYUV;
}
STDMETHODIMP CMpeg2DecFilter::EnableInterlaced(bool fEnable)
{
- CAutoLock cAutoLock(&m_csProps);
- m_fInterlaced = fEnable;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_fInterlaced = fEnable;
+ return S_OK;
}
STDMETHODIMP_(bool) CMpeg2DecFilter::IsInterlacedEnabled()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_fInterlaced;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_fInterlaced;
}
//
@@ -1180,185 +1166,185 @@ STDMETHODIMP_(bool) CMpeg2DecFilter::IsInterlacedEnabled()
//
CMpeg2DecInputPin::CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(NAME("CMpeg2DecInputPin"), pFilter, phr, pName)
+ : CDeCSSInputPin(NAME("CMpeg2DecInputPin"), pFilter, phr, pName)
{
- m_CorrectTS = 0;
- m_ratechange.Rate = 10000;
- m_ratechange.StartTime = _I64_MAX;
+ m_CorrectTS = 0;
+ m_ratechange.Rate = 10000;
+ m_ratechange.StartTime = _I64_MAX;
}
// IKsPropertySet
STDMETHODIMP CMpeg2DecInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/)
- return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
-
- if(PropSet == AM_KSPROPSETID_TSRateChange)
- switch(Id)
- {
- case AM_RATE_SimpleRateChange:
- {
- AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
- if(!m_CorrectTS) return E_PROP_ID_UNSUPPORTED;
- CAutoLock cAutoLock(&m_csRateLock);
- m_ratechange = *p;
- DbgLog((LOG_TRACE, 0, _T("StartTime=%I64d, Rate=%d"), p->StartTime, p->Rate));
- }
- break;
- case AM_RATE_UseRateVersion:
- {
- WORD* p = (WORD*)pPropertyData;
- if(*p > 0x0101) return E_PROP_ID_UNSUPPORTED;
- }
- break;
- case AM_RATE_CorrectTS:
- {
- LONG* p = (LONG*)pPropertyData;
- m_CorrectTS = *p;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if(PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch(Id)
- {
- case AM_RATE_ChangeRate:
- {
- AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
+ if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/)
+ return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+
+ if(PropSet == AM_KSPROPSETID_TSRateChange)
+ switch(Id)
+ {
+ case AM_RATE_SimpleRateChange:
+ {
+ AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
+ if(!m_CorrectTS) return E_PROP_ID_UNSUPPORTED;
+ CAutoLock cAutoLock(&m_csRateLock);
+ m_ratechange = *p;
+ DbgLog((LOG_TRACE, 0, _T("StartTime=%I64d, Rate=%d"), p->StartTime, p->Rate));
+ }
+ break;
+ case AM_RATE_UseRateVersion:
+ {
+ WORD* p = (WORD*)pPropertyData;
+ if(*p > 0x0101) return E_PROP_ID_UNSUPPORTED;
+ }
+ break;
+ case AM_RATE_CorrectTS:
+ {
+ LONG* p = (LONG*)pPropertyData;
+ m_CorrectTS = *p;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+/*
+ if(PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch(Id)
+ {
+ case AM_RATE_ChangeRate:
+ {
+ AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+*/
+ return S_OK;
}
STDMETHODIMP CMpeg2DecInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/)
- return __super::Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
-
- if(PropSet == AM_KSPROPSETID_TSRateChange)
- switch(Id)
- {
- case AM_RATE_SimpleRateChange:
- {
- AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- case AM_RATE_MaxFullDataRate:
- {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- *p = 8 * 10000;
- *pBytesReturned = sizeof(AM_MaxFullDataRate);
- }
- break;
- case AM_RATE_QueryFullFrameRate:
- {
- AM_QueryRate* p = (AM_QueryRate*)pPropertyData;
- p->lMaxForwardFullFrame = 8 * 10000;
- p->lMaxReverseFullFrame = 8 * 10000;
- *pBytesReturned = sizeof(AM_QueryRate);
- }
- break;
- case AM_RATE_QueryLastRateSegPTS:
- {
- REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if(PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch(Id)
- {
- case AM_RATE_FullDataRateMax:
- {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- }
- break;
- case AM_RATE_ReverseDecode:
- {
- LONG* p = (LONG*)pPropertyData;
- }
- break;
- case AM_RATE_DecoderPosition:
- {
- AM_DVD_DecoderPosition* p = (AM_DVD_DecoderPosition*)pPropertyData;
- }
- break;
- case AM_RATE_DecoderVersion:
- {
- LONG* p = (LONG*)pPropertyData;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
+ if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/)
+ return __super::Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
+
+ if(PropSet == AM_KSPROPSETID_TSRateChange)
+ switch(Id)
+ {
+ case AM_RATE_SimpleRateChange:
+ {
+ AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ break;
+ case AM_RATE_MaxFullDataRate:
+ {
+ AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
+ *p = 8*10000;
+ *pBytesReturned = sizeof(AM_MaxFullDataRate);
+ }
+ break;
+ case AM_RATE_QueryFullFrameRate:
+ {
+ AM_QueryRate* p = (AM_QueryRate*)pPropertyData;
+ p->lMaxForwardFullFrame = 8*10000;
+ p->lMaxReverseFullFrame = 8*10000;
+ *pBytesReturned = sizeof(AM_QueryRate);
+ }
+ break;
+ case AM_RATE_QueryLastRateSegPTS:
+ {
+ REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+/*
+ if(PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch(Id)
+ {
+ case AM_RATE_FullDataRateMax:
+ {
+ AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
+ }
+ break;
+ case AM_RATE_ReverseDecode:
+ {
+ LONG* p = (LONG*)pPropertyData;
+ }
+ break;
+ case AM_RATE_DecoderPosition:
+ {
+ AM_DVD_DecoderPosition* p = (AM_DVD_DecoderPosition*)pPropertyData;
+ }
+ break;
+ case AM_RATE_DecoderVersion:
+ {
+ LONG* p = (LONG*)pPropertyData;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+*/
+ return S_OK;
}
STDMETHODIMP CMpeg2DecInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/)
- return __super::QuerySupported(PropSet, Id, pTypeSupport);
-
- if(PropSet == AM_KSPROPSETID_TSRateChange)
- switch(Id)
- {
- case AM_RATE_SimpleRateChange:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_MaxFullDataRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_UseRateVersion:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_QueryFullFrameRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_QueryLastRateSegPTS:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_CorrectTS:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if(PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch(Id)
- {
- case AM_RATE_ChangeRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_FullDataRateMax:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_ReverseDecode:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_DecoderPosition:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_DecoderVersion:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
+ if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/)
+ return __super::QuerySupported(PropSet, Id, pTypeSupport);
+
+ if(PropSet == AM_KSPROPSETID_TSRateChange)
+ switch(Id)
+ {
+ case AM_RATE_SimpleRateChange:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_RATE_MaxFullDataRate:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_UseRateVersion:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_RATE_QueryFullFrameRate:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_QueryLastRateSegPTS:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_CorrectTS:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+/*
+ if(PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch(Id)
+ {
+ case AM_RATE_ChangeRate:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_RATE_FullDataRateMax:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_ReverseDecode:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_DecoderPosition:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_DecoderVersion:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+*/
+ return S_OK;
}
//
@@ -1366,70 +1352,70 @@ STDMETHODIMP CMpeg2DecInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG*
//
CMpeg2DecOutputPin::CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CBaseVideoOutputPin(NAME("CMpeg2DecOutputPin"), pFilter, phr, pName)
+ : CBaseVideoOutputPin(NAME("CMpeg2DecOutputPin"), pFilter, phr, pName)
{
}
HRESULT CMpeg2DecOutputPin::Active()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- // TODO
+ // TODO
- if(m_Connected && !m_pOutputQueue)
- {
- HRESULT hr = NOERROR;
+ if(m_Connected && !m_pOutputQueue)
+ {
+ HRESULT hr = NOERROR;
- m_pOutputQueue.Attach(DNew COutputQueue(m_Connected, &hr));
- if(!m_pOutputQueue) hr = E_OUTOFMEMORY;
+ m_pOutputQueue.Attach(DNew COutputQueue(m_Connected, &hr));
+ if(!m_pOutputQueue) hr = E_OUTOFMEMORY;
- if(FAILED(hr))
- {
- m_pOutputQueue.Free();
- return hr;
- }
- }
+ if(FAILED(hr))
+ {
+ m_pOutputQueue.Free();
+ return hr;
+ }
+ }
- return __super::Active();
+ return __super::Active();
}
HRESULT CMpeg2DecOutputPin::Inactive()
{
- CAutoLock cAutoLock(m_pLock);
- m_pOutputQueue.Free();
- return __super::Inactive();
+ CAutoLock cAutoLock(m_pLock);
+ m_pOutputQueue.Free();
+ return __super::Inactive();
}
HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if(!m_pOutputQueue) return NOERROR;
- pMediaSample->AddRef();
- return m_pOutputQueue->Receive(pMediaSample);
+ if(!m_pOutputQueue) return NOERROR;
+ pMediaSample->AddRef();
+ return m_pOutputQueue->Receive(pMediaSample);
}
#define CallQueue(call) \
if(!m_pOutputQueue) return NOERROR; \
m_pOutputQueue->##call; \
return NOERROR; \
-
+
HRESULT CMpeg2DecOutputPin::DeliverEndOfStream()
{
- CallQueue(EOS());
+ CallQueue(EOS());
}
HRESULT CMpeg2DecOutputPin::DeliverBeginFlush()
{
- CallQueue(BeginFlush());
+ CallQueue(BeginFlush());
}
HRESULT CMpeg2DecOutputPin::DeliverEndFlush()
{
- CallQueue(EndFlush());
+ CallQueue(EndFlush());
}
HRESULT CMpeg2DecOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CallQueue(NewSegment(tStart, tStop, dRate));
+ CallQueue(NewSegment(tStart, tStop, dRate));
}
@@ -1439,771 +1425,733 @@ HRESULT CMpeg2DecOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_T
#define PTS2RT(pts) (10000i64*pts/90)
-CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
- : CMpeg2DecInputPin(pFilter, phr, L"SubPicture")
- , m_spon(TRUE)
- , m_fsppal(false)
+CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
+ : CMpeg2DecInputPin(pFilter, phr, L"SubPicture")
+ , m_spon(TRUE)
+ , m_fsppal(false)
{
- m_sppal[0].Y = 0x00;
- m_sppal[0].U = m_sppal[0].V = 0x80;
- m_sppal[1].Y = 0xe0;
- m_sppal[1].U = m_sppal[1].V = 0x80;
- m_sppal[2].Y = 0x80;
- m_sppal[2].U = m_sppal[2].V = 0x80;
- m_sppal[3].Y = 0x20;
- m_sppal[3].U = m_sppal[3].V = 0x80;
+ m_sppal[0].Y = 0x00;
+ m_sppal[0].U = m_sppal[0].V = 0x80;
+ m_sppal[1].Y = 0xe0;
+ m_sppal[1].U = m_sppal[1].V = 0x80;
+ m_sppal[2].Y = 0x80;
+ m_sppal[2].U = m_sppal[2].V = 0x80;
+ m_sppal[3].Y = 0x20;
+ m_sppal[3].U = m_sppal[3].V = 0x80;
}
HRESULT CSubpicInputPin::CheckMediaType(const CMediaType* mtIn)
{
- return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- || mtIn->majortype == MEDIATYPE_MPEG2_PACK
- || mtIn->majortype == MEDIATYPE_MPEG2_PES
- || mtIn->majortype == MEDIATYPE_Video)
- && (mtIn->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || mtIn->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || mtIn->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
+ || mtIn->majortype == MEDIATYPE_MPEG2_PACK
+ || mtIn->majortype == MEDIATYPE_MPEG2_PES
+ || mtIn->majortype == MEDIATYPE_Video)
+ && (mtIn->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || mtIn->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || mtIn->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CSubpicInputPin::SetMediaType(const CMediaType* mtIn)
{
- return CBasePin::SetMediaType(mtIn);
+ return CBasePin::SetMediaType(mtIn);
}
bool CSubpicInputPin::HasAnythingToRender(REFERENCE_TIME rt)
{
- if(!IsConnected()) return(false);
+ if(!IsConnected()) return(false);
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
- spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon))
- return(true);
- }
+ POSITION pos = m_sps.GetHeadPosition();
+ while(pos)
+ {
+ spu* sp = m_sps.GetNext(pos);
+ if(sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon))
+ return(true);
+ }
- return(false);
+ return(false);
}
void CSubpicInputPin::RenderSubpics(REFERENCE_TIME rt, BYTE** yuv, int w, int h)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- POSITION pos;
+ POSITION pos;
- // remove no longer needed things first
- pos = m_sps.GetHeadPosition();
- while(pos)
- {
- POSITION cur = pos;
- spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStop <= rt) m_sps.RemoveAt(cur);
- }
+ // remove no longer needed things first
+ pos = m_sps.GetHeadPosition();
+ while(pos)
+ {
+ POSITION cur = pos;
+ spu* sp = m_sps.GetNext(pos);
+ if(sp->m_rtStop <= rt) m_sps.RemoveAt(cur);
+ }
- pos = m_sps.GetHeadPosition();
- while(pos)
- {
- spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= rt && rt < sp->m_rtStop
- && (m_spon || sp->m_fForced && ((static_cast<CMpeg2DecFilter*>(m_pFilter))->IsForcedSubtitlesEnabled() || sp->m_psphli)))
- sp->Render(rt, yuv, w, h, m_sppal, m_fsppal);
- }
+ pos = m_sps.GetHeadPosition();
+ while(pos)
+ {
+ spu* sp = m_sps.GetNext(pos);
+ if(sp->m_rtStart <= rt && rt < sp->m_rtStop
+ && (m_spon || sp->m_fForced && ((static_cast<CMpeg2DecFilter*>(m_pFilter))->IsForcedSubtitlesEnabled() || sp->m_psphli)))
+ sp->Render(rt, yuv, w, h, m_sppal, m_fsppal);
+ }
}
HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
{
- HRESULT hr;
-
- AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- BYTE* pDataIn = NULL;
- if(FAILED(hr = pSample->GetPointer(&pDataIn))) return hr;
-
- long len = pSample->GetActualDataLength();
-
- StripPacket(pDataIn, len);
-
- if(len <= 0) return S_FALSE;
-
- if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- {
- pDataIn += 4;
- len -= 4;
- }
-
- if(len <= 0) return S_FALSE;
-
- CAutoLock cAutoLock(&m_csReceive);
-
- REFERENCE_TIME rtStart = 0, rtStop = 0;
- hr = pSample->GetTime(&rtStart, &rtStop);
-
- bool fRefresh = false;
-
- if(FAILED(hr))
- {
- if(!m_sps.IsEmpty())
- {
- spu* sp = m_sps.GetTail();
- sp->SetCount(sp->GetCount() + len);
- memcpy(sp->GetData() + sp->GetCount() - len, pDataIn, len);
- }
- }
- else
- {
- POSITION pos = m_sps.GetTailPosition();
- while(pos)
- {
- POSITION cur = pos;
- spu* sp = m_sps.GetPrev(pos);
- if(sp->m_rtStop == _I64_MAX)
- {
- sp->m_rtStop = rtStart;
- break;
- }
- }
-
- CAutoPtr<spu> p;
-
- if(m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE) p.Attach(DNew dvdspu());
- else if(m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE) p.Attach(DNew cvdspu());
- else if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) p.Attach(DNew svcdspu());
- else return E_FAIL;
-
- p->m_rtStart = rtStart;
- p->m_rtStop = _I64_MAX;
-
- p->SetCount(len);
- memcpy(p->GetData(), pDataIn, len);
-
- if(m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM))
- {
- p->m_psphli = m_sphli;
- fRefresh = true;
- }
-
- m_sps.AddTail(p);
- }
-
- if(!m_sps.IsEmpty())
- {
- m_sps.GetTail()->Parse();
- }
-
- if(fRefresh)
- {
+ HRESULT hr;
+
+ AM_MEDIA_TYPE* pmt;
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
+ {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
+
+ BYTE* pDataIn = NULL;
+ if(FAILED(hr = pSample->GetPointer(&pDataIn))) return hr;
+
+ long len = pSample->GetActualDataLength();
+
+ StripPacket(pDataIn, len);
+
+ if(len <= 0) return S_FALSE;
+
+ if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
+ {
+ pDataIn += 4;
+ len -= 4;
+ }
+
+ if(len <= 0) return S_FALSE;
+
+ CAutoLock cAutoLock(&m_csReceive);
+
+ REFERENCE_TIME rtStart = 0, rtStop = 0;
+ hr = pSample->GetTime(&rtStart, &rtStop);
+
+ bool fRefresh = false;
+
+ if(FAILED(hr))
+ {
+ if(!m_sps.IsEmpty())
+ {
+ spu* sp = m_sps.GetTail();
+ sp->SetCount(sp->GetCount() + len);
+ memcpy(sp->GetData() + sp->GetCount() - len, pDataIn, len);
+ }
+ }
+ else
+ {
+ POSITION pos = m_sps.GetTailPosition();
+ while(pos)
+ {
+ POSITION cur = pos;
+ spu* sp = m_sps.GetPrev(pos);
+ if(sp->m_rtStop == _I64_MAX)
+ {
+ sp->m_rtStop = rtStart;
+ break;
+ }
+ }
+
+ CAutoPtr<spu> p;
+
+ if(m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE) p.Attach(DNew dvdspu());
+ else if(m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE) p.Attach(DNew cvdspu());
+ else if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) p.Attach(DNew svcdspu());
+ else return E_FAIL;
+
+ p->m_rtStart = rtStart;
+ p->m_rtStop = _I64_MAX;
+
+ p->SetCount(len);
+ memcpy(p->GetData(), pDataIn, len);
+
+ if(m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM))
+ {
+ p->m_psphli = m_sphli;
+ fRefresh = true;
+ }
+
+ m_sps.AddTail(p);
+ }
+
+ if(!m_sps.IsEmpty())
+ {
+ m_sps.GetTail()->Parse();
+ }
+
+ if(fRefresh)
+ {
// ((CMpeg2DecFilter*)m_pFilter)->Deliver(true);
- }
+ }
- return S_FALSE;
+ return S_FALSE;
}
STDMETHODIMP CSubpicInputPin::EndFlush()
{
- CAutoLock cAutoLock(&m_csReceive);
- m_sps.RemoveAll();
- return S_OK;
+ CAutoLock cAutoLock(&m_csReceive);
+ m_sps.RemoveAll();
+ return S_OK;
}
// IKsPropertySet
STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic)
- return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
-
- bool fRefresh = false;
-
- switch(Id)
- {
- case AM_PROPERTY_DVDSUBPIC_PALETTE:
- {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_SPPAL* pSPPAL = (AM_PROPERTY_SPPAL*)pPropertyData;
- memcpy(m_sppal, pSPPAL->sppal, sizeof(AM_PROPERTY_SPPAL));
- m_fsppal = true;
-
- DbgLog((LOG_TRACE, 0, _T("new palette")));
- }
- break;
- case AM_PROPERTY_DVDSUBPIC_HLI:
- {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_SPHLI* pSPHLI = (AM_PROPERTY_SPHLI*)pPropertyData;
-
- m_sphli.Free();
-
- if(pSPHLI->HLISS)
- {
- POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
- spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop)
- {
- fRefresh = true;
- sp->m_psphli.Free();
- sp->m_psphli.Attach(DNew AM_PROPERTY_SPHLI);
- memcpy((AM_PROPERTY_SPHLI*)sp->m_psphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
- }
- }
-
- if(!fRefresh) // save it for later, a subpic might be late for this hli
- {
- m_sphli.Attach(DNew AM_PROPERTY_SPHLI);
- memcpy((AM_PROPERTY_SPHLI*)m_sphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
- }
- }
- else
- {
- POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
- spu* sp = m_sps.GetNext(pos);
- fRefresh |= !!sp->m_psphli;
- sp->m_psphli.Free();
- }
- }
-
- if(pSPHLI->HLISS)
- DbgLog((LOG_TRACE, 0, _T("hli: %I64d - %I64d, (%d,%d) - (%d,%d)"),
- PTS2RT(pSPHLI->StartPTM) / 10000, PTS2RT(pSPHLI->EndPTM) / 10000,
- pSPHLI->StartX, pSPHLI->StartY, pSPHLI->StopX, pSPHLI->StopY));
- }
- break;
- case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON:
- {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_COMPOSIT_ON* pCompositOn = (AM_PROPERTY_COMPOSIT_ON*)pPropertyData;
- m_spon = *pCompositOn;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
-
- if(fRefresh)
- {
- (static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
- }
-
- return S_OK;
+ if(PropSet != AM_KSPROPSETID_DvdSubPic)
+ return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+
+ bool fRefresh = false;
+
+ switch(Id)
+ {
+ case AM_PROPERTY_DVDSUBPIC_PALETTE:
+ {
+ CAutoLock cAutoLock(&m_csReceive);
+
+ AM_PROPERTY_SPPAL* pSPPAL = (AM_PROPERTY_SPPAL*)pPropertyData;
+ memcpy(m_sppal, pSPPAL->sppal, sizeof(AM_PROPERTY_SPPAL));
+ m_fsppal = true;
+
+ DbgLog((LOG_TRACE, 0, _T("new palette")));
+ }
+ break;
+ case AM_PROPERTY_DVDSUBPIC_HLI:
+ {
+ CAutoLock cAutoLock(&m_csReceive);
+
+ AM_PROPERTY_SPHLI* pSPHLI = (AM_PROPERTY_SPHLI*)pPropertyData;
+
+ m_sphli.Free();
+
+ if(pSPHLI->HLISS)
+ {
+ POSITION pos = m_sps.GetHeadPosition();
+ while(pos)
+ {
+ spu* sp = m_sps.GetNext(pos);
+ if(sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop)
+ {
+ fRefresh = true;
+ sp->m_psphli.Free();
+ sp->m_psphli.Attach(DNew AM_PROPERTY_SPHLI);
+ memcpy((AM_PROPERTY_SPHLI*)sp->m_psphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
+ }
+ }
+
+ if(!fRefresh) // save it for later, a subpic might be late for this hli
+ {
+ m_sphli.Attach(DNew AM_PROPERTY_SPHLI);
+ memcpy((AM_PROPERTY_SPHLI*)m_sphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
+ }
+ }
+ else
+ {
+ POSITION pos = m_sps.GetHeadPosition();
+ while(pos)
+ {
+ spu* sp = m_sps.GetNext(pos);
+ fRefresh |= !!sp->m_psphli;
+ sp->m_psphli.Free();
+ }
+ }
+
+ if(pSPHLI->HLISS)
+ DbgLog((LOG_TRACE, 0, _T("hli: %I64d - %I64d, (%d,%d) - (%d,%d)"),
+ PTS2RT(pSPHLI->StartPTM)/10000, PTS2RT(pSPHLI->EndPTM)/10000,
+ pSPHLI->StartX, pSPHLI->StartY, pSPHLI->StopX, pSPHLI->StopY));
+ }
+ break;
+ case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON:
+ {
+ CAutoLock cAutoLock(&m_csReceive);
+
+ AM_PROPERTY_COMPOSIT_ON* pCompositOn = (AM_PROPERTY_COMPOSIT_ON*)pPropertyData;
+ m_spon = *pCompositOn;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+
+ if(fRefresh)
+ {
+ (static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
+ }
+
+ return S_OK;
}
STDMETHODIMP CSubpicInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic)
- return __super::QuerySupported(PropSet, Id, pTypeSupport);
-
- switch(Id)
- {
- case AM_PROPERTY_DVDSUBPIC_PALETTE:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDSUBPIC_HLI:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
-
- return S_OK;
+ if(PropSet != AM_KSPROPSETID_DvdSubPic)
+ return __super::QuerySupported(PropSet, Id, pTypeSupport);
+
+ switch(Id)
+ {
+ case AM_PROPERTY_DVDSUBPIC_PALETTE:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDSUBPIC_HLI:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+
+ return S_OK;
}
// CSubpicInputPin::spu
static __inline BYTE GetNibble(BYTE* p, DWORD* offset, int& nField, int& fAligned)
{
- BYTE ret = (p[offset[nField]] >> (fAligned << 2)) & 0x0f;
- offset[nField] += 1 - fAligned;
- fAligned = !fAligned;
+ BYTE ret = (p[offset[nField]] >> (fAligned << 2)) & 0x0f;
+ offset[nField] += 1-fAligned;
+ fAligned = !fAligned;
return ret;
}
static __inline BYTE GetHalfNibble(BYTE* p, DWORD* offset, int& nField, int& n)
{
- BYTE ret = (p[offset[nField]] >> (n << 1)) & 0x03;
- if(!n) offset[nField]++;
- n = (n - 1 + 4) & 3;
+ BYTE ret = (p[offset[nField]] >> (n << 1)) & 0x03;
+ if(!n) offset[nField]++;
+ n = (n-1+4)&3;
return ret;
}
static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
{
- if(c.Reserved == 0) return;
+ if(c.Reserved == 0) return;
- BYTE* p = &yuv[0][pt.y*pitch + pt.x];
+ BYTE* p = &yuv[0][pt.y*pitch + pt.x];
// *p = (*p*(15-contrast) + sppal[color].Y*contrast)>>4;
- *p -= (*p - c.Y) * c.Reserved >> 4;
+ *p -= (*p - c.Y) * c.Reserved >> 4;
- if(pt.y & 1) return; // since U/V is half res there is no need to overwrite the same line again
+ if(pt.y&1) return; // since U/V is half res there is no need to overwrite the same line again
- pt.x = (pt.x + 1) / 2;
- pt.y = (pt.y /*+ 1*/) / 2; // only paint the upper field always, don't round it
- pitch /= 2;
+ pt.x = (pt.x + 1) / 2;
+ pt.y = (pt.y /*+ 1*/) / 2; // only paint the upper field always, don't round it
+ pitch /= 2;
- // U/V is exchanged? wierd but looks true when comparing the outputted colors from other decoders
+ // U/V is exchanged? wierd but looks true when comparing the outputted colors from other decoders
- p = &yuv[1][pt.y*pitch + pt.x];
+ p = &yuv[1][pt.y*pitch + pt.x];
// *p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].V-0x80)*contrast) >> 4) + 0x80);
- *p -= (*p - c.V) * c.Reserved >> 4;
+ *p -= (*p - c.V) * c.Reserved >> 4;
- p = &yuv[2][pt.y*pitch + pt.x];
+ p = &yuv[2][pt.y*pitch + pt.x];
// *p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].U-0x80)*contrast) >> 4) + 0x80);
- *p -= (*p - c.U) * c.Reserved >> 4;
+ *p -= (*p - c.U) * c.Reserved >> 4;
- // Neighter of the blending formulas are accurate (">>4" should be "/15").
- // Even though the second one is a bit worse, since we are scaling the difference only,
- // the error is still not noticable.
+ // Neighter of the blending formulas are accurate (">>4" should be "/15").
+ // Even though the second one is a bit worse, since we are scaling the difference only,
+ // the error is still not noticable.
}
static __inline void DrawPixels(BYTE** yuv, int pitch, CPoint pt, int len, AM_DVD_YUV& c, CRect& rc)
{
if(pt.y < rc.top || pt.y >= rc.bottom) return;
- if(pt.x < rc.left)
- {
- len -= rc.left - pt.x;
- pt.x = rc.left;
- }
- if(pt.x + len > rc.right) len = rc.right - pt.x;
- if(len <= 0 || pt.x >= rc.right) return;
+ if(pt.x < rc.left) {len -= rc.left - pt.x; pt.x = rc.left;}
+ if(pt.x + len > rc.right) len = rc.right - pt.x;
+ if(len <= 0 || pt.x >= rc.right) return;
- if(c.Reserved == 0)
- {
- if(rc.IsRectEmpty())
- return;
+ if(c.Reserved == 0)
+ {
+ if(rc.IsRectEmpty())
+ return;
- if(pt.y < rc.top || pt.y >= rc.bottom
- || pt.x + len < rc.left || pt.x >= rc.right)
- return;
- }
+ if(pt.y < rc.top || pt.y >= rc.bottom
+ || pt.x+len < rc.left || pt.x >= rc.right)
+ return;
+ }
- while(len-- > 0)
- {
- DrawPixel(yuv, pt, pitch, c);
- pt.x++;
- }
+ while(len-- > 0)
+ {
+ DrawPixel(yuv, pt, pitch, c);
+ pt.x++;
+ }
}
// CSubpicInputPin::dvdspu
bool CSubpicInputPin::dvdspu::Parse()
{
- m_offsets.RemoveAll();
+ m_offsets.RemoveAll();
- BYTE* p = GetData();
+ BYTE* p = GetData();
- WORD packetsize = (p[0] << 8) | p[1];
- WORD datasize = (p[2] << 8) | p[3];
+ WORD packetsize = (p[0]<<8)|p[1];
+ WORD datasize = (p[2]<<8)|p[3];
if(packetsize > GetCount() || datasize > packetsize)
- return(false);
-
- int i, next = datasize;
-
-#define GetWORD (p[i]<<8)|p[i+1]; i += 2
-
- do
- {
- i = next;
-
- int pts = GetWORD;
- next = GetWORD;
-
- if(next > packetsize || next < datasize)
- return(false);
-
- REFERENCE_TIME rt = m_rtStart + 1024 * PTS2RT(pts);
-
- for(bool fBreak = false; !fBreak;)
- {
- int len = 0;
-
- switch(p[i])
- {
- case 0x00:
- len = 0;
- break;
- case 0x01:
- len = 0;
- break;
- case 0x02:
- len = 0;
- break;
- case 0x03:
- len = 2;
- break;
- case 0x04:
- len = 2;
- break;
- case 0x05:
- len = 6;
- break;
- case 0x06:
- len = 4;
- break;
- case 0x07:
- len = 0;
- break; // TODO
- default:
- len = 0;
- break;
- }
-
- if(i + len >= packetsize)
- {
- TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
- break;
- }
-
- switch(p[i++])
- {
- case 0x00: // forced start displaying
- m_fForced = true;
- break;
- case 0x01: // normal start displaying
- m_fForced = false;
- break;
- case 0x02: // stop displaying
- m_rtStop = rt;
- break;
- case 0x03:
- m_sphli.ColCon.emph2col = p[i] >> 4;
- m_sphli.ColCon.emph1col = p[i] & 0xf;
- m_sphli.ColCon.patcol = p[i+1] >> 4;
- m_sphli.ColCon.backcol = p[i+1] & 0xf;
- i += 2;
- break;
- case 0x04:
- m_sphli.ColCon.emph2con = p[i] >> 4;
- m_sphli.ColCon.emph1con = p[i] & 0xf;
- m_sphli.ColCon.patcon = p[i+1] >> 4;
- m_sphli.ColCon.backcon = p[i+1] & 0xf;
- i += 2;
- break;
- case 0x05:
- m_sphli.StartX = (p[i] << 4) + (p[i+1] >> 4);
- m_sphli.StopX = ((p[i+1] & 0x0f) << 8) + p[i+2] + 1;
- m_sphli.StartY = (p[i+3] << 4) + (p[i+4] >> 4);
- m_sphli.StopY = ((p[i+4] & 0x0f) << 8) + p[i+5] + 1;
- i += 6;
- break;
- case 0x06:
- m_offset[0] = GetWORD;
- m_offset[1] = GetWORD;
- break;
- case 0x07:
- // TODO
- break;
- case 0xff: // end of ctrlblk
- fBreak = true;
- continue;
- default: // skip this ctrlblk
- fBreak = true;
- break;
- }
- }
-
- offset_t o = {rt, m_sphli};
- m_offsets.AddTail(o); // is it always going to be sorted?
- }
- while(i <= next && i < packetsize);
-
- return(true);
+ return(false);
+
+ int i, next = datasize;
+
+ #define GetWORD (p[i]<<8)|p[i+1]; i += 2
+
+ do
+ {
+ i = next;
+
+ int pts = GetWORD;
+ next = GetWORD;
+
+ if(next > packetsize || next < datasize)
+ return(false);
+
+ REFERENCE_TIME rt = m_rtStart + 1024*PTS2RT(pts);
+
+ for(bool fBreak = false; !fBreak; )
+ {
+ int len = 0;
+
+ switch(p[i])
+ {
+ case 0x00: len = 0; break;
+ case 0x01: len = 0; break;
+ case 0x02: len = 0; break;
+ case 0x03: len = 2; break;
+ case 0x04: len = 2; break;
+ case 0x05: len = 6; break;
+ case 0x06: len = 4; break;
+ case 0x07: len = 0; break; // TODO
+ default: len = 0; break;
+ }
+
+ if(i+len >= packetsize)
+ {
+ TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
+ break;
+ }
+
+ switch(p[i++])
+ {
+ case 0x00: // forced start displaying
+ m_fForced = true;
+ break;
+ case 0x01: // normal start displaying
+ m_fForced = false;
+ break;
+ case 0x02: // stop displaying
+ m_rtStop = rt;
+ break;
+ case 0x03:
+ m_sphli.ColCon.emph2col = p[i]>>4;
+ m_sphli.ColCon.emph1col = p[i]&0xf;
+ m_sphli.ColCon.patcol = p[i+1]>>4;
+ m_sphli.ColCon.backcol = p[i+1]&0xf;
+ i += 2;
+ break;
+ case 0x04:
+ m_sphli.ColCon.emph2con = p[i]>>4;
+ m_sphli.ColCon.emph1con = p[i]&0xf;
+ m_sphli.ColCon.patcon = p[i+1]>>4;
+ m_sphli.ColCon.backcon = p[i+1]&0xf;
+ i += 2;
+ break;
+ case 0x05:
+ m_sphli.StartX = (p[i]<<4) + (p[i+1]>>4);
+ m_sphli.StopX = ((p[i+1]&0x0f)<<8) + p[i+2]+1;
+ m_sphli.StartY = (p[i+3]<<4) + (p[i+4]>>4);
+ m_sphli.StopY = ((p[i+4]&0x0f)<<8) + p[i+5]+1;
+ i += 6;
+ break;
+ case 0x06:
+ m_offset[0] = GetWORD;
+ m_offset[1] = GetWORD;
+ break;
+ case 0x07:
+ // TODO
+ break;
+ case 0xff: // end of ctrlblk
+ fBreak = true;
+ continue;
+ default: // skip this ctrlblk
+ fBreak = true;
+ break;
+ }
+ }
+
+ offset_t o = {rt, m_sphli};
+ m_offsets.AddTail(o); // is it always going to be sorted?
+ }
+ while(i <= next && i < packetsize);
+
+ return(true);
}
void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
-
- AM_PROPERTY_SPHLI sphli = m_sphli;
- CPoint pt(sphli.StartX, sphli.StartY);
- CRect rc(pt, CPoint(sphli.StopX, sphli.StopY));
-
- CRect rcclip(0, 0, w, h);
- rcclip &= rc;
-
- if(m_psphli)
- {
- rcclip &= CRect(m_psphli->StartX, m_psphli->StartY, m_psphli->StopX, m_psphli->StopY);
- sphli = *m_psphli;
- }
- else if(m_offsets.GetCount() > 1)
- {
- POSITION pos = m_offsets.GetTailPosition();
- while(pos)
- {
- const offset_t& o = m_offsets.GetPrev(pos);
- if(rt >= o.rt)
- {
- sphli = o.sphli;
- break;
- }
- }
- }
-
- AM_DVD_YUV pal[4];
- pal[0] = sppal[fsppal ? sphli.ColCon.backcol : 0];
- pal[0].Reserved = sphli.ColCon.backcon;
- pal[1] = sppal[fsppal ? sphli.ColCon.patcol : 1];
- pal[1].Reserved = sphli.ColCon.patcon;
- pal[2] = sppal[fsppal ? sphli.ColCon.emph1col : 2];
- pal[2].Reserved = sphli.ColCon.emph1con;
- pal[3] = sppal[fsppal ? sphli.ColCon.emph2col : 3];
- pal[3].Reserved = sphli.ColCon.emph2con;
-
- int nField = 0;
- int fAligned = 1;
-
- DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
-
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
- DWORD code;
-
- if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x10
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x40
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x100)
- {
- DrawPixels(yuv, w, pt, code >> 2, pal[code&3], rcclip);
- if((pt.x += code >> 2) < rc.right) continue;
- }
-
- DrawPixels(yuv, w, pt, rc.right - pt.x, pal[code&3], rcclip);
-
- if(!fAligned) GetNibble(p, offset, nField, fAligned); // align to byte
-
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
+ BYTE* p = GetData();
+ DWORD offset[2] = {m_offset[0], m_offset[1]};
+
+ AM_PROPERTY_SPHLI sphli = m_sphli;
+ CPoint pt(sphli.StartX, sphli.StartY);
+ CRect rc(pt, CPoint(sphli.StopX, sphli.StopY));
+
+ CRect rcclip(0, 0, w, h);
+ rcclip &= rc;
+
+ if(m_psphli)
+ {
+ rcclip &= CRect(m_psphli->StartX, m_psphli->StartY, m_psphli->StopX, m_psphli->StopY);
+ sphli = *m_psphli;
+ }
+ else if(m_offsets.GetCount() > 1)
+ {
+ POSITION pos = m_offsets.GetTailPosition();
+ while(pos)
+ {
+ const offset_t& o = m_offsets.GetPrev(pos);
+ if(rt >= o.rt) {sphli = o.sphli; break;}
+ }
+ }
+
+ AM_DVD_YUV pal[4];
+ pal[0] = sppal[fsppal ? sphli.ColCon.backcol : 0];
+ pal[0].Reserved = sphli.ColCon.backcon;
+ pal[1] = sppal[fsppal ? sphli.ColCon.patcol : 1];
+ pal[1].Reserved = sphli.ColCon.patcon;
+ pal[2] = sppal[fsppal ? sphli.ColCon.emph1col : 2];
+ pal[2].Reserved = sphli.ColCon.emph1con;
+ pal[3] = sppal[fsppal ? sphli.ColCon.emph2col : 3];
+ pal[3].Reserved = sphli.ColCon.emph2con;
+
+ int nField = 0;
+ int fAligned = 1;
+
+ DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
+
+ while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
+ {
+ DWORD code;
+
+ if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4
+ || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x10
+ || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x40
+ || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x100)
+ {
+ DrawPixels(yuv, w, pt, code >> 2, pal[code&3], rcclip);
+ if((pt.x += code >> 2) < rc.right) continue;
+ }
+
+ DrawPixels(yuv, w, pt, rc.right - pt.x, pal[code&3], rcclip);
+
+ if(!fAligned) GetNibble(p, offset, nField, fAligned); // align to byte
+
+ pt.x = rc.left;
+ pt.y++;
+ nField = 1 - nField;
+ }
}
// CSubpicInputPin::cvdspu
bool CSubpicInputPin::cvdspu::Parse()
{
- BYTE* p = GetData();
+ BYTE* p = GetData();
- WORD packetsize = (p[0] << 8) | p[1];
- WORD datasize = (p[2] << 8) | p[3];
+ WORD packetsize = (p[0]<<8)|p[1];
+ WORD datasize = (p[2]<<8)|p[3];
if(packetsize > GetCount() || datasize > packetsize)
- return(false);
-
- p = GetData() + datasize;
-
- for(int i = datasize, j = packetsize - 4; i <= j; i += 4, p += 4)
- {
- switch(p[0])
- {
- case 0x0c:
- break;
- case 0x04:
- m_rtStop = m_rtStart + 10000i64 * ((p[1] << 16) | (p[2] << 8) | p[3]) / 90;
- break;
- case 0x17:
- m_sphli.StartX = ((p[1] & 0x0f) << 6) + (p[2] >> 2);
- m_sphli.StartY = ((p[2] & 0x03) << 8) + p[3];
- break;
- case 0x1f:
- m_sphli.StopX = ((p[1] & 0x0f) << 6) + (p[2] >> 2);
- m_sphli.StopY = ((p[2] & 0x03) << 8) + p[3];
- break;
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- m_sppal[0][p[0] - 0x24].Y = p[1];
- m_sppal[0][p[0] - 0x24].U = p[2];
- m_sppal[0][p[0] - 0x24].V = p[3];
- break;
- case 0x2c:
- case 0x2d:
- case 0x2e:
- case 0x2f:
- m_sppal[1][p[0] - 0x2c].Y = p[1];
- m_sppal[1][p[0] - 0x2c].U = p[2];
- m_sppal[1][p[0] - 0x2c].V = p[3];
- break;
- case 0x37:
- m_sppal[0][3].Reserved = p[2] >> 4;
- m_sppal[0][2].Reserved = p[2] & 0xf;
- m_sppal[0][1].Reserved = p[3] >> 4;
- m_sppal[0][0].Reserved = p[3] & 0xf;
- break;
- case 0x3f:
- m_sppal[1][3].Reserved = p[2] >> 4;
- m_sppal[1][2].Reserved = p[2] & 0xf;
- m_sppal[1][1].Reserved = p[3] >> 4;
- m_sppal[1][0].Reserved = p[3] & 0xf;
- break;
- case 0x47:
- m_offset[0] = (p[2] << 8) | p[3];
- break;
- case 0x4f:
- m_offset[1] = (p[2] << 8) | p[3];
- break;
- default:
- break;
- }
- }
-
- return(true);
+ return(false);
+
+ p = GetData() + datasize;
+
+ for(int i = datasize, j = packetsize-4; i <= j; i+=4, p+=4)
+ {
+ switch(p[0])
+ {
+ case 0x0c:
+ break;
+ case 0x04:
+ m_rtStop = m_rtStart + 10000i64*((p[1]<<16)|(p[2]<<8)|p[3])/90;
+ break;
+ case 0x17:
+ m_sphli.StartX = ((p[1]&0x0f)<<6) + (p[2]>>2);
+ m_sphli.StartY = ((p[2]&0x03)<<8) + p[3];
+ break;
+ case 0x1f:
+ m_sphli.StopX = ((p[1]&0x0f)<<6) + (p[2]>>2);
+ m_sphli.StopY = ((p[2]&0x03)<<8) + p[3];
+ break;
+ case 0x24: case 0x25: case 0x26: case 0x27:
+ m_sppal[0][p[0]-0x24].Y = p[1];
+ m_sppal[0][p[0]-0x24].U = p[2];
+ m_sppal[0][p[0]-0x24].V = p[3];
+ break;
+ case 0x2c: case 0x2d: case 0x2e: case 0x2f:
+ m_sppal[1][p[0]-0x2c].Y = p[1];
+ m_sppal[1][p[0]-0x2c].U = p[2];
+ m_sppal[1][p[0]-0x2c].V = p[3];
+ break;
+ case 0x37:
+ m_sppal[0][3].Reserved = p[2]>>4;
+ m_sppal[0][2].Reserved = p[2]&0xf;
+ m_sppal[0][1].Reserved = p[3]>>4;
+ m_sppal[0][0].Reserved = p[3]&0xf;
+ break;
+ case 0x3f:
+ m_sppal[1][3].Reserved = p[2]>>4;
+ m_sppal[1][2].Reserved = p[2]&0xf;
+ m_sppal[1][1].Reserved = p[3]>>4;
+ m_sppal[1][0].Reserved = p[3]&0xf;
+ break;
+ case 0x47:
+ m_offset[0] = (p[2]<<8)|p[3];
+ break;
+ case 0x4f:
+ m_offset[1] = (p[2]<<8)|p[3];
+ break;
+ default:
+ break;
+ }
+ }
+
+ return(true);
}
void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
+ BYTE* p = GetData();
+ DWORD offset[2] = {m_offset[0], m_offset[1]};
- CRect rcclip(0, 0, w, h);
+ CRect rcclip(0, 0, w, h);
- /* FIXME: startx/y looks to be wrong in the sample I tested
- CPoint pt(m_sphli.StartX, m_sphli.StartY);
- CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
- */
+ /* FIXME: startx/y looks to be wrong in the sample I tested
+ CPoint pt(m_sphli.StartX, m_sphli.StartY);
+ CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
+ */
- CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
- CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height() * 3 - size.cy * 1) / 4);
- CRect rc(pt, size);
+ CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
+ CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height()*3 - size.cy*1) / 4);
+ CRect rc(pt, size);
- int nField = 0;
- int fAligned = 1;
+ int nField = 0;
+ int fAligned = 1;
- DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
+ DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
- BYTE code;
+ while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
+ {
+ BYTE code;
- if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4)
- {
- DrawPixels(yuv, w, pt, code >> 2, m_sppal[0][code&3], rcclip);
- pt.x += code >> 2;
- continue;
- }
+ if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4)
+ {
+ DrawPixels(yuv, w, pt, code >> 2, m_sppal[0][code&3], rcclip);
+ pt.x += code >> 2;
+ continue;
+ }
- code = GetNibble(p, offset, nField, fAligned);
- DrawPixels(yuv, w, pt, rc.right - pt.x, m_sppal[0][code&3], rcclip);
+ code = GetNibble(p, offset, nField, fAligned);
+ DrawPixels(yuv, w, pt, rc.right - pt.x, m_sppal[0][code&3], rcclip);
- if(!fAligned) GetNibble(p, offset, nField, fAligned); // align to byte
+ if(!fAligned) GetNibble(p, offset, nField, fAligned); // align to byte
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
+ pt.x = rc.left;
+ pt.y++;
+ nField = 1 - nField;
+ }
}
// CSubpicInputPin::svcdspu
bool CSubpicInputPin::svcdspu::Parse()
{
- BYTE* p = GetData();
- BYTE* p0 = p;
+ BYTE* p = GetData();
+ BYTE* p0 = p;
- if(GetCount() < 2)
- return(false);
+ if(GetCount() < 2)
+ return(false);
- WORD packetsize = (p[0] << 8) | p[1];
- p += 2;
+ WORD packetsize = (p[0]<<8)|p[1]; p += 2;
if(packetsize > GetCount())
- return(false);
+ return(false);
- bool duration = !!(*p++ & 0x04);
+ bool duration = !!(*p++&0x04);
- *p++; // unknown
+ *p++; // unknown
- if(duration)
- {
- m_rtStop = m_rtStart + 10000i64 * ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]) / 90;
- p += 4;
- }
+ if(duration)
+ {
+ m_rtStop = m_rtStart + 10000i64*((p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3])/90;
+ p += 4;
+ }
- m_sphli.StartX = m_sphli.StopX = (p[0] << 8) | p[1];
- p += 2;
- m_sphli.StartY = m_sphli.StopY = (p[0] << 8) | p[1];
- p += 2;
- m_sphli.StopX += (p[0] << 8) | p[1];
- p += 2;
- m_sphli.StopY += (p[0] << 8) | p[1];
- p += 2;
-
- for(int i = 0; i < 4; i++)
- {
- m_sppal[i].Y = *p++;
- m_sppal[i].U = *p++;
- m_sppal[i].V = *p++;
- m_sppal[i].Reserved = *p++ >> 4;
- }
+ m_sphli.StartX = m_sphli.StopX = (p[0]<<8)|p[1]; p += 2;
+ m_sphli.StartY = m_sphli.StopY = (p[0]<<8)|p[1]; p += 2;
+ m_sphli.StopX += (p[0]<<8)|p[1]; p += 2;
+ m_sphli.StopY += (p[0]<<8)|p[1]; p += 2;
+
+ for(int i = 0; i < 4; i++)
+ {
+ m_sppal[i].Y = *p++;
+ m_sppal[i].U = *p++;
+ m_sppal[i].V = *p++;
+ m_sppal[i].Reserved = *p++ >> 4;
+ }
- if(*p++ & 0xc0)
- p += 4; // duration of the shift operation should be here, but it is untested
+ if(*p++&0xc0)
+ p += 4; // duration of the shift operation should be here, but it is untested
- m_offset[1] = (p[0] << 8) | p[1];
- p += 2;
+ m_offset[1] = (p[0]<<8)|p[1]; p += 2;
- m_offset[0] = p - p0;
- m_offset[1] += m_offset[0];
+ m_offset[0] = p - p0;
+ m_offset[1] += m_offset[0];
- return(true);
+ return(true);
}
void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
+ BYTE* p = GetData();
+ DWORD offset[2] = {m_offset[0], m_offset[1]};
- CRect rcclip(0, 0, w, h);
+ CRect rcclip(0, 0, w, h);
- /* FIXME: startx/y looks to be wrong in the sample I tested (yes, this one too!)
- CPoint pt(m_sphli.StartX, m_sphli.StartY);
- CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
- */
+ /* FIXME: startx/y looks to be wrong in the sample I tested (yes, this one too!)
+ CPoint pt(m_sphli.StartX, m_sphli.StartY);
+ CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
+ */
- CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
- CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height() * 3 - size.cy * 1) / 4);
- CRect rc(pt, size);
+ CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
+ CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height()*3 - size.cy*1) / 4);
+ CRect rc(pt, size);
- int nField = 0;
- int n = 3;
+ int nField = 0;
+ int n = 3;
- DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
+ DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
- BYTE code = GetHalfNibble(p, offset, nField, n);
- BYTE repeat = 1 + (code == 0 ? GetHalfNibble(p, offset, nField, n) : 0);
+ while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
+ {
+ BYTE code = GetHalfNibble(p, offset, nField, n);
+ BYTE repeat = 1 + (code == 0 ? GetHalfNibble(p, offset, nField, n) : 0);
- DrawPixels(yuv, w, pt, repeat, m_sppal[code&3], rcclip);
- if((pt.x += repeat) < rc.right) continue;
+ DrawPixels(yuv, w, pt, repeat, m_sppal[code&3], rcclip);
+ if((pt.x += repeat) < rc.right) continue;
- while(n != 3)
- GetHalfNibble(p, offset, nField, n); // align to byte
+ while(n != 3)
+ GetHalfNibble(p, offset, nField, n); // align to byte
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
+ pt.x = rc.left;
+ pt.y++;
+ nField = 1 - nField;
+ }
}
//
@@ -2211,62 +2159,62 @@ void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int
//
CClosedCaptionOutputPin::CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(NAME("CClosedCaptionOutputPin"), pFilter, pLock, phr, L"~CC")
+ : CBaseOutputPin(NAME("CClosedCaptionOutputPin"), pFilter, pLock, phr, L"~CC")
{
}
HRESULT CClosedCaptionOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- return mtOut->majortype == MEDIATYPE_AUXLine21Data && mtOut->subtype == MEDIASUBTYPE_Line21_GOPPacket
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return mtOut->majortype == MEDIATYPE_AUXLine21Data && mtOut->subtype == MEDIASUBTYPE_Line21_GOPPacket
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CClosedCaptionOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- 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->InitMediaType();
- pmt->majortype = MEDIATYPE_AUXLine21Data;
- pmt->subtype = MEDIASUBTYPE_Line21_GOPPacket;
- pmt->formattype = FORMAT_None;
+ pmt->InitMediaType();
+ pmt->majortype = MEDIATYPE_AUXLine21Data;
+ pmt->subtype = MEDIASUBTYPE_Line21_GOPPacket;
+ pmt->formattype = FORMAT_None;
- return S_OK;
+ return S_OK;
}
HRESULT CClosedCaptionOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 2048;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = 2048;
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
- return hr;
+ 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;
+ ? E_FAIL
+ : NOERROR;
}
HRESULT CClosedCaptionOutputPin::Deliver(const void* ptr, int len)
{
- HRESULT hr = S_FALSE;
-
- if(len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected())
- {
- CComPtr<IMediaSample> pSample;
- GetDeliveryBuffer(&pSample, NULL, NULL, 0);
- BYTE* pData = NULL;
- pSample->GetPointer(&pData);
- *(DWORD*)pData = 0xb2010000;
- memcpy(pData + 4, ptr, len);
- pSample->SetActualDataLength(len + 4);
- hr = __super::Deliver(pSample);
- }
-
- return hr;
+ HRESULT hr = S_FALSE;
+
+ if(len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected())
+ {
+ CComPtr<IMediaSample> pSample;
+ GetDeliveryBuffer(&pSample, NULL, NULL, 0);
+ BYTE* pData = NULL;
+ pSample->GetPointer(&pData);
+ *(DWORD*)pData = 0xb2010000;
+ memcpy(pData + 4, ptr, len);
+ pSample->SetActualDataLength(len + 4);
+ hr = __super::Deliver(pSample);
+ }
+
+ return hr;
}
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
index e0e8c6a6f..66a0acdd6 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.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
*
*/
@@ -33,164 +33,153 @@ class CClosedCaptionOutputPin;
class CMpeg2Dec;
[uuid("39F498AF-1A09-4275-B193-673B0BA3D478")]
-class CMpeg2DecFilter
- : public CBaseVideoFilter
- , public IMpeg2DecFilter
- , public ISpecifyPropertyPages2
+class CMpeg2DecFilter
+ : public CBaseVideoFilter
+ , public IMpeg2DecFilter
+ , public ISpecifyPropertyPages2
{
- CSubpicInputPin* m_pSubpicInput;
- CClosedCaptionOutputPin* m_pClosedCaptionOutput;
-
- CAutoPtr<CMpeg2Dec> m_dec;
-
- REFERENCE_TIME m_AvgTimePerFrame;
- bool m_fWaitForKeyFrame;
-
- struct framebuf
- {
- int w, h, pitch;
- BYTE* buf_base;
- BYTE* buf[6];
- REFERENCE_TIME rtStart, rtStop;
- DWORD flags;
- ditype di;
+ CSubpicInputPin* m_pSubpicInput;
+ CClosedCaptionOutputPin* m_pClosedCaptionOutput;
+
+ CAutoPtr<CMpeg2Dec> m_dec;
+
+ REFERENCE_TIME m_AvgTimePerFrame;
+ bool m_fWaitForKeyFrame;
+
+ struct framebuf
+ {
+ int w, h, pitch;
+ BYTE* buf_base;
+ BYTE* buf[6];
+ REFERENCE_TIME rtStart, rtStop;
+ DWORD flags;
+ ditype di;
framebuf()
- {
- w = h = pitch = 0;
- buf_base = NULL;
- memset(&buf, 0, sizeof(buf));
- rtStart = rtStop = 0;
- flags = 0;
- }
- ~framebuf()
- {
- Free();
- }
- void Alloc(int w, int h, int pitch)
- {
- this->w = w;
- this->h = h;
- this->pitch = pitch;
- int size = pitch * h;
- buf_base = (BYTE*)_aligned_malloc(size * 3 + 6 * 32, 32);
- BYTE* p = buf_base;
- buf[0] = p;
- p += (size + 31) & ~31;
- buf[3] = p;
- p += (size + 31) & ~31;
- buf[1] = p;
- p += (size / 4 + 31) & ~31;
- buf[4] = p;
- p += (size / 4 + 31) & ~31;
- buf[2] = p;
- p += (size / 4 + 31) & ~31;
- buf[5] = p;
- p += (size / 4 + 31) & ~31;
- }
- void Free()
- {
- if(buf_base) _aligned_free(buf_base);
- buf_base = NULL;
- }
- } m_fb;
-
- bool m_fFilm;
- void SetDeinterlaceMethod();
- void SetTypeSpecificFlags(IMediaSample* pMS);
-
- AM_SimpleRateChange m_rate;
+ {
+ w = h = pitch = 0;
+ buf_base = NULL;
+ memset(&buf, 0, sizeof(buf));
+ rtStart = rtStop = 0;
+ flags = 0;
+ }
+ ~framebuf() {Free();}
+ void Alloc(int w, int h, int pitch)
+ {
+ this->w = w; this->h = h; this->pitch = pitch;
+ int size = pitch*h;
+ buf_base = (BYTE*)_aligned_malloc(size*3+6*32, 32);
+ BYTE* p = buf_base;
+ buf[0] = p; p += (size + 31) & ~31;
+ buf[3] = p; p += (size + 31) & ~31;
+ buf[1] = p; p += (size/4 + 31) & ~31;
+ buf[4] = p; p += (size/4 + 31) & ~31;
+ buf[2] = p; p += (size/4 + 31) & ~31;
+ buf[5] = p; p += (size/4 + 31) & ~31;
+ }
+ void Free()
+ {
+ if(buf_base) _aligned_free(buf_base);
+ buf_base = NULL;
+ }
+ } m_fb;
+
+ bool m_fFilm;
+ void SetDeinterlaceMethod();
+ void SetTypeSpecificFlags(IMediaSample* pMS);
+
+ AM_SimpleRateChange m_rate;
protected:
- void InputTypeChanged();
- HRESULT Transform(IMediaSample* pIn);
- bool IsVideoInterlaced();
+ void InputTypeChanged();
+ HRESULT Transform(IMediaSample* pIn);
+ bool IsVideoInterlaced();
public:
- CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMpeg2DecFilter();
+ CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CMpeg2DecFilter();
- DECLARE_IUNKNOWN
+ DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DeliverFast();
- HRESULT DeliverNormal();
- HRESULT Deliver(bool fRepeatLast);
+ HRESULT DeliverFast();
+ HRESULT DeliverNormal();
+ HRESULT Deliver(bool fRepeatLast);
- int GetPinCount();
- CBasePin* GetPin(int n);
+ int GetPinCount();
+ CBasePin* GetPin(int n);
HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
+ HRESULT BeginFlush();
+ HRESULT EndFlush();
HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
+ HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT StartStreaming();
- HRESULT StopStreaming();
+ HRESULT StartStreaming();
+ HRESULT StopStreaming();
- bool m_fDropFrames;
- HRESULT AlterQuality(Quality q);
+ bool m_fDropFrames;
+ HRESULT AlterQuality(Quality q);
protected:
- CCritSec m_csProps;
- ditype m_ditype;
- float m_bright, m_cont, m_hue, m_sat;
- BYTE m_YTbl[256], m_UTbl[256*256], m_VTbl[256*256];
- bool m_fForcedSubs;
- bool m_fPlanarYUV;
- bool m_fInterlaced;
-
- static void CalcBrCont(BYTE* YTbl, float bright, float cont);
- static void CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat);
- void ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch);
-
+ CCritSec m_csProps;
+ ditype m_ditype;
+ float m_bright, m_cont, m_hue, m_sat;
+ BYTE m_YTbl[256], m_UTbl[256*256], m_VTbl[256*256];
+ bool m_fForcedSubs;
+ bool m_fPlanarYUV;
+ bool m_fInterlaced;
+
+ static void CalcBrCont(BYTE* YTbl, float bright, float cont);
+ static void CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat);
+ void ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch);
+
public:
- // ISpecifyPropertyPages2
+ // ISpecifyPropertyPages2
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
+ STDMETHODIMP GetPages(CAUUID* pPages);
+ STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
- // IMpeg2DecFilter
+ // IMpeg2DecFilter
- STDMETHODIMP SetDeinterlaceMethod(ditype di);
- STDMETHODIMP_(ditype) GetDeinterlaceMethod();
+ STDMETHODIMP SetDeinterlaceMethod(ditype di);
+ STDMETHODIMP_(ditype) GetDeinterlaceMethod();
- STDMETHODIMP SetBrightness(float bright);
- STDMETHODIMP SetContrast(float cont);
- STDMETHODIMP SetHue(float hue);
- STDMETHODIMP SetSaturation(float sat);
- STDMETHODIMP_(float) GetBrightness();
- STDMETHODIMP_(float) GetContrast();
- STDMETHODIMP_(float) GetHue();
- STDMETHODIMP_(float) GetSaturation();
+ STDMETHODIMP SetBrightness(float bright);
+ STDMETHODIMP SetContrast(float cont);
+ STDMETHODIMP SetHue(float hue);
+ STDMETHODIMP SetSaturation(float sat);
+ STDMETHODIMP_(float) GetBrightness();
+ STDMETHODIMP_(float) GetContrast();
+ STDMETHODIMP_(float) GetHue();
+ STDMETHODIMP_(float) GetSaturation();
- STDMETHODIMP EnableForcedSubtitles(bool fEnable);
- STDMETHODIMP_(bool) IsForcedSubtitlesEnabled();
+ STDMETHODIMP EnableForcedSubtitles(bool fEnable);
+ STDMETHODIMP_(bool) IsForcedSubtitlesEnabled();
- STDMETHODIMP EnablePlanarYUV(bool fEnable);
- STDMETHODIMP_(bool) IsPlanarYUVEnabled();
+ STDMETHODIMP EnablePlanarYUV(bool fEnable);
+ STDMETHODIMP_(bool) IsPlanarYUVEnabled();
- // IMpeg2DecFilter2
+ // IMpeg2DecFilter2
- STDMETHODIMP EnableInterlaced(bool fEnable);
- STDMETHODIMP_(bool) IsInterlacedEnabled();
+ STDMETHODIMP EnableInterlaced(bool fEnable);
+ STDMETHODIMP_(bool) IsInterlacedEnabled();
};
class CMpeg2DecInputPin : public CDeCSSInputPin
{
- LONG m_CorrectTS;
+ LONG m_CorrectTS;
public:
CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
- CCritSec m_csRateLock;
- AM_SimpleRateChange m_ratechange;
+ CCritSec m_csRateLock;
+ AM_SimpleRateChange m_ratechange;
- // IKsPropertySet
+ // IKsPropertySet
STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned);
STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
@@ -199,115 +188,91 @@ public:
class CMpeg2DecOutputPin : public CBaseVideoOutputPin
{
public:
- CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName);
+ CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName);
- CAutoPtr<COutputQueue> m_pOutputQueue;
+ CAutoPtr<COutputQueue> m_pOutputQueue;
- HRESULT Active();
+ HRESULT Active();
HRESULT Inactive();
- HRESULT Deliver(IMediaSample* pMediaSample);
+ HRESULT Deliver(IMediaSample* pMediaSample);
HRESULT DeliverEndOfStream();
HRESULT DeliverBeginFlush();
- HRESULT DeliverEndFlush();
+ HRESULT DeliverEndFlush();
HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
class CSubpicInputPin : public CMpeg2DecInputPin
{
- CCritSec m_csReceive;
-
- AM_PROPERTY_COMPOSIT_ON m_spon;
- AM_DVD_YUV m_sppal[16];
- bool m_fsppal;
- CAutoPtr<AM_PROPERTY_SPHLI> m_sphli; // temp
-
- class spu : public CAtlArray<BYTE>
- {
- public:
- bool m_fForced;
- REFERENCE_TIME m_rtStart, m_rtStop;
- DWORD m_offset[2];
- AM_PROPERTY_SPHLI m_sphli; // parsed
- CAutoPtr<AM_PROPERTY_SPHLI> m_psphli; // for the menu (optional)
- spu()
- {
- memset(&m_sphli, 0, sizeof(m_sphli));
- m_fForced = false;
- m_rtStart = m_rtStop = 0;
- }
- virtual ~spu() {}
- virtual bool Parse() = 0;
- virtual void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal) = 0;
- };
-
- class dvdspu : public spu
- {
- public:
- struct offset_t
- {
- REFERENCE_TIME rt;
- AM_PROPERTY_SPHLI sphli;
- };
- CAtlList<offset_t> m_offsets;
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- class cvdspu : public spu
- {
- public:
- AM_DVD_YUV m_sppal[2][4];
- cvdspu()
- {
- memset(m_sppal, 0, sizeof(m_sppal));
- }
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- class svcdspu : public spu
- {
- public:
- AM_DVD_YUV m_sppal[4];
- svcdspu()
- {
- memset(m_sppal, 0, sizeof(m_sppal));
- }
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- CAutoPtrList<spu> m_sps;
+ CCritSec m_csReceive;
+
+ AM_PROPERTY_COMPOSIT_ON m_spon;
+ AM_DVD_YUV m_sppal[16];
+ bool m_fsppal;
+ CAutoPtr<AM_PROPERTY_SPHLI> m_sphli; // temp
+
+ class spu : public CAtlArray<BYTE>
+ {
+ public:
+ bool m_fForced;
+ REFERENCE_TIME m_rtStart, m_rtStop;
+ DWORD m_offset[2];
+ AM_PROPERTY_SPHLI m_sphli; // parsed
+ CAutoPtr<AM_PROPERTY_SPHLI> m_psphli; // for the menu (optional)
+ spu() {memset(&m_sphli, 0, sizeof(m_sphli)); m_fForced = false; m_rtStart = m_rtStop = 0;}
+ virtual ~spu() {}
+ virtual bool Parse() = 0;
+ virtual void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal) = 0;
+ };
+
+ class dvdspu : public spu
+ {
+ public:
+ struct offset_t {REFERENCE_TIME rt; AM_PROPERTY_SPHLI sphli;};
+ CAtlList<offset_t> m_offsets;
+ bool Parse();
+ void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
+ };
+
+ class cvdspu : public spu
+ {
+ public:
+ AM_DVD_YUV m_sppal[2][4];
+ cvdspu() {memset(m_sppal, 0, sizeof(m_sppal));}
+ bool Parse();
+ void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
+ };
+
+ class svcdspu : public spu
+ {
+ public:
+ AM_DVD_YUV m_sppal[4];
+ svcdspu() {memset(m_sppal, 0, sizeof(m_sppal));}
+ bool Parse();
+ void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
+ };
+
+ CAutoPtrList<spu> m_sps;
protected:
- HRESULT Transform(IMediaSample* pSample);
+ HRESULT Transform(IMediaSample* pSample);
public:
- CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr);
+ CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr);
- bool HasAnythingToRender(REFERENCE_TIME rt);
- void RenderSubpics(REFERENCE_TIME rt, BYTE** p, int w, int h);
+ bool HasAnythingToRender(REFERENCE_TIME rt);
+ void RenderSubpics(REFERENCE_TIME rt, BYTE** p, int w, int h);
HRESULT CheckMediaType(const CMediaType* mtIn);
- HRESULT SetMediaType(const CMediaType* mtIn);
-
- // we shouldn't pass these to the filter from this pin
- STDMETHODIMP EndOfStream()
- {
- return S_OK;
- }
- STDMETHODIMP BeginFlush()
- {
- return S_OK;
- }
+ HRESULT SetMediaType(const CMediaType* mtIn);
+
+ // we shouldn't pass these to the filter from this pin
+ STDMETHODIMP EndOfStream() {return S_OK;}
+ STDMETHODIMP BeginFlush() {return S_OK;}
STDMETHODIMP EndFlush();
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
- {
- return S_OK;
- }
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) {return S_OK;}
- // IKsPropertySet
+ // IKsPropertySet
STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
};
@@ -315,16 +280,13 @@ public:
class CClosedCaptionOutputPin : public CBaseOutputPin
{
public:
- CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
HRESULT CheckMediaType(const CMediaType* mtOut);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- CMediaType& CurrentMediaType()
- {
- return m_mt;
- }
+ CMediaType& CurrentMediaType() {return m_mt;}
- HRESULT Deliver(const void* ptr, int len);
+ HRESULT Deliver(const void* ptr, int len);
};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
index 046a006f8..101e126d3 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.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
*
*/
@@ -38,193 +38,193 @@ static TCHAR m_strSaturation[100];
CMpeg2DecSettingsWnd::CMpeg2DecSettingsWnd()
{
- wcscpy(m_strBrightness, ResStr(IDS_MPEG2_BRIGHTNESS));
- wcscpy(m_strContrast, ResStr(IDS_MPEG2_CONTRAST));
- wcscpy(m_strHue, ResStr(IDS_MPEG2_HUE));
- wcscpy(m_strSaturation, ResStr(IDS_MPEG2_SATURATION));
+ wcscpy (m_strBrightness, ResStr(IDS_MPEG2_BRIGHTNESS));
+ wcscpy (m_strContrast, ResStr(IDS_MPEG2_CONTRAST));
+ wcscpy (m_strHue, ResStr(IDS_MPEG2_HUE));
+ wcscpy (m_strSaturation, ResStr(IDS_MPEG2_SATURATION));
}
bool CMpeg2DecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pM2DF);
-
- m_pM2DF.Release();
+ ASSERT(!m_pM2DF);
- POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pM2DF = pUnks.GetNext(pos)));
+ m_pM2DF.Release();
- if(!m_pM2DF) return false;
+ POSITION pos = pUnks.GetHeadPosition();
+ while(pos && !(m_pM2DF = pUnks.GetNext(pos)));
+
+ if(!m_pM2DF) return false;
- m_ditype = m_pM2DF->GetDeinterlaceMethod();
- m_procamp[0] = m_pM2DF->GetBrightness();
- m_procamp[1] = m_pM2DF->GetContrast();
- m_procamp[2] = m_pM2DF->GetHue();
- m_procamp[3] = m_pM2DF->GetSaturation();
- m_forcedsubs = m_pM2DF->IsForcedSubtitlesEnabled();
- m_planaryuv = m_pM2DF->IsPlanarYUVEnabled();
- m_interlaced = m_pM2DF->IsInterlacedEnabled();
+ m_ditype = m_pM2DF->GetDeinterlaceMethod();
+ m_procamp[0] = m_pM2DF->GetBrightness();
+ m_procamp[1] = m_pM2DF->GetContrast();
+ m_procamp[2] = m_pM2DF->GetHue();
+ m_procamp[3] = m_pM2DF->GetSaturation();
+ m_forcedsubs = m_pM2DF->IsForcedSubtitlesEnabled();
+ m_planaryuv = m_pM2DF->IsPlanarYUVEnabled();
+ m_interlaced = m_pM2DF->IsInterlacedEnabled();
- return true;
+ return true;
}
void CMpeg2DecSettingsWnd::OnDisconnect()
{
- m_pM2DF.Release();
+ m_pM2DF.Release();
}
bool CMpeg2DecSettingsWnd::OnActivate()
{
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
-
- CPoint p(10, 10);
-
- m_planaryuv_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_0), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK1);
- m_planaryuv_check.SetCheck(m_planaryuv ? BST_CHECKED : BST_UNCHECKED);
- p.y += m_fontheight + 5;
-
- m_interlaced_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_1), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK2);
- m_interlaced_check.SetCheck(m_interlaced ? BST_CHECKED : BST_UNCHECKED);
- p.y += m_fontheight + 5;
-
- m_forcedsubs_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_2), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK3);
- m_forcedsubs_check.SetCheck(m_forcedsubs ? BST_CHECKED : BST_UNCHECKED);
- p.y += m_fontheight + 5;
-
- p.y += 10;
-
- m_ditype_static.Create(ResStr(IDS_MPEG2_DEINTERLACING), dwStyle, CRect(p, CSize(70, m_fontheight)), this);
- m_ditype_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CSize(85, -3), CSize(100, 200)), this, IDC_PP_COMBO1);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Auto")), (DWORD)DIAuto);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Weave")), (DWORD)DIWeave);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Blend")), (DWORD)DIBlend);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Bob")), (DWORD)DIBob);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Field Shift")), (DWORD)DIFieldShift);
- m_ditype_combo.SetCurSel(0);
- for(int i = 0; i < m_ditype_combo.GetCount(); i++)
- if((int)m_ditype_combo.GetItemData(i) == m_ditype)
- m_ditype_combo.SetCurSel(i);
-
- p.y += m_fontheight + 20;
-
- for(int i = 0, h = max(20, m_fontheight) + 1; i < countof(m_procamp_slider); i++, p.y += h)
- {
- static const TCHAR* labels[] = {m_strBrightness, m_strContrast, m_strHue, m_strSaturation};
- m_procamp_static[i].Create(labels[i], dwStyle, CRect(p, CSize(70, h)), this);
- m_procamp_slider[i].Create(dwStyle, CRect(p + CPoint(80, 0), CSize(200, h)), this, IDC_PP_SLIDER1 + i);
- m_procamp_value[i].Create(_T(""), dwStyle, CRect(p + CPoint(280, 0), CSize(40, h)), this);
- }
-
- m_procamp_slider[0].SetRange(0, 2 * 128);
- m_procamp_slider[0].SetTic(128);
- m_procamp_slider[0].SetPos((int)(m_procamp[0] + (m_procamp[0] >= 0 ? 0.5f : -0.5f)) + 128);
- m_procamp_slider[1].SetRange(0, 200);
- m_procamp_slider[1].SetTic(100);
- m_procamp_slider[1].SetPos((int)(100 * m_procamp[1] + 0.5f));
- m_procamp_slider[2].SetRange(0, 2 * 180);
- m_procamp_slider[2].SetTic(180);
- m_procamp_slider[2].SetPos((int)(m_procamp[2] + (m_procamp[2] >= 0 ? 0.5f : -0.5f)) + 180);
- m_procamp_slider[3].SetRange(0, 200);
- m_procamp_slider[3].SetTic(100);
- m_procamp_slider[3].SetPos((int)(100 * m_procamp[3] + 0.5f));
-
- p.y += 5;
-
- m_procamp_tv2pc.Create(_T("TV->PC"), dwStyle, CRect(p + CPoint(50 + 200 / 2 - 55, 0), CSize(80, 20)), this, IDC_PP_BUTTON1);
- m_procamp_reset.Create(ResStr(IDS_MPEG2_RESET), dwStyle, CRect(p + CPoint(80 + 200 / 2 + 5, 0), CSize(80, 20)), this, IDC_PP_BUTTON2);
-
- p.y += 30;
-
- UpdateProcampValues();
-
- m_note_static.Create(
- ResStr(IDS_MPEG2DECSETTINGSWND_7) +
- ResStr(IDS_MPEG2DECSETTINGSWND_8),
- dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
-
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
- pWnd->SetFont(&m_font, FALSE);
-
- return true;
+ DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP;
+
+ CPoint p(10, 10);
+
+ m_planaryuv_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_0), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK1);
+ m_planaryuv_check.SetCheck(m_planaryuv ? BST_CHECKED : BST_UNCHECKED);
+ p.y += m_fontheight + 5;
+
+ m_interlaced_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_1), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK2);
+ m_interlaced_check.SetCheck(m_interlaced ? BST_CHECKED : BST_UNCHECKED);
+ p.y += m_fontheight + 5;
+
+ m_forcedsubs_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_2), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK3);
+ m_forcedsubs_check.SetCheck(m_forcedsubs ? BST_CHECKED : BST_UNCHECKED);
+ p.y += m_fontheight + 5;
+
+ p.y += 10;
+
+ m_ditype_static.Create(ResStr(IDS_MPEG2_DEINTERLACING), dwStyle, CRect(p, CSize(70, m_fontheight)), this);
+ m_ditype_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(85, -3), CSize(100, 200)), this, IDC_PP_COMBO1);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Auto")), (DWORD)DIAuto);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Weave")), (DWORD)DIWeave);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Blend")), (DWORD)DIBlend);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Bob")), (DWORD)DIBob);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Field Shift")), (DWORD)DIFieldShift);
+ m_ditype_combo.SetCurSel(0);
+ for(int i = 0; i < m_ditype_combo.GetCount(); i++)
+ if((int)m_ditype_combo.GetItemData(i) == m_ditype)
+ m_ditype_combo.SetCurSel(i);
+
+ p.y += m_fontheight + 20;
+
+ for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_procamp_slider); i++, p.y += h)
+ {
+ static const TCHAR* labels[] = {m_strBrightness, m_strContrast, m_strHue, m_strSaturation};
+ m_procamp_static[i].Create(labels[i], dwStyle, CRect(p, CSize(70, h)), this);
+ m_procamp_slider[i].Create(dwStyle, CRect(p + CPoint(80, 0), CSize(200, h)), this, IDC_PP_SLIDER1+i);
+ m_procamp_value[i].Create(_T(""), dwStyle, CRect(p + CPoint(280, 0), CSize(40, h)), this);
+ }
+
+ m_procamp_slider[0].SetRange(0, 2*128);
+ m_procamp_slider[0].SetTic(128);
+ m_procamp_slider[0].SetPos((int)(m_procamp[0] + (m_procamp[0] >= 0 ? 0.5f : -0.5f)) + 128);
+ m_procamp_slider[1].SetRange(0, 200);
+ m_procamp_slider[1].SetTic(100);
+ m_procamp_slider[1].SetPos((int)(100*m_procamp[1] + 0.5f));
+ m_procamp_slider[2].SetRange(0, 2*180);
+ m_procamp_slider[2].SetTic(180);
+ m_procamp_slider[2].SetPos((int)(m_procamp[2] + (m_procamp[2] >= 0 ? 0.5f : -0.5f)) + 180);
+ m_procamp_slider[3].SetRange(0, 200);
+ m_procamp_slider[3].SetTic(100);
+ m_procamp_slider[3].SetPos((int)(100*m_procamp[3] + 0.5f));
+
+ p.y += 5;
+
+ m_procamp_tv2pc.Create(_T("TV->PC"), dwStyle, CRect(p + CPoint(50 + 200/2 - 55, 0), CSize(80, 20)), this, IDC_PP_BUTTON1);
+ m_procamp_reset.Create(ResStr(IDS_MPEG2_RESET), dwStyle, CRect(p + CPoint(80 + 200/2 + 5, 0), CSize(80, 20)), this, IDC_PP_BUTTON2);
+
+ p.y += 30;
+
+ UpdateProcampValues();
+
+ m_note_static.Create(
+ ResStr(IDS_MPEG2DECSETTINGSWND_7) +
+ ResStr(IDS_MPEG2DECSETTINGSWND_8),
+ dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
+
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ pWnd->SetFont(&m_font, FALSE);
+
+ return true;
}
void CMpeg2DecSettingsWnd::OnDeactivate()
{
- m_ditype = (ditype)m_ditype_combo.GetItemData(m_ditype_combo.GetCurSel());
- m_procamp[0] = (float)m_procamp_slider[0].GetPos() - 128;
- m_procamp[1] = (float)m_procamp_slider[1].GetPos() / 100;
- m_procamp[2] = (float)m_procamp_slider[2].GetPos() - 180;
- m_procamp[3] = (float)m_procamp_slider[3].GetPos() / 100;
- m_planaryuv = !!IsDlgButtonChecked(m_planaryuv_check.GetDlgCtrlID());
- m_interlaced = !!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID());
- m_forcedsubs = !!IsDlgButtonChecked(m_forcedsubs_check.GetDlgCtrlID());
+ m_ditype = (ditype)m_ditype_combo.GetItemData(m_ditype_combo.GetCurSel());
+ m_procamp[0] = (float)m_procamp_slider[0].GetPos() - 128;
+ m_procamp[1] = (float)m_procamp_slider[1].GetPos() / 100;
+ m_procamp[2] = (float)m_procamp_slider[2].GetPos() - 180;
+ m_procamp[3] = (float)m_procamp_slider[3].GetPos() / 100;
+ m_planaryuv = !!IsDlgButtonChecked(m_planaryuv_check.GetDlgCtrlID());
+ m_interlaced = !!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID());
+ m_forcedsubs = !!IsDlgButtonChecked(m_forcedsubs_check.GetDlgCtrlID());
}
bool CMpeg2DecSettingsWnd::OnApply()
{
- OnDeactivate();
-
- if(m_pM2DF)
- {
- m_pM2DF->SetDeinterlaceMethod(m_ditype);
- m_pM2DF->SetBrightness(m_procamp[0]);
- m_pM2DF->SetContrast(m_procamp[1]);
- m_pM2DF->SetHue(m_procamp[2]);
- m_pM2DF->SetSaturation(m_procamp[3]);
- m_pM2DF->EnableForcedSubtitles(m_forcedsubs);
- m_pM2DF->EnablePlanarYUV(m_planaryuv);
- m_pM2DF->EnableInterlaced(m_interlaced);
- }
-
- return true;
+ OnDeactivate();
+
+ if(m_pM2DF)
+ {
+ m_pM2DF->SetDeinterlaceMethod(m_ditype);
+ m_pM2DF->SetBrightness(m_procamp[0]);
+ m_pM2DF->SetContrast(m_procamp[1]);
+ m_pM2DF->SetHue(m_procamp[2]);
+ m_pM2DF->SetSaturation(m_procamp[3]);
+ m_pM2DF->EnableForcedSubtitles(m_forcedsubs);
+ m_pM2DF->EnablePlanarYUV(m_planaryuv);
+ m_pM2DF->EnableInterlaced(m_interlaced);
+ }
+
+ return true;
}
void CMpeg2DecSettingsWnd::UpdateProcampValues()
{
- CString str;
-
- str.Format(_T("%d"), m_procamp_slider[0].GetPos() - 128);
- m_procamp_value[0].SetWindowText(str);
- str.Format(_T("%d%%"), m_procamp_slider[1].GetPos());
- m_procamp_value[1].SetWindowText(str);
- str.Format(_T("%d"), m_procamp_slider[2].GetPos() - 180);
- m_procamp_value[2].SetWindowText(str);
- str.Format(_T("%d%%"), m_procamp_slider[3].GetPos());
- m_procamp_value[3].SetWindowText(str);
+ CString str;
+
+ str.Format(_T("%d"), m_procamp_slider[0].GetPos() - 128);
+ m_procamp_value[0].SetWindowText(str);
+ str.Format(_T("%d%%"), m_procamp_slider[1].GetPos());
+ m_procamp_value[1].SetWindowText(str);
+ str.Format(_T("%d"), m_procamp_slider[2].GetPos() - 180);
+ m_procamp_value[2].SetWindowText(str);
+ str.Format(_T("%d%%"), m_procamp_slider[3].GetPos());
+ m_procamp_value[3].SetWindowText(str);
}
BEGIN_MESSAGE_MAP(CMpeg2DecSettingsWnd, CInternalPropertyPageWnd)
- ON_BN_CLICKED(IDC_PP_BUTTON1, OnButtonProcampPc2Tv)
- ON_BN_CLICKED(IDC_PP_BUTTON2, OnButtonProcampReset)
- ON_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
- ON_WM_HSCROLL()
+ ON_BN_CLICKED(IDC_PP_BUTTON1, OnButtonProcampPc2Tv)
+ ON_BN_CLICKED(IDC_PP_BUTTON2, OnButtonProcampReset)
+ ON_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
+ ON_WM_HSCROLL()
END_MESSAGE_MAP()
void CMpeg2DecSettingsWnd::OnButtonProcampPc2Tv()
{
- m_procamp_slider[0].SetPos(128 - 16);
- m_procamp_slider[1].SetPos(100 * 255 / (235 - 16));
+ m_procamp_slider[0].SetPos(128 - 16);
+ m_procamp_slider[1].SetPos(100 * 255/(235-16));
- UpdateProcampValues();
+ UpdateProcampValues();
}
void CMpeg2DecSettingsWnd::OnButtonProcampReset()
{
- m_procamp_slider[0].SetPos(128);
- m_procamp_slider[1].SetPos(100);
- m_procamp_slider[2].SetPos(180);
- m_procamp_slider[3].SetPos(100);
+ m_procamp_slider[0].SetPos(128);
+ m_procamp_slider[1].SetPos(100);
+ m_procamp_slider[2].SetPos(180);
+ m_procamp_slider[3].SetPos(100);
- UpdateProcampValues();
+ UpdateProcampValues();
}
void CMpeg2DecSettingsWnd::OnButtonInterlaced()
{
- m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
+ m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
}
void CMpeg2DecSettingsWnd::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- UpdateProcampValues();
+ UpdateProcampValues();
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
index 89202ebdb..4f694d8cb 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.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
*
*/
@@ -28,64 +28,58 @@
[uuid("E5FB6957-65E6-491B-BB37-B25C9FE3BEA7")]
class CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
{
- CComQIPtr<IMpeg2DecFilter> m_pM2DF;
+ CComQIPtr<IMpeg2DecFilter> m_pM2DF;
- ditype m_ditype;
- float m_procamp[4];
- bool m_planaryuv;
- bool m_interlaced;
- bool m_forcedsubs;
+ ditype m_ditype;
+ float m_procamp[4];
+ bool m_planaryuv;
+ bool m_interlaced;
+ bool m_forcedsubs;
- enum
- {
- IDC_PP_COMBO1 = 10000,
- IDC_PP_SLIDER1,
- IDC_PP_SLIDER2,
- IDC_PP_SLIDER3,
- IDC_PP_SLIDER4,
- IDC_PP_CHECK1,
- IDC_PP_CHECK2,
- IDC_PP_CHECK3,
- IDC_PP_BUTTON1,
- IDC_PP_BUTTON2,
- };
+ enum
+ {
+ IDC_PP_COMBO1 = 10000,
+ IDC_PP_SLIDER1,
+ IDC_PP_SLIDER2,
+ IDC_PP_SLIDER3,
+ IDC_PP_SLIDER4,
+ IDC_PP_CHECK1,
+ IDC_PP_CHECK2,
+ IDC_PP_CHECK3,
+ IDC_PP_BUTTON1,
+ IDC_PP_BUTTON2,
+ };
- CStatic m_ditype_static;
- CComboBox m_ditype_combo;
- CStatic m_procamp_static[4];
- CSliderCtrl m_procamp_slider[4];
- CStatic m_procamp_value[4];
- CButton m_procamp_tv2pc;
- CButton m_procamp_reset;
- CButton m_planaryuv_check;
- CButton m_interlaced_check;
- CButton m_forcedsubs_check;
- CStatic m_note_static;
+ CStatic m_ditype_static;
+ CComboBox m_ditype_combo;
+ CStatic m_procamp_static[4];
+ CSliderCtrl m_procamp_slider[4];
+ CStatic m_procamp_value[4];
+ CButton m_procamp_tv2pc;
+ CButton m_procamp_reset;
+ CButton m_planaryuv_check;
+ CButton m_interlaced_check;
+ CButton m_forcedsubs_check;
+ CStatic m_note_static;
- void UpdateProcampValues();
+ void UpdateProcampValues();
public:
- CMpeg2DecSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
+ CMpeg2DecSettingsWnd();
+
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
- static LPCTSTR GetWindowTitle()
- {
- return _T("Settings");
- }
- static CSize GetWindowSize()
- {
- return CSize(320, 240);
- }
+ static LPCTSTR GetWindowTitle() {return _T("Settings");}
+ static CSize GetWindowSize() {return CSize(320, 240);}
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- afx_msg void OnButtonProcampPc2Tv();
- afx_msg void OnButtonProcampReset();
- afx_msg void OnButtonInterlaced();
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnButtonProcampPc2Tv();
+ afx_msg void OnButtonProcampReset();
+ afx_msg void OnButtonInterlaced();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
}; \ No newline at end of file
diff --git a/src/filters/transform/Mpeg2DecFilter/attributes.h b/src/filters/transform/Mpeg2DecFilter/attributes.h
index dd504dabe..e587e158f 100644
--- a/src/filters/transform/Mpeg2DecFilter/attributes.h
+++ b/src/filters/transform/Mpeg2DecFilter/attributes.h
@@ -26,11 +26,11 @@
/* use gcc attribs to align critical data structures */
#ifdef __GNUC__
-#define __align8(t,v) t v __attribute__ ((aligned (8)))
-#define __align16(t,v) t v __attribute__ ((aligned (16)))
+ #define __align8(t,v) t v __attribute__ ((aligned (8)))
+ #define __align16(t,v) t v __attribute__ ((aligned (16)))
#else
-#define __align8(t,v) __declspec(align(8)) t v
-#define __align16(t,v) __declspec(align(16)) t v
+ #define __align8(t,v) __declspec(align(8)) t v
+ #define __align16(t,v) __declspec(align(16)) t v
#endif
#ifdef HAVE_BUILTIN_EXPECT
diff --git a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
index bc9816a40..134707c76 100644
--- a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -31,202 +31,202 @@
// AP-945
// http://cache-www.intel.com/cd/00/00/01/76/17680_w_idct.pdf
-static const int BITS_INV_ACC = 4;
-static const int SHIFT_INV_ROW = 16 - BITS_INV_ACC;
-static const int SHIFT_INV_COL = 1 + BITS_INV_ACC;
-static const int RND_INV_ROW = 1024 * (6 - BITS_INV_ACC);
-static const int RND_INV_COL = 16 * (BITS_INV_ACC - 3);
-static const int RND_INV_CORR = RND_INV_COL - 1;
+static const int BITS_INV_ACC=4;
+static const int SHIFT_INV_ROW=16-BITS_INV_ACC;
+static const int SHIFT_INV_COL=1+BITS_INV_ACC;
+static const int RND_INV_ROW =1024*(6-BITS_INV_ACC);
+static const int RND_INV_COL =16*(BITS_INV_ACC-3);
+static const int RND_INV_CORR =RND_INV_COL-1;
-static __align16(const short, M128_round_inv_row[8]) = {RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0};
-static __align16(const short, M128_one_corr[8]) = {1, 1, 1, 1, 1, 1, 1, 1};
-static __align16(const short, M128_round_inv_col[8]) = {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL};
-static __align16(const short, M128_round_inv_corr[8]) = {RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR};
-static __align16(const short, M128_tg_1_16[8]) = {13036, 13036, 13036, 13036, 13036, 13036, 13036, 13036}; // tg * (2<<16) + 0.5
-static __align16(const short, M128_tg_2_16[8]) = {27146, 27146, 27146, 27146, 27146, 27146, 27146, 27146}; // tg * (2<<16) + 0.5
-static __align16(const short, M128_tg_3_16[8]) = { -21746, -21746, -21746, -21746, -21746, -21746, -21746, -21746}; // tg * (2<<16) + 0.5
-static __align16(const short, M128_cos_4_16[8]) = { -19195, -19195, -19195, -19195, -19195, -19195, -19195, -19195}; // cos * (2<<16) + 0.5
+static __align16(const short,M128_round_inv_row[8]) = {RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0};
+static __align16(const short,M128_one_corr[8]) = {1,1,1,1,1,1,1,1};
+static __align16(const short,M128_round_inv_col[8]) = {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL};
+static __align16(const short,M128_round_inv_corr[8])= {RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR};
+static __align16(const short,M128_tg_1_16[8]) = {13036, 13036, 13036, 13036, 13036, 13036, 13036, 13036}; // tg * (2<<16) + 0.5
+static __align16(const short,M128_tg_2_16[8]) = {27146, 27146, 27146, 27146, 27146, 27146, 27146, 27146}; // tg * (2<<16) + 0.5
+static __align16(const short,M128_tg_3_16[8]) = {-21746, -21746, -21746, -21746, -21746, -21746, -21746, -21746}; // tg * (2<<16) + 0.5
+static __align16(const short,M128_cos_4_16[8]) = {-19195, -19195, -19195, -19195, -19195, -19195, -19195, -19195};// cos * (2<<16) + 0.5
-static __align16(const int16_t, M128_tab_i_04[]) = {16384, 21407, 16384, 8867, 16384, -8867, 16384, -21407, 16384, 8867, -16384, -21407, -16384, 21407, 16384, -8867, 22725, 19266, 19266, -4520, 12873, -22725, 4520, -12873, 12873, 4520, -22725, -12873, 4520, 19266, 19266, -22725};
-static __align16(const int16_t, M128_tab_i_17[]) = {22725, 29692, 22725, 12299, 22725, -12299, 22725, -29692, 22725, 12299, -22725, -29692, -22725, 29692, 22725, -12299, 31521, 26722, 26722, -6270, 17855, -31521, 6270, -17855, 17855, 6270, -31521, -17855, 6270, 26722, 26722, -31521};
-static __align16(const int16_t, M128_tab_i_26[]) = {21407, 27969, 21407, 11585, 21407, -11585, 21407, -27969, 21407, 11585, -21407, -27969, -21407, 27969, 21407, -11585, 29692, 25172, 25172, -5906, 16819, -29692, 5906, -16819, 16819, 5906, -29692, -16819, 5906, 25172, 25172, -29692};
-static __align16(const int16_t, M128_tab_i_35[]) = {19266, 25172, 19266, 10426, 19266, -10426, 19266, -25172, 19266, 10426, -19266, -25172, -19266, 25172, 19266, -10426, 26722, 22654, 22654, -5315, 15137, -26722, 5315, -15137, 15137, 5315, -26722, -15137, 5315, 22654, 22654, -26722};
+static __align16(const int16_t,M128_tab_i_04[])={16384, 21407, 16384, 8867, 16384, -8867, 16384, -21407, 16384, 8867, -16384, -21407, -16384, 21407, 16384, -8867, 22725, 19266, 19266, -4520, 12873, -22725, 4520, -12873, 12873, 4520, -22725, -12873, 4520, 19266, 19266, -22725};
+static __align16(const int16_t,M128_tab_i_17[])={22725, 29692, 22725, 12299, 22725, -12299, 22725, -29692, 22725, 12299, -22725, -29692, -22725, 29692, 22725, -12299, 31521, 26722, 26722, -6270, 17855, -31521, 6270, -17855, 17855, 6270, -31521, -17855, 6270, 26722, 26722, -31521};
+static __align16(const int16_t,M128_tab_i_26[])={21407, 27969, 21407, 11585, 21407, -11585, 21407, -27969, 21407, 11585, -21407, -27969, -21407, 27969, 21407, -11585, 29692, 25172, 25172, -5906, 16819, -29692, 5906, -16819, 16819, 5906, -29692, -16819, 5906, 25172, 25172, -29692};
+static __align16(const int16_t,M128_tab_i_35[])={19266, 25172, 19266, 10426, 19266, -10426, 19266, -25172, 19266, 10426, -19266, -25172, -19266, 25172, 19266, -10426, 26722, 22654, 22654, -5315, 15137, -26722, 5315, -15137, 15137, 5315, -26722, -15137, 5315, 22654, 22654, -26722};
-static __forceinline void DCT_8_INV_ROW(const uint8_t * const ecx, const uint8_t * const esi, __m128i &xmm0, __m128i &xmm1, __m128i &xmm2, __m128i &xmm3, __m128i &xmm4, __m128i &xmm5, __m128i &xmm6, __m128i &xmm7)
+static __forceinline void DCT_8_INV_ROW(const uint8_t * const ecx,const uint8_t * const esi,__m128i &xmm0,__m128i &xmm1,__m128i &xmm2,__m128i &xmm3,__m128i &xmm4,__m128i &xmm5,__m128i &xmm6,__m128i &xmm7)
{
- xmm0 = _mm_shufflelo_epi16(xmm0, 0xD8);
- xmm1 = _mm_shuffle_epi32(xmm0, 0);
- pmaddwd(xmm1, esi);
- xmm3 = _mm_shuffle_epi32(xmm0, 0x55);
- xmm0 = _mm_shufflehi_epi16(xmm0, 0xD8);
- pmaddwd(xmm3, esi + 32);
- xmm2 = _mm_shuffle_epi32(xmm0, 0xAA);
- xmm0 = _mm_shuffle_epi32(xmm0, 0xFF);
- pmaddwd(xmm2, esi + 16);
- xmm4 = _mm_shufflehi_epi16(xmm4, 0xD8);
- paddd(xmm1, M128_round_inv_row);
- xmm4 = _mm_shufflelo_epi16(xmm4, 0xD8);
- pmaddwd(xmm0, esi + 48);
- xmm5 = _mm_shuffle_epi32(xmm4, 0);
- xmm6 = _mm_shuffle_epi32(xmm4, 0xAA);
- pmaddwd(xmm5, ecx);
- paddd(xmm1, xmm2);
- movdqa(xmm2, xmm1);
- xmm7 = _mm_shuffle_epi32(xmm4, 0x55);
- pmaddwd(xmm6, ecx + 16);
- paddd(xmm0, xmm3);
- xmm4 = _mm_shuffle_epi32(xmm4, 0xFF);
- psubd(xmm2, xmm0);
- pmaddwd(xmm7, ecx + 32);
- paddd(xmm0, xmm1);
- psrad(xmm2, 12);
- paddd(xmm5, M128_round_inv_row);
- pmaddwd(xmm4, ecx + 48);
- paddd(xmm5, xmm6);
- movdqa(xmm6, xmm5);
- psrad(xmm0, 12);
- xmm2 = _mm_shuffle_epi32(xmm2, 0x1B);
- packssdw(xmm0, xmm2);
- paddd(xmm4, xmm7);
- psubd(xmm6, xmm4);
- paddd(xmm4, xmm5);
- psrad(xmm6, 12);
- psrad(xmm4, 12);
- xmm6 = _mm_shuffle_epi32(xmm6, 0x1B);
- packssdw(xmm4, xmm6);
+ xmm0=_mm_shufflelo_epi16(xmm0, 0xD8 );
+ xmm1=_mm_shuffle_epi32( xmm0, 0 );
+ pmaddwd (xmm1, esi);
+ xmm3=_mm_shuffle_epi32( xmm0, 0x55);
+ xmm0=_mm_shufflehi_epi16( xmm0, 0xD8 );
+ pmaddwd( xmm3, esi+32 );
+ xmm2=_mm_shuffle_epi32( xmm0, 0xAA );
+ xmm0=_mm_shuffle_epi32( xmm0, 0xFF );
+ pmaddwd( xmm2, esi+16 );
+ xmm4=_mm_shufflehi_epi16( xmm4, 0xD8 );
+ paddd (xmm1, M128_round_inv_row);
+ xmm4=_mm_shufflelo_epi16 (xmm4, 0xD8 );
+ pmaddwd (xmm0, esi+48 );
+ xmm5=_mm_shuffle_epi32( xmm4, 0 );
+ xmm6=_mm_shuffle_epi32( xmm4, 0xAA );
+ pmaddwd (xmm5, ecx );
+ paddd (xmm1, xmm2 );
+ movdqa (xmm2, xmm1 );
+ xmm7=_mm_shuffle_epi32( xmm4, 0x55 );
+ pmaddwd (xmm6, ecx+16 );
+ paddd (xmm0, xmm3 );
+ xmm4=_mm_shuffle_epi32( xmm4, 0xFF );
+ psubd (xmm2, xmm0 );
+ pmaddwd (xmm7, ecx+32 );
+ paddd (xmm0, xmm1 );
+ psrad (xmm2, 12 );
+ paddd (xmm5, M128_round_inv_row);
+ pmaddwd (xmm4, ecx+48 );
+ paddd (xmm5, xmm6 );
+ movdqa (xmm6, xmm5 );
+ psrad (xmm0, 12 );
+ xmm2=_mm_shuffle_epi32( xmm2, 0x1B );
+ packssdw (xmm0, xmm2 );
+ paddd (xmm4, xmm7 );
+ psubd (xmm6, xmm4 );
+ paddd (xmm4, xmm5 );
+ psrad (xmm6, 12 );
+ psrad (xmm4, 12 );
+ xmm6=_mm_shuffle_epi32( xmm6, 0x1B );
+ packssdw (xmm4, xmm6 );
}
-static __forceinline void DCT_8_INV_COL_8(__m128i &src0, __m128i &src1, __m128i &src2, __m128i &src3, __m128i &src4, __m128i &src5, __m128i &src6, __m128i &src7,
- __m128i &xmm0, __m128i &xmm1, __m128i &xmm2, __m128i &xmm3, __m128i &xmm4, __m128i &xmm5, __m128i &xmm6, __m128i &xmm7)
+static __forceinline void DCT_8_INV_COL_8(__m128i &src0,__m128i &src1,__m128i &src2,__m128i &src3,__m128i &src4,__m128i &src5,__m128i &src6,__m128i &src7,
+ __m128i &xmm0,__m128i &xmm1,__m128i &xmm2,__m128i &xmm3,__m128i &xmm4,__m128i &xmm5,__m128i &xmm6,__m128i &xmm7)
{
- movdqa(xmm1, M128_tg_3_16);
- movdqa(xmm2, xmm0);
- movdqa(xmm3, src3);
- pmulhw(xmm0, xmm1);
- pmulhw(xmm1, xmm3);
- movdqa(xmm5, M128_tg_1_16);
- movdqa(xmm6, xmm4);
- pmulhw(xmm4, xmm5);
- paddsw(xmm0, xmm2);
- pmulhw(xmm5, src1);
- paddsw(xmm1, xmm3);
- movdqa(xmm7, src6);
- paddsw(xmm0, xmm3);
- movdqa(xmm3, M128_tg_2_16);
- psubsw(xmm2, xmm1);
- pmulhw(xmm7, xmm3);
- movdqa(xmm1, xmm0);
- pmulhw(xmm3, src2);
- psubsw(xmm5, xmm6);
- paddsw(xmm4, src1);
- paddsw(xmm0, xmm4);
- paddsw(xmm0, M128_one_corr);
- psubsw(xmm4, xmm1);
- movdqa(xmm6, xmm5);
- psubsw(xmm5, xmm2);
- paddsw(xmm5, M128_one_corr);
- paddsw(xmm6, xmm2);
- movdqa(src7, xmm0);
- movdqa(xmm1, xmm4);
- movdqa(xmm0, M128_cos_4_16);
- paddsw(xmm4, xmm5);
- movdqa(xmm2, M128_cos_4_16);
- pmulhw(xmm2, xmm4);
- movdqa(src3, xmm6);
- psubsw(xmm1, xmm5);
- paddsw(xmm7, src2);
- psubsw(xmm3, src6);
- movdqa(xmm6, src0);
- pmulhw(xmm0, xmm1);
- movdqa(xmm5, src4);
- paddsw(xmm5, xmm6);
- psubsw(xmm6, src4);
- paddsw(xmm4, xmm2);
- por(xmm4, M128_one_corr);
- paddsw(xmm0, xmm1);
- por(xmm0, M128_one_corr);
- movdqa(xmm2, xmm5);
- paddsw(xmm5, xmm7);
- movdqa(xmm1, xmm6);
- paddsw(xmm5, M128_round_inv_col);
- psubsw(xmm2, xmm7);
- movdqa(xmm7, src7);
- paddsw(xmm6, xmm3);
- paddsw(xmm6, M128_round_inv_col);
- paddsw(xmm7, xmm5);
- psraw(xmm7, SHIFT_INV_COL);
- psubsw(xmm1, xmm3);
- paddsw(xmm1, M128_round_inv_corr);
- movdqa(xmm3, xmm6);
- paddsw(xmm2, M128_round_inv_corr);
- paddsw(xmm6, xmm4);
- movdqa(src0, xmm7);
- psraw(xmm6, SHIFT_INV_COL);
- movdqa(xmm7, xmm1);
- paddsw(xmm1, xmm0);
- movdqa(src1, xmm6);
- psraw(xmm1, SHIFT_INV_COL);
- movdqa(xmm6, src3);
- psubsw(xmm7, xmm0);
- psraw(xmm7, SHIFT_INV_COL);
- movdqa(src2, xmm1);
- psubsw(xmm5, src7);
- psraw(xmm5, SHIFT_INV_COL);
- movdqa(src7, xmm5);
- psubsw(xmm3, xmm4);
- paddsw(xmm6, xmm2);
- psubsw(xmm2, src3);
- psraw(xmm6, SHIFT_INV_COL);
- psraw(xmm2, SHIFT_INV_COL);
- movdqa(src3, xmm6);
- psraw(xmm3, SHIFT_INV_COL);
- movdqa(src4, xmm2);
- movdqa(src5, xmm7);
- movdqa(src6, xmm3);
+ movdqa( xmm1, M128_tg_3_16 );
+ movdqa( xmm2, xmm0 );
+ movdqa( xmm3, src3 );
+ pmulhw( xmm0, xmm1 );
+ pmulhw( xmm1, xmm3 );
+ movdqa( xmm5, M128_tg_1_16 );
+ movdqa( xmm6, xmm4 );
+ pmulhw( xmm4, xmm5 );
+ paddsw( xmm0, xmm2 );
+ pmulhw( xmm5, src1 );
+ paddsw( xmm1, xmm3 );
+ movdqa( xmm7, src6 );
+ paddsw( xmm0, xmm3 );
+ movdqa( xmm3, M128_tg_2_16 );
+ psubsw( xmm2, xmm1 );
+ pmulhw( xmm7, xmm3 );
+ movdqa( xmm1, xmm0 );
+ pmulhw( xmm3, src2 );
+ psubsw( xmm5, xmm6 );
+ paddsw( xmm4, src1 );
+ paddsw( xmm0, xmm4 );
+ paddsw( xmm0, M128_one_corr );
+ psubsw( xmm4, xmm1 );
+ movdqa( xmm6, xmm5 );
+ psubsw( xmm5, xmm2 );
+ paddsw( xmm5, M128_one_corr );
+ paddsw( xmm6, xmm2 );
+ movdqa( src7, xmm0 );
+ movdqa( xmm1, xmm4 );
+ movdqa( xmm0, M128_cos_4_16 );
+ paddsw( xmm4, xmm5 );
+ movdqa( xmm2, M128_cos_4_16 );
+ pmulhw( xmm2, xmm4 );
+ movdqa( src3, xmm6 );
+ psubsw( xmm1, xmm5 );
+ paddsw( xmm7, src2 );
+ psubsw( xmm3, src6 );
+ movdqa( xmm6, src0 );
+ pmulhw( xmm0, xmm1 );
+ movdqa( xmm5, src4 );
+ paddsw( xmm5, xmm6 );
+ psubsw( xmm6, src4 );
+ paddsw( xmm4, xmm2 );
+ por ( xmm4, M128_one_corr );
+ paddsw( xmm0, xmm1 );
+ por ( xmm0, M128_one_corr );
+ movdqa( xmm2, xmm5 );
+ paddsw( xmm5, xmm7 );
+ movdqa( xmm1, xmm6 );
+ paddsw( xmm5, M128_round_inv_col );
+ psubsw( xmm2, xmm7 );
+ movdqa( xmm7, src7 );
+ paddsw( xmm6, xmm3 );
+ paddsw( xmm6, M128_round_inv_col );
+ paddsw( xmm7, xmm5 );
+ psraw ( xmm7, SHIFT_INV_COL );
+ psubsw( xmm1, xmm3 );
+ paddsw( xmm1, M128_round_inv_corr );
+ movdqa( xmm3, xmm6 );
+ paddsw( xmm2, M128_round_inv_corr );
+ paddsw( xmm6, xmm4 );
+ movdqa( src0,xmm7 );
+ psraw (xmm6, SHIFT_INV_COL );
+ movdqa( xmm7, xmm1 );
+ paddsw( xmm1, xmm0 );
+ movdqa( src1, xmm6 );
+ psraw (xmm1, SHIFT_INV_COL );
+ movdqa( xmm6, src3 );
+ psubsw( xmm7, xmm0 );
+ psraw (xmm7, SHIFT_INV_COL );
+ movdqa( src2, xmm1 );
+ psubsw( xmm5, src7 );
+ psraw (xmm5, SHIFT_INV_COL );
+ movdqa( src7, xmm5 );
+ psubsw( xmm3, xmm4 );
+ paddsw( xmm6, xmm2 );
+ psubsw( xmm2, src3 );
+ psraw (xmm6, SHIFT_INV_COL );
+ psraw (xmm2, SHIFT_INV_COL );
+ movdqa( src3, xmm6 );
+ psraw (xmm3, SHIFT_INV_COL );
+ movdqa( src4, xmm2 );
+ movdqa( src5, xmm7 );
+ movdqa( src6, xmm3 );
}
-static __forceinline void idct_M128ASM(__m128i &src0, __m128i &src1, __m128i &src2, __m128i &src3, __m128i &src4, __m128i &src5, __m128i &src6, __m128i &src7)
+static __forceinline void idct_M128ASM(__m128i &src0,__m128i &src1,__m128i &src2,__m128i &src3,__m128i &src4,__m128i &src5,__m128i &src6,__m128i &src7)
{
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
- movdqa(xmm0, src0);
- uint8_t *esi = (uint8_t*)M128_tab_i_04;
- movdqa(xmm4, src2);
- uint8_t *ecx = (uint8_t*)M128_tab_i_26;
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- movdqa(src0, xmm0);
- movdqa(src2, xmm4);
+__m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7;
+ movdqa (xmm0, src0);
+ uint8_t *esi=(uint8_t*)M128_tab_i_04;
+ movdqa (xmm4, src2);
+ uint8_t *ecx=(uint8_t*)M128_tab_i_26;
+ DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
+ movdqa (src0, xmm0);
+ movdqa (src2, xmm4);
- movdqa(xmm0, src4);
- movdqa(xmm4, src6);
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- movdqa(src4, xmm0);
- movdqa(src6, xmm4);
+ movdqa (xmm0, src4);
+ movdqa (xmm4, src6);
+ DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
+ movdqa (src4, xmm0);
+ movdqa (src6, xmm4);
- movdqa(xmm0, src3);
- esi = (uint8_t*)M128_tab_i_35;
- movdqa(xmm4, src1);
- ecx = (uint8_t*)M128_tab_i_17;
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- movdqa(src3, xmm0);
- movdqa(src1, xmm4);
+ movdqa (xmm0, src3);
+ esi=(uint8_t*)M128_tab_i_35;
+ movdqa (xmm4, src1);
+ ecx=(uint8_t*)M128_tab_i_17;
+ DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
+ movdqa (src3, xmm0);
+ movdqa (src1, xmm4);
- movdqa(xmm0, src5);
- movdqa(xmm4, src7);
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- DCT_8_INV_COL_8(src0, src1, src2, src3, src4, src5, src6, src7,
- xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
+ movdqa (xmm0, src5);
+ movdqa (xmm4, src7);
+ DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
+ DCT_8_INV_COL_8(src0,src1,src2,src3,src4,src5,src6,src7,
+ xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
}
void mpeg2_idct_copy_sse2(int16_t* block, uint8_t* dest, const int stride)
{
- __m128i &src0 = *(__m128i*)(block + 0 * 16 / 2);
- __m128i &src1 = *(__m128i*)(block + 1 * 16 / 2);
- __m128i &src2 = *(__m128i*)(block + 2 * 16 / 2);
- __m128i &src3 = *(__m128i*)(block + 3 * 16 / 2);
- __m128i &src4 = *(__m128i*)(block + 4 * 16 / 2);
- __m128i &src5 = *(__m128i*)(block + 5 * 16 / 2);
- __m128i &src6 = *(__m128i*)(block + 6 * 16 / 2);
- __m128i &src7 = *(__m128i*)(block + 7 * 16 / 2);
- idct_M128ASM(src0, src1, src2, src3, src4, src5, src6, src7);
+ __m128i &src0=*(__m128i*)(block+0*16/2);
+ __m128i &src1=*(__m128i*)(block+1*16/2);
+ __m128i &src2=*(__m128i*)(block+2*16/2);
+ __m128i &src3=*(__m128i*)(block+3*16/2);
+ __m128i &src4=*(__m128i*)(block+4*16/2);
+ __m128i &src5=*(__m128i*)(block+5*16/2);
+ __m128i &src6=*(__m128i*)(block+6*16/2);
+ __m128i &src7=*(__m128i*)(block+7*16/2);
+ idct_M128ASM (src0,src1,src2,src3,src4,src5,src6,src7);
__m128i zero = _mm_setzero_si128();
@@ -254,17 +254,17 @@ void mpeg2_idct_copy_sse2(int16_t* block, uint8_t* dest, const int stride)
_mm_store_si128(&src7, zero);
}
-void mpeg2_idct_add_sse2(int, int16_t* block, uint8_t* dest, const int stride)
+void mpeg2_idct_add_sse2(int,int16_t* block, uint8_t* dest, const int stride)
{
- __m128i &src0 = *(__m128i*)(block + 0 * 16 / 2);
- __m128i &src1 = *(__m128i*)(block + 1 * 16 / 2);
- __m128i &src2 = *(__m128i*)(block + 2 * 16 / 2);
- __m128i &src3 = *(__m128i*)(block + 3 * 16 / 2);
- __m128i &src4 = *(__m128i*)(block + 4 * 16 / 2);
- __m128i &src5 = *(__m128i*)(block + 5 * 16 / 2);
- __m128i &src6 = *(__m128i*)(block + 6 * 16 / 2);
- __m128i &src7 = *(__m128i*)(block + 7 * 16 / 2);
- idct_M128ASM(src0, src1, src2, src3, src4, src5, src6, src7);
+ __m128i &src0=*(__m128i*)(block+0*16/2);
+ __m128i &src1=*(__m128i*)(block+1*16/2);
+ __m128i &src2=*(__m128i*)(block+2*16/2);
+ __m128i &src3=*(__m128i*)(block+3*16/2);
+ __m128i &src4=*(__m128i*)(block+4*16/2);
+ __m128i &src5=*(__m128i*)(block+5*16/2);
+ __m128i &src6=*(__m128i*)(block+6*16/2);
+ __m128i &src7=*(__m128i*)(block+7*16/2);
+ idct_M128ASM (src0,src1,src2,src3,src4,src5,src6,src7);
__m128i zero = _mm_setzero_si128();
diff --git a/src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp b/src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp
index 1947095c1..bb3aceb00 100644
--- a/src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp
@@ -37,8 +37,7 @@
#define PIC_CODING_EXT 0x100
/* default intra quant matrix, in zig-zag order */
-static const uint8_t default_intra_quantizer_matrix[64] =
-{
+static const uint8_t default_intra_quantizer_matrix[64] = {
8,
16, 16,
19, 16, 19,
@@ -56,19 +55,17 @@ static const uint8_t default_intra_quantizer_matrix[64] =
83
};
-static uint8_t mpeg2_scan_norm_2[64] =
-{
+static uint8_t mpeg2_scan_norm_2[64] = {
/* Zig-Zag scan pattern */
- 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
+ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
};
-static uint8_t mpeg2_scan_alt_2[64] =
-{
+static uint8_t mpeg2_scan_alt_2[64] = {
/* Alternate scan pattern */
- 0, 8, 16, 24, 1, 9, 2, 10, 17, 25, 32, 40, 48, 56, 57, 49,
+ 0, 8, 16, 24, 1, 9, 2, 10, 17, 25, 32, 40, 48, 56, 57, 49,
41, 33, 26, 18, 3, 11, 4, 12, 19, 27, 34, 42, 50, 58, 35, 43,
51, 59, 20, 28, 5, 13, 6, 14, 21, 29, 36, 44, 52, 60, 37, 45,
53, 61, 22, 30, 7, 15, 23, 31, 38, 46, 54, 62, 39, 47, 55, 63
@@ -113,14 +110,14 @@ static void __inline idct_row(int16_t* block)
/* shortcut */
if(!(block[1] | ((int32_t *)block)[1] | ((int32_t *)block)[2] | ((int32_t *)block)[3]))
- {
- uint32_t tmp = (uint16_t)(block[0] << 3);
- tmp |= tmp << 16;
- ((int32_t *)block)[0] = tmp;
- ((int32_t *)block)[1] = tmp;
- ((int32_t *)block)[2] = tmp;
- ((int32_t *)block)[3] = tmp;
- return;
+ {
+ uint32_t tmp = (uint16_t) (block[0] << 3);
+ tmp |= tmp << 16;
+ ((int32_t *)block)[0] = tmp;
+ ((int32_t *)block)[1] = tmp;
+ ((int32_t *)block)[2] = tmp;
+ ((int32_t *)block)[3] = tmp;
+ return;
}
d0 = (block[0] << 11) + 128;
@@ -201,96 +198,84 @@ static void __inline idct_col(int16_t* block)
static void mpeg2_idct_copy_c(int16_t* block, uint8_t* dest, const int stride)
{
- for(int i = 0; i < 8; i++) idct_row(block + 8 * i);
- for(int i = 0; i < 8; i++) idct_col(block + i);
+ for(int i = 0; i < 8; i++) idct_row(block + 8 * i);
+ for(int i = 0; i < 8; i++) idct_col(block + i);
for(int i = 0; i < 8; i++)
- {
- dest[0] = CLIP(block[0]);
- dest[1] = CLIP(block[1]);
- dest[2] = CLIP(block[2]);
- dest[3] = CLIP(block[3]);
- dest[4] = CLIP(block[4]);
- dest[5] = CLIP(block[5]);
- dest[6] = CLIP(block[6]);
- dest[7] = CLIP(block[7]);
-
- block[0] = 0;
- block[1] = 0;
- block[2] = 0;
- block[3] = 0;
- block[4] = 0;
- block[5] = 0;
- block[6] = 0;
- block[7] = 0;
-
- dest += stride;
- block += 8;
+ {
+ dest[0] = CLIP(block[0]);
+ dest[1] = CLIP(block[1]);
+ dest[2] = CLIP(block[2]);
+ dest[3] = CLIP(block[3]);
+ dest[4] = CLIP(block[4]);
+ dest[5] = CLIP(block[5]);
+ dest[6] = CLIP(block[6]);
+ dest[7] = CLIP(block[7]);
+
+ block[0] = 0; block[1] = 0; block[2] = 0; block[3] = 0;
+ block[4] = 0; block[5] = 0; block[6] = 0; block[7] = 0;
+
+ dest += stride;
+ block += 8;
}
}
static void mpeg2_idct_add_c(const int last, int16_t* block, uint8_t* dest, const int stride)
{
if(last != 129 || (block[0] & 7) == 4)
- {
- for(int i = 0; i < 8; i++) idct_row(block + 8 * i);
- for(int i = 0; i < 8; i++) idct_col(block + i);
- for(int i = 0; i < 8; i++)
- {
- dest[0] = CLIP(block[0] + dest[0]);
- dest[1] = CLIP(block[1] + dest[1]);
- dest[2] = CLIP(block[2] + dest[2]);
- dest[3] = CLIP(block[3] + dest[3]);
- dest[4] = CLIP(block[4] + dest[4]);
- dest[5] = CLIP(block[5] + dest[5]);
- dest[6] = CLIP(block[6] + dest[6]);
- dest[7] = CLIP(block[7] + dest[7]);
-
- block[0] = 0;
- block[1] = 0;
- block[2] = 0;
- block[3] = 0;
- block[4] = 0;
- block[5] = 0;
- block[6] = 0;
- block[7] = 0;
-
- dest += stride;
- block += 8;
- }
- }
- else
- {
- int DC = (block[0] + 4) >> 3;
- block[0] = block[63] = 0;
- for(int i = 0; i < 8; i++)
- {
- dest[0] = CLIP(DC + dest[0]);
- dest[1] = CLIP(DC + dest[1]);
- dest[2] = CLIP(DC + dest[2]);
- dest[3] = CLIP(DC + dest[3]);
- dest[4] = CLIP(DC + dest[4]);
- dest[5] = CLIP(DC + dest[5]);
- dest[6] = CLIP(DC + dest[6]);
- dest[7] = CLIP(DC + dest[7]);
- dest += stride;
- }
+ {
+ for(int i = 0; i < 8; i++) idct_row(block + 8 * i);
+ for(int i = 0; i < 8; i++) idct_col(block + i);
+ for(int i = 0; i < 8; i++)
+ {
+ dest[0] = CLIP(block[0] + dest[0]);
+ dest[1] = CLIP(block[1] + dest[1]);
+ dest[2] = CLIP(block[2] + dest[2]);
+ dest[3] = CLIP(block[3] + dest[3]);
+ dest[4] = CLIP(block[4] + dest[4]);
+ dest[5] = CLIP(block[5] + dest[5]);
+ dest[6] = CLIP(block[6] + dest[6]);
+ dest[7] = CLIP(block[7] + dest[7]);
+
+ block[0] = 0; block[1] = 0; block[2] = 0; block[3] = 0;
+ block[4] = 0; block[5] = 0; block[6] = 0; block[7] = 0;
+
+ dest += stride;
+ block += 8;
+ }
+ }
+ else
+ {
+ int DC = (block[0] + 4) >> 3;
+ block[0] = block[63] = 0;
+ for(int i = 0; i < 8; i++)
+ {
+ dest[0] = CLIP(DC + dest[0]);
+ dest[1] = CLIP(DC + dest[1]);
+ dest[2] = CLIP(DC + dest[2]);
+ dest[3] = CLIP(DC + dest[3]);
+ dest[4] = CLIP(DC + dest[4]);
+ dest[5] = CLIP(DC + dest[5]);
+ dest[6] = CLIP(DC + dest[6]);
+ dest[7] = CLIP(DC + dest[7]);
+ dest += stride;
+ }
}
}
static void mpeg2_idct_init_c()
{
- for(int i = -3840; i < 3840 + 256; i++)
- {
- CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
- }
+ for(int i = -3840; i < 3840 + 256; i++)
+ {
+ CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
+ }
- // only needed with idct_c
+ // only needed with idct_c
- for(int i = 0; i < 64; i++)
- {
- mpeg2_scan_norm_2[i] = ((mpeg2_scan_norm_2[i] & 0x36) >> 1) | ((mpeg2_scan_norm_2[i] & 0x09) << 2);
- mpeg2_scan_alt_2[i] = ((mpeg2_scan_alt_2[i] & 0x36) >> 1) | ((mpeg2_scan_alt_2[i] & 0x09) << 2);
- }
+ for(int i = 0; i < 64; i++)
+ {
+ mpeg2_scan_norm_2[i] = ((mpeg2_scan_norm_2[i] & 0x36) >> 1) | ((mpeg2_scan_norm_2[i] & 0x09) << 2);
+ mpeg2_scan_alt_2[i] = ((mpeg2_scan_alt_2[i] & 0x36) >> 1) | ((mpeg2_scan_alt_2[i] & 0x09) << 2);
+ }
}
// mc (c)
@@ -350,14 +335,14 @@ static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, const int
/* definitions of the actual mc functions */
-MC_FUNC(put, o)
-MC_FUNC(avg, o)
-MC_FUNC(put, x)
-MC_FUNC(avg, x)
-MC_FUNC(put, y)
-MC_FUNC(avg, y)
-MC_FUNC(put, xy)
-MC_FUNC(avg, xy)
+MC_FUNC(put,o)
+MC_FUNC(avg,o)
+MC_FUNC(put,x)
+MC_FUNC(avg,x)
+MC_FUNC(put,y)
+MC_FUNC(avg,y)
+MC_FUNC(put,xy)
+MC_FUNC(avg,xy)
#define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \
{MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
@@ -376,9 +361,9 @@ extern "C" void mpeg2_idct_add_mmx(const int last, int16_t* block, uint8_t* dest
static void mpeg2_idct_init_mmx()
{
for(int i = 0; i < 64; i++)
- {
- mpeg2_scan_norm_2[i] = (mpeg2_scan_norm_2[i] & 0x38) | ((mpeg2_scan_norm_2[i] & 6) >> 1) | ((mpeg2_scan_norm_2[i] & 1) << 2);
- mpeg2_scan_alt_2[i] = (mpeg2_scan_alt_2[i] & 0x38) | ((mpeg2_scan_alt_2[i] & 6) >> 1) | ((mpeg2_scan_alt_2[i] & 1) << 2);
+ {
+ mpeg2_scan_norm_2[i] = (mpeg2_scan_norm_2[i] & 0x38) | ((mpeg2_scan_norm_2[i] & 6) >> 1) | ((mpeg2_scan_norm_2[i] & 1) << 2);
+ mpeg2_scan_alt_2[i] = (mpeg2_scan_alt_2[i] & 0x38) | ((mpeg2_scan_alt_2[i] & 6) >> 1) | ((mpeg2_scan_alt_2[i] & 1) << 2);
}
}
@@ -402,7 +387,7 @@ static void mpeg2_idct_init_c();
static void mpeg2_idct_copy_c(int16_t* block, uint8_t* dest, const int stride);
static void mpeg2_idct_add_c(const int last, int16_t* block, uint8_t* dest, const int stride);
-// mc (c)
+ // mc (c)
static void MC_c(uint8_t* dest, const uint8_t* ref, const int stride, int height);
@@ -414,11 +399,11 @@ CMpeg2Dec::CMpeg2Dec()
{
m_shift = 0;
m_is_display_initialized = 0;
- m_action = NULL;
+ m_action = NULL;
m_state = STATE_BUFFER;
m_ext_state = 0;
- m_chunk_buffer = m_chunk_start = m_chunk_ptr = NULL;
+ m_chunk_buffer = m_chunk_start = m_chunk_ptr = NULL;
m_code = 0;
m_pts_current = m_pts_previous = 0;
@@ -432,7 +417,7 @@ CMpeg2Dec::CMpeg2Dec()
memset(&m_sequence, 0, sizeof(m_sequence));
memset(&m_gop, 0, sizeof(m_gop));
memset(&m_pictures, 0, sizeof(m_pictures));
- m_picture = NULL;
+ m_picture = NULL;
memset(&m_fbuf, 0, sizeof(m_fbuf));
memset(&m_fbuf_alloc, 0, sizeof(m_fbuf_alloc));
@@ -444,288 +429,288 @@ CMpeg2Dec::CMpeg2Dec()
memset(&m_intra_quantizer_matrix, 0, sizeof(m_intra_quantizer_matrix));
memset(&m_non_intra_quantizer_matrix, 0, sizeof(m_non_intra_quantizer_matrix));
- //
+ //
- mpeg2_init();
+ mpeg2_init();
}
CMpeg2Dec::~CMpeg2Dec()
{
- mpeg2_close();
+ mpeg2_close();
}
void CMpeg2Dec::mpeg2_init()
{
- m_chunk_buffer = (uint8_t*)_aligned_malloc(BUFFER_SIZE + 4, 16);
- m_shift = 0xffffff00;
- m_code = 0xb4;
- m_action = &CMpeg2Dec::mpeg2_seek_sequence;
- m_sequence.width = (unsigned) - 1;
+ m_chunk_buffer = (uint8_t*)_aligned_malloc(BUFFER_SIZE + 4, 16);
+ m_shift = 0xffffff00;
+ m_code = 0xb4;
+ m_action = &CMpeg2Dec::mpeg2_seek_sequence;
+ m_sequence.width = (unsigned)-1;
}
void CMpeg2Dec::mpeg2_close()
{
- /* static uint8_t finalizer[] = {0,0,1,0xb4}; */
- /* mpeg2_decode_data (mpeg2dec, finalizer, finalizer+4); */
+ /* static uint8_t finalizer[] = {0,0,1,0xb4}; */
+ /* mpeg2_decode_data (mpeg2dec, finalizer, finalizer+4); */
- mpeg2_header_state_init();
- _aligned_free(m_chunk_buffer);
+ mpeg2_header_state_init();
+ _aligned_free(m_chunk_buffer);
}
//
int CMpeg2Dec::skip_chunk(int bytes)
{
- if(!bytes)
- return 0;
+ if(!bytes)
+ return 0;
- int len = 0;
+ int len = 0;
- uint8_t* current = m_buf_start;
- uint8_t* limit = current + bytes;
+ uint8_t* current = m_buf_start;
+ uint8_t* limit = current + bytes;
- while(current < limit)
- {
- if(m_shift == 0x00000100)
- {
- m_shift = 0xffffff00;
- len = ++current - m_buf_start;
- break;
- }
+ while(current < limit)
+ {
+ if(m_shift == 0x00000100)
+ {
+ m_shift = 0xffffff00;
+ len = ++current - m_buf_start;
+ break;
+ }
- m_shift = (m_shift | *current++) << 8;
- }
+ m_shift = (m_shift | *current++) << 8;
+ }
- m_buf_start = current;
+ m_buf_start = current;
- return len;
+ return len;
}
int CMpeg2Dec::copy_chunk(int bytes)
{
- if(!bytes)
- return 0;
+ if(!bytes)
+ return 0;
- int len = 0;
+ int len = 0;
- // this assembly gives us a nice speed up
- // 36 sec down to 32 sec decoding the ts.stream.tpr test file
- // (idtc, mc was set to null)
+ // this assembly gives us a nice speed up
+ // 36 sec down to 32 sec decoding the ts.stream.tpr test file
+ // (idtc, mc was set to null)
#ifndef _WIN64
- __asm
- {
- mov ebx, this
- mov esi, [ebx].m_buf_start
- mov edi, [ebx].m_chunk_ptr
- mov ecx, bytes
- mov edx, [ebx].m_shift
-
- copy_chunk_loop:
-
- cmp edx, 0x00000100
- jne copy_chunk_continue
- mov edx, 0xffffff00
-
- inc edi
- mov [ebx].m_chunk_ptr, edi
-
- inc esi
- mov eax, esi
- sub eax, [ebx].m_buf_start
- mov len, eax
-
- jmp copy_chunk_end
-
- copy_chunk_continue:
-
- movzx eax, byte ptr [esi]
- or edx, eax
- shl edx, 8
- mov byte ptr [edi], al
- inc esi
- inc edi
- dec ecx
- jnz copy_chunk_loop
-
- copy_chunk_end:
-
- mov [ebx].m_buf_start, esi
- mov [ebx].m_shift, edx
- }
+ __asm
+ {
+ mov ebx, this
+ mov esi, [ebx].m_buf_start
+ mov edi, [ebx].m_chunk_ptr
+ mov ecx, bytes
+ mov edx, [ebx].m_shift
+
+ copy_chunk_loop:
+
+ cmp edx, 0x00000100
+ jne copy_chunk_continue
+ mov edx, 0xffffff00
+
+ inc edi
+ mov [ebx].m_chunk_ptr, edi
+
+ inc esi
+ mov eax, esi
+ sub eax, [ebx].m_buf_start
+ mov len, eax
+
+ jmp copy_chunk_end
+
+ copy_chunk_continue:
+
+ movzx eax, byte ptr [esi]
+ or edx, eax
+ shl edx, 8
+ mov byte ptr [edi], al
+ inc esi
+ inc edi
+ dec ecx
+ jnz copy_chunk_loop
+
+ copy_chunk_end:
+
+ mov [ebx].m_buf_start, esi
+ mov [ebx].m_shift, edx
+ }
#else
- uint8_t* chunk_ptr = m_chunk_ptr;
- uint8_t* current = m_buf_start;
- uint8_t* limit = current + bytes;
-
- while(current < limit)
- {
- if(m_shift == 0x00000100)
- {
- m_shift = 0xffffff00;
- len = ++current - m_buf_start;
- m_chunk_ptr = ++chunk_ptr;
- break;
- }
-
- m_shift = (m_shift | (*chunk_ptr++ = *current++)) << 8;
- }
-
- m_buf_start = current;
+ uint8_t* chunk_ptr = m_chunk_ptr;
+ uint8_t* current = m_buf_start;
+ uint8_t* limit = current + bytes;
+
+ while(current < limit)
+ {
+ if(m_shift == 0x00000100)
+ {
+ m_shift = 0xffffff00;
+ len = ++current - m_buf_start;
+ m_chunk_ptr = ++chunk_ptr;
+ break;
+ }
+
+ m_shift = (m_shift | (*chunk_ptr++ = *current++)) << 8;
+ }
+
+ m_buf_start = current;
#endif
- return len;
+ return len;
}
mpeg2_state_t CMpeg2Dec::seek_chunk()
{
- int size = m_buf_end - m_buf_start;
+ int size = m_buf_end - m_buf_start;
- if(int skipped = skip_chunk(size))
- {
- m_bytes_since_pts += skipped;
- m_code = m_buf_start[-1];
- return (mpeg2_state_t) - 1;
- }
+ if(int skipped = skip_chunk(size))
+ {
+ m_bytes_since_pts += skipped;
+ m_code = m_buf_start[-1];
+ return (mpeg2_state_t)-1;
+ }
- m_bytes_since_pts += size;
- return STATE_BUFFER;
+ m_bytes_since_pts += size;
+ return STATE_BUFFER;
}
mpeg2_state_t CMpeg2Dec::seek_header()
{
- while(m_code != 0xb3 && (m_code != 0xb7 && m_code != 0xb8 && m_code || m_sequence.width == (unsigned) - 1))
- {
- if(seek_chunk() == STATE_BUFFER)
- return STATE_BUFFER;
- }
+ while(m_code != 0xb3 && (m_code != 0xb7 && m_code != 0xb8 && m_code || m_sequence.width == (unsigned)-1))
+ {
+ if(seek_chunk() == STATE_BUFFER)
+ return STATE_BUFFER;
+ }
- m_chunk_start = m_chunk_ptr = m_chunk_buffer;
+ m_chunk_start = m_chunk_ptr = m_chunk_buffer;
- return m_code
- ? mpeg2_parse_header()
- : mpeg2_header_picture_start();
+ return m_code
+ ? mpeg2_parse_header()
+ : mpeg2_header_picture_start();
}
mpeg2_state_t CMpeg2Dec::seek_sequence()
{
- mpeg2_header_state_init();
- m_action = &CMpeg2Dec::seek_header;
- return seek_header();
+ mpeg2_header_state_init();
+ m_action = &CMpeg2Dec::seek_header;
+ return seek_header();
}
//
void CMpeg2Dec::mpeg2_buffer(uint8_t* start, uint8_t* end)
{
- m_buf_start = start;
- m_buf_end = end;
+ m_buf_start = start;
+ m_buf_end = end;
}
int CMpeg2Dec::mpeg2_getpos()
{
- return m_buf_end - m_buf_start;
+ return m_buf_end - m_buf_start;
}
//
mpeg2_state_t CMpeg2Dec::mpeg2_parse()
{
- if(m_action)
- {
- mpeg2_state_t state = (this->*m_action)();
- if((int)state >= 0)
- return state;
- }
-
- while(1)
- {
- while((unsigned)(m_code - m_first_decode_slice) < m_nb_decode_slices)
- {
- int size_buffer = m_buf_end - m_buf_start;
- int size_chunk = (m_chunk_buffer + BUFFER_SIZE - m_chunk_ptr);
- int copied;
-
- if(size_buffer <= size_chunk)
- {
- copied = copy_chunk(size_buffer);
- if(!copied)
- {
- m_bytes_since_pts += size_buffer;
- m_chunk_ptr += size_buffer;
- return STATE_BUFFER;
- }
- }
- else
- {
- copied = copy_chunk(size_chunk);
- if(!copied)
- {
- /* filled the chunk buffer without finding a start code */
- m_bytes_since_pts += size_chunk;
- m_action = &CMpeg2Dec::seek_chunk;
- return STATE_INVALID;
- }
- }
-
- m_bytes_since_pts += copied;
-
- m_decoder.mpeg2_slice(m_code, m_chunk_start);
- m_code = m_buf_start[-1];
- m_chunk_ptr = m_chunk_start;
- }
-
- if((unsigned)(m_code - 1) >= 0xb0 - 1)
- break;
- if(seek_chunk() == STATE_BUFFER)
- return STATE_BUFFER;
- }
-
- switch(m_code)
- {
- case 0x00:
- m_action = &CMpeg2Dec::mpeg2_header_picture_start;
- return m_state;
- case 0xb7:
- m_action = &CMpeg2Dec::mpeg2_header_end;
- break;
- case 0xb3:
- case 0xb8:
- m_action = &CMpeg2Dec::mpeg2_parse_header;
- break;
- case 0xbe:
- m_action = &CMpeg2Dec::seek_chunk;
- return STATE_PADDING;
- default:
- m_action = &CMpeg2Dec::seek_chunk;
- return STATE_INVALID;
- }
-
- if(m_state != STATE_SLICE)
- m_state = STATE_INVALID;
-
- return m_state;
+ if(m_action)
+ {
+ mpeg2_state_t state = (this->*m_action)();
+ if((int)state >= 0)
+ return state;
+ }
+
+ while(1)
+ {
+ while((unsigned)(m_code - m_first_decode_slice) < m_nb_decode_slices)
+ {
+ int size_buffer = m_buf_end - m_buf_start;
+ int size_chunk = (m_chunk_buffer + BUFFER_SIZE - m_chunk_ptr);
+ int copied;
+
+ if(size_buffer <= size_chunk)
+ {
+ copied = copy_chunk(size_buffer);
+ if(!copied)
+ {
+ m_bytes_since_pts += size_buffer;
+ m_chunk_ptr += size_buffer;
+ return STATE_BUFFER;
+ }
+ }
+ else
+ {
+ copied = copy_chunk(size_chunk);
+ if(!copied)
+ {
+ /* filled the chunk buffer without finding a start code */
+ m_bytes_since_pts += size_chunk;
+ m_action = &CMpeg2Dec::seek_chunk;
+ return STATE_INVALID;
+ }
+ }
+
+ m_bytes_since_pts += copied;
+
+ m_decoder.mpeg2_slice(m_code, m_chunk_start);
+ m_code = m_buf_start[-1];
+ m_chunk_ptr = m_chunk_start;
+ }
+
+ if((unsigned)(m_code - 1) >= 0xb0 - 1)
+ break;
+ if(seek_chunk() == STATE_BUFFER)
+ return STATE_BUFFER;
+ }
+
+ switch(m_code)
+ {
+ case 0x00:
+ m_action = &CMpeg2Dec::mpeg2_header_picture_start;
+ return m_state;
+ case 0xb7:
+ m_action = &CMpeg2Dec::mpeg2_header_end;
+ break;
+ case 0xb3:
+ case 0xb8:
+ m_action = &CMpeg2Dec::mpeg2_parse_header;
+ break;
+ case 0xbe:
+ m_action = &CMpeg2Dec::seek_chunk;
+ return STATE_PADDING;
+ default:
+ m_action = &CMpeg2Dec::seek_chunk;
+ return STATE_INVALID;
+ }
+
+ if(m_state != STATE_SLICE)
+ m_state = STATE_INVALID;
+
+ return m_state;
}
void CMpeg2Dec::mpeg2_skip(int skip)
{
- m_first_decode_slice = 1;
- m_nb_decode_slices = skip ? 0 : (0xb0 - 1);
+ m_first_decode_slice = 1;
+ m_nb_decode_slices = skip ? 0 : (0xb0 - 1);
}
void CMpeg2Dec::mpeg2_slice_region(int start, int end)
{
- start = (start < 1) ? 1 : (start > 0xb0) ? 0xb0 : start;
- end = (end < start) ? start : (end > 0xb0) ? 0xb0 : end;
- m_first_decode_slice = start;
- m_nb_decode_slices = end - start;
+ start = (start < 1) ? 1 : (start > 0xb0) ? 0xb0 : start;
+ end = (end < start) ? start : (end > 0xb0) ? 0xb0 : end;
+ m_first_decode_slice = start;
+ m_nb_decode_slices = end - start;
}
void CMpeg2Dec::mpeg2_pts(uint32_t pts)
{
- m_pts_previous = m_pts_current;
- m_pts_current = pts;
- m_num_pts++;
- m_bytes_since_pts = 0;
+ m_pts_previous = m_pts_current;
+ m_pts_current = pts;
+ m_num_pts++;
+ m_bytes_since_pts = 0;
}
//
@@ -736,123 +721,123 @@ void CMpeg2Dec::mpeg2_pts(uint32_t pts)
mpeg2_state_t CMpeg2Dec::mpeg2_seek_sequence()
{
- mpeg2_header_state_init();
- m_action = &CMpeg2Dec::seek_header;
- return seek_header();
+ mpeg2_header_state_init();
+ m_action = &CMpeg2Dec::seek_header;
+ return seek_header();
}
mpeg2_state_t CMpeg2Dec::mpeg2_parse_header()
{
- static int (CMpeg2Dec::* process_header[])() =
- {
- &CMpeg2Dec::mpeg2_header_picture,
- &CMpeg2Dec::mpeg2_header_extension,
- &CMpeg2Dec::mpeg2_header_user_data,
- &CMpeg2Dec::mpeg2_header_sequence,
- NULL, NULL, NULL, NULL,
- &CMpeg2Dec::mpeg2_header_gop
- };
-
- m_action = &CMpeg2Dec::mpeg2_parse_header;
-
- while(1)
- {
- int size_buffer = m_buf_end - m_buf_start;
- int size_chunk = (m_chunk_buffer + BUFFER_SIZE - m_chunk_ptr);
- int copied;
- if(size_buffer <= size_chunk)
- {
- copied = copy_chunk(size_buffer);
- if(!copied)
- {
- m_bytes_since_pts += size_buffer;
- m_chunk_ptr += size_buffer;
- return STATE_BUFFER;
- }
- }
- else
- {
- copied = copy_chunk(size_chunk);
- if(!copied)
- {
- /* filled the chunk buffer without finding a start code */
- m_bytes_since_pts += size_chunk;
- m_code = 0xb4;
- m_action = &CMpeg2Dec::seek_header;
- return STATE_INVALID;
- }
- }
- m_bytes_since_pts += copied;
-
- if((this->*(process_header[m_code & 0x0b]))())
- {
- m_code = m_buf_start[-1];
- m_action = &CMpeg2Dec::seek_header;
- return STATE_INVALID;
- }
-
- m_code = m_buf_start[-1];
-
- switch(RECEIVED(m_code, m_state))
- {
- /* state transition after a sequence header */
- case RECEIVED(0x00, STATE_SEQUENCE):
- m_action = &CMpeg2Dec::mpeg2_header_picture_start;
- case RECEIVED(0xb8, STATE_SEQUENCE):
- mpeg2_header_sequence_finalize();
- break;
-
- /* other legal state transitions */
- case RECEIVED(0x00, STATE_GOP):
- m_action = &CMpeg2Dec::mpeg2_header_picture_start;
- break;
- case RECEIVED(0x01, STATE_PICTURE):
- case RECEIVED(0x01, STATE_PICTURE_2ND):
- mpeg2_header_matrix_finalize();
- m_action = &CMpeg2Dec::mpeg2_header_slice_start;
- break;
-
- /* legal headers within a given state */
- case RECEIVED(0xb2, STATE_SEQUENCE):
- case RECEIVED(0xb2, STATE_GOP):
- case RECEIVED(0xb2, STATE_PICTURE):
- case RECEIVED(0xb2, STATE_PICTURE_2ND):
- case RECEIVED(0xb5, STATE_SEQUENCE):
- case RECEIVED(0xb5, STATE_PICTURE):
- case RECEIVED(0xb5, STATE_PICTURE_2ND):
- m_chunk_ptr = m_chunk_start;
- continue;
-
- default:
- m_action = &CMpeg2Dec::seek_header;
- return STATE_INVALID;
- }
-
- m_chunk_start = m_chunk_ptr = m_chunk_buffer;
- return m_state;
- }
+ static int (CMpeg2Dec::* process_header[]) () =
+ {
+ &CMpeg2Dec::mpeg2_header_picture,
+ &CMpeg2Dec::mpeg2_header_extension,
+ &CMpeg2Dec::mpeg2_header_user_data,
+ &CMpeg2Dec::mpeg2_header_sequence,
+ NULL, NULL, NULL, NULL,
+ &CMpeg2Dec::mpeg2_header_gop
+ };
+
+ m_action = &CMpeg2Dec::mpeg2_parse_header;
+
+ while(1)
+ {
+ int size_buffer = m_buf_end - m_buf_start;
+ int size_chunk = (m_chunk_buffer + BUFFER_SIZE - m_chunk_ptr);
+ int copied;
+ if(size_buffer <= size_chunk)
+ {
+ copied = copy_chunk(size_buffer);
+ if(!copied)
+ {
+ m_bytes_since_pts += size_buffer;
+ m_chunk_ptr += size_buffer;
+ return STATE_BUFFER;
+ }
+ }
+ else
+ {
+ copied = copy_chunk(size_chunk);
+ if(!copied)
+ {
+ /* filled the chunk buffer without finding a start code */
+ m_bytes_since_pts += size_chunk;
+ m_code = 0xb4;
+ m_action = &CMpeg2Dec::seek_header;
+ return STATE_INVALID;
+ }
+ }
+ m_bytes_since_pts += copied;
+
+ if((this->*(process_header[m_code & 0x0b]))())
+ {
+ m_code = m_buf_start[-1];
+ m_action = &CMpeg2Dec::seek_header;
+ return STATE_INVALID;
+ }
+
+ m_code = m_buf_start[-1];
+
+ switch(RECEIVED(m_code, m_state))
+ {
+ /* state transition after a sequence header */
+ case RECEIVED(0x00, STATE_SEQUENCE):
+ m_action = &CMpeg2Dec::mpeg2_header_picture_start;
+ case RECEIVED(0xb8, STATE_SEQUENCE):
+ mpeg2_header_sequence_finalize();
+ break;
+
+ /* other legal state transitions */
+ case RECEIVED (0x00, STATE_GOP):
+ m_action = &CMpeg2Dec::mpeg2_header_picture_start;
+ break;
+ case RECEIVED (0x01, STATE_PICTURE):
+ case RECEIVED (0x01, STATE_PICTURE_2ND):
+ mpeg2_header_matrix_finalize();
+ m_action = &CMpeg2Dec::mpeg2_header_slice_start;
+ break;
+
+ /* legal headers within a given state */
+ case RECEIVED (0xb2, STATE_SEQUENCE):
+ case RECEIVED (0xb2, STATE_GOP):
+ case RECEIVED (0xb2, STATE_PICTURE):
+ case RECEIVED (0xb2, STATE_PICTURE_2ND):
+ case RECEIVED (0xb5, STATE_SEQUENCE):
+ case RECEIVED (0xb5, STATE_PICTURE):
+ case RECEIVED (0xb5, STATE_PICTURE_2ND):
+ m_chunk_ptr = m_chunk_start;
+ continue;
+
+ default:
+ m_action = &CMpeg2Dec::seek_header;
+ return STATE_INVALID;
+ }
+
+ m_chunk_start = m_chunk_ptr = m_chunk_buffer;
+ return m_state;
+ }
}
/* header.c */
void CMpeg2Dec::mpeg2_header_state_init()
{
- if(m_sequence.width != (unsigned) - 1)
- {
- m_sequence.width = (unsigned) - 1;
- for(int i = 0; i < m_alloc_index; i++)
- _aligned_free(m_fbuf_alloc[i].buf[0]);
+ if(m_sequence.width != (unsigned)-1)
+ {
+ m_sequence.width = (unsigned)-1;
+ for(int i = 0; i < m_alloc_index; i++)
+ _aligned_free(m_fbuf_alloc[i].buf[0]);
}
- m_decoder.m_scan = mpeg2_scan_norm_2;
- m_picture = m_pictures;
- m_fbuf[0] = &m_fbuf_alloc[0];
- m_fbuf[1] = &m_fbuf_alloc[1];
- m_fbuf[2] = &m_fbuf_alloc[2];
- m_first = true;
- m_alloc_index = 0;
- m_first_decode_slice = 1;
- m_nb_decode_slices = 0xb0 - 1;
+ m_decoder.m_scan = mpeg2_scan_norm_2;
+ m_picture = m_pictures;
+ m_fbuf[0] = &m_fbuf_alloc[0];
+ m_fbuf[1] = &m_fbuf_alloc[1];
+ m_fbuf[2] = &m_fbuf_alloc[2];
+ m_first = true;
+ m_alloc_index = 0;
+ m_first_decode_slice = 1;
+ m_nb_decode_slices = 0xb0 - 1;
}
int CMpeg2Dec::mpeg2_header_sequence()
@@ -862,13 +847,13 @@ int CMpeg2Dec::mpeg2_header_sequence()
static unsigned int frame_period[9] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000};
if((buffer[6] & 0x20) != 0x20) /* missing marker_bit */
- return 1;
+ return 1;
int i = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
if(!(sequence->display_width = sequence->picture_width = i >> 12))
- return 1;
+ return 1;
if(!(sequence->display_height = sequence->picture_height = i & 0xfff))
- return 1;
+ return 1;
sequence->width = (sequence->picture_width + 15) & ~15;
sequence->height = (sequence->picture_height + 15) & ~15;
@@ -878,33 +863,33 @@ int CMpeg2Dec::mpeg2_header_sequence()
sequence->pixel_width = buffer[3] >> 4; /* aspect ratio */
sequence->frame_period = 0;
if((buffer[3] & 15) < 9) sequence->frame_period = frame_period[buffer[3] & 15];
- sequence->byte_rate = (buffer[4] << 10) | (buffer[5] << 2) | (buffer[6] >> 6);
- sequence->vbv_buffer_size = ((buffer[6] << 16) | (buffer[7] << 8)) & 0x1ff800;
+ sequence->byte_rate = (buffer[4]<<10) | (buffer[5]<<2) | (buffer[6]>>6);
+ sequence->vbv_buffer_size = ((buffer[6]<<16)|(buffer[7]<<8))&0x1ff800;
if(buffer[7] & 4) sequence->flags |= SEQ_FLAG_CONSTRAINED_PARAMETERS;
m_copy_matrix = 3;
if(buffer[7] & 2)
- {
- for(i = 0; i < 64; i++)
- m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i+7] << 7) | (buffer[i+8] >> 1);
- buffer += 64;
- }
- else
- {
- for(i = 0; i < 64; i++)
- m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = default_intra_quantizer_matrix[i];
+ {
+ for(i = 0; i < 64; i++)
+ m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i+7] << 7) | (buffer[i+8] >> 1);
+ buffer += 64;
}
+ else
+ {
+ for (i = 0; i < 64; i++)
+ m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = default_intra_quantizer_matrix[i];
+ }
if(buffer[7] & 1)
- {
- for(i = 0; i < 64; i++)
+ {
+ for(i = 0; i < 64; i++)
m_non_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = buffer[i+8];
- }
+ }
else
- {
- for(i = 0; i < 64; i++)
- m_non_intra_quantizer_matrix[i] = 16;
- }
+ {
+ for(i = 0; i < 64; i++)
+ m_non_intra_quantizer_matrix[i] = 16;
+ }
sequence->profile_level_id = 0x80;
sequence->colour_primaries = 0;
@@ -924,9 +909,9 @@ int CMpeg2Dec::mpeg2_header_sequence()
int CMpeg2Dec::mpeg2_header_gop()
{
uint8_t* buffer = m_chunk_start;
- m_info.Reset();
- if(!(buffer[1] & 8))
- return 1;
+ m_info.Reset();
+ if(!(buffer[1] & 8))
+ return 1;
m_info.m_gop = &m_gop;
m_gop.hours = (buffer[0] >> 2) & 31;
m_gop.minutes = ((buffer[0] << 4) | (buffer[1] >> 4)) & 63;
@@ -939,169 +924,167 @@ int CMpeg2Dec::mpeg2_header_gop()
mpeg2_state_t CMpeg2Dec::mpeg2_header_picture_start()
{
- {
- mpeg2_picture_t* picture;
-
- if(m_state != STATE_SLICE_1ST)
- {
- m_state = STATE_PICTURE;
- picture = m_pictures;
- if((m_decoder.m_coding_type != PIC_FLAG_CODING_TYPE_B) ^(m_picture >= m_pictures + 2))
- picture += 2;
- }
- else
- {
- m_state = STATE_PICTURE_2ND;
- picture = m_picture + 1; /* second field picture */
- }
-
- m_picture = picture;
- }
+ {
+ mpeg2_picture_t* picture;
+
+ if(m_state != STATE_SLICE_1ST)
+ {
+ m_state = STATE_PICTURE;
+ picture = m_pictures;
+ if((m_decoder.m_coding_type != PIC_FLAG_CODING_TYPE_B) ^ (m_picture >= m_pictures + 2))
+ picture += 2;
+ }
+ else
+ {
+ m_state = STATE_PICTURE_2ND;
+ picture = m_picture + 1; /* second field picture */
+ }
+
+ m_picture = picture;
+ }
m_picture->flags = 0;
if(m_num_pts)
- {
- if(m_bytes_since_pts >= 4)
- {
- m_num_pts = 0;
- m_picture->pts = m_pts_current;
- m_picture->flags = PIC_FLAG_PTS;
- }
- else if(m_num_pts > 1)
- {
- m_num_pts = 1;
- m_picture->pts = m_pts_previous;
- m_picture->flags = PIC_FLAG_PTS;
- }
- }
-
- m_picture->display_offset[0].x =
- m_picture->display_offset[1].x =
- m_picture->display_offset[2].x = m_display_offset_x;
- m_picture->display_offset[0].y =
- m_picture->display_offset[1].y =
- m_picture->display_offset[2].y = m_display_offset_y;
+ {
+ if(m_bytes_since_pts >= 4)
+ {
+ m_num_pts = 0;
+ m_picture->pts = m_pts_current;
+ m_picture->flags = PIC_FLAG_PTS;
+ }
+ else if(m_num_pts > 1)
+ {
+ m_num_pts = 1;
+ m_picture->pts = m_pts_previous;
+ m_picture->flags = PIC_FLAG_PTS;
+ }
+ }
+
+ m_picture->display_offset[0].x =
+ m_picture->display_offset[1].x =
+ m_picture->display_offset[2].x = m_display_offset_x;
+ m_picture->display_offset[0].y =
+ m_picture->display_offset[1].y =
+ m_picture->display_offset[2].y = m_display_offset_y;
return mpeg2_parse_header();
}
int CMpeg2Dec::mpeg2_header_picture()
{
- uint8_t* buffer = m_chunk_start;
- mpeg2_picture_t* picture = m_picture;
- int type;
- int low_delay;
-
- type = (buffer [1] >> 3) & 7;
- low_delay = m_sequence.flags & SEQ_FLAG_LOW_DELAY;
-
- if(m_state == STATE_PICTURE)
- {
- mpeg2_picture_t* other;
-
- m_decoder.m_second_field = 0;
- other = m_pictures;
- if(other == picture)
- other += 2;
- if(m_decoder.m_coding_type != PIC_FLAG_CODING_TYPE_B)
- {
- m_fbuf[2] = m_fbuf[1];
- m_fbuf[1] = m_fbuf[0];
- }
- m_fbuf[0] = NULL;
- m_info.Reset();
- m_info.m_current_picture = picture;
- m_info.m_display_picture = picture;
- if(type != PIC_FLAG_CODING_TYPE_B)
- {
- if(!low_delay)
- {
- if(m_first)
- {
- m_info.m_display_picture = NULL;
- m_first = false;
- }
- else
- {
- m_info.m_display_picture = other;
- if(other->nb_fields == 1)
- m_info.m_display_picture_2nd = other + 1;
- m_info.m_display_fbuf = m_fbuf[1];
- }
- }
-
- if(!low_delay + !NULL/*m_convert_start*/)
- m_info.m_discard_fbuf = m_fbuf[!low_delay + !NULL/*m_convert_start*/];
- }
-
- while(m_alloc_index < 3)
- {
- mpeg2_fbuf_t* fbuf = &m_fbuf_alloc[m_alloc_index++];
- fbuf->id = NULL;
-
- int size = m_decoder.m_width * m_decoder.m_height;
- fbuf->buf[0] = (uint8_t*)_aligned_malloc(6 * size >> 2, 16);
- fbuf->buf[1] = fbuf->buf[0] + size;
- fbuf->buf[2] = fbuf->buf[1] + (size >> 2);
- memset(fbuf->buf[0], 0x10, size);
- memset(fbuf->buf[1], 0x80, size >> 2);
- memset(fbuf->buf[2], 0x80, size >> 2);
- }
- mpeg2_set_fbuf(type);
- }
- else
- {
- m_decoder.m_second_field = 1;
- m_info.m_current_picture_2nd = picture;
- m_info.m_user_data = NULL;
- m_info.m_user_data_len = 0;
- if(low_delay || type == PIC_FLAG_CODING_TYPE_B)
- m_info.m_display_picture_2nd = picture;
- }
- m_ext_state = PIC_CODING_EXT;
-
- picture->temporal_reference = (buffer[0] << 2) | (buffer[1] >> 6);
-
- m_decoder.m_coding_type = type;
- picture->flags |= type;
-
- if(type == PIC_FLAG_CODING_TYPE_P || type == PIC_FLAG_CODING_TYPE_B)
- {
- /* forward_f_code and backward_f_code - used in mpeg1 only */
- m_decoder.m_f_motion.f_code[1] = (buffer[3] >> 2) & 1;
- m_decoder.m_f_motion.f_code[0] = (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
- m_decoder.m_b_motion.f_code[1] = (buffer[4] >> 6) & 1;
- m_decoder.m_b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1;
- }
-
- /* XXXXXX decode extra_information_picture as well */
-
- picture->nb_fields = 2;
-
- m_decoder.m_intra_dc_precision = 0;
- m_decoder.m_frame_pred_frame_dct = 1;
- m_decoder.m_q_scale_type = 0;
- m_decoder.m_concealment_motion_vectors = 0;
- m_decoder.m_scan = mpeg2_scan_norm_2;
- m_decoder.m_picture_structure = FRAME_PICTURE;
- m_copy_matrix = 0;
-
- return 0;
+ uint8_t* buffer = m_chunk_start;
+ mpeg2_picture_t* picture = m_picture;
+ int type;
+ int low_delay;
+
+ type = (buffer [1] >> 3) & 7;
+ low_delay = m_sequence.flags & SEQ_FLAG_LOW_DELAY;
+
+ if(m_state == STATE_PICTURE)
+ {
+ mpeg2_picture_t* other;
+
+ m_decoder.m_second_field = 0;
+ other = m_pictures;
+ if(other == picture)
+ other += 2;
+ if(m_decoder.m_coding_type != PIC_FLAG_CODING_TYPE_B)
+ {
+ m_fbuf[2] = m_fbuf[1];
+ m_fbuf[1] = m_fbuf[0];
+ }
+ m_fbuf[0] = NULL;
+ m_info.Reset();
+ m_info.m_current_picture = picture;
+ m_info.m_display_picture = picture;
+ if(type != PIC_FLAG_CODING_TYPE_B)
+ {
+ if(!low_delay)
+ {
+ if(m_first) {
+ m_info.m_display_picture = NULL;
+ m_first = false;
+ }
+ else
+ {
+ m_info.m_display_picture = other;
+ if(other->nb_fields == 1)
+ m_info.m_display_picture_2nd = other + 1;
+ m_info.m_display_fbuf = m_fbuf[1];
+ }
+ }
+
+ if(!low_delay + !NULL/*m_convert_start*/)
+ m_info.m_discard_fbuf = m_fbuf[!low_delay + !NULL/*m_convert_start*/];
+ }
+
+ while(m_alloc_index < 3)
+ {
+ mpeg2_fbuf_t* fbuf = &m_fbuf_alloc[m_alloc_index++];
+ fbuf->id = NULL;
+
+ int size = m_decoder.m_width * m_decoder.m_height;
+ fbuf->buf[0] = (uint8_t*)_aligned_malloc(6 * size >> 2, 16);
+ fbuf->buf[1] = fbuf->buf[0] + size;
+ fbuf->buf[2] = fbuf->buf[1] + (size >> 2);
+ memset(fbuf->buf[0], 0x10, size);
+ memset(fbuf->buf[1], 0x80, size >> 2);
+ memset(fbuf->buf[2], 0x80, size >> 2);
+ }
+ mpeg2_set_fbuf(type);
+ }
+ else
+ {
+ m_decoder.m_second_field = 1;
+ m_info.m_current_picture_2nd = picture;
+ m_info.m_user_data = NULL; m_info.m_user_data_len = 0;
+ if(low_delay || type == PIC_FLAG_CODING_TYPE_B)
+ m_info.m_display_picture_2nd = picture;
+ }
+ m_ext_state = PIC_CODING_EXT;
+
+ picture->temporal_reference = (buffer[0] << 2) | (buffer[1] >> 6);
+
+ m_decoder.m_coding_type = type;
+ picture->flags |= type;
+
+ if(type == PIC_FLAG_CODING_TYPE_P || type == PIC_FLAG_CODING_TYPE_B)
+ {
+ /* forward_f_code and backward_f_code - used in mpeg1 only */
+ m_decoder.m_f_motion.f_code[1] = (buffer[3] >> 2) & 1;
+ m_decoder.m_f_motion.f_code[0] = (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
+ m_decoder.m_b_motion.f_code[1] = (buffer[4] >> 6) & 1;
+ m_decoder.m_b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1;
+ }
+
+ /* XXXXXX decode extra_information_picture as well */
+
+ picture->nb_fields = 2;
+
+ m_decoder.m_intra_dc_precision = 0;
+ m_decoder.m_frame_pred_frame_dct = 1;
+ m_decoder.m_q_scale_type = 0;
+ m_decoder.m_concealment_motion_vectors = 0;
+ m_decoder.m_scan = mpeg2_scan_norm_2;
+ m_decoder.m_picture_structure = FRAME_PICTURE;
+ m_copy_matrix = 0;
+
+ return 0;
}
int CMpeg2Dec::mpeg2_header_extension()
{
- static int (CMpeg2Dec::* parser[])() =
- {
- NULL,
- &CMpeg2Dec::sequence_ext,
- &CMpeg2Dec::sequence_display_ext,
- &CMpeg2Dec::quant_matrix_ext,
- &CMpeg2Dec::copyright_ext,
- NULL, NULL,
- &CMpeg2Dec::picture_display_ext,
- &CMpeg2Dec::picture_coding_ext
+ static int (CMpeg2Dec::* parser[]) () =
+ {
+ NULL,
+ &CMpeg2Dec::sequence_ext,
+ &CMpeg2Dec::sequence_display_ext,
+ &CMpeg2Dec::quant_matrix_ext,
+ &CMpeg2Dec::copyright_ext,
+ NULL, NULL,
+ &CMpeg2Dec::picture_display_ext,
+ &CMpeg2Dec::picture_coding_ext
};
int ext, ext_bit;
@@ -1110,7 +1093,7 @@ int CMpeg2Dec::mpeg2_header_extension()
ext_bit = 1 << ext;
if(!(m_ext_state & ext_bit)) /* ignore illegal extensions */
- return 0;
+ return 0;
m_ext_state &= ~ext_bit;
return (this->*parser[ext])();
}
@@ -1120,7 +1103,7 @@ int CMpeg2Dec::mpeg2_header_user_data()
if(!m_info.m_user_data_len) m_info.m_user_data = m_chunk_start;
else m_info.m_user_data_len += 3;
- m_info.m_user_data_len += (m_chunk_ptr - 4 - m_chunk_start);
+ m_info.m_user_data_len += (m_chunk_ptr - 4 - m_chunk_start);
m_chunk_start = m_chunk_ptr - 1;
return 0;
@@ -1129,10 +1112,10 @@ int CMpeg2Dec::mpeg2_header_user_data()
void CMpeg2Dec::mpeg2_header_matrix_finalize()
{
if(m_copy_matrix & 1)
- memcpy(m_decoder.m_intra_quantizer_matrix, m_intra_quantizer_matrix, 64);
+ memcpy(m_decoder.m_intra_quantizer_matrix, m_intra_quantizer_matrix, 64);
if(m_copy_matrix & 2)
- memcpy(m_decoder.m_non_intra_quantizer_matrix, m_non_intra_quantizer_matrix, 64);
+ memcpy(m_decoder.m_non_intra_quantizer_matrix, m_non_intra_quantizer_matrix, 64);
}
void mpeg2_sequence_t::finalize()
@@ -1142,76 +1125,54 @@ void mpeg2_sequence_t::finalize()
byte_rate *= 50;
if(flags & SEQ_FLAG_MPEG2)
- {
- switch(pixel_width)
- {
- case 1: /* square pixels */
- pixel_width = pixel_height = 1;
- return;
- case 2: /* 4:3 aspect ratio */
- w = 4;
- h = 3;
- break;
- case 3: /* 16:9 aspect ratio */
- w = 16;
- h = 9;
- break;
- case 4: /* 2.21:1 aspect ratio */
- w = 221;
- h = 100;
- break;
- default: /* illegal */
- pixel_width = pixel_height = 0;
- return;
- }
-
- w *= display_height;
- h *= display_width;
- }
- else
- {
- if(byte_rate == 50 * 0x3ffff)
- byte_rate = 0; /* mpeg-1 VBR */
-
- switch(pixel_width)
- {
- case 0:
- case 15: /* illegal */
- pixel_width = pixel_height = 0;
- return;
- case 1: /* square pixels */
- pixel_width = pixel_height = 1;
- return;
- case 3: /* 720x576 16:9 */
- pixel_width = 64;
- pixel_height = 45;
- return;
- case 6: /* 720x480 16:9 */
- pixel_width = 32;
- pixel_height = 27;
- return;
- case 12: /* 720*480 4:3 */
- pixel_width = 8;
- pixel_height = 9;
- return;
- default:
- h = 88 * pixel_width + 1171;
- w = 2000;
- }
+ {
+ switch(pixel_width)
+ {
+ case 1: /* square pixels */
+ pixel_width = pixel_height = 1; return;
+ case 2: /* 4:3 aspect ratio */
+ w = 4; h = 3; break;
+ case 3: /* 16:9 aspect ratio */
+ w = 16; h = 9; break;
+ case 4: /* 2.21:1 aspect ratio */
+ w = 221; h = 100; break;
+ default: /* illegal */
+ pixel_width = pixel_height = 0; return;
+ }
+
+ w *= display_height;
+ h *= display_width;
+ }
+ else
+ {
+ if(byte_rate == 50 * 0x3ffff)
+ byte_rate = 0; /* mpeg-1 VBR */
+
+ switch(pixel_width)
+ {
+ case 0: case 15: /* illegal */
+ pixel_width = pixel_height = 0; return;
+ case 1: /* square pixels */
+ pixel_width = pixel_height = 1; return;
+ case 3: /* 720x576 16:9 */
+ pixel_width = 64; pixel_height = 45; return;
+ case 6: /* 720x480 16:9 */
+ pixel_width = 32; pixel_height = 27; return;
+ case 12: /* 720*480 4:3 */
+ pixel_width = 8; pixel_height = 9; return;
+ default:
+ h = 88 * pixel_width + 1171;
+ w = 2000;
+ }
}
pixel_width = w;
pixel_height = h;
- /* find greatest common divisor */
- while(w)
- {
- int tmp = w;
- w = h % tmp;
- h = tmp;
- }
+ /* find greatest common divisor */
+ while(w) {int tmp = w; w = h % tmp; h = tmp;}
- pixel_width /= h;
+ pixel_width /= h;
pixel_height /= h;
}
@@ -1236,21 +1197,21 @@ void CMpeg2Dec::mpeg2_header_sequence_finalize()
* repeat sequence headers.
*/
- // EDIT: some dvds will work if we allow the last three fields to vary (which aren't needed anyway)
- // EDIT2: vbv_buffer_size can be ignored as well, not used by libmpeg2
+ // EDIT: some dvds will work if we allow the last three fields to vary (which aren't needed anyway)
+ // EDIT2: vbv_buffer_size can be ignored as well, not used by libmpeg2
- m_sequence.byte_rate = sequence->byte_rate;
- m_sequence.vbv_buffer_size = sequence->vbv_buffer_size;
+ m_sequence.byte_rate = sequence->byte_rate;
+ m_sequence.vbv_buffer_size = sequence->vbv_buffer_size;
- if(!memcmp(&m_sequence, sequence, FIELD_OFFSET(mpeg2_sequence_t, colour_primaries) /*sizeof(mpeg2_sequence_t)*/))
- {
- m_state = STATE_SEQUENCE_REPEATED;
- }
- else if(m_sequence.width != (unsigned) - 1)
- {
- m_action = &CMpeg2Dec::mpeg2_seek_sequence;
- m_state = STATE_INVALID; /* XXXX STATE_INVALID_END ? */
- return;
+ if(!memcmp(&m_sequence, sequence, FIELD_OFFSET(mpeg2_sequence_t, colour_primaries) /*sizeof(mpeg2_sequence_t)*/))
+ {
+ m_state = STATE_SEQUENCE_REPEATED;
+ }
+ else if(m_sequence.width != (unsigned)-1)
+ {
+ m_action = &CMpeg2Dec::mpeg2_seek_sequence;
+ m_state = STATE_INVALID; /* XXXX STATE_INVALID_END ? */
+ return;
}
m_sequence = *sequence;
@@ -1259,131 +1220,131 @@ void CMpeg2Dec::mpeg2_header_sequence_finalize()
mpeg2_state_t CMpeg2Dec::mpeg2_header_slice_start()
{
- m_info.m_user_data = NULL;
- m_info.m_user_data_len = 0;
- m_state = (m_picture->nb_fields > 1 || m_state == STATE_PICTURE_2ND) ? STATE_SLICE : STATE_SLICE_1ST;
+ m_info.m_user_data = NULL;
+ m_info.m_user_data_len = 0;
+ m_state = (m_picture->nb_fields > 1 || m_state == STATE_PICTURE_2ND) ? STATE_SLICE : STATE_SLICE_1ST;
- if(!m_nb_decode_slices)
- {
- m_picture->flags |= PIC_FLAG_SKIP;
- }
- else
- {
- int b_type = m_decoder.m_coding_type == B_TYPE;
- m_decoder.mpeg2_init_fbuf(m_fbuf[0]->buf, m_fbuf[b_type + 1]->buf, m_fbuf[b_type]->buf);
- }
+ if(!m_nb_decode_slices)
+ {
+ m_picture->flags |= PIC_FLAG_SKIP;
+ }
+ else
+ {
+ int b_type = m_decoder.m_coding_type == B_TYPE;
+ m_decoder.mpeg2_init_fbuf(m_fbuf[0]->buf, m_fbuf[b_type + 1]->buf, m_fbuf[b_type]->buf);
+ }
- m_action = NULL;
+ m_action = NULL;
- return (mpeg2_state_t) - 1;
+ return (mpeg2_state_t)-1;
}
mpeg2_state_t CMpeg2Dec::mpeg2_header_end()
{
- mpeg2_picture_t* picture = m_pictures;
-
- int b_type = m_decoder.m_coding_type == B_TYPE;
+ mpeg2_picture_t* picture = m_pictures;
- if((m_picture >= picture + 2) ^ b_type)
- picture = m_pictures + 2;
+ int b_type = m_decoder.m_coding_type == B_TYPE;
- m_state = STATE_END;
- m_info.Reset();
+ if((m_picture >= picture + 2) ^ b_type)
+ picture = m_pictures + 2;
- if(!(m_sequence.flags & SEQ_FLAG_LOW_DELAY))
- {
- m_info.m_display_picture = picture;
- if(picture->nb_fields == 1)
- m_info.m_display_picture_2nd = picture + 1;
- m_info.m_display_fbuf = m_fbuf[b_type];
- m_info.m_discard_fbuf = m_fbuf[b_type + 1];
- }
- else
- {
- m_info.m_discard_fbuf = m_fbuf[b_type];
- }
+ m_state = STATE_END;
+ m_info.Reset();
+
+ if(!(m_sequence.flags & SEQ_FLAG_LOW_DELAY))
+ {
+ m_info.m_display_picture = picture;
+ if(picture->nb_fields == 1)
+ m_info.m_display_picture_2nd = picture + 1;
+ m_info.m_display_fbuf = m_fbuf[b_type];
+ m_info.m_discard_fbuf = m_fbuf[b_type + 1];
+ }
+ else
+ {
+ m_info.m_discard_fbuf = m_fbuf[b_type];
+ }
- m_action = &CMpeg2Dec::mpeg2_seek_sequence;
- m_first = true;
+ m_action = &CMpeg2Dec::mpeg2_seek_sequence;
+ m_first = true;
- return STATE_END;
+ return STATE_END;
}
void CMpeg2Dec::mpeg2_set_fbuf(int coding_type)
{
for(int i = 0; i < 3; i++)
- {
- if(m_fbuf[1] != &m_fbuf_alloc[i] && m_fbuf[2] != &m_fbuf_alloc[i])
- {
- m_fbuf[0] = &m_fbuf_alloc[i];
- m_info.m_current_fbuf = m_fbuf[0];
- if(coding_type == B_TYPE || (m_sequence.flags & SEQ_FLAG_LOW_DELAY))
- {
- if(coding_type == B_TYPE)
- m_info.m_discard_fbuf = m_fbuf[0];
- m_info.m_display_fbuf = m_fbuf[0];
- }
- break;
- }
- }
+ {
+ if(m_fbuf[1] != &m_fbuf_alloc[i] && m_fbuf[2] != &m_fbuf_alloc[i])
+ {
+ m_fbuf[0] = &m_fbuf_alloc[i];
+ m_info.m_current_fbuf = m_fbuf[0];
+ if(coding_type == B_TYPE || (m_sequence.flags & SEQ_FLAG_LOW_DELAY))
+ {
+ if(coding_type == B_TYPE)
+ m_info.m_discard_fbuf = m_fbuf[0];
+ m_info.m_display_fbuf = m_fbuf[0];
+ }
+ break;
+ }
+ }
}
//
int CMpeg2Dec::sequence_ext()
{
- uint8_t* buffer = m_chunk_start;
- mpeg2_sequence_t* sequence = &m_new_sequence;
+ uint8_t* buffer = m_chunk_start;
+ mpeg2_sequence_t* sequence = &m_new_sequence;
- if(!(buffer[3] & 1))
- return 1;
+ if(!(buffer[3]&1))
+ return 1;
- sequence->profile_level_id = (buffer[0] << 4) | (buffer[1] >> 4);
+ sequence->profile_level_id = (buffer[0] << 4) | (buffer[1] >> 4);
- sequence->display_width =
- sequence->picture_width += ((buffer[1] << 13) | (buffer[2] << 5)) & 0x3000;
- sequence->display_height =
- sequence->picture_height += (buffer[2] << 7) & 0x3000;
+ sequence->display_width =
+ sequence->picture_width += ((buffer[1] << 13) | (buffer[2] << 5)) & 0x3000;
+ sequence->display_height =
+ sequence->picture_height += (buffer[2] << 7) & 0x3000;
- sequence->width = (sequence->picture_width + 15) & ~15;
- sequence->height = (sequence->picture_height + 15) & ~15;
+ sequence->width = (sequence->picture_width + 15) & ~15;
+ sequence->height = (sequence->picture_height + 15) & ~15;
- sequence->flags |= SEQ_FLAG_MPEG2;
+ sequence->flags |= SEQ_FLAG_MPEG2;
- if(!(buffer[1] & 8))
- {
- sequence->flags &= ~SEQ_FLAG_PROGRESSIVE_SEQUENCE;
- sequence->height = (sequence->height + 31) & ~31;
- }
+ if(!(buffer[1] & 8))
+ {
+ sequence->flags &= ~SEQ_FLAG_PROGRESSIVE_SEQUENCE;
+ sequence->height = (sequence->height + 31) & ~31;
+ }
- if(buffer[5] & 0x80)
- {
- sequence->flags |= SEQ_FLAG_LOW_DELAY;
- }
+ if(buffer[5] & 0x80)
+ {
+ sequence->flags |= SEQ_FLAG_LOW_DELAY;
+ }
- sequence->chroma_width = sequence->width;
- sequence->chroma_height = sequence->height;
-
- switch(buffer[1] & 6)
- {
- case 0: /* invalid */
- return 1;
- case 2: /* 4:2:0 */
- sequence->chroma_height >>= 1;
- case 4: /* 4:2:2 */
- sequence->chroma_width >>= 1;
- }
+ sequence->chroma_width = sequence->width;
+ sequence->chroma_height = sequence->height;
- sequence->byte_rate += ((buffer[2] << 25) | (buffer[3] << 17)) & 0x3ffc0000;
+ switch(buffer[1] & 6)
+ {
+ case 0: /* invalid */
+ return 1;
+ case 2: /* 4:2:0 */
+ sequence->chroma_height >>= 1;
+ case 4: /* 4:2:2 */
+ sequence->chroma_width >>= 1;
+ }
- sequence->vbv_buffer_size |= buffer[4] << 21;
+ sequence->byte_rate += ((buffer[2]<<25) | (buffer[3]<<17)) & 0x3ffc0000;
- sequence->frame_period =
- sequence->frame_period * ((buffer[5] & 31) + 1) / (((buffer[5] >> 2) & 3) + 1);
+ sequence->vbv_buffer_size |= buffer[4] << 21;
- m_ext_state = SEQ_DISPLAY_EXT;
+ sequence->frame_period =
+ sequence->frame_period * ((buffer[5]&31)+1) / (((buffer[5]>>2)&3)+1);
- return 0;
+ m_ext_state = SEQ_DISPLAY_EXT;
+
+ return 0;
}
int CMpeg2Dec::sequence_display_ext()
@@ -1391,24 +1352,24 @@ int CMpeg2Dec::sequence_display_ext()
uint8_t* buffer = m_chunk_start;
mpeg2_sequence_t* sequence = &m_new_sequence;
- uint32_t flags = (sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) | ((buffer[0] << 4) & SEQ_MASK_VIDEO_FORMAT);
+ uint32_t flags = (sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) | ((buffer[0]<<4) & SEQ_MASK_VIDEO_FORMAT);
if(buffer[0] & 1)
- {
- flags |= SEQ_FLAG_COLOUR_DESCRIPTION;
- sequence->colour_primaries = buffer[1];
- sequence->transfer_characteristics = buffer[2];
- sequence->matrix_coefficients = buffer[3];
- buffer += 3;
+ {
+ flags |= SEQ_FLAG_COLOUR_DESCRIPTION;
+ sequence->colour_primaries = buffer[1];
+ sequence->transfer_characteristics = buffer[2];
+ sequence->matrix_coefficients = buffer[3];
+ buffer += 3;
}
if(!(buffer[2] & 2)) /* missing marker_bit */
- return 1;
+ return 1;
- // ???
+ // ???
// sequence->flags = flags;
- sequence->display_width = (buffer[1] << 6) | (buffer[2] >> 2);
- sequence->display_height = ((buffer[2] & 1) << 13) | (buffer[3] << 5) | (buffer[4] >> 3);
+ sequence->display_width = (buffer[1] << 6) | (buffer[2] >> 2);
+ sequence->display_height = ((buffer[2]& 1 ) << 13) | (buffer[3] << 5) | (buffer[4] >> 3);
return 0;
}
@@ -1418,18 +1379,18 @@ int CMpeg2Dec::quant_matrix_ext()
uint8_t* buffer = m_chunk_start;
if(buffer[0] & 8)
- {
- for(int i = 0; i < 64; i++)
- m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i] << 5) | (buffer[i+1] >> 3);
- m_copy_matrix |= 1;
- buffer += 64;
+ {
+ for(int i = 0; i < 64; i++)
+ m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i] << 5) | (buffer[i+1] >> 3);
+ m_copy_matrix |= 1;
+ buffer += 64;
}
if(buffer[0] & 4)
- {
- for(int i = 0; i < 64; i++)
- m_non_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i] << 6) | (buffer[i+1] >> 2);
- m_copy_matrix |= 2;
+ {
+ for(int i = 0; i < 64; i++)
+ m_non_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i] << 6) | (buffer[i+1] >> 2);
+ m_copy_matrix |= 2;
}
return 0;
@@ -1447,27 +1408,27 @@ int CMpeg2Dec::picture_display_ext()
int nb_pos = picture->nb_fields;
if(m_sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
- nb_pos >>= 1;
+ nb_pos >>= 1;
- int i = 0;
+ int i = 0;
for(; i < nb_pos; i++)
- {
- int x = ((buffer[4*i] << 24) | (buffer[4*i+1] << 16) |
- (buffer[4*i+2] << 8) | buffer[4*i+3]) >> (11 - 2 * i);
- int y = ((buffer[4*i+2] << 24) | (buffer[4*i+3] << 16) |
- (buffer[4*i+4] << 8) | buffer[4*i+5]) >> (10 - 2 * i);
- if(!(x & y & 1))
- return 1;
-
- picture->display_offset[i].x = m_display_offset_x = x >> 1;
- picture->display_offset[i].y = m_display_offset_y = y >> 1;
- }
+ {
+ int x = ((buffer[4*i] << 24) | (buffer[4*i+1] << 16) |
+ (buffer[4*i+2] << 8) | buffer[4*i+3]) >> (11-2*i);
+ int y = ((buffer[4*i+2] << 24) | (buffer[4*i+3] << 16) |
+ (buffer[4*i+4] << 8) | buffer[4*i+5]) >> (10-2*i);
+ if(!(x&y&1))
+ return 1;
+
+ picture->display_offset[i].x = m_display_offset_x = x >> 1;
+ picture->display_offset[i].y = m_display_offset_y = y >> 1;
+ }
for(; i < 3; i++)
- {
- picture->display_offset[i].x = m_display_offset_x;
- picture->display_offset[i].y = m_display_offset_y;
+ {
+ picture->display_offset[i].x = m_display_offset_x;
+ picture->display_offset[i].y = m_display_offset_y;
}
return 0;
@@ -1487,25 +1448,25 @@ int CMpeg2Dec::picture_coding_ext()
m_decoder.m_intra_dc_precision = (buffer[2] >> 2) & 3;
m_decoder.m_picture_structure = buffer[2] & 3;
switch(m_decoder.m_picture_structure)
- {
+ {
case TOP_FIELD:
- picture->flags |= PIC_FLAG_TOP_FIELD_FIRST;
+ picture->flags |= PIC_FLAG_TOP_FIELD_FIRST;
case BOTTOM_FIELD:
- picture->nb_fields = 1;
- break;
+ picture->nb_fields = 1;
+ break;
case FRAME_PICTURE:
- if(!(m_sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE))
- {
- picture->nb_fields = (buffer[3] & 2) ? 3 : 2;
- picture->flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0;
- }
- else
- {
- picture->nb_fields = (buffer[3] & 2) ? ((buffer[3] & 128) ? 6 : 4) : 2;
- }
- break;
+ if(!(m_sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE))
+ {
+ picture->nb_fields = (buffer[3] & 2) ? 3 : 2;
+ picture->flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0;
+ }
+ else
+ {
+ picture->nb_fields = (buffer[3]&2) ? ((buffer[3]&128) ? 6 : 4) : 2;
+ }
+ break;
default:
- return 1;
+ return 1;
}
m_decoder.m_top_field_first = buffer[3] >> 7;
@@ -1515,12 +1476,12 @@ int CMpeg2Dec::picture_coding_ext()
m_decoder.m_intra_vlc_format = (buffer[3] >> 3) & 1;
m_decoder.m_scan = (buffer[3] & 4) ? mpeg2_scan_alt_2 : mpeg2_scan_norm_2;
- if(buffer[3] & 2)
- picture->flags |= PIC_FLAG_REPEAT_FIRST_FIELD;
+ if(buffer[3] & 2)
+ picture->flags |= PIC_FLAG_REPEAT_FIRST_FIELD;
picture->flags |= (buffer[4] & 0x80) ? PIC_FLAG_PROGRESSIVE_FRAME : 0;
if(buffer[4] & 0x40)
- picture->flags |= (((buffer[4] << 26) | (buffer[5] << 18) | (buffer[6] << 10)) & PIC_MASK_COMPOSITE_DISPLAY) | PIC_FLAG_COMPOSITE_DISPLAY;
+ picture->flags |= (((buffer[4]<<26) | (buffer[5]<<18) | (buffer[6]<<10)) & PIC_MASK_COMPOSITE_DISPLAY) | PIC_FLAG_COMPOSITE_DISPLAY;
m_ext_state = PIC_DISPLAY_EXT | COPYRIGHT_EXT | QUANT_MATRIX_EXT;
@@ -1568,45 +1529,38 @@ do { \
/* take num bits from the high part of bit_buf and sign extend them */
#define SBITS(bit_buf,num) (((int32_t)(bit_buf)) >> (32 - (num)))
-typedef struct
-{
+typedef struct {
uint8_t modes;
uint8_t len;
} MBtab;
-typedef struct
-{
+typedef struct {
uint8_t delta;
uint8_t len;
} MVtab;
-typedef struct
-{
+typedef struct {
int8_t dmv;
uint8_t len;
} DMVtab;
-typedef struct
-{
+typedef struct {
uint8_t cbp;
uint8_t len;
} CBPtab;
-typedef struct
-{
+typedef struct {
uint8_t size;
uint8_t len;
} DCtab;
-typedef struct
-{
+typedef struct {
uint8_t run;
uint8_t level;
uint8_t len;
} DCTtab;
-typedef struct
-{
+typedef struct {
uint8_t mba;
uint8_t len;
} MBAtab;
@@ -1615,50 +1569,47 @@ typedef struct
#define INTRA MACROBLOCK_INTRA
#define QUANT MACROBLOCK_QUANT
-static const MBtab MB_I [] =
-{
- {INTRA | QUANT, 2}, {INTRA, 1}
+static const MBtab MB_I [] = {
+ {INTRA|QUANT, 2}, {INTRA, 1}
};
#define MC MACROBLOCK_MOTION_FORWARD
#define CODED MACROBLOCK_PATTERN
-static const MBtab MB_P [] =
-{
- {INTRA | QUANT, 6}, {CODED | QUANT, 5}, {MC | CODED | QUANT, 5}, {INTRA, 5},
+static const MBtab MB_P [] = {
+ {INTRA|QUANT, 6}, {CODED|QUANT, 5}, {MC|CODED|QUANT, 5}, {INTRA, 5},
{MC, 3}, {MC, 3}, {MC, 3}, {MC, 3},
{CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
{CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
- {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1},
- {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1},
- {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1},
- {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1}, {MC | CODED, 1}
+ {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
+ {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
+ {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
+ {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}
};
#define FWD MACROBLOCK_MOTION_FORWARD
#define BWD MACROBLOCK_MOTION_BACKWARD
#define INTER MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD
-static const MBtab MB_B [] =
-{
- {0, 0}, {INTRA | QUANT, 6},
- {BWD | CODED | QUANT, 6}, {FWD | CODED | QUANT, 6},
- {INTER | CODED | QUANT, 5}, {INTER | CODED | QUANT, 5},
- {INTRA, 5}, {INTRA, 5},
+static const MBtab MB_B [] = {
+ {0, 0}, {INTRA|QUANT, 6},
+ {BWD|CODED|QUANT, 6}, {FWD|CODED|QUANT, 6},
+ {INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
+ {INTRA, 5}, {INTRA, 5},
{FWD, 4}, {FWD, 4}, {FWD, 4}, {FWD, 4},
- {FWD | CODED, 4}, {FWD | CODED, 4}, {FWD | CODED, 4}, {FWD | CODED, 4},
+ {FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4},
{BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
{BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
- {BWD | CODED, 3}, {BWD | CODED, 3}, {BWD | CODED, 3}, {BWD | CODED, 3},
- {BWD | CODED, 3}, {BWD | CODED, 3}, {BWD | CODED, 3}, {BWD | CODED, 3},
+ {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
+ {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
- {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2},
- {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2},
- {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2},
- {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2}, {INTER | CODED, 2}
+ {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
+ {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
+ {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
+ {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}
};
#undef INTRA
@@ -1670,30 +1621,26 @@ static const MBtab MB_B [] =
#undef INTER
-static const MVtab MV_4 [] =
-{
+static const MVtab MV_4 [] = {
{ 3, 6}, { 2, 4}, { 1, 3}, { 1, 3}, { 0, 2}, { 0, 2}, { 0, 2}, { 0, 2}
};
-static const MVtab MV_10 [] =
-{
- { 0, 10}, { 0, 10}, { 0, 10}, { 0, 10}, { 0, 10}, { 0, 10}, { 0, 10}, { 0, 10},
- { 0, 10}, { 0, 10}, { 0, 10}, { 0, 10}, {15, 10}, {14, 10}, {13, 10}, {12, 10},
- {11, 10}, {10, 10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
+static const MVtab MV_10 [] = {
+ { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10},
+ { 0,10}, { 0,10}, { 0,10}, { 0,10}, {15,10}, {14,10}, {13,10}, {12,10},
+ {11,10}, {10,10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
{ 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7},
{ 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7},
{ 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}
};
-static const DMVtab DMV_2 [] =
-{
- { 0, 1}, { 0, 1}, { 1, 2}, { -1, 2}
+static const DMVtab DMV_2 [] = {
+ { 0, 1}, { 0, 1}, { 1, 2}, {-1, 2}
};
-static const CBPtab CBP_7 [] =
-{
+static const CBPtab CBP_7 [] = {
{0x22, 7}, {0x12, 7}, {0x0a, 7}, {0x06, 7},
{0x21, 7}, {0x11, 7}, {0x09, 7}, {0x05, 7},
{0x3f, 6}, {0x3f, 6}, {0x03, 6}, {0x03, 6},
@@ -1724,8 +1671,7 @@ static const CBPtab CBP_7 [] =
{0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3}
};
-static const CBPtab CBP_9 [] =
-{
+static const CBPtab CBP_9 [] = {
{0, 0}, {0x00, 9}, {0x27, 9}, {0x1b, 9},
{0x3b, 9}, {0x37, 9}, {0x2f, 9}, {0x1f, 9},
{0x3a, 8}, {0x3a, 8}, {0x36, 8}, {0x36, 8},
@@ -1745,24 +1691,21 @@ static const CBPtab CBP_9 [] =
};
-static const DCtab DC_lum_5 [] =
-{
+static const DCtab DC_lum_5 [] = {
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
{0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
{4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}
};
-static const DCtab DC_chrom_5 [] =
-{
+static const DCtab DC_chrom_5 [] = {
{0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
{3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}
};
-static const DCtab DC_long [] =
-{
+static const DCtab DC_long [] = {
{6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
{6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
{7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, { 7, 6}, { 7, 6},
@@ -1770,58 +1713,53 @@ static const DCtab DC_long [] =
};
-static const DCTtab DCT_16 [] =
-{
+static const DCTtab DCT_16 [] = {
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
- { 2, 18, 0}, { 2, 17, 0}, { 2, 16, 0}, { 2, 15, 0},
+ { 2,18, 0}, { 2,17, 0}, { 2,16, 0}, { 2,15, 0},
{ 7, 3, 0}, { 17, 2, 0}, { 16, 2, 0}, { 15, 2, 0},
{ 14, 2, 0}, { 13, 2, 0}, { 12, 2, 0}, { 32, 1, 0},
{ 31, 1, 0}, { 30, 1, 0}, { 29, 1, 0}, { 28, 1, 0}
};
-static const DCTtab DCT_15 [] =
-{
- { 1, 40, 15}, { 1, 39, 15}, { 1, 38, 15}, { 1, 37, 15},
- { 1, 36, 15}, { 1, 35, 15}, { 1, 34, 15}, { 1, 33, 15},
- { 1, 32, 15}, { 2, 14, 15}, { 2, 13, 15}, { 2, 12, 15},
- { 2, 11, 15}, { 2, 10, 15}, { 2, 9, 15}, { 2, 8, 15},
- { 1, 31, 14}, { 1, 31, 14}, { 1, 30, 14}, { 1, 30, 14},
- { 1, 29, 14}, { 1, 29, 14}, { 1, 28, 14}, { 1, 28, 14},
- { 1, 27, 14}, { 1, 27, 14}, { 1, 26, 14}, { 1, 26, 14},
- { 1, 25, 14}, { 1, 25, 14}, { 1, 24, 14}, { 1, 24, 14},
- { 1, 23, 14}, { 1, 23, 14}, { 1, 22, 14}, { 1, 22, 14},
- { 1, 21, 14}, { 1, 21, 14}, { 1, 20, 14}, { 1, 20, 14},
- { 1, 19, 14}, { 1, 19, 14}, { 1, 18, 14}, { 1, 18, 14},
- { 1, 17, 14}, { 1, 17, 14}, { 1, 16, 14}, { 1, 16, 14}
+static const DCTtab DCT_15 [] = {
+ { 1,40,15}, { 1,39,15}, { 1,38,15}, { 1,37,15},
+ { 1,36,15}, { 1,35,15}, { 1,34,15}, { 1,33,15},
+ { 1,32,15}, { 2,14,15}, { 2,13,15}, { 2,12,15},
+ { 2,11,15}, { 2,10,15}, { 2, 9,15}, { 2, 8,15},
+ { 1,31,14}, { 1,31,14}, { 1,30,14}, { 1,30,14},
+ { 1,29,14}, { 1,29,14}, { 1,28,14}, { 1,28,14},
+ { 1,27,14}, { 1,27,14}, { 1,26,14}, { 1,26,14},
+ { 1,25,14}, { 1,25,14}, { 1,24,14}, { 1,24,14},
+ { 1,23,14}, { 1,23,14}, { 1,22,14}, { 1,22,14},
+ { 1,21,14}, { 1,21,14}, { 1,20,14}, { 1,20,14},
+ { 1,19,14}, { 1,19,14}, { 1,18,14}, { 1,18,14},
+ { 1,17,14}, { 1,17,14}, { 1,16,14}, { 1,16,14}
};
-static const DCTtab DCT_13 [] =
-{
- { 11, 2, 13}, { 10, 2, 13}, { 6, 3, 13}, { 4, 4, 13},
- { 3, 5, 13}, { 2, 7, 13}, { 2, 6, 13}, { 1, 15, 13},
- { 1, 14, 13}, { 1, 13, 13}, { 1, 12, 13}, { 27, 1, 13},
- { 26, 1, 13}, { 25, 1, 13}, { 24, 1, 13}, { 23, 1, 13},
- { 1, 11, 12}, { 1, 11, 12}, { 9, 2, 12}, { 9, 2, 12},
- { 5, 3, 12}, { 5, 3, 12}, { 1, 10, 12}, { 1, 10, 12},
- { 3, 4, 12}, { 3, 4, 12}, { 8, 2, 12}, { 8, 2, 12},
- { 22, 1, 12}, { 22, 1, 12}, { 21, 1, 12}, { 21, 1, 12},
- { 1, 9, 12}, { 1, 9, 12}, { 20, 1, 12}, { 20, 1, 12},
- { 19, 1, 12}, { 19, 1, 12}, { 2, 5, 12}, { 2, 5, 12},
- { 4, 3, 12}, { 4, 3, 12}, { 1, 8, 12}, { 1, 8, 12},
- { 7, 2, 12}, { 7, 2, 12}, { 18, 1, 12}, { 18, 1, 12}
+static const DCTtab DCT_13 [] = {
+ { 11, 2,13}, { 10, 2,13}, { 6, 3,13}, { 4, 4,13},
+ { 3, 5,13}, { 2, 7,13}, { 2, 6,13}, { 1,15,13},
+ { 1,14,13}, { 1,13,13}, { 1,12,13}, { 27, 1,13},
+ { 26, 1,13}, { 25, 1,13}, { 24, 1,13}, { 23, 1,13},
+ { 1,11,12}, { 1,11,12}, { 9, 2,12}, { 9, 2,12},
+ { 5, 3,12}, { 5, 3,12}, { 1,10,12}, { 1,10,12},
+ { 3, 4,12}, { 3, 4,12}, { 8, 2,12}, { 8, 2,12},
+ { 22, 1,12}, { 22, 1,12}, { 21, 1,12}, { 21, 1,12},
+ { 1, 9,12}, { 1, 9,12}, { 20, 1,12}, { 20, 1,12},
+ { 19, 1,12}, { 19, 1,12}, { 2, 5,12}, { 2, 5,12},
+ { 4, 3,12}, { 4, 3,12}, { 1, 8,12}, { 1, 8,12},
+ { 7, 2,12}, { 7, 2,12}, { 18, 1,12}, { 18, 1,12}
};
-static const DCTtab DCT_B14_10 [] =
-{
- { 17, 1, 10}, { 6, 2, 10}, { 1, 7, 10}, { 3, 3, 10},
- { 2, 4, 10}, { 16, 1, 10}, { 15, 1, 10}, { 5, 2, 10}
+static const DCTtab DCT_B14_10 [] = {
+ { 17, 1,10}, { 6, 2,10}, { 1, 7,10}, { 3, 3,10},
+ { 2, 4,10}, { 16, 1,10}, { 15, 1,10}, { 5, 2,10}
};
-static const DCTtab DCT_B14_8 [] =
-{
+static const DCTtab DCT_B14_8 [] = {
{ 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
{ 3, 2, 7}, { 3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
{ 1, 4, 7}, { 1, 4, 7}, { 9, 1, 7}, { 9, 1, 7},
@@ -1833,9 +1771,8 @@ static const DCTtab DCT_B14_8 [] =
{ 4, 2, 8}, { 2, 3, 8}, { 1, 5, 8}, { 11, 1, 8}
};
-static const DCTtab DCT_B14AC_5 [] =
-{
- { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
+static const DCTtab DCT_B14AC_5 [] = {
+ { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
{ 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
@@ -1844,9 +1781,8 @@ static const DCTtab DCT_B14AC_5 [] =
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}
};
-static const DCTtab DCT_B14DC_5 [] =
-{
- { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
+static const DCTtab DCT_B14DC_5 [] = {
+ { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
{ 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
@@ -1855,14 +1791,12 @@ static const DCTtab DCT_B14DC_5 [] =
{ 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}
};
-static const DCTtab DCT_B15_10 [] =
-{
+static const DCTtab DCT_B15_10 [] = {
{ 6, 2, 9}, { 6, 2, 9}, { 15, 1, 9}, { 15, 1, 9},
- { 3, 4, 10}, { 17, 1, 10}, { 16, 1, 9}, { 16, 1, 9}
+ { 3, 4,10}, { 17, 1,10}, { 16, 1, 9}, { 16, 1, 9}
};
-static const DCTtab DCT_B15_8 [] =
-{
+static const DCTtab DCT_B15_8 [] = {
{ 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
{ 8, 1, 7}, { 8, 1, 7}, { 9, 1, 7}, { 9, 1, 7},
{ 7, 1, 7}, { 7, 1, 7}, { 3, 2, 7}, { 3, 2, 7},
@@ -1870,7 +1804,7 @@ static const DCTtab DCT_B15_8 [] =
{ 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6},
{ 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6},
{ 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6},
- { 2, 5, 8}, { 12, 1, 8}, { 1, 11, 8}, { 1, 10, 8},
+ { 2, 5, 8}, { 12, 1, 8}, { 1,11, 8}, { 1,10, 8},
{ 14, 1, 8}, { 13, 1, 8}, { 4, 2, 8}, { 2, 4, 8},
{ 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
{ 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
@@ -1924,21 +1858,19 @@ static const DCTtab DCT_B15_8 [] =
{ 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5},
{ 10, 1, 7}, { 10, 1, 7}, { 2, 3, 7}, { 2, 3, 7},
{ 11, 1, 7}, { 11, 1, 7}, { 1, 8, 7}, { 1, 8, 7},
- { 1, 9, 7}, { 1, 9, 7}, { 1, 12, 8}, { 1, 13, 8},
- { 3, 3, 8}, { 5, 2, 8}, { 1, 14, 8}, { 1, 15, 8}
+ { 1, 9, 7}, { 1, 9, 7}, { 1,12, 8}, { 1,13, 8},
+ { 3, 3, 8}, { 5, 2, 8}, { 1,14, 8}, { 1,15, 8}
};
-static const MBAtab MBA_5 [] =
-{
- {6, 5}, {5, 5}, {4, 4}, {4, 4}, {3, 4}, {3, 4},
+static const MBAtab MBA_5 [] = {
+ {6, 5}, {5, 5}, {4, 4}, {4, 4}, {3, 4}, {3, 4},
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1},
{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}
};
-static const MBAtab MBA_11 [] =
-{
+static const MBAtab MBA_11 [] = {
{32, 11}, {31, 11}, {30, 11}, {29, 11},
{28, 11}, {27, 11}, {26, 11}, {25, 11},
{24, 11}, {23, 11}, {22, 11}, {21, 11},
@@ -1970,10 +1902,9 @@ static const MBAtab MBA_11 [] =
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
-static int non_linear_quantizer_scale [] =
-{
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 10, 12, 14, 16, 18, 20, 22,
+static int non_linear_quantizer_scale [] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 10, 12, 14, 16, 18, 20, 22,
24, 28, 32, 36, 40, 44, 48, 52,
56, 64, 72, 80, 88, 96, 104, 112
};
@@ -1982,29 +1913,29 @@ bool CMpeg2Decoder::m_idct_initialized = false;
CMpeg2Decoder::CMpeg2Decoder()
{
- memset(&m_b_motion, 0, sizeof(m_b_motion));
- memset(&m_f_motion, 0, sizeof(m_f_motion));
+ memset(&m_b_motion, 0, sizeof(m_b_motion));
+ memset(&m_f_motion, 0, sizeof(m_f_motion));
- m_DCTblock = (int16_t*)_aligned_malloc(64 * sizeof(int16_t), 16);
- memset(m_DCTblock, 0, 64 * sizeof(int16_t));
+ m_DCTblock = (int16_t*)_aligned_malloc(64*sizeof(int16_t), 16);
+ memset(m_DCTblock, 0, 64*sizeof(int16_t));
m_bitstream_buf = 0;
m_bitstream_bits = 0;
m_bitstream_ptr = NULL;
-
- memset(&m_dest, 0, sizeof(m_dest));
- memset(&m_picture_dest, 0, sizeof(m_picture_dest));
+
+ memset(&m_dest, 0, sizeof(m_dest));
+ memset(&m_picture_dest, 0, sizeof(m_picture_dest));
m_offset = m_stride = m_uv_stride = 0;
m_limit_x = m_limit_y_16 = m_limit_y_8 = m_limit_y = 0;
- memset(&m_dc_dct_pred, 0, sizeof(m_dc_dct_pred));
+ memset(&m_dc_dct_pred, 0, sizeof(m_dc_dct_pred));
m_quantizer_scale = m_dmv_offset = 0;
m_v_offset = 0;
- memset(&m_intra_quantizer_matrix, 0, sizeof(m_intra_quantizer_matrix));
- memset(&m_non_intra_quantizer_matrix, 0, sizeof(m_non_intra_quantizer_matrix));
+ memset(&m_intra_quantizer_matrix, 0, sizeof(m_intra_quantizer_matrix));
+ memset(&m_non_intra_quantizer_matrix, 0, sizeof(m_non_intra_quantizer_matrix));
m_width = m_height = 0;
m_vertical_position_extension = 0;
@@ -2013,171 +1944,171 @@ CMpeg2Decoder::CMpeg2Decoder()
m_intra_dc_precision = 0;
m_picture_structure = 0;
- m_frame_pred_frame_dct = 0;
+ m_frame_pred_frame_dct = 0;
m_concealment_motion_vectors = 0;
m_q_scale_type = 0;
m_intra_vlc_format = 0;
m_top_field_first = 0;
- m_scan = NULL;
+ m_scan = NULL;
m_second_field = 0;
- m_mpeg1 = 0;
+ m_mpeg1 = 0;
- if(g_cpuid.m_flags & CCpuID::sse2)
- {
- m_idct_init = mpeg2_idct_init_sse2;
- m_idct_copy = mpeg2_idct_copy_sse2;
- m_idct_add = mpeg2_idct_add_sse2;
- m_mc = &mpeg2_mc_sse2;
- }
+ if(g_cpuid.m_flags&CCpuID::sse2)
+ {
+ m_idct_init = mpeg2_idct_init_sse2;
+ m_idct_copy = mpeg2_idct_copy_sse2;
+ m_idct_add = mpeg2_idct_add_sse2;
+ m_mc = &mpeg2_mc_sse2;
+ }
#ifndef _WIN64
- else if(g_cpuid.m_flags & CCpuID::mmx)
- {
- m_idct_init = mpeg2_idct_init_mmx;
- m_idct_copy = mpeg2_idct_copy_mmx;
- m_idct_add = mpeg2_idct_add_mmx;
- m_mc = &mpeg2_mc_mmx;
- }
- else
+ else if(g_cpuid.m_flags&CCpuID::mmx)
+ {
+ m_idct_init = mpeg2_idct_init_mmx;
+ m_idct_copy = mpeg2_idct_copy_mmx;
+ m_idct_add = mpeg2_idct_add_mmx;
+ m_mc = &mpeg2_mc_mmx;
+ }
+ else
#endif
- {
- m_idct_init = mpeg2_idct_init_c;
- m_idct_copy = mpeg2_idct_copy_c;
- m_idct_add = mpeg2_idct_add_c;
- m_mc = &mpeg2_mc_c;
- }
- if(!m_idct_initialized)
- {
- m_idct_init();
- m_idct_initialized = true;
- }
+ {
+ m_idct_init = mpeg2_idct_init_c;
+ m_idct_copy = mpeg2_idct_copy_c;
+ m_idct_add = mpeg2_idct_add_c;
+ m_mc = &mpeg2_mc_c;
+ }
+ if(!m_idct_initialized)
+ {
+ m_idct_init();
+ m_idct_initialized = true;
+ }
}
CMpeg2Decoder::~CMpeg2Decoder()
{
- if(m_DCTblock) _aligned_free(m_DCTblock);
+ if(m_DCTblock) _aligned_free(m_DCTblock);
}
#define bit_buf (m_bitstream_buf)
#define bits (m_bitstream_bits)
#define bit_ptr (m_bitstream_ptr)
-
+
int CMpeg2Decoder::get_macroblock_modes()
{
- int macroblock_modes;
+ int macroblock_modes;
const MBtab* tab;
switch(m_coding_type)
- {
- case P_TYPE:
- tab = MB_P + UBITS(bit_buf, 5);
- DUMPBITS(tab->len);
- macroblock_modes = tab->modes;
-
- if(m_picture_structure != FRAME_PICTURE)
- {
- if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- return macroblock_modes;
- }
- else if(m_frame_pred_frame_dct)
- {
- if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
- macroblock_modes |= MC_FRAME;
-
- return macroblock_modes;
- }
-
- if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- if(macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN))
- {
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
-
- return macroblock_modes;
-
- case B_TYPE:
- tab = MB_B + UBITS(bit_buf, 6);
- DUMPBITS(tab->len);
- macroblock_modes = tab->modes;
-
- if(m_picture_structure != FRAME_PICTURE)
- {
- if(!(macroblock_modes & MACROBLOCK_INTRA))
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- return macroblock_modes;
- }
- else if(m_frame_pred_frame_dct)
- {
- // if(!(macroblock_modes & MACROBLOCK_INTRA))
- macroblock_modes |= MC_FRAME;
-
- return macroblock_modes;
- }
- /*
- if(macroblock_modes & MACROBLOCK_INTRA)
- goto intra;
-
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
-
- if(macroblock_modes & (MACROBLOCK_INTRA|MACROBLOCK_PATTERN))
- {
- intra:
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
- */
- if(!(macroblock_modes & MACROBLOCK_INTRA))
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- if(macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN))
- {
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
-
- return macroblock_modes;
+ {
+ case P_TYPE:
+ tab = MB_P + UBITS(bit_buf, 5);
+ DUMPBITS(tab->len);
+ macroblock_modes = tab->modes;
+
+ if(m_picture_structure != FRAME_PICTURE)
+ {
+ if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
+ {
+ macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
+ DUMPBITS(2);
+ }
+
+ return macroblock_modes;
+ }
+ else if(m_frame_pred_frame_dct)
+ {
+ if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
+ macroblock_modes |= MC_FRAME;
+
+ return macroblock_modes;
+ }
+
+ if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
+ {
+ macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
+ DUMPBITS(2);
+ }
+
+ if(macroblock_modes & (MACROBLOCK_INTRA|MACROBLOCK_PATTERN))
+ {
+ macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
+ DUMPBITS(1);
+ }
+
+ return macroblock_modes;
+
+ case B_TYPE:
+ tab = MB_B + UBITS(bit_buf, 6);
+ DUMPBITS(tab->len);
+ macroblock_modes = tab->modes;
+
+ if(m_picture_structure != FRAME_PICTURE)
+ {
+ if(!(macroblock_modes & MACROBLOCK_INTRA))
+ {
+ macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
+ DUMPBITS(2);
+ }
+
+ return macroblock_modes;
+ }
+ else if(m_frame_pred_frame_dct)
+ {
+ // if(!(macroblock_modes & MACROBLOCK_INTRA))
+ macroblock_modes |= MC_FRAME;
+
+ return macroblock_modes;
+ }
+/*
+ if(macroblock_modes & MACROBLOCK_INTRA)
+ goto intra;
+
+ macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
+ DUMPBITS(2);
+
+ if(macroblock_modes & (MACROBLOCK_INTRA|MACROBLOCK_PATTERN))
+ {
+intra:
+ macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
+ DUMPBITS(1);
+ }
+*/
+ if(!(macroblock_modes & MACROBLOCK_INTRA))
+ {
+ macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
+ DUMPBITS(2);
+ }
- case I_TYPE:
- tab = MB_I + UBITS(bit_buf, 1);
- DUMPBITS(tab->len);
- macroblock_modes = tab->modes;
+ if(macroblock_modes & (MACROBLOCK_INTRA|MACROBLOCK_PATTERN))
+ {
+ macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
+ DUMPBITS(1);
+ }
- if(!m_frame_pred_frame_dct && m_picture_structure == FRAME_PICTURE)
- {
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
+ return macroblock_modes;
- return macroblock_modes;
+ case I_TYPE:
+ tab = MB_I + UBITS(bit_buf, 1);
+ DUMPBITS(tab->len);
+ macroblock_modes = tab->modes;
- case D_TYPE:
+ if(!m_frame_pred_frame_dct && m_picture_structure == FRAME_PICTURE)
+ {
+ macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
+ DUMPBITS(1);
+ }
- DUMPBITS(1);
- return MACROBLOCK_INTRA;
- }
+ return macroblock_modes;
- return 0;
+ case D_TYPE:
+
+ DUMPBITS(1);
+ return MACROBLOCK_INTRA;
+ }
+
+ return 0;
}
int CMpeg2Decoder::get_quantizer_scale()
@@ -2185,9 +2116,9 @@ int CMpeg2Decoder::get_quantizer_scale()
int quantizer_scale_code = UBITS(bit_buf, 5);
DUMPBITS(5);
- return m_q_scale_type
- ? non_linear_quantizer_scale[quantizer_scale_code]
- : (quantizer_scale_code << 1);
+ return m_q_scale_type
+ ? non_linear_quantizer_scale[quantizer_scale_code]
+ : (quantizer_scale_code << 1);
}
int CMpeg2Decoder::get_motion_delta(const int f_code)
@@ -2197,47 +2128,47 @@ int CMpeg2Decoder::get_motion_delta(const int f_code)
const MVtab* tab;
if(bit_buf & 0x80000000)
- {
- DUMPBITS(1);
- return 0;
+ {
+ DUMPBITS(1);
+ return 0;
}
- else if(bit_buf >= 0x0c000000)
- {
- tab = MV_4 + UBITS(bit_buf, 4);
- delta = (tab->delta << f_code) + 1;
- bits += tab->len + f_code + 1;
- bit_buf <<= tab->len;
+ else if(bit_buf >= 0x0c000000)
+ {
+ tab = MV_4 + UBITS(bit_buf, 4);
+ delta = (tab->delta << f_code) + 1;
+ bits += tab->len + f_code + 1;
+ bit_buf <<= tab->len;
- sign = SBITS(bit_buf, 1);
- bit_buf <<= 1;
+ sign = SBITS(bit_buf, 1);
+ bit_buf <<= 1;
- if(f_code)
- {
- delta += UBITS(bit_buf, f_code);
- }
+ if(f_code)
+ {
+ delta += UBITS(bit_buf, f_code);
+ }
- bit_buf <<= f_code;
+ bit_buf <<= f_code;
- return (delta ^ sign) - sign;
+ return (delta ^ sign) - sign;
}
- else
- {
- tab = MV_10 + UBITS(bit_buf, 10);
- delta = (tab->delta << f_code) + 1;
- bits += tab->len + 1;
- bit_buf <<= tab->len;
-
- sign = SBITS(bit_buf, 1);
- bit_buf <<= 1;
-
- if(f_code)
- {
- NEEDBITS;
- delta += UBITS(bit_buf, f_code);
- DUMPBITS(f_code);
- }
-
- return (delta ^ sign) - sign;
+ else
+ {
+ tab = MV_10 + UBITS(bit_buf, 10);
+ delta = (tab->delta << f_code) + 1;
+ bits += tab->len + 1;
+ bit_buf <<= tab->len;
+
+ sign = SBITS(bit_buf, 1);
+ bit_buf <<= 1;
+
+ if(f_code)
+ {
+ NEEDBITS;
+ delta += UBITS(bit_buf, f_code);
+ DUMPBITS(f_code);
+ }
+
+ return (delta ^ sign) - sign;
}
}
@@ -2260,16 +2191,16 @@ int CMpeg2Decoder::get_coded_block_pattern()
NEEDBITS;
if(bit_buf >= 0x20000000)
- {
- tab = CBP_7 + (UBITS(bit_buf, 7) - 16);
- DUMPBITS(tab->len);
- return tab->cbp;
+ {
+ tab = CBP_7 + (UBITS(bit_buf, 7) - 16);
+ DUMPBITS(tab->len);
+ return tab->cbp;
}
- else
- {
- tab = CBP_9 + UBITS(bit_buf, 9);
- DUMPBITS(tab->len);
- return tab->cbp;
+ else
+ {
+ tab = CBP_9 + UBITS(bit_buf, 9);
+ DUMPBITS(tab->len);
+ return tab->cbp;
}
}
@@ -2280,33 +2211,33 @@ int CMpeg2Decoder::get_luma_dc_dct_diff()
int dc_diff;
if(bit_buf < 0xf8000000)
- {
- tab = DC_lum_5 + UBITS(bit_buf, 5);
- size = tab->size;
- if(size)
- {
- bits += tab->len + size;
- bit_buf <<= tab->len;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- bit_buf <<= size;
- return dc_diff;
- }
- else
- {
- DUMPBITS(3);
- return 0;
- }
- }
- else
- {
- tab = DC_long + (UBITS(bit_buf, 9) - 0x1e0);
- size = tab->size;
- DUMPBITS(tab->len);
- NEEDBITS;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- DUMPBITS(size);
- return dc_diff;
- }
+ {
+ tab = DC_lum_5 + UBITS(bit_buf, 5);
+ size = tab->size;
+ if(size)
+ {
+ bits += tab->len + size;
+ bit_buf <<= tab->len;
+ dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
+ bit_buf <<= size;
+ return dc_diff;
+ }
+ else
+ {
+ DUMPBITS(3);
+ return 0;
+ }
+ }
+ else
+ {
+ tab = DC_long + (UBITS(bit_buf, 9) - 0x1e0);
+ size = tab->size;
+ DUMPBITS(tab->len);
+ NEEDBITS;
+ dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
+ DUMPBITS(size);
+ return dc_diff;
+ }
}
int CMpeg2Decoder::get_chroma_dc_dct_diff()
@@ -2316,34 +2247,34 @@ int CMpeg2Decoder::get_chroma_dc_dct_diff()
int dc_diff;
if(bit_buf < 0xf8000000)
- {
- tab = DC_chrom_5 + UBITS(bit_buf, 5);
- size = tab->size;
-
- if(size)
- {
- bits += tab->len + size;
- bit_buf <<= tab->len;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- bit_buf <<= size;
- return dc_diff;
- }
- else
- {
- DUMPBITS(2);
- return 0;
- }
- }
- else
- {
- tab = DC_long + (UBITS(bit_buf, 10) - 0x3e0);
- size = tab->size;
- DUMPBITS(tab->len + 1);
- NEEDBITS;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- DUMPBITS(size);
- return dc_diff;
- }
+ {
+ tab = DC_chrom_5 + UBITS(bit_buf, 5);
+ size = tab->size;
+
+ if(size)
+ {
+ bits += tab->len + size;
+ bit_buf <<= tab->len;
+ dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
+ bit_buf <<= size;
+ return dc_diff;
+ }
+ else
+ {
+ DUMPBITS(2);
+ return 0;
+ }
+ }
+ else
+ {
+ tab = DC_long + (UBITS(bit_buf, 10) - 0x3e0);
+ size = tab->size;
+ DUMPBITS(tab->len + 1);
+ NEEDBITS;
+ dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
+ DUMPBITS(size);
+ return dc_diff;
+ }
}
#undef bit_buf
@@ -2381,101 +2312,101 @@ void CMpeg2Decoder::get_intra_block_B14()
NEEDBITS;
while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
-
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
-
- normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
-
- // if(bitstream_get (1)) val = -val;
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = (SBITS(bit_buf, 12) * quantizer_scale * quant_matrix[j]) / 16;
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- DUMPBITS(12);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD(bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- dest[63] ^= mismatch & 1;
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
+ {
+ if(bit_buf >= 0x28000000)
+ {
+ tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
+
+ i += tab->run;
+ if(i >= 64)
+ break; /* end of block */
+
+normal_code:
+ j = scan[i];
+ bit_buf <<= tab->len;
+ bits += tab->len + 1;
+ val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
+
+ // if(bitstream_get (1)) val = -val;
+ val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
+
+ SATURATE(val);
+ dest[j] = val;
+ mismatch ^= val;
+
+ bit_buf <<= 1;
+ NEEDBITS;
+
+ continue;
+ }
+ else if(bit_buf >= 0x04000000)
+ {
+ tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
+
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+
+ /* escape code */
+
+ i += UBITS(bit_buf << 6, 6) - 64;
+ if(i >= 64)
+ break; /* illegal, check needed to avoid buffer overflow */
+
+ j = scan[i];
+
+ DUMPBITS(12);
+ NEEDBITS;
+ val = (SBITS(bit_buf, 12) * quantizer_scale * quant_matrix[j]) / 16;
+
+ SATURATE(val);
+ dest[j] = val;
+ mismatch ^= val;
+
+ DUMPBITS(12);
+ NEEDBITS;
+
+ continue;
+ }
+ else if(bit_buf >= 0x02000000)
+ {
+ tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00800000)
+ {
+ tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00200000)
+ {
+ tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else
+ {
+ tab = DCT_16 + UBITS(bit_buf, 16);
+ bit_buf <<= 16;
+ GETWORD (bit_buf, bits + 16, bit_ptr);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+
+ break; /* illegal, check needed to avoid buffer overflow */
+ }
+
+ dest[63] ^= mismatch & 1;
+ DUMPBITS(2); /* dump end of block code */
+ m_bitstream_buf = bit_buf;
+ m_bitstream_bits = bits;
+ m_bitstream_ptr = bit_ptr;
}
void CMpeg2Decoder::get_intra_block_B15()
@@ -2502,102 +2433,102 @@ void CMpeg2Decoder::get_intra_block_B15()
NEEDBITS;
- while(1)
- {
- if(bit_buf >= 0x04000000)
- {
- tab = DCT_B15_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- {
- normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
-
- // if(bitstream_get (1)) val = -val;
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
- else
- {
- /* end of block. I commented out this code because if we */
- /* dont exit here we will still exit at the later test :) */
-
- /* if(i >= 128) break; */ /* end of block */
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check against buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = (SBITS(bit_buf, 12) *
- quantizer_scale * quant_matrix[j]) / 16;
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- DUMPBITS(12);
- NEEDBITS;
-
- continue;
- }
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B15_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD(bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- dest[63] ^= mismatch & 1;
- DUMPBITS(4); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
+ while(1)
+ {
+ if(bit_buf >= 0x04000000)
+ {
+ tab = DCT_B15_8 + (UBITS(bit_buf, 8) - 4);
+
+ i += tab->run;
+ if(i < 64)
+ {
+normal_code:
+ j = scan[i];
+ bit_buf <<= tab->len;
+ bits += tab->len + 1;
+ val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
+
+ // if(bitstream_get (1)) val = -val;
+ val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
+
+ SATURATE(val);
+ dest[j] = val;
+ mismatch ^= val;
+
+ bit_buf <<= 1;
+ NEEDBITS;
+
+ continue;
+ }
+ else
+ {
+ /* end of block. I commented out this code because if we */
+ /* dont exit here we will still exit at the later test :) */
+
+ /* if(i >= 128) break; */ /* end of block */
+
+ /* escape code */
+
+ i += UBITS(bit_buf << 6, 6) - 64;
+ if(i >= 64)
+ break; /* illegal, check against buffer overflow */
+
+ j = scan[i];
+
+ DUMPBITS(12);
+ NEEDBITS;
+ val = (SBITS(bit_buf, 12) *
+ quantizer_scale * quant_matrix[j]) / 16;
+
+ SATURATE(val);
+ dest[j] = val;
+ mismatch ^= val;
+
+ DUMPBITS(12);
+ NEEDBITS;
+
+ continue;
+ }
+ }
+ else if(bit_buf >= 0x02000000)
+ {
+ tab = DCT_B15_10 + (UBITS(bit_buf, 10) - 8);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00800000)
+ {
+ tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00200000)
+ {
+ tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else
+ {
+ tab = DCT_16 + UBITS(bit_buf, 16);
+ bit_buf <<= 16;
+ GETWORD(bit_buf, bits + 16, bit_ptr);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+
+ break; /* illegal, check needed to avoid buffer overflow */
+ }
+
+ dest[63] ^= mismatch & 1;
+ DUMPBITS(4); /* dump end of block code */
+ m_bitstream_buf = bit_buf;
+ m_bitstream_bits = bits;
+ m_bitstream_ptr = bit_ptr;
}
int CMpeg2Decoder::get_non_intra_block()
@@ -2624,115 +2555,115 @@ int CMpeg2Decoder::get_non_intra_block()
NEEDBITS;
if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14DC_5 + (UBITS(bit_buf, 5) - 5);
- goto entry_1;
- }
- else
- {
- goto entry_2;
+ {
+ tab = DCT_B14DC_5 + (UBITS(bit_buf, 5) - 5);
+ goto entry_1;
}
+ else
+ {
+ goto entry_2;
+ }
while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
- entry_1:
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
- normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = ((2 * tab->level + 1) * quantizer_scale * quant_matrix[j]) >> 5;
-
- /* if(bitstream_get (1)) val = -val; */
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
-
- entry_2:
- if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = 2 * (SBITS(bit_buf, 12) + SBITS(bit_buf, 1)) + 1;
- val = (val * quantizer_scale * quant_matrix[j]) / 32;
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- DUMPBITS(12);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD(bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- dest[63] ^= mismatch & 1;
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
-
- return i;
+ {
+ if(bit_buf >= 0x28000000)
+ {
+ tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
+entry_1:
+ i += tab->run;
+ if(i >= 64)
+ break; /* end of block */
+normal_code:
+ j = scan[i];
+ bit_buf <<= tab->len;
+ bits += tab->len + 1;
+ val = ((2*tab->level+1) * quantizer_scale * quant_matrix[j]) >> 5;
+
+ /* if(bitstream_get (1)) val = -val; */
+ val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
+
+ SATURATE(val);
+ dest[j] = val;
+ mismatch ^= val;
+
+ bit_buf <<= 1;
+ NEEDBITS;
+
+ continue;
+ }
+
+entry_2:
+ if(bit_buf >= 0x04000000)
+ {
+ tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
+
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+
+ /* escape code */
+
+ i += UBITS(bit_buf << 6, 6) - 64;
+ if(i >= 64)
+ break; /* illegal, check needed to avoid buffer overflow */
+
+ j = scan[i];
+
+ DUMPBITS(12);
+ NEEDBITS;
+ val = 2 * (SBITS(bit_buf, 12) + SBITS(bit_buf, 1)) + 1;
+ val = (val * quantizer_scale * quant_matrix[j]) / 32;
+
+ SATURATE(val);
+ dest[j] = val;
+ mismatch ^= val;
+
+ DUMPBITS(12);
+ NEEDBITS;
+
+ continue;
+ }
+ else if(bit_buf >= 0x02000000)
+ {
+ tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00800000)
+ {
+ tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00200000)
+ {
+ tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else
+ {
+ tab = DCT_16 + UBITS(bit_buf, 16);
+ bit_buf <<= 16;
+ GETWORD (bit_buf, bits + 16, bit_ptr);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+
+ break; /* illegal, check needed to avoid buffer overflow */
+ }
+
+ dest[63] ^= mismatch & 1;
+ DUMPBITS(2); /* dump end of block code */
+ m_bitstream_buf = bit_buf;
+ m_bitstream_bits = bits;
+ m_bitstream_ptr = bit_ptr;
+
+ return i;
}
void CMpeg2Decoder::get_mpeg1_intra_block()
@@ -2758,109 +2689,109 @@ void CMpeg2Decoder::get_mpeg1_intra_block()
NEEDBITS;
while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
-
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
- normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
-
- /* oddification */
- val = (val - 1) | 1;
-
- /* if(bitstream_get (1)) val = -val; */
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = SBITS(bit_buf, 8);
- if(!(val & 0x7f))
- {
- DUMPBITS(8);
- val = UBITS(bit_buf, 8) + 2 * val;
- }
- val = (val * quantizer_scale * quant_matrix[j]) / 16;
-
- /* oddification */
- val = (val + ~SBITS(val, 1)) | 1;
-
- SATURATE(val);
- dest[j] = val;
-
- DUMPBITS(8);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD(bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
+ {
+ if(bit_buf >= 0x28000000)
+ {
+ tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
+
+ i += tab->run;
+ if(i >= 64)
+ break; /* end of block */
+normal_code:
+ j = scan[i];
+ bit_buf <<= tab->len;
+ bits += tab->len + 1;
+ val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
+
+ /* oddification */
+ val = (val - 1) | 1;
+
+ /* if(bitstream_get (1)) val = -val; */
+ val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
+
+ SATURATE(val);
+ dest[j] = val;
+
+ bit_buf <<= 1;
+ NEEDBITS;
+
+ continue;
+ }
+ else if(bit_buf >= 0x04000000)
+ {
+ tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
+
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+
+ /* escape code */
+
+ i += UBITS(bit_buf << 6, 6) - 64;
+ if(i >= 64)
+ break; /* illegal, check needed to avoid buffer overflow */
+
+ j = scan[i];
+
+ DUMPBITS(12);
+ NEEDBITS;
+ val = SBITS(bit_buf, 8);
+ if(!(val & 0x7f))
+ {
+ DUMPBITS(8);
+ val = UBITS(bit_buf, 8) + 2 * val;
+ }
+ val = (val * quantizer_scale * quant_matrix[j]) / 16;
+
+ /* oddification */
+ val = (val + ~SBITS(val, 1)) | 1;
+
+ SATURATE(val);
+ dest[j] = val;
+
+ DUMPBITS(8);
+ NEEDBITS;
+
+ continue;
+ }
+ else if(bit_buf >= 0x02000000)
+ {
+ tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00800000)
+ {
+ tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00200000)
+ {
+ tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else
+ {
+ tab = DCT_16 + UBITS(bit_buf, 16);
+ bit_buf <<= 16;
+ GETWORD(bit_buf, bits + 16, bit_ptr);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+
+ break; /* illegal, check needed to avoid buffer overflow */
+ }
+
+ DUMPBITS(2); /* dump end of block code */
+ m_bitstream_buf = bit_buf;
+ m_bitstream_bits = bits;
+ m_bitstream_ptr = bit_ptr;
}
int CMpeg2Decoder::get_mpeg1_non_intra_block()
@@ -2885,124 +2816,124 @@ int CMpeg2Decoder::get_mpeg1_non_intra_block()
NEEDBITS;
if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14DC_5 + (UBITS(bit_buf, 5) - 5);
- goto entry_1;
- }
- else
- {
- goto entry_2;
- }
-
- while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
- entry_1:
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
- normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = ((2 * tab->level + 1) * quantizer_scale * quant_matrix[j]) >> 5;
-
- /* oddification */
- val = (val - 1) | 1;
-
- /* if(bitstream_get (1)) val = -val; */
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
-
- entry_2:
- if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = SBITS(bit_buf, 8);
- if(!(val & 0x7f))
- {
- DUMPBITS(8);
- val = UBITS(bit_buf, 8) + 2 * val;
- }
- val = 2 * (val + SBITS(val, 1)) + 1;
- val = (val * quantizer_scale * quant_matrix[j]) / 32;
-
- /* oddification */
- val = (val + ~SBITS(val, 1)) | 1;
-
- SATURATE(val);
- dest[j] = val;
-
- DUMPBITS(8);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD(bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
-
- return i;
+ {
+ tab = DCT_B14DC_5 + (UBITS(bit_buf, 5) - 5);
+ goto entry_1;
+ }
+ else
+ {
+ goto entry_2;
+ }
+
+ while(1)
+ {
+ if(bit_buf >= 0x28000000)
+ {
+ tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
+entry_1:
+ i += tab->run;
+ if(i >= 64)
+ break; /* end of block */
+normal_code:
+ j = scan[i];
+ bit_buf <<= tab->len;
+ bits += tab->len + 1;
+ val = ((2*tab->level+1) * quantizer_scale * quant_matrix[j]) >> 5;
+
+ /* oddification */
+ val = (val - 1) | 1;
+
+ /* if(bitstream_get (1)) val = -val; */
+ val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
+
+ SATURATE(val);
+ dest[j] = val;
+
+ bit_buf <<= 1;
+ NEEDBITS;
+
+ continue;
+ }
+
+entry_2:
+ if(bit_buf >= 0x04000000)
+ {
+ tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
+
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+
+ /* escape code */
+
+ i += UBITS(bit_buf << 6, 6) - 64;
+ if(i >= 64)
+ break; /* illegal, check needed to avoid buffer overflow */
+
+ j = scan[i];
+
+ DUMPBITS(12);
+ NEEDBITS;
+ val = SBITS(bit_buf, 8);
+ if(!(val & 0x7f))
+ {
+ DUMPBITS(8);
+ val = UBITS(bit_buf, 8) + 2 * val;
+ }
+ val = 2 * (val + SBITS(val, 1)) + 1;
+ val = (val * quantizer_scale * quant_matrix[j]) / 32;
+
+ /* oddification */
+ val = (val + ~SBITS(val, 1)) | 1;
+
+ SATURATE(val);
+ dest[j] = val;
+
+ DUMPBITS(8);
+ NEEDBITS;
+
+ continue;
+ }
+ else if(bit_buf >= 0x02000000)
+ {
+ tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00800000)
+ {
+ tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else if(bit_buf >= 0x00200000)
+ {
+ tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+ else
+ {
+ tab = DCT_16 + UBITS(bit_buf, 16);
+ bit_buf <<= 16;
+ GETWORD (bit_buf, bits + 16, bit_ptr);
+ i += tab->run;
+ if(i < 64)
+ goto normal_code;
+ }
+
+ break; /* illegal, check needed to avoid buffer overflow */
+ }
+
+ DUMPBITS(2); /* dump end of block code */
+ m_bitstream_buf = bit_buf;
+ m_bitstream_bits = bits;
+ m_bitstream_ptr = bit_ptr;
+
+ return i;
}
#define bit_buf (m_bitstream_buf)
@@ -3014,108 +2945,106 @@ void CMpeg2Decoder::slice_intra_DCT(const int cc, uint8_t* dest, int stride)
NEEDBITS;
/* Get the intra DC coefficient and inverse quantize it */
- m_dc_dct_pred[cc] += (cc == 0)
- ? get_luma_dc_dct_diff()
- : get_chroma_dc_dct_diff();
-
- m_DCTblock[0] = m_dc_dct_pred[cc] << (3 - m_intra_dc_precision);
+ m_dc_dct_pred[cc] += (cc == 0)
+ ? get_luma_dc_dct_diff()
+ : get_chroma_dc_dct_diff();
+
+ m_DCTblock[0] = m_dc_dct_pred[cc] << (3 - m_intra_dc_precision);
if(m_mpeg1)
- {
- if(m_coding_type != D_TYPE)
- get_mpeg1_intra_block();
- }
- else if(m_intra_vlc_format)
- {
- get_intra_block_B15();
- }
+ {
+ if(m_coding_type != D_TYPE)
+ get_mpeg1_intra_block();
+ }
+ else if(m_intra_vlc_format)
+ {
+ get_intra_block_B15();
+ }
else
- {
- get_intra_block_B14();
- }
+ {
+ get_intra_block_B14();
+ }
m_idct_copy(m_DCTblock, dest, stride);
}
void CMpeg2Decoder::slice_non_intra_DCT(uint8_t* dest, int stride)
{
- int last = m_mpeg1
- ? get_mpeg1_non_intra_block()
- : get_non_intra_block();
-
- m_idct_add(last, m_DCTblock, dest, stride);
+ int last = m_mpeg1
+ ? get_mpeg1_non_intra_block()
+ : get_non_intra_block ();
+
+ m_idct_add(last, m_DCTblock, dest, stride);
}
void CMpeg2Decoder::MOTION(
- mpeg2_mc_fct * const * const table, uint8_t** ref,
- int motion_x, int motion_y,
- unsigned int size, unsigned int y, unsigned int limit_y)
+ mpeg2_mc_fct * const * const table, uint8_t** ref,
+ int motion_x, int motion_y,
+ unsigned int size, unsigned int y, unsigned int limit_y)
{
- unsigned int pos_x, pos_y, xy_half, offset, dest_offset;
+ unsigned int pos_x, pos_y, xy_half, offset, dest_offset;
- pos_x = 2 * m_offset + motion_x;
- pos_y = 2 * m_v_offset + motion_y + 2 * y;
+ pos_x = 2 * m_offset + motion_x;
+ pos_y = 2 * m_v_offset + motion_y + 2 * y;
- if(pos_x > m_limit_x)
- {
- pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
- motion_x = pos_x - 2 * m_offset;
- }
+ if(pos_x > m_limit_x)
+ {
+ pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
+ motion_x = pos_x - 2 * m_offset;
+ }
- if(pos_y > limit_y)
- {
- pos_y = ((int)pos_y < 0) ? 0 : limit_y;
- motion_y = pos_y - 2 * m_v_offset - 2 * y;
- }
+ if(pos_y > limit_y)
+ {
+ pos_y = ((int)pos_y < 0) ? 0 : limit_y;
+ motion_y = pos_y - 2 * m_v_offset - 2 * y;
+ }
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
- offset = (pos_x >> 1) + (pos_y >> 1) * m_stride;
- table[xy_half](m_dest[0] + y * m_stride + m_offset, ref[0] + offset, m_stride, size);
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
+ offset = (pos_x >> 1) + (pos_y >> 1) * m_stride;
+ table[xy_half] (m_dest[0] + y * m_stride + m_offset, ref[0] + offset, m_stride, size);
- motion_x /= 2;
- motion_y /= 2;
+ motion_x /= 2; motion_y /= 2;
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
- offset = ((m_offset + motion_x) >> 1) + ((((m_v_offset + motion_y) >> 1) + y / 2) * m_uv_stride);
- dest_offset = y / 2 * m_uv_stride + (m_offset >> 1);
- table[4+xy_half](m_dest[1] + dest_offset, ref[1] + offset, m_uv_stride, size / 2);
- table[4+xy_half](m_dest[2] + dest_offset, ref[2] + offset, m_uv_stride, size / 2);
+ xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
+ offset = ((m_offset + motion_x) >> 1) + ((((m_v_offset + motion_y) >> 1) + y/2) * m_uv_stride);
+ dest_offset = y/2 * m_uv_stride + (m_offset >> 1);
+ table[4+xy_half] (m_dest[1] + dest_offset, ref[1] + offset, m_uv_stride, size/2);
+ table[4+xy_half] (m_dest[2] + dest_offset, ref[2] + offset, m_uv_stride, size/2);
}
void CMpeg2Decoder::MOTION_FIELD(
- mpeg2_mc_fct * const * const table, uint8_t** ref,
- int motion_x, int motion_y,
- int dest_field, int src_field, unsigned int op)
+ mpeg2_mc_fct * const * const table, uint8_t** ref,
+ int motion_x, int motion_y,
+ int dest_field, int src_field, unsigned int op)
{
unsigned int pos_x, pos_y, xy_half, offset, dest_offset;
- pos_x = 2 * m_offset + motion_x;
- pos_y = m_v_offset + motion_y;
-
- if(pos_x > m_limit_x)
- {
- pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
- motion_x = pos_x - 2 * m_offset;
- }
+ pos_x = 2 * m_offset + motion_x;
+ pos_y = m_v_offset + motion_y;
- if(pos_y > m_limit_y)
- {
- pos_y = ((int)pos_y < 0) ? 0 : m_limit_y;
- motion_y = pos_y - m_v_offset;
- }
+ if(pos_x > m_limit_x)
+ {
+ pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
+ motion_x = pos_x - 2 * m_offset;
+ }
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
- offset = (pos_x >> 1) + ((op ? (pos_y | 1) : (pos_y & ~1)) + src_field) * m_stride;
- table[xy_half](m_dest[0] + dest_field * m_stride + m_offset, ref[0] + offset, 2 * m_stride, 8);
+ if(pos_y > m_limit_y)
+ {
+ pos_y = ((int)pos_y < 0) ? 0 : m_limit_y;
+ motion_y = pos_y - m_v_offset;
+ }
- motion_x /= 2;
- motion_y /= 2;
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
+ offset = (pos_x >> 1) + ((op ? (pos_y | 1) : (pos_y & ~1)) + src_field) * m_stride;
+ table[xy_half] (m_dest[0] + dest_field * m_stride + m_offset, ref[0] + offset, 2 * m_stride, 8);
+
+ motion_x /= 2; motion_y /= 2;
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
- offset = ((m_offset + motion_x) >> 1) + (((m_v_offset >> 1) + (op ? (motion_y | 1) : (motion_y & ~1)) + src_field) * m_uv_stride);
- dest_offset = dest_field * m_uv_stride + (m_offset >> 1);
- table[4+xy_half](m_dest[1] + dest_offset, ref[1] + offset, 2 * m_uv_stride, 4);
- table[4+xy_half](m_dest[2] + dest_offset, ref[2] + offset, 2 * m_uv_stride, 4);
+ xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
+ offset = ((m_offset + motion_x) >> 1) + (((m_v_offset >> 1) + (op ? (motion_y | 1) :(motion_y & ~1)) + src_field) * m_uv_stride);
+ dest_offset = dest_field * m_uv_stride + (m_offset >> 1);
+ table[4+xy_half] (m_dest[1] + dest_offset, ref[1] + offset, 2 * m_uv_stride, 4);
+ table[4+xy_half] (m_dest[2] + dest_offset, ref[2] + offset, 2 * m_uv_stride, 4);
}
void CMpeg2Decoder::motion_mp1(motion_t* motion, mpeg2_mc_fct * const * const table)
@@ -3146,7 +3075,7 @@ void CMpeg2Decoder::motion_fr_frame(motion_t* motion, mpeg2_mc_fct * const * con
NEEDBITS;
motion_y = motion->pmv[0][1] + get_motion_delta(motion->f_code[1]);
- motion_y = bound_motion_vector(motion_y, motion->f_code[1]);
+ motion_y = bound_motion_vector (motion_y, motion->f_code[1]);
motion->pmv[1][1] = motion->pmv[0][1] = motion_y;
MOTION(table, motion->ref[0], motion_x, motion_y, 16, 0, m_limit_y_16);
@@ -3218,22 +3147,22 @@ void CMpeg2Decoder::motion_fr_dmv(motion_t* motion, mpeg2_mc_fct * const * const
pos_x = 2 * m_offset + motion_x;
pos_y = m_v_offset + motion_y;
if(pos_x > m_limit_x)
- {
- pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
- motion_x = pos_x - 2 * m_offset;
+ {
+ pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
+ motion_x = pos_x - 2 * m_offset;
}
if(pos_y > m_limit_y)
- {
- pos_y = ((int)pos_y < 0) ? 0 : m_limit_y;
- motion_y = pos_y - m_v_offset;
+ {
+ pos_y = ((int)pos_y < 0) ? 0 : m_limit_y;
+ motion_y = pos_y - m_v_offset;
}
xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
offset = (pos_x >> 1) + (pos_y & ~1) * m_stride;
m_mc->avg[xy_half](m_dest[0] + m_offset, motion->ref[0][0] + offset, 2 * m_stride, 8);
m_mc->avg[xy_half](m_dest[0] + m_stride + m_offset, motion->ref[0][0] + m_stride + offset, 2 * m_stride, 8);
- motion_x /= 2;
- motion_y /= 2;
+ motion_x /= 2;
+ motion_y /= 2;
xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
offset = ((m_offset + motion_x) >> 1) + ((m_v_offset >> 1) + (motion_y & ~1)) * m_uv_stride;
m_mc->avg[4+xy_half](m_dest[1] + (m_offset >> 1), motion->ref[0][1] + offset, 2 * m_uv_stride, 4);
@@ -3290,7 +3219,7 @@ void CMpeg2Decoder::motion_fi_field(motion_t * motion, mpeg2_mc_fct * const * co
DUMPBITS(1);
motion_x = motion->pmv[0][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]);
motion->pmv[1][0] = motion->pmv[0][0] = motion_x;
NEEDBITS;
@@ -3326,7 +3255,7 @@ void CMpeg2Decoder::motion_fi_16x8(motion_t* motion, mpeg2_mc_fct * const * cons
DUMPBITS(1);
motion_x = motion->pmv[1][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]);
motion->pmv[1][0] = motion_x;
NEEDBITS;
@@ -3351,7 +3280,7 @@ void CMpeg2Decoder::motion_fi_dmv(motion_t* motion, mpeg2_mc_fct * const * const
motion_y = motion->pmv[0][1] + get_motion_delta(motion->f_code[1]);
motion_y = bound_motion_vector(motion_y, motion->f_code[1]);
motion->pmv[1][1] = motion->pmv[0][1] = motion_y;
- other_y = ((motion_y + (motion_y > 0)) >> 1) + get_dmv() + m_dmv_offset;
+ other_y = ((motion_y + (motion_y > 0)) >> 1) + get_dmv () + m_dmv_offset;
MOTION(m_mc->put, motion->ref[0], motion_x, motion_y, 16, 0, m_limit_y_16);
MOTION(m_mc->avg, motion->ref[1], other_x, other_y, 16, 0, m_limit_y_16);
@@ -3364,7 +3293,7 @@ void CMpeg2Decoder::motion_fi_conceal()
NEEDBITS;
DUMPBITS(1); /* remove field_select */
- tmp = m_f_motion.pmv[0][0] + get_motion_delta(m_f_motion.f_code[0]);
+ tmp = m_f_motion.pmv[0][0] + get_motion_delta (m_f_motion.f_code[0]);
tmp = bound_motion_vector(tmp, m_f_motion.f_code[0]);
m_f_motion.pmv[1][0] = m_f_motion.pmv[0][0] = tmp;
@@ -3420,35 +3349,35 @@ void CMpeg2Decoder::mpeg2_init_fbuf(uint8_t* current_fbuf[3], uint8_t* forward_f
m_b_motion.ref[0][2] = backward_fbuf[2] + (offset >> 1);
if(m_picture_structure != FRAME_PICTURE)
- {
- m_dmv_offset = bottom_field ? 1 : -1;
- m_f_motion.ref2[0] = m_f_motion.ref[bottom_field];
- m_f_motion.ref2[1] = m_f_motion.ref[!bottom_field];
- m_b_motion.ref2[0] = m_b_motion.ref[bottom_field];
- m_b_motion.ref2[1] = m_b_motion.ref[!bottom_field];
- offset = stride - offset;
-
- if(m_second_field && (m_coding_type != B_TYPE))
- forward_fbuf = current_fbuf;
-
- m_f_motion.ref[1][0] = forward_fbuf[0] + offset;
- m_f_motion.ref[1][1] = forward_fbuf[1] + (offset >> 1);
- m_f_motion.ref[1][2] = forward_fbuf[2] + (offset >> 1);
-
- m_b_motion.ref[1][0] = backward_fbuf[0] + offset;
- m_b_motion.ref[1][1] = backward_fbuf[1] + (offset >> 1);
- m_b_motion.ref[1][2] = backward_fbuf[2] + (offset >> 1);
-
- stride <<= 1;
- height >>= 1;
- }
+ {
+ m_dmv_offset = bottom_field ? 1 : -1;
+ m_f_motion.ref2[0] = m_f_motion.ref[bottom_field];
+ m_f_motion.ref2[1] = m_f_motion.ref[!bottom_field];
+ m_b_motion.ref2[0] = m_b_motion.ref[bottom_field];
+ m_b_motion.ref2[1] = m_b_motion.ref[!bottom_field];
+ offset = stride - offset;
+
+ if(m_second_field && (m_coding_type != B_TYPE))
+ forward_fbuf = current_fbuf;
+
+ m_f_motion.ref[1][0] = forward_fbuf[0] + offset;
+ m_f_motion.ref[1][1] = forward_fbuf[1] + (offset >> 1);
+ m_f_motion.ref[1][2] = forward_fbuf[2] + (offset >> 1);
- m_stride = stride;
- m_uv_stride = stride >> 1;
- m_limit_x = 2 * m_width - 32;
- m_limit_y_16 = 2 * height - 32;
- m_limit_y_8 = 2 * height - 16;
- m_limit_y = height - 16;
+ m_b_motion.ref[1][0] = backward_fbuf[0] + offset;
+ m_b_motion.ref[1][1] = backward_fbuf[1] + (offset >> 1);
+ m_b_motion.ref[1][2] = backward_fbuf[2] + (offset >> 1);
+
+ stride <<= 1;
+ height >>= 1;
+ }
+
+ m_stride = stride;
+ m_uv_stride = stride >> 1;
+ m_limit_x = 2 * m_width - 32;
+ m_limit_y_16 = 2 * height - 32;
+ m_limit_y_8 = 2 * height - 16;
+ m_limit_y = height - 16;
}
int CMpeg2Decoder::slice_init(int code)
@@ -3457,7 +3386,7 @@ int CMpeg2Decoder::slice_init(int code)
const MBAtab* mba;
m_dc_dct_pred[0] = m_dc_dct_pred[1] =
- m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
+ m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
@@ -3465,9 +3394,9 @@ int CMpeg2Decoder::slice_init(int code)
m_b_motion.pmv[1][0] = m_b_motion.pmv[1][1] = 0;
if(m_vertical_position_extension)
- {
- code += UBITS(bit_buf, 3) << 7;
- DUMPBITS(3);
+ {
+ code += UBITS(bit_buf, 3) << 7;
+ DUMPBITS(3);
}
m_v_offset = (code - 1) * 16;
@@ -3481,61 +3410,61 @@ int CMpeg2Decoder::slice_init(int code)
/* ignore intra_slice and all the extra data */
while(bit_buf & 0x80000000)
- {
- DUMPBITS(9);
- NEEDBITS;
+ {
+ DUMPBITS(9);
+ NEEDBITS;
}
/* decode initial macroblock address increment */
offset = 0;
while(1)
- {
- if(bit_buf >= 0x08000000)
- {
- mba = MBA_5 + (UBITS(bit_buf, 6) - 2);
- break;
- }
- else if(bit_buf >= 0x01800000)
- {
- mba = MBA_11 + (UBITS(bit_buf, 12) - 24);
- break;
- }
- else
- {
- switch(UBITS(bit_buf, 12))
- {
- case 8: /* macroblock_escape */
- offset += 33;
- DUMPBITS(11);
- NEEDBITS;
- continue;
- case 15: /* macroblock_stuffing (MPEG1 only) */
- bit_buf &= 0xfffff;
- DUMPBITS(11);
- NEEDBITS;
- continue;
- default: /* error */
- return 1;
- }
- }
- }
-
- DUMPBITS(mba->len + 1);
- m_offset = (offset + mba->mba) << 4;
-
- while(m_offset - m_width >= 0)
- {
- m_offset -= m_width;
- m_dest[0] += 16 * m_stride;
- m_dest[1] += 4 * m_stride;
- m_dest[2] += 4 * m_stride;
- m_v_offset += 16;
- }
-
- if(m_v_offset > m_limit_y)
- return 1;
-
- return 0;
+ {
+ if(bit_buf >= 0x08000000)
+ {
+ mba = MBA_5 + (UBITS(bit_buf, 6) - 2);
+ break;
+ }
+ else if(bit_buf >= 0x01800000)
+ {
+ mba = MBA_11 + (UBITS(bit_buf, 12) - 24);
+ break;
+ }
+ else
+ {
+ switch(UBITS(bit_buf, 12))
+ {
+ case 8: /* macroblock_escape */
+ offset += 33;
+ DUMPBITS(11);
+ NEEDBITS;
+ continue;
+ case 15: /* macroblock_stuffing (MPEG1 only) */
+ bit_buf &= 0xfffff;
+ DUMPBITS(11);
+ NEEDBITS;
+ continue;
+ default: /* error */
+ return 1;
+ }
+ }
+ }
+
+ DUMPBITS(mba->len + 1);
+ m_offset = (offset + mba->mba) << 4;
+
+ while(m_offset - m_width >= 0)
+ {
+ m_offset -= m_width;
+ m_dest[0] += 16 * m_stride;
+ m_dest[1] += 4 * m_stride;
+ m_dest[2] += 4 * m_stride;
+ m_v_offset += 16;
+ }
+
+ if(m_v_offset > m_limit_y)
+ return 1;
+
+ return 0;
}
void CMpeg2Decoder::mpeg2_slice(int code, const uint8_t* buffer)
@@ -3545,237 +3474,233 @@ void CMpeg2Decoder::mpeg2_slice(int code, const uint8_t* buffer)
m_bitstream_bits = -16;
if(slice_init(code))
- return;
-
- while(1)
- {
- int macroblock_modes;
- int mba_inc;
- const MBAtab * mba;
-
- NEEDBITS;
-
- macroblock_modes = get_macroblock_modes();
-
- /* maybe integrate MACROBLOCK_QUANT test into get_macroblock_modes ? */
- if(macroblock_modes & MACROBLOCK_QUANT)
- m_quantizer_scale = get_quantizer_scale();
-
- if(macroblock_modes & MACROBLOCK_INTRA)
- {
- int DCT_offset, DCT_stride;
- int offset;
- uint8_t* dest_y;
-
- if(m_concealment_motion_vectors)
- {
- if(m_picture_structure == FRAME_PICTURE) motion_fr_conceal();
- else motion_fi_conceal();
- }
- else
- {
- m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
- m_b_motion.pmv[0][0] = m_b_motion.pmv[0][1] = 0;
- m_b_motion.pmv[1][0] = m_b_motion.pmv[1][1] = 0;
- }
-
- if(macroblock_modes & DCT_TYPE_INTERLACED)
- {
- DCT_offset = m_stride;
- DCT_stride = m_stride * 2;
- }
- else
- {
- DCT_offset = m_stride * 8;
- DCT_stride = m_stride;
- }
-
- offset = m_offset;
- dest_y = m_dest[0] + offset;
- slice_intra_DCT(0, dest_y, DCT_stride);
- slice_intra_DCT(0, dest_y + 8, DCT_stride);
- slice_intra_DCT(0, dest_y + DCT_offset, DCT_stride);
- slice_intra_DCT(0, dest_y + DCT_offset + 8, DCT_stride);
- slice_intra_DCT(1, m_dest[1] + (offset >> 1), m_uv_stride);
- slice_intra_DCT(2, m_dest[2] + (offset >> 1), m_uv_stride);
-
- if(m_coding_type == D_TYPE)
- {
- NEEDBITS;
- DUMPBITS(1);
- }
- }
- else
- {
- if(m_picture_structure == FRAME_PICTURE)
- {
- switch((macroblock_modes >> 6) & 3) // macroblock_modes & MOTION_TYPE_MASK
- {
- case 0:
- // non-intra mb without forward mv in a P picture //
- m_f_motion.pmv[0][0] = 0;
- m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = 0;
- m_f_motion.pmv[1][1] = 0;
- MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
- break;
-
- case 1: // MC_FIELD:
- MOTION_CALL(motion_fr_field, macroblock_modes);
- break;
-
- case 2: // MC_FRAME:
-
- if(m_mpeg1) MOTION_CALL(motion_mp1, macroblock_modes);
- else MOTION_CALL(motion_fr_frame, macroblock_modes);
- break;
-
- case 3: // MC_DMV:
- MOTION_CALL(motion_fr_dmv, MACROBLOCK_MOTION_FORWARD);
- break;
-
- default:
- __assume(0);
- }
- }
- else
- {
- switch((macroblock_modes >> 6) & 3) // macroblock_modes & MOTION_TYPE_MASK
- {
- case 0:
- /* non-intra mb without forward mv in a P picture */
- m_f_motion.pmv[0][0] = 0;
- m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = 0;
- m_f_motion.pmv[1][1] = 0;
- MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
- break;
-
- case 1: // MC_FIELD
- MOTION_CALL(motion_fi_field, macroblock_modes);
- break;
-
- case 2: // MC_16X8
- MOTION_CALL(motion_fi_16x8, macroblock_modes);
- break;
-
- case 3: // MC_DMV
- MOTION_CALL(motion_fi_dmv, MACROBLOCK_MOTION_FORWARD);
- break;
-
- default:
- __assume(0);
- }
- }
-
- if(macroblock_modes & MACROBLOCK_PATTERN)
- {
- int coded_block_pattern;
- int DCT_offset, DCT_stride;
- int offset;
- uint8_t* dest_y;
-
- if(macroblock_modes & DCT_TYPE_INTERLACED)
- {
- DCT_offset = m_stride;
- DCT_stride = m_stride * 2;
- }
- else
- {
- DCT_offset = m_stride * 8;
- DCT_stride = m_stride;
- }
-
- coded_block_pattern = get_coded_block_pattern();
-
- offset = m_offset;
- dest_y = m_dest[0] + offset;
-
- if(coded_block_pattern & 0x20)
- slice_non_intra_DCT(dest_y, DCT_stride);
- if(coded_block_pattern & 0x10)
- slice_non_intra_DCT(dest_y + 8, DCT_stride);
- if(coded_block_pattern & 0x08)
- slice_non_intra_DCT(dest_y + DCT_offset, DCT_stride);
- if(coded_block_pattern & 0x04)
- slice_non_intra_DCT(dest_y + DCT_offset + 8, DCT_stride);
- if(coded_block_pattern & 0x2)
- slice_non_intra_DCT(m_dest[1] + (offset >> 1), m_uv_stride);
- if(coded_block_pattern & 0x1)
- slice_non_intra_DCT(m_dest[2] + (offset >> 1), m_uv_stride);
- }
-
- m_dc_dct_pred[0] =
- m_dc_dct_pred[1] =
- m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
- }
-
- NEXT_MACROBLOCK;
-
- NEEDBITS;
- mba_inc = 0;
- while(1)
- {
- if(bit_buf >= 0x10000000)
- {
- mba = MBA_5 + (UBITS(bit_buf, 5) - 2);
- break;
- }
- else if(bit_buf >= 0x03000000)
- {
- mba = MBA_11 + (UBITS(bit_buf, 11) - 24);
- break;
- }
- else
- {
- switch(UBITS(bit_buf, 11))
- {
- case 8: /* macroblock_escape */
- mba_inc += 33;
- /* pass through */
- case 15: /* macroblock_stuffing (MPEG1 only) */
- DUMPBITS(11);
- NEEDBITS;
- continue;
- default: /* end of slice, or error */
- return;
- }
- }
- }
-
- DUMPBITS(mba->len);
- mba_inc += mba->mba;
-
- if(mba_inc)
- {
- m_dc_dct_pred[0] =
- m_dc_dct_pred[1] =
- m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
-
- if(m_coding_type == P_TYPE)
- {
- m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
-
- do
- {
- MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
- NEXT_MACROBLOCK;
- }
- while(--mba_inc);
- }
- else
- {
- do
- {
- MOTION_CALL(motion_reuse, macroblock_modes);
- NEXT_MACROBLOCK;
- }
- while(--mba_inc);
- }
- }
- }
+ return;
+
+ while(1)
+ {
+ int macroblock_modes;
+ int mba_inc;
+ const MBAtab * mba;
+
+ NEEDBITS;
+
+ macroblock_modes = get_macroblock_modes();
+
+ /* maybe integrate MACROBLOCK_QUANT test into get_macroblock_modes ? */
+ if(macroblock_modes & MACROBLOCK_QUANT)
+ m_quantizer_scale = get_quantizer_scale();
+
+ if(macroblock_modes & MACROBLOCK_INTRA)
+ {
+ int DCT_offset, DCT_stride;
+ int offset;
+ uint8_t* dest_y;
+
+ if(m_concealment_motion_vectors)
+ {
+ if(m_picture_structure == FRAME_PICTURE) motion_fr_conceal();
+ else motion_fi_conceal();
+ }
+ else
+ {
+ m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
+ m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
+ m_b_motion.pmv[0][0] = m_b_motion.pmv[0][1] = 0;
+ m_b_motion.pmv[1][0] = m_b_motion.pmv[1][1] = 0;
+ }
+
+ if(macroblock_modes & DCT_TYPE_INTERLACED)
+ {
+ DCT_offset = m_stride;
+ DCT_stride = m_stride * 2;
+ }
+ else
+ {
+ DCT_offset = m_stride * 8;
+ DCT_stride = m_stride;
+ }
+
+ offset = m_offset;
+ dest_y = m_dest[0] + offset;
+ slice_intra_DCT(0, dest_y, DCT_stride);
+ slice_intra_DCT(0, dest_y + 8, DCT_stride);
+ slice_intra_DCT(0, dest_y + DCT_offset, DCT_stride);
+ slice_intra_DCT(0, dest_y + DCT_offset + 8, DCT_stride);
+ slice_intra_DCT(1, m_dest[1] + (offset >> 1), m_uv_stride);
+ slice_intra_DCT (2, m_dest[2] + (offset >> 1), m_uv_stride);
+
+ if(m_coding_type == D_TYPE)
+ {
+ NEEDBITS;
+ DUMPBITS(1);
+ }
+ }
+ else
+ {
+ if(m_picture_structure == FRAME_PICTURE)
+ {
+ switch((macroblock_modes >> 6) & 3) // macroblock_modes & MOTION_TYPE_MASK
+ {
+ case 0:
+ // non-intra mb without forward mv in a P picture //
+ m_f_motion.pmv[0][0] = 0;
+ m_f_motion.pmv[0][1] = 0;
+ m_f_motion.pmv[1][0] = 0;
+ m_f_motion.pmv[1][1] = 0;
+ MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
+ break;
+
+ case 1: // MC_FIELD:
+ MOTION_CALL(motion_fr_field, macroblock_modes);
+ break;
+
+ case 2: // MC_FRAME:
+
+ if(m_mpeg1) MOTION_CALL(motion_mp1, macroblock_modes);
+ else MOTION_CALL (motion_fr_frame, macroblock_modes);
+ break;
+
+ case 3: // MC_DMV:
+ MOTION_CALL(motion_fr_dmv, MACROBLOCK_MOTION_FORWARD);
+ break;
+
+ default:
+ __assume(0);
+ }
+ }
+ else
+ {
+ switch((macroblock_modes >> 6) & 3) // macroblock_modes & MOTION_TYPE_MASK
+ {
+ case 0:
+ /* non-intra mb without forward mv in a P picture */
+ m_f_motion.pmv[0][0] = 0;
+ m_f_motion.pmv[0][1] = 0;
+ m_f_motion.pmv[1][0] = 0;
+ m_f_motion.pmv[1][1] = 0;
+ MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
+ break;
+
+ case 1: // MC_FIELD
+ MOTION_CALL(motion_fi_field, macroblock_modes);
+ break;
+
+ case 2: // MC_16X8
+ MOTION_CALL(motion_fi_16x8, macroblock_modes);
+ break;
+
+ case 3: // MC_DMV
+ MOTION_CALL(motion_fi_dmv, MACROBLOCK_MOTION_FORWARD);
+ break;
+
+ default:
+ __assume(0);
+ }
+ }
+
+ if(macroblock_modes & MACROBLOCK_PATTERN)
+ {
+ int coded_block_pattern;
+ int DCT_offset, DCT_stride;
+ int offset;
+ uint8_t* dest_y;
+
+ if(macroblock_modes & DCT_TYPE_INTERLACED)
+ {
+ DCT_offset = m_stride;
+ DCT_stride = m_stride * 2;
+ }
+ else
+ {
+ DCT_offset = m_stride * 8;
+ DCT_stride = m_stride;
+ }
+
+ coded_block_pattern = get_coded_block_pattern();
+
+ offset = m_offset;
+ dest_y = m_dest[0] + offset;
+
+ if(coded_block_pattern & 0x20)
+ slice_non_intra_DCT(dest_y, DCT_stride);
+ if(coded_block_pattern & 0x10)
+ slice_non_intra_DCT(dest_y + 8, DCT_stride);
+ if(coded_block_pattern & 0x08)
+ slice_non_intra_DCT(dest_y + DCT_offset, DCT_stride);
+ if(coded_block_pattern & 0x04)
+ slice_non_intra_DCT(dest_y + DCT_offset + 8, DCT_stride);
+ if(coded_block_pattern & 0x2)
+ slice_non_intra_DCT(m_dest[1] + (offset >> 1), m_uv_stride);
+ if(coded_block_pattern & 0x1)
+ slice_non_intra_DCT(m_dest[2] + (offset >> 1), m_uv_stride);
+ }
+
+ m_dc_dct_pred[0] =
+ m_dc_dct_pred[1] =
+ m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
+ }
+
+ NEXT_MACROBLOCK;
+
+ NEEDBITS;
+ mba_inc = 0;
+ while(1)
+ {
+ if(bit_buf >= 0x10000000)
+ {
+ mba = MBA_5 + (UBITS(bit_buf, 5) - 2);
+ break;
+ }
+ else if(bit_buf >= 0x03000000)
+ {
+ mba = MBA_11 + (UBITS(bit_buf, 11) - 24);
+ break;
+ }
+ else
+ {
+ switch(UBITS(bit_buf, 11))
+ {
+ case 8: /* macroblock_escape */
+ mba_inc += 33;
+ /* pass through */
+ case 15: /* macroblock_stuffing (MPEG1 only) */
+ DUMPBITS(11);
+ NEEDBITS;
+ continue;
+ default: /* end of slice, or error */
+ return;
+ }
+ }
+ }
+
+ DUMPBITS(mba->len);
+ mba_inc += mba->mba;
+
+ if(mba_inc)
+ {
+ m_dc_dct_pred[0] =
+ m_dc_dct_pred[1] =
+ m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
+
+ if(m_coding_type == P_TYPE)
+ {
+ m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
+ m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
+
+ do {
+ MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
+ NEXT_MACROBLOCK;
+ } while(--mba_inc);
+ }
+ else
+ {
+ do {
+ MOTION_CALL (motion_reuse, macroblock_modes);
+ NEXT_MACROBLOCK;
+ } while(--mba_inc);
+ }
+ }
+ }
}
#undef bit_buf
@@ -3787,9 +3712,9 @@ void CMpeg2Decoder::mpeg2_slice(int code, const uint8_t* buffer)
CMpeg2Info::CMpeg2Info()
{
- m_sequence = NULL;
+ m_sequence = NULL;
m_gop = NULL;
- Reset();
+ Reset();
}
CMpeg2Info::~CMpeg2Info()
@@ -3802,6 +3727,6 @@ void CMpeg2Info::Reset()
m_display_picture = m_display_picture_2nd = NULL;
m_current_fbuf = m_display_fbuf = m_discard_fbuf = NULL;
m_user_data = NULL;
- m_user_data_len = 0;
+ m_user_data_len = 0;
}
diff --git a/src/filters/transform/Mpeg2DecFilter/libmpeg2.h b/src/filters/transform/Mpeg2DecFilter/libmpeg2.h
index ca97d23c8..ee64ca0c4 100644
--- a/src/filters/transform/Mpeg2DecFilter/libmpeg2.h
+++ b/src/filters/transform/Mpeg2DecFilter/libmpeg2.h
@@ -41,8 +41,7 @@
#define SEQ_VIDEO_FORMAT_MAC 0x80
#define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0
-typedef struct
-{
+typedef struct {
unsigned int width, height;
unsigned int chroma_width, chroma_height;
unsigned int byte_rate;
@@ -59,15 +58,14 @@ typedef struct
uint8_t transfer_characteristics;
uint8_t matrix_coefficients;
- void finalize();
+ void finalize();
} mpeg2_sequence_t;
#define GOP_FLAG_DROP_FRAME 1
#define GOP_FLAG_BROKEN_LINK 2
#define GOP_FLAG_CLOSED_GOP 4
-typedef struct
-{
+typedef struct {
uint8_t hours;
uint8_t minutes;
uint8_t seconds;
@@ -89,28 +87,24 @@ typedef struct
#define PIC_FLAG_REPEAT_FIRST_FIELD 256
#define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
-typedef struct
-{
+typedef struct {
unsigned int temporal_reference;
unsigned int nb_fields;
uint32_t pts;
uint32_t flags;
- struct
- {
- int x, y;
+ struct {
+ int x, y;
} display_offset[3];
- __int64 rtStart, rtStop;
- bool fDiscontinuity, fDelivered;
+ __int64 rtStart, rtStop;
+ bool fDiscontinuity, fDelivered;
} mpeg2_picture_t;
-typedef struct
-{
+typedef struct {
uint8_t* buf[3];
void* id;
} mpeg2_fbuf_t;
-typedef enum
-{
+typedef enum {
STATE_BUFFER = 0,
STATE_SEQUENCE = 1,
STATE_SEQUENCE_REPEATED = 2,
@@ -157,11 +151,7 @@ typedef enum
////////////////////////////////////////////////////////////////////////////////////////////////
typedef void mpeg2_mc_fct(uint8_t*, const uint8_t*, int, int);
-typedef struct
-{
- mpeg2_mc_fct* put[8];
- mpeg2_mc_fct* avg[8];
-} mpeg2_mc_t;
+typedef struct {mpeg2_mc_fct* put[8]; mpeg2_mc_fct* avg[8];} mpeg2_mc_t;
class CMpeg2Decoder
{
@@ -170,63 +160,62 @@ public:
/* The f_ and b_ correspond to the forward and backward motion */
/* predictors */
- struct motion_t
- {
- uint8_t* ref[2][3];
- uint8_t** ref2[2];
- int pmv[2][2];
- int f_code[2];
- } m_b_motion, m_f_motion;
+ struct motion_t {
+ uint8_t* ref[2][3];
+ uint8_t** ref2[2];
+ int pmv[2][2];
+ int f_code[2];
+ } m_b_motion, m_f_motion;
private:
- int get_macroblock_modes();
- int get_quantizer_scale();
- int get_motion_delta(const int f_code);
- int bound_motion_vector(const int vector, const int f_code);
- int get_dmv();
- int get_coded_block_pattern();
- int get_luma_dc_dct_diff();
- int get_chroma_dc_dct_diff();
-
- void get_intra_block_B14();
- void get_intra_block_B15();
- int get_non_intra_block();
- void get_mpeg1_intra_block();
- int get_mpeg1_non_intra_block();
- void slice_intra_DCT(const int cc, uint8_t* dest, int stride);
- void slice_non_intra_DCT(uint8_t* dest, int stride);
-
- void MOTION(mpeg2_mc_fct * const * const table, uint8_t** ref, int motion_x, int motion_y, unsigned int size, unsigned int y, unsigned int limit_y);
- void MOTION_FIELD(mpeg2_mc_fct * const * const table, uint8_t** ref, int motion_x, int motion_y, int dest_field, int src_field, unsigned int op);
-
- void motion_mp1(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_frame(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_field(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_dmv(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_reuse(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_zero(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_conceal();
- void motion_fi_field(motion_t * motion, mpeg2_mc_fct * const * const table);
- void motion_fi_16x8(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fi_dmv(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fi_conceal();
-
- int slice_init(int code);
-
- static bool m_idct_initialized;
- void (*m_idct_init)();
- void (*m_idct_copy)(int16_t* block, uint8_t* dest, const int stride);
- void (*m_idct_add)(const int last, int16_t* block, uint8_t* dest, const int stride);
- mpeg2_mc_t* m_mc;
+ int get_macroblock_modes();
+ int get_quantizer_scale();
+ int get_motion_delta(const int f_code);
+ int bound_motion_vector(const int vector, const int f_code);
+ int get_dmv();
+ int get_coded_block_pattern();
+ int get_luma_dc_dct_diff();
+ int get_chroma_dc_dct_diff();
+
+ void get_intra_block_B14();
+ void get_intra_block_B15();
+ int get_non_intra_block();
+ void get_mpeg1_intra_block();
+ int get_mpeg1_non_intra_block();
+ void slice_intra_DCT(const int cc, uint8_t* dest, int stride);
+ void slice_non_intra_DCT(uint8_t* dest, int stride);
+
+ void MOTION(mpeg2_mc_fct * const * const table, uint8_t** ref, int motion_x, int motion_y, unsigned int size, unsigned int y, unsigned int limit_y);
+ void MOTION_FIELD(mpeg2_mc_fct * const * const table, uint8_t** ref, int motion_x, int motion_y, int dest_field, int src_field, unsigned int op);
+
+ void motion_mp1(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_fr_frame(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_fr_field(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_fr_dmv(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_reuse(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_zero(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_fr_conceal();
+ void motion_fi_field(motion_t * motion, mpeg2_mc_fct * const * const table);
+ void motion_fi_16x8(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_fi_dmv(motion_t* motion, mpeg2_mc_fct * const * const table);
+ void motion_fi_conceal();
+
+ int slice_init(int code);
+
+ static bool m_idct_initialized;
+ void (*m_idct_init)();
+ void (*m_idct_copy)(int16_t* block, uint8_t* dest, const int stride);
+ void (*m_idct_add)(const int last, int16_t* block, uint8_t* dest, const int stride);
+ mpeg2_mc_t* m_mc;
public:
- CMpeg2Decoder();
- virtual ~CMpeg2Decoder();
+ CMpeg2Decoder();
+ virtual ~CMpeg2Decoder();
- void mpeg2_init_fbuf(uint8_t* current_fbuf[3], uint8_t* forward_fbuf[3], uint8_t* backward_fbuf[3]);
- void mpeg2_slice(int code, const uint8_t* buffer);
+ void mpeg2_init_fbuf(uint8_t* current_fbuf[3], uint8_t* forward_fbuf[3], uint8_t* backward_fbuf[3]);
+ void mpeg2_slice(int code, const uint8_t* buffer);
- int16_t* m_DCTblock;
+ int16_t* m_DCTblock;
/* bit parsing stuff */
uint32_t m_bitstream_buf; /* current 32 bit working set */
@@ -292,12 +281,12 @@ public:
class CMpeg2Info
{
public:
- CMpeg2Info();
- virtual ~CMpeg2Info();
+ CMpeg2Info();
+ virtual ~CMpeg2Info();
- void Reset();
+ void Reset();
- mpeg2_sequence_t* m_sequence;
+ mpeg2_sequence_t* m_sequence;
mpeg2_gop_t* m_gop;
mpeg2_picture_t* m_current_picture;
mpeg2_picture_t* m_current_picture_2nd;
@@ -312,60 +301,60 @@ public:
class CMpeg2Dec
{
- int skip_chunk(int bytes);
- int copy_chunk(int bytes);
- mpeg2_state_t seek_chunk(), seek_header(), seek_sequence();
+ int skip_chunk(int bytes);
+ int copy_chunk(int bytes);
+ mpeg2_state_t seek_chunk(), seek_header(), seek_sequence();
- int sequence_ext();
- int sequence_display_ext();
- int quant_matrix_ext();
- int copyright_ext();
- int picture_display_ext();
- int picture_coding_ext();
+ int sequence_ext();
+ int sequence_display_ext();
+ int quant_matrix_ext();
+ int copyright_ext();
+ int picture_display_ext();
+ int picture_coding_ext();
public:
- CMpeg2Dec();
- virtual ~CMpeg2Dec();
+ CMpeg2Dec();
+ virtual ~CMpeg2Dec();
- void mpeg2_init();
- void mpeg2_close();
+ void mpeg2_init();
+ void mpeg2_close();
- void mpeg2_buffer(uint8_t* start, uint8_t* end);
- int mpeg2_getpos();
- mpeg2_state_t mpeg2_parse();
+ void mpeg2_buffer(uint8_t* start, uint8_t* end);
+ int mpeg2_getpos();
+ mpeg2_state_t mpeg2_parse();
- void mpeg2_skip(int skip);
- void mpeg2_slice_region(int start, int end);
+ void mpeg2_skip(int skip);
+ void mpeg2_slice_region(int start, int end);
- void mpeg2_pts(uint32_t pts);
+ void mpeg2_pts(uint32_t pts);
- /* decode.c */
- mpeg2_state_t mpeg2_seek_sequence();
- mpeg2_state_t mpeg2_parse_header();
+ /* decode.c */
+ mpeg2_state_t mpeg2_seek_sequence();
+ mpeg2_state_t mpeg2_parse_header();
- /* header.c */
- void mpeg2_header_state_init();
- int mpeg2_header_sequence();
- int mpeg2_header_gop();
- mpeg2_state_t mpeg2_header_picture_start();
- int mpeg2_header_picture();
- int mpeg2_header_extension();
- int mpeg2_header_user_data();
- void mpeg2_header_matrix_finalize();
- void mpeg2_header_sequence_finalize();
- mpeg2_state_t mpeg2_header_slice_start();
- mpeg2_state_t mpeg2_header_end();
- void mpeg2_set_fbuf(int coding_type);
+ /* header.c */
+ void mpeg2_header_state_init();
+ int mpeg2_header_sequence();
+ int mpeg2_header_gop();
+ mpeg2_state_t mpeg2_header_picture_start();
+ int mpeg2_header_picture();
+ int mpeg2_header_extension();
+ int mpeg2_header_user_data();
+ void mpeg2_header_matrix_finalize();
+ void mpeg2_header_sequence_finalize();
+ mpeg2_state_t mpeg2_header_slice_start();
+ mpeg2_state_t mpeg2_header_end();
+ void mpeg2_set_fbuf(int coding_type);
- enum {BUFFER_SIZE = 1194 * 1024};
+ enum {BUFFER_SIZE = 1194 * 1024};
- CMpeg2Decoder m_decoder;
+ CMpeg2Decoder m_decoder;
CMpeg2Info m_info;
uint32_t m_shift;
int m_is_display_initialized;
- mpeg2_state_t (CMpeg2Dec::* m_action)();
+ mpeg2_state_t (CMpeg2Dec::* m_action)();
mpeg2_state_t m_state;
uint32_t m_ext_state;
@@ -393,10 +382,9 @@ public:
mpeg2_gop_t m_gop;
mpeg2_picture_t m_pictures[4];
mpeg2_picture_t* m_picture;
- /*const*/
- mpeg2_fbuf_t* m_fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */
+ /*const*/ mpeg2_fbuf_t* m_fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */
- mpeg2_fbuf_t m_fbuf_alloc[3];
+ mpeg2_fbuf_t m_fbuf_alloc[3];
uint8_t* m_buf_start;
uint8_t* m_buf_end;
diff --git a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
index f01d2f9dd..3d5061bd0 100644
--- a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -27,473 +27,463 @@
#include "attributes.h"
#include "../../../DSUtil/simd.h"
-static const __m128i const_1_16_bytes = _mm_set1_epi16(1);
+static const __m128i const_1_16_bytes=_mm_set1_epi16(1);
static void MC_put_o_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- __m128i xmm0, xmm1, xmm2, xmm3;
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- }
+ const int edi= eax+eax;
+ const int ebx= edi+eax;
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4){
+ __m128i xmm0,xmm1,xmm2,xmm3;
+ movdqu (xmm0, edx );
+ movdqu (xmm1, edx+eax);
+ movdqu (xmm2, edx+edi);
+ movdqu (xmm3, edx+ebx);
+ movdqa (ecx, xmm0 );
+ movdqa (ecx+eax, xmm1 );
+ movdqa (ecx+edi, xmm2 );
+ movdqa (ecx+ebx, xmm3 );
+ }
}
static void MC_put_o_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- __m128d xmm0, xmm1, xmm2, xmm3;
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + eax);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + ebx);
- movlpd(ecx, xmm0);
- movlpd(ecx + eax, xmm1);
- movlpd(ecx + edi, xmm2);
- movlpd(ecx + ebx, xmm3);
- }
+ const int edi= eax+eax;
+ const int ebx= edi+eax;
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4){
+ __m128d xmm0,xmm1,xmm2,xmm3;
+ movlpd (xmm0, edx);
+ movlpd (xmm1, edx+eax);
+ movlpd (xmm2, edx+edi);
+ movlpd (xmm3, edx+ebx);
+ movlpd (ecx, xmm0);
+ movlpd (ecx+eax, xmm1 );
+ movlpd (ecx+edi, xmm2);
+ movlpd (ecx+ebx, xmm3 );
+ }
}
static void MC_put_x_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- movdqu(xmm6, edx + ebx);
- movdqu(xmm7, edx + ebx + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm4, xmm5);
- pavgb(xmm6, xmm7);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm2);
- movdqa(ecx + edi, xmm4);
- movdqa(ecx + ebx, xmm6);
- }
+ const int edi= eax+eax;
+ const int ebx= edi+eax;
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4){
+ __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7;
+ movdqu (xmm0, edx);
+ movdqu (xmm1, edx+1);
+ movdqu (xmm2, edx+eax);
+ movdqu (xmm3, edx+eax+1);
+ movdqu (xmm4, edx+edi);
+ movdqu( xmm5, edx+edi+1);
+ movdqu( xmm6, edx+ebx );
+ movdqu( xmm7, edx+ebx+1 );
+ pavgb (xmm0, xmm1);
+ pavgb (xmm2, xmm3);
+ pavgb (xmm4, xmm5);
+ pavgb (xmm6, xmm7);
+ movdqa (ecx, xmm0);
+ movdqa (ecx+eax, xmm2);
+ movdqa (ecx+edi, xmm4);
+ movdqa (ecx+ebx, xmm6);
+ }
}
static void MC_put_x_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- __m128i xmm0, xmm1, xmm2, xmm3;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + 1);
- movhpd(xmm0, edx + eax);
- movhpd(xmm1, edx + eax + 1);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + edi + 1);
- movhpd(xmm2, edx + ebx);
- movhpd(xmm3, edx + ebx + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movlpd(ecx, xmm0);
- movhpd(ecx + eax, xmm0);
- movlpd(ecx + edi, xmm2);
- movhpd(ecx + ebx, xmm2);
- }
+ const int edi= eax+eax;
+ const int ebx= edi+eax;
+ __m128i xmm0,xmm1,xmm2,xmm3;
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4){
+ movlpd (xmm0, edx);
+ movlpd (xmm1, edx+1);
+ movhpd (xmm0, edx+eax);
+ movhpd (xmm1, edx+eax+1);
+ movlpd (xmm2, edx+edi);
+ movlpd (xmm3, edx+edi+1);
+ movhpd (xmm2, edx+ebx);
+ movhpd (xmm3, edx+ebx+1);
+ pavgb (xmm0, xmm1);
+ pavgb (xmm2, xmm3);
+ movlpd (ecx, xmm0);
+ movhpd (ecx+eax, xmm0);
+ movlpd (ecx+edi, xmm2);
+ movhpd (ecx+ebx, xmm2);
+ }
}
static void MC_put_y_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- __m128i xmm0;
- movdqu(xmm0, edx);
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- __m128i xmm1, xmm2, xmm3, xmm4;
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- movdqu(xmm4, edx + edi * 2);
- pavgb(xmm0, xmm1);
- pavgb(xmm1, xmm2);
- pavgb(xmm2, xmm3);
- pavgb(xmm3, xmm4);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- movdqa(xmm0, xmm4);
- }
+ const int edi= eax+eax;
+ const int ebx= edi+eax;
+ __m128i xmm0;
+ movdqu (xmm0, edx);
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4){
+ __m128i xmm1,xmm2,xmm3,xmm4;
+ movdqu (xmm1, edx+eax);
+ movdqu (xmm2, edx+edi );
+ movdqu (xmm3, edx+ebx );
+ movdqu (xmm4, edx+edi*2 );
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm1, xmm2 );
+ pavgb (xmm2, xmm3 );
+ pavgb (xmm3, xmm4 );
+ movdqa (ecx, xmm0 );
+ movdqa (ecx+eax, xmm1 );
+ movdqa (ecx+edi, xmm2 );
+ movdqa (ecx+ebx, xmm3 );
+ movdqa (xmm0, xmm4 );
+ }
}
static void MC_put_y_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- __m128i xmm0;
- movlpd(xmm0, edx);
+ const int edi= eax+eax;
+ const int ebx= edi+eax;
+ __m128i xmm0;
+ movlpd (xmm0, edx);
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- __m128i xmm1, xmm2, xmm3, xmm4;
- movlpd(xmm1, edx + eax);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + ebx);
- movlpd(xmm4, edx + edi * 2);
- pavgb(xmm0, xmm1);
- pavgb(xmm1, xmm2);
- pavgb(xmm2, xmm3);
- pavgb(xmm3, xmm4);
- movlpd(ecx, xmm0);
- movlpd(ecx + eax, xmm1);
- movlpd(ecx + edi, xmm2);
- movlpd(ecx + ebx, xmm3);
- movdqa(xmm0, xmm4);
- }
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4){
+ __m128i xmm1,xmm2,xmm3,xmm4;
+ movlpd (xmm1, edx+eax );
+ movlpd (xmm2, edx+edi );
+ movlpd (xmm3, edx+ebx );
+ movlpd (xmm4, edx+edi*2 );
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm1, xmm2);
+ pavgb (xmm2, xmm3 );
+ pavgb (xmm3, xmm4 );
+ movlpd (ecx, xmm0 );
+ movlpd (ecx+eax, xmm1 );
+ movlpd (ecx+edi, xmm2 );
+ movlpd (ecx+ebx, xmm3 );
+ movdqa (xmm0, xmm4 );
+ }
}
static void MC_put_xy_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref ;
- uint8_t *ecx = dest;
- int eax = stride;
- int esi = height;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm1, xmm4, xmm5, xmm2, xmm3;
- movdqa(xmm7, const_1_16_bytes);
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- for(; esi; edx += edi, ecx += edi, esi -= 2)
- {
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movdqa(xmm1, xmm5);
- pavgb(xmm5, xmm4);
- psubusb(xmm2, xmm7);
- pavgb(xmm0, xmm2);
- pavgb(xmm2, xmm5);
- movdqa(ecx, xmm0);
- movdqa(xmm0, xmm4);
- movdqa(ecx + eax, xmm2);
- }
+ const uint8_t *edx= ref ;
+ uint8_t *ecx= dest;
+ int eax= stride;
+ int esi= height;
+ int edi= eax+eax;
+ __m128i xmm7,xmm0,xmm1,xmm4,xmm5,xmm2,xmm3;
+ movdqa (xmm7, const_1_16_bytes );
+ movdqu (xmm0, edx );
+ movdqu (xmm1, edx+1 );
+ for (;esi;edx+= edi,ecx+= edi,esi-= 2)
+ {
+ movdqu (xmm2, edx+eax );
+ movdqu (xmm3, edx+eax+1 );
+ movdqu (xmm4, edx+edi );
+ movdqu (xmm5, edx+edi+1 );
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm2, xmm3 );
+ movdqa( xmm1, xmm5 );
+ pavgb (xmm5, xmm4 );
+ psubusb( xmm2, xmm7 );
+ pavgb (xmm0, xmm2 );
+ pavgb (xmm2, xmm5);
+ movdqa (ecx, xmm0);
+ movdqa (xmm0, xmm4);
+ movdqa (ecx+eax, xmm2);
+ }
}
static void MC_put_xy_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int eax = stride;
- int esi = height;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm2, xmm1, xmm3, xmm4, xmm5;
- movdqa(xmm7, const_1_16_bytes);
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + 1);
- for(; esi; edx += edi, ecx += edi, esi -= 2)
- {
- movlpd(xmm2, edx + eax);
- movlpd(xmm3, edx + eax + 1);
- movlpd(xmm4, edx + edi);
- movlpd(xmm5, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movdqa(xmm1, xmm5);
- pavgb(xmm5, xmm4);
- psubusb(xmm2, xmm7);
- pavgb(xmm0, xmm2);
- pavgb(xmm2, xmm5);
- movlpd(ecx, xmm0);
- movdqa(xmm0, xmm4);
- movlpd(ecx + eax, xmm2);
- }
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int eax= stride;
+ int esi= height;
+ int edi= eax+eax;
+ __m128i xmm7,xmm0,xmm2,xmm1,xmm3,xmm4,xmm5;
+ movdqa (xmm7, const_1_16_bytes);
+ movlpd (xmm0, edx);
+ movlpd (xmm1, edx+1);
+ for (;esi;edx+= edi,ecx+= edi,esi-= 2)
+ {
+ movlpd (xmm2, edx+eax);
+ movlpd (xmm3, edx+eax+1);
+ movlpd (xmm4, edx+edi);
+ movlpd (xmm5, edx+edi+1);
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm2, xmm3 );
+ movdqa( xmm1, xmm5 );
+ pavgb (xmm5, xmm4 );
+ psubusb( xmm2, xmm7 );
+ pavgb (xmm0, xmm2 );
+ pavgb (xmm2, xmm5);
+ movlpd (ecx, xmm0);
+ movdqa (xmm0, xmm4);
+ movlpd (ecx+eax, xmm2);
+ }
}
static void MC_avg_o_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ int ebx= edi+eax;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- __m128i xmm0, xmm1, xmm2, xmm3;
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- pavgb(xmm0, ecx);
- pavgb(xmm1, ecx + eax);
- pavgb(xmm2, ecx + edi);
- pavgb(xmm3, ecx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- }
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4)
+ {
+ __m128i xmm0,xmm1,xmm2,xmm3;
+ movdqu (xmm0, edx);
+ movdqu (xmm1, edx+eax );
+ movdqu (xmm2, edx+edi);
+ movdqu (xmm3, edx+ebx );
+ pavgb (xmm0, ecx);
+ pavgb (xmm1, ecx+eax);
+ pavgb (xmm2, ecx+edi);
+ pavgb (xmm3, ecx+ebx);
+ movdqa (ecx, xmm0);
+ movdqa (ecx+eax, xmm1 );
+ movdqa (ecx+edi, xmm2);
+ movdqa (ecx+ebx, xmm3 );
+ }
}
static void MC_avg_o_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ int ebx= edi+eax;
- __m128i xmm0, xmm1, xmm2, xmm3;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- movlpd(xmm0, edx);
- movhpd(xmm0, edx + eax);
- movlpd(xmm2, edx + edi);
- movhpd(xmm2, edx + ebx);
- movlpd(xmm1, ecx);
- movhpd(xmm1, ecx + eax);
- movlpd(xmm3, ecx + edi);
- movhpd(xmm3, ecx + ebx);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movlpd(ecx, xmm0);
- movhpd(ecx + eax, xmm0);
- movlpd(ecx + edi, xmm2);
- movhpd(ecx + ebx, xmm2);
- }
+ __m128i xmm0,xmm1,xmm2,xmm3;
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4)
+ {
+ movlpd (xmm0, edx);
+ movhpd (xmm0, edx+eax );
+ movlpd (xmm2, edx+edi);
+ movhpd (xmm2, edx+ebx );
+ movlpd (xmm1, ecx);
+ movhpd (xmm1, ecx+eax);
+ movlpd (xmm3, ecx+edi);
+ movhpd (xmm3, ecx+ebx);
+ pavgb (xmm0, xmm1);
+ pavgb (xmm2, xmm3);
+ movlpd (ecx, xmm0);
+ movhpd (ecx+eax, xmm0);
+ movlpd (ecx+edi, xmm2);
+ movhpd (ecx+ebx, xmm2);
+ }
}
static void MC_avg_x_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ int ebx= edi+eax;
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- movdqu(xmm6, edx + ebx);
- movdqu(xmm7, edx + ebx + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm4, xmm5);
- pavgb(xmm6, xmm7);
- pavgb(xmm0, ecx);
- pavgb(xmm2, ecx + eax);
- pavgb(xmm4, ecx + edi);
- pavgb(xmm6, ecx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm2);
- movdqa(ecx + edi, xmm4);
- movdqa(ecx + ebx, xmm6);
- }
+ __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7;
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4)
+ {
+ movdqu (xmm0, edx);
+ movdqu (xmm1, edx+1);
+ movdqu (xmm2, edx+eax);
+ movdqu (xmm3, edx+eax+1);
+ movdqu (xmm4, edx+edi);
+ movdqu (xmm5, edx+edi+1);
+ movdqu (xmm6, edx+ebx);
+ movdqu (xmm7, edx+ebx+1);
+ pavgb (xmm0, xmm1);
+ pavgb (xmm2, xmm3);
+ pavgb (xmm4, xmm5);
+ pavgb (xmm6, xmm7);
+ pavgb (xmm0, ecx);
+ pavgb (xmm2, ecx+eax);
+ pavgb (xmm4, ecx+edi);
+ pavgb (xmm6, ecx+ebx);
+ movdqa (ecx, xmm0);
+ movdqa (ecx+eax, xmm2);
+ movdqa (ecx+edi, xmm4);
+ movdqa (ecx+ebx, xmm6);
+ }
}
static void MC_avg_x_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ int ebx= edi+eax;
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + 1);
- movhpd(xmm0, edx + eax);
- movhpd(xmm1, edx + eax + 1);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + edi + 1);
- movhpd(xmm2, edx + ebx);
- movhpd(xmm3, edx + ebx + 1);
- movlpd(xmm4, ecx);
- movhpd(xmm4, ecx + eax);
- movlpd(xmm5, ecx + edi);
- movhpd(xmm5, ecx + ebx);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm0, xmm4);
- pavgb(xmm2, xmm5);
- movlpd(ecx, xmm0);
- movhpd(ecx + eax, xmm0);
- movlpd(ecx + edi, xmm2);
- movhpd(ecx + ebx, xmm2);
- }
+ __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5;
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4)
+ {
+ movlpd (xmm0, edx);
+ movlpd (xmm1, edx+1);
+ movhpd (xmm0, edx+eax);
+ movhpd (xmm1, edx+eax+1);
+ movlpd (xmm2, edx+edi);
+ movlpd (xmm3, edx+edi+1);
+ movhpd (xmm2, edx+ebx);
+ movhpd (xmm3, edx+ebx+1);
+ movlpd (xmm4, ecx);
+ movhpd (xmm4, ecx+eax);
+ movlpd (xmm5, ecx+edi);
+ movhpd (xmm5, ecx+ebx);
+ pavgb (xmm0, xmm1);
+ pavgb (xmm2, xmm3);
+ pavgb (xmm0, xmm4);
+ pavgb (xmm2, xmm5);
+ movlpd (ecx, xmm0);
+ movhpd (ecx+eax, xmm0);
+ movlpd (ecx+edi, xmm2);
+ movhpd (ecx+ebx, xmm2);
+ }
}
static void MC_avg_y_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4;
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ int ebx= edi+eax;
+ __m128i xmm0,xmm1,xmm2,xmm3,xmm4;
- movdqu(xmm0, edx);
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- movdqu(xmm4, edx + edi * 2);
- pavgb(xmm0, xmm1);
- pavgb(xmm1, xmm2);
- pavgb(xmm2, xmm3);
- pavgb(xmm3, xmm4);
- pavgb(xmm0, ecx);
- pavgb(xmm1, ecx + eax);
- pavgb(xmm2, ecx + edi);
- pavgb(xmm3, ecx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- movdqa(xmm0, xmm4);
- }
+ movdqu (xmm0,edx);
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4)
+ {
+ movdqu (xmm1, edx+eax );
+ movdqu (xmm2, edx+edi );
+ movdqu (xmm3, edx+ebx );
+ movdqu (xmm4, edx+edi*2 );
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm1, xmm2 );
+ pavgb (xmm2, xmm3 );
+ pavgb (xmm3, xmm4 );
+ pavgb (xmm0, ecx);
+ pavgb (xmm1, ecx+eax );
+ pavgb (xmm2, ecx+edi);
+ pavgb (xmm3, ecx+ebx );
+ movdqa (ecx, xmm0 );
+ movdqa (ecx+eax, xmm1 );
+ movdqa (ecx+edi, xmm2 );
+ movdqa (ecx+ebx, xmm3 );
+ movdqa (xmm0, xmm4 );
+ }
}
static void MC_avg_y_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
- movhpd(xmm0, edx);
- movlpd(xmm0, edx + eax);
- for(; esi; edx += edi * 2, ecx += edi * 2, esi -= 4)
- {
- movlhps(xmm1, xmm0);
- movlpd(xmm1, edx + edi);
- movlhps(xmm2, xmm1);
- movlpd(xmm2, edx + ebx);
- movlhps(xmm3, xmm2);
- movlpd(xmm3, edx + edi * 2);
- movhpd(xmm4, ecx);
- movlpd(xmm4, ecx + eax);
- movhpd(xmm5, ecx + edi);
- movlpd(xmm5, ecx + ebx);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm0, xmm4);
- pavgb(xmm2, xmm5);
- movhpd(ecx, xmm0);
- movlpd(ecx + eax, xmm0);
- movhpd(ecx + edi, xmm2);
- movlpd(ecx + ebx, xmm2);
- movdqa(xmm0, xmm3);
- }
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ int ebx= edi+eax;
+ __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5;
+ movhpd (xmm0, edx );
+ movlpd (xmm0, edx+eax );
+ for (;esi;edx+=edi*2,ecx+=edi*2,esi-=4)
+ {
+ movlhps (xmm1, xmm0);
+ movlpd (xmm1, edx+edi );
+ movlhps (xmm2, xmm1);
+ movlpd (xmm2, edx+ebx );
+ movlhps (xmm3, xmm2);
+ movlpd (xmm3, edx+edi*2 );
+ movhpd (xmm4, ecx );
+ movlpd (xmm4, ecx+eax );
+ movhpd (xmm5, ecx+edi );
+ movlpd (xmm5, ecx+ebx );
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm2, xmm3);
+ pavgb (xmm0, xmm4);
+ pavgb (xmm2, xmm5);
+ movhpd (ecx, xmm0 );
+ movlpd (ecx+eax, xmm0 );
+ movhpd (ecx+edi, xmm2 );
+ movlpd (ecx+ebx, xmm2);
+ movdqa (xmm0, xmm3 );
+ }
}
static void MC_avg_xy_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
- movdqa(xmm7, const_1_16_bytes);
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- for(; esi; edx += edi, ecx += edi, esi -= 2)
- {
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movdqa(xmm1, xmm5);
- pavgb(xmm5, xmm4);
- psubusb(xmm2, xmm7);
- pavgb(xmm0, xmm2);
- pavgb(xmm2, xmm5);
- pavgb(xmm0, ecx);
- pavgb(xmm2, ecx + eax);
- movdqa(ecx, xmm0);
- movdqa(xmm0, xmm4);
- movdqa(ecx + eax, xmm2);
- }
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ __m128i xmm7,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5;
+ movdqa (xmm7, const_1_16_bytes );
+ movdqu (xmm0, edx );
+ movdqu (xmm1, edx+1 );
+ for (;esi;edx+=edi,ecx+=edi,esi-=2)
+ {
+ movdqu (xmm2, edx+eax );
+ movdqu (xmm3, edx+eax+1 );
+ movdqu (xmm4, edx+edi );
+ movdqu (xmm5, edx+edi+1 );
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm2, xmm3 );
+ movdqa (xmm1, xmm5 );
+ pavgb (xmm5, xmm4 );
+ psubusb (xmm2, xmm7 );
+ pavgb (xmm0, xmm2 );
+ pavgb (xmm2, xmm5);
+ pavgb (xmm0, ecx );
+ pavgb (xmm2, ecx+eax);
+ movdqa (ecx, xmm0);
+ movdqa (xmm0, xmm4);
+ movdqa (ecx+eax, xmm2);
+ }
}
static void MC_avg_xy_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx = ref;
- uint8_t *ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm2, xmm1, xmm3, xmm4;
- movdqa(xmm7, const_1_16_bytes);
- movhpd(xmm0, edx);
- movlpd(xmm0, edx + eax);
- movhpd(xmm2, edx + 1);
- movlpd(xmm2, edx + eax + 1);
- for(; esi; edx += edi, ecx += edi, esi -= 2)
- {
+ const uint8_t *edx= ref;
+ uint8_t *ecx= dest;
+ int esi= height;
+ int eax= stride;
+ int edi= eax+eax;
+ __m128i xmm7,xmm0,xmm2,xmm1,xmm3,xmm4;
+ movdqa (xmm7, const_1_16_bytes );
+ movhpd (xmm0, edx );
+ movlpd (xmm0, edx+eax );
+ movhpd (xmm2, edx+1 );
+ movlpd (xmm2, edx+eax+1 );
+ for (;esi;edx+=edi,ecx+=edi,esi-=2)
+ {
- movhpd(xmm1, edx + eax);
- movlpd(xmm1, edx + edi);
- movhpd(xmm3, edx + eax + 1);
- movlpd(xmm3, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- psubusb(xmm0, xmm7);
- pavgb(xmm0, xmm2);
- movhpd(xmm4, ecx);
- movlpd(xmm4, ecx + eax);
- pavgb(xmm0, xmm4);
- movhpd(ecx, xmm0);
- movlpd(ecx + eax, xmm0);
- movdqa(xmm0, xmm1);
- movdqa(xmm2, xmm3);
- }
+ movhpd (xmm1, edx+eax );
+ movlpd (xmm1, edx+edi );
+ movhpd (xmm3, edx+eax+1 );
+ movlpd (xmm3, edx+edi+1 );
+ pavgb (xmm0, xmm1 );
+ pavgb (xmm2, xmm3 );
+ psubusb( xmm0, xmm7 );
+ pavgb (xmm0, xmm2 );
+ movhpd( xmm4, ecx);
+ movlpd( xmm4, ecx+eax);
+ pavgb (xmm0, xmm4 );
+ movhpd (ecx, xmm0 );
+ movlpd (ecx+eax, xmm0 );
+ movdqa (xmm0, xmm1 );
+ movdqa (xmm2, xmm3 );
+ }
}
mpeg2_mc_t mpeg2_mc_sse2 =
{
- {
- MC_put_o_16_sse2, MC_put_x_16_sse2, MC_put_y_16_sse2, MC_put_xy_16_sse2,
- MC_put_o_8_sse2, MC_put_x_8_sse2, MC_put_y_8_sse2, MC_put_xy_8_sse2
- },
- {
- MC_avg_o_16_sse2, MC_avg_x_16_sse2, MC_avg_y_16_sse2, MC_avg_xy_16_sse2,
- MC_avg_o_8_sse2, MC_avg_x_8_sse2, MC_avg_y_8_sse2, MC_avg_xy_8_sse2
- }
+ {MC_put_o_16_sse2, MC_put_x_16_sse2, MC_put_y_16_sse2, MC_put_xy_16_sse2,
+ MC_put_o_8_sse2, MC_put_x_8_sse2, MC_put_y_8_sse2, MC_put_xy_8_sse2},
+ {MC_avg_o_16_sse2, MC_avg_x_16_sse2, MC_avg_y_16_sse2, MC_avg_xy_16_sse2,
+ MC_avg_o_8_sse2, MC_avg_x_8_sse2, MC_avg_y_8_sse2, MC_avg_xy_8_sse2}
};
diff --git a/src/filters/transform/Mpeg2DecFilter/resource.h b/src/filters/transform/Mpeg2DecFilter/resource.h
index e6056a041..5050ae86a 100644
--- a/src/filters/transform/Mpeg2DecFilter/resource.h
+++ b/src/filters/transform/Mpeg2DecFilter/resource.h
@@ -15,7 +15,7 @@
#define IDS_MPEG2DECSETTINGSWND_8 33160
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
diff --git a/src/filters/transform/Mpeg2DecFilter/stdafx.cpp b/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
index 5899c1666..4b29d63b8 100644
--- a/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/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/transform/Mpeg2DecFilter/stdafx.h b/src/filters/transform/Mpeg2DecFilter/stdafx.h
index c202d2a46..d4cb512b1 100644
--- a/src/filters/transform/Mpeg2DecFilter/stdafx.h
+++ b/src/filters/transform/Mpeg2DecFilter/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
*
*/