Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2010-12-17 19:42:55 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-12-17 19:42:55 +0300
commit7359bd509afa235acc2ac2f7f95fc9cb5cafd1a4 (patch)
treeb5bb90eeca58fdeb9fde6825f21a25a319823cb4 /src/filters/transform
parentd30b15ed4b98c28951d6d45b8928f4c2b6a11129 (diff)
apply astyle formatting
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2786 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform')
-rw-r--r--src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp320
-rw-r--r--src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h23
-rw-r--r--src/filters/transform/AVI2AC3Filter/stdafx.cpp6
-rw-r--r--src/filters/transform/AVI2AC3Filter/stdafx.h6
-rw-r--r--src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp448
-rw-r--r--src/filters/transform/BaseVideoFilter/BaseVideoFilter.h25
-rw-r--r--src/filters/transform/BaseVideoFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/BaseVideoFilter/stdafx.h6
-rw-r--r--src/filters/transform/BufferFilter/BufferFilter.cpp129
-rw-r--r--src/filters/transform/BufferFilter/BufferFilter.h49
-rw-r--r--src/filters/transform/BufferFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/BufferFilter/stdafx.h6
-rw-r--r--src/filters/transform/DeCSSFilter/DeCSSFilter.cpp157
-rw-r--r--src/filters/transform/DeCSSFilter/DeCSSFilter.h18
-rw-r--r--src/filters/transform/DeCSSFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/DeCSSFilter/stdafx.h6
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.cpp545
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.h15
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp228
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp81
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp95
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.h18
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.c387
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.h3
-rw-r--r--src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h116
-rw-r--r--src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h6
-rw-r--r--src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp96
-rw-r--r--src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h2
-rw-r--r--src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp9
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp1038
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h61
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp131
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h3
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp6
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.h3
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp70
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h17
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp31
-rw-r--r--src/filters/transform/MPCVideoDec/stdafx.cpp6
-rw-r--r--src/filters/transform/MpaDecFilter/IMpaDecFilter.h6
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.cpp1641
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.h12
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp68
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h3
-rw-r--r--src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h10
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp1410
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h125
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp30
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h21
-rw-r--r--src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp478
-rw-r--r--src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp767
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.h6
-rw-r--r--src/filters/transform/VSFilter/AvgLines.cpp75
-rw-r--r--src/filters/transform/VSFilter/Copy.cpp111
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.cpp248
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.h8
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.cpp848
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.h3
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubPropPage.cpp851
-rw-r--r--src/filters/transform/VSFilter/IDirectVobSub.h9
-rw-r--r--src/filters/transform/VSFilter/Scale2x.cpp65
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.cpp60
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.h5
-rw-r--r--src/filters/transform/VSFilter/Systray.cpp335
-rw-r--r--src/filters/transform/VSFilter/VSFilter.cpp40
-rw-r--r--src/filters/transform/VSFilter/csri.h532
-rw-r--r--src/filters/transform/VSFilter/csriapi.cpp43
-rw-r--r--src/filters/transform/VSFilter/plugins.cpp1828
-rw-r--r--src/filters/transform/VSFilter/vfr.cpp39
-rw-r--r--src/filters/transform/VSFilter/vfr.h3
71 files changed, 6919 insertions, 6951 deletions
diff --git a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
index 412e860c6..24394dd83 100644
--- a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
+++ b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -29,31 +29,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CAVI2AC3Filter), L"MPC - AVI<->AC3/DTS", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAVI2AC3Filter>, NULL, &sudFilter[0]}
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAVI2AC3Filter>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
@@ -79,9 +74,11 @@ CFilterApp theApp;
//
CAVI2AC3Filter::CAVI2AC3Filter(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CAVI2AC3Filter"), lpunk, __uuidof(this))
+ : CTransformFilter(NAME("CAVI2AC3Filter"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CAVI2AC3Filter::~CAVI2AC3Filter()
@@ -93,77 +90,76 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
HRESULT hr;
BYTE* pIn = NULL;
- if(FAILED(hr = pSample->GetPointer(&pIn))) return hr;
+ if(FAILED(hr = pSample->GetPointer(&pIn))) {
+ return hr;
+ }
BYTE* pInOrg = pIn;
long len = pSample->GetActualDataLength();
- if(len <= 0) return S_FALSE;
+ if(len <= 0) {
+ return S_FALSE;
+ }
BYTE* pOut = NULL;
- if(FAILED(hr = pOutSample->GetPointer(&pOut))) return hr;
+ if(FAILED(hr = pOutSample->GetPointer(&pOut))) {
+ return hr;
+ }
BYTE* pOutOrg = pOut;
int size = pOutSample->GetSize();
if((CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType()))
- && (CheckWAVEAC3(&m_pOutput->CurrentMediaType()) || CheckWAVEDTS(&m_pOutput->CurrentMediaType())))
- {
- if(*(DWORD*)pIn == 0xBA010000)
- {
+ && (CheckWAVEAC3(&m_pOutput->CurrentMediaType()) || CheckWAVEDTS(&m_pOutput->CurrentMediaType()))) {
+ if(*(DWORD*)pIn == 0xBA010000) {
pIn += 14;
}
- if(*(DWORD*)pIn == 0xBD010000)
- {
+ if(*(DWORD*)pIn == 0xBD010000) {
pIn += 8 + 1 + pIn[8] + 1 + 3;
}
len -= (pInOrg - pIn);
- if(size < len) return E_FAIL;
+ if(size < len) {
+ return E_FAIL;
+ }
memcpy(pOut, pIn, len);
pOut += len;
- }
- else if((CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType()))
- && (CheckAC3(&m_pOutput->CurrentMediaType()) || CheckDTS(&m_pOutput->CurrentMediaType())))
- {
+ } else if((CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType()))
+ && (CheckAC3(&m_pOutput->CurrentMediaType()) || CheckDTS(&m_pOutput->CurrentMediaType()))) {
if((m_pOutput->CurrentMediaType().majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- || m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES)
- && (len + 12 + 3) >= 0x10000) // damn, this can happen if the interleave time is too big
- {
+ || m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES)
+ && (len + 12 + 3) >= 0x10000) { // damn, this can happen if the interleave time is too big
REFERENCE_TIME rtStart = 0, rtStop = 1;
bool fHasTime = (S_OK == pSample->GetTime(&rtStart, &rtStop));
bool fDiscontinuity = (S_OK == pOutSample->IsDiscontinuity());
int pos = 0;
- while(pos < len)
- {
+ while(pos < len) {
int curlen = min(len - pos, 2013);
pos += 2013;
CComPtr<IMediaSample> pOutSample;
hr = InitializeOutputSample(pSample, &pOutSample);
- if(fDiscontinuity)
- {
- if(fHasTime)
- {
+ if(fDiscontinuity) {
+ if(fHasTime) {
rtStop = rtStart + (rtStop - rtStart) * curlen / len;
pOutSample->SetTime(&rtStart, &rtStop);
}
fDiscontinuity = false;
- }
- else
- {
+ } else {
pOutSample->SetTime(NULL, NULL);
pOutSample->SetDiscontinuity(FALSE);
}
BYTE* pOut = NULL;
- if(FAILED(hr = pOutSample->GetPointer(&pOut))) return hr;
+ if(FAILED(hr = pOutSample->GetPointer(&pOut))) {
+ return hr;
+ }
BYTE* pOutOrg = pOut;
int size = pOutSample->GetSize();
@@ -171,12 +167,12 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
- if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- {
- if(size < curlen + 32 + 3) return E_FAIL;
+ if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if(size < curlen + 32 + 3) {
+ return E_FAIL;
+ }
- BYTE PESHeader[] =
- {
+ BYTE PESHeader[] = {
0x00,0x00,0x01,0xBA, // PES id
0x44,0x00,0x04,0x00,0x04,0x01, // SCR (0)
0x01,0x89,0xC3,0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
@@ -188,12 +184,12 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_MPEG2_PES;
}
- if(*majortype == MEDIATYPE_MPEG2_PES)
- {
- if(size < curlen + 20 + 3) return E_FAIL;
+ if(*majortype == MEDIATYPE_MPEG2_PES) {
+ if(size < curlen + 20 + 3) {
+ return E_FAIL;
+ }
- BYTE Private1Header[] =
- {
+ BYTE Private1Header[] = {
0x00,0x00,0x01,0xBD, // private stream 1 id
0x07,0xEC, // packet length (TODO: modify it later)
0x81,0x80, // marker, original, PTS - flags
@@ -209,30 +205,22 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
Private1Header[4] = (packetlen>>8)&0xff;
Private1Header[5] = packetlen&0xff;
- if(*subtype == MEDIASUBTYPE_DTS)
- {
+ if(*subtype == MEDIASUBTYPE_DTS) {
Private1Header[17] += 8;
}
- if(*subtype == MEDIASUBTYPE_DOLBY_AC3)
- {
- for(int i = 0; i < curlen; i++)
- {
- if(*(DWORD*)&pIn[i] == 0x770B)
- {
+ if(*subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ for(int i = 0; i < curlen; i++) {
+ if(*(DWORD*)&pIn[i] == 0x770B) {
i++;
Private1Header[19] = (i>>8)&0xff;
Private1Header[20] = i&0xff;
break;
}
}
- }
- else if(*subtype == MEDIASUBTYPE_DTS)
- {
- for(int i = 0; i < curlen; i++)
- {
- if(*(DWORD*)&pIn[i] == 0x0180FE7F)
- {
+ } else if(*subtype == MEDIASUBTYPE_DTS) {
+ for(int i = 0; i < curlen; i++) {
+ if(*(DWORD*)&pIn[i] == 0x0180FE7F) {
i++;
Private1Header[19] = (i>>8)&0xff;
Private1Header[20] = i&0xff;
@@ -247,9 +235,10 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_Audio;
}
- if(*majortype == MEDIATYPE_Audio)
- {
- if(size < curlen) return E_FAIL;
+ if(*majortype == MEDIATYPE_Audio) {
+ if(size < curlen) {
+ return E_FAIL;
+ }
memcpy(pOut, pIn, curlen);
pIn += curlen;
pOut += curlen;
@@ -261,18 +250,16 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
}
return S_FALSE;
- }
- else // phew, we can do the easier way
- {
+ } else { // phew, we can do the easier way
const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
- if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- {
- if(size < len + 32 + 3) return E_FAIL;
+ if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if(size < len + 32 + 3) {
+ return E_FAIL;
+ }
- BYTE PESHeader[] =
- {
+ BYTE PESHeader[] = {
0x00,0x00,0x01,0xBA, // PES id
0x44,0x00,0x04,0x00,0x04,0x01, // SCR (0)
0x01,0x89,0xC3,0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
@@ -284,12 +271,12 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_MPEG2_PES;
}
- if(*majortype == MEDIATYPE_MPEG2_PES)
- {
- if(size < len + 20 + 3) return E_FAIL;
+ if(*majortype == MEDIATYPE_MPEG2_PES) {
+ if(size < len + 20 + 3) {
+ return E_FAIL;
+ }
- BYTE Private1Header[] =
- {
+ BYTE Private1Header[] = {
0x00,0x00,0x01,0xBD, // private stream 1 id
0x07,0xEC, // packet length (TODO: modify it later)
0x81,0x80, // marker, original, PTS - flags
@@ -305,8 +292,7 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
Private1Header[4] = (packetlen>>8)&0xff;
Private1Header[5] = packetlen&0xff;
- if(*subtype == MEDIASUBTYPE_DTS)
- {
+ if(*subtype == MEDIASUBTYPE_DTS) {
Private1Header[17] += 8;
}
@@ -316,18 +302,17 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_Audio;
}
- if(*majortype == MEDIATYPE_Audio)
- {
- if(size < len) return E_FAIL;
+ if(*majortype == MEDIATYPE_Audio) {
+ if(size < len) {
+ return E_FAIL;
+ }
memcpy(pOut, pIn, len);
pIn += len;
pOut += len;
}
}
- }
- else
- {
+ } else {
return E_FAIL;
}
@@ -339,33 +324,33 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
bool CAVI2AC3Filter::CheckAC3(const CMediaType* pmt)
{
return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
|| pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
}
bool CAVI2AC3Filter::CheckDTS(const CMediaType* pmt)
{
return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
|| pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DTS;
+ && pmt->subtype == MEDIASUBTYPE_DTS;
}
bool CAVI2AC3Filter::CheckWAVEAC3(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
+ && pmt->subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
}
bool CAVI2AC3Filter::CheckWAVEDTS(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
+ && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
}
HRESULT CAVI2AC3Filter::CheckInputType(const CMediaType* mtIn)
@@ -373,28 +358,32 @@ HRESULT CAVI2AC3Filter::CheckInputType(const CMediaType* mtIn)
bool fWaveFormatEx = !!(mtIn->formattype == FORMAT_WaveFormatEx);
return CheckAC3(mtIn) && fWaveFormatEx || CheckDTS(mtIn) && fWaveFormatEx
- || CheckWAVEAC3(mtIn) || CheckWAVEDTS(mtIn)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ || CheckWAVEAC3(mtIn) || CheckWAVEDTS(mtIn)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CAVI2AC3Filter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
return CheckAC3(mtIn) && CheckWAVEAC3(mtOut)
- || CheckWAVEAC3(mtIn) && CheckAC3(mtOut)
- || CheckDTS(mtIn) && CheckWAVEDTS(mtOut)
- || CheckWAVEDTS(mtIn) && CheckDTS(mtOut)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ || CheckWAVEAC3(mtIn) && CheckAC3(mtOut)
+ || CheckDTS(mtIn) && CheckWAVEDTS(mtOut)
+ || CheckWAVEDTS(mtIn) && CheckDTS(mtOut)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CAVI2AC3Filter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
pAllocatorIn->GetProperties(pProperties);
@@ -405,26 +394,32 @@ HRESULT CAVI2AC3Filter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PR
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
- return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
const GUID& majortype = m_pInput->CurrentMediaType().majortype;
const GUID& subtype = m_pInput->CurrentMediaType().subtype;
UNUSED_ALWAYS(majortype);
-
- if(CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType()))
- {
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
+
+ if(CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType())) {
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
pMediaType->majortype = MEDIATYPE_Audio;
@@ -438,44 +433,38 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
wfe->nChannels = 2;
wfe->nBlockAlign = 1;
- if(subtype == MEDIASUBTYPE_DOLBY_AC3)
- {
+ if(subtype == MEDIASUBTYPE_DOLBY_AC3) {
pMediaType->subtype = MEDIASUBTYPE_WAVE_DOLBY_AC3;
wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- }
- else if(subtype == MEDIASUBTYPE_DTS)
- {
+ } else if(subtype == MEDIASUBTYPE_DTS) {
pMediaType->subtype = MEDIASUBTYPE_WAVE_DTS;
wfe->wFormatTag = WAVE_FORMAT_DVD_DTS;
+ } else {
+ return E_INVALIDARG;
}
- else
- {
+ } else if(CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType())) {
+ if(iPosition < 0) {
return E_INVALIDARG;
}
- }
- else if(CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType()))
- {
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 4) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition > 4) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- if(subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3)
- {
+ if(subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
pMediaType->subtype = MEDIASUBTYPE_DOLBY_AC3;
pMediaType->formattype = FORMAT_WaveFormatEx;
DOLBYAC3WAVEFORMAT* wfe = (DOLBYAC3WAVEFORMAT*)pMediaType->AllocFormatBuffer(sizeof(DOLBYAC3WAVEFORMAT));
memset(wfe, 0, sizeof(DOLBYAC3WAVEFORMAT));
- // unfortunately we can't tell what we are going to get in transform,
- // so we just set the most common values and hope that the ac3 decoder
+ // unfortunately we can't tell what we are going to get in transform,
+ // so we just set the most common values and hope that the ac3 decoder
// is flexible enough (it is usually :) to find out these from the bitstream
wfe->wfx.cbSize = sizeof(DOLBYAC3WAVEFORMAT) - sizeof(WAVEFORMATEX);
wfe->wfx.wFormatTag = WAVE_FORMAT_DOLBY_AC3;
wfe->wfx.nSamplesPerSec = 48000;
wfe->wfx.nChannels = 6;
wfe->bBigEndian = TRUE;
- }
- else if(subtype == MEDIASUBTYPE_WAVE_DTS)
- {
+ } else if(subtype == MEDIASUBTYPE_WAVE_DTS) {
pMediaType->subtype = MEDIASUBTYPE_DTS;
pMediaType->formattype = FORMAT_WaveFormatEx;
@@ -486,35 +475,30 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
wfe->wFormatTag = WAVE_FORMAT_PCM;
wfe->nSamplesPerSec = 48000;
wfe->nChannels = 6;
- }
- else
- {
+ } else {
return E_INVALIDARG;
}
- switch(iPosition)
- {
- case 0:
- pMediaType->majortype = MEDIATYPE_Audio;
- break;
- case 1:
- pMediaType->ResetFormatBuffer();
- pMediaType->formattype = FORMAT_None;
- case 2:
- pMediaType->majortype = MEDIATYPE_MPEG2_PES;
- break;
- case 3:
- pMediaType->ResetFormatBuffer();
- pMediaType->formattype = FORMAT_None;
- case 4:
- pMediaType->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
- break;
- default:
- return E_INVALIDARG;
+ switch(iPosition) {
+ case 0:
+ pMediaType->majortype = MEDIATYPE_Audio;
+ break;
+ case 1:
+ pMediaType->ResetFormatBuffer();
+ pMediaType->formattype = FORMAT_None;
+ case 2:
+ pMediaType->majortype = MEDIATYPE_MPEG2_PES;
+ break;
+ case 3:
+ pMediaType->ResetFormatBuffer();
+ pMediaType->formattype = FORMAT_None;
+ case 4:
+ pMediaType->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
+ break;
+ default:
+ return E_INVALIDARG;
}
- }
- else
- {
+ } else {
return VFW_S_NO_MORE_ITEMS;
}
diff --git a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
index c199bfa90..f178ef616 100644
--- a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
+++ b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -32,14 +32,13 @@
*/
-typedef struct tagDOLBYAC3WAVEFORMAT
-{
- WAVEFORMATEX wfx;
- BYTE bBigEndian; // TRUE = Big Endian, FALSE little endian
- BYTE bsid;
- BYTE lfeon;
- BYTE copyrightb;
- BYTE nAuxBitsCode; // Aux bits per frame
+typedef struct tagDOLBYAC3WAVEFORMAT {
+ WAVEFORMATEX wfx;
+ BYTE bBigEndian; // TRUE = Big Endian, FALSE little endian
+ BYTE bsid;
+ BYTE lfeon;
+ BYTE copyrightb;
+ BYTE nAuxBitsCode; // Aux bits per frame
} DOLBYAC3WAVEFORMAT;
//
@@ -47,7 +46,7 @@ typedef struct tagDOLBYAC3WAVEFORMAT
//
class __declspec(uuid("93230DD0-7B3C-4efb-AFBB-DC380FEC9E6B"))
-CAVI2AC3Filter : public CTransformFilter
+ CAVI2AC3Filter : public CTransformFilter
{
bool CheckAC3(const CMediaType* pmt);
bool CheckDTS(const CMediaType* pmt);
diff --git a/src/filters/transform/AVI2AC3Filter/stdafx.cpp b/src/filters/transform/AVI2AC3Filter/stdafx.cpp
index 2d8565418..9508867df 100644
--- a/src/filters/transform/AVI2AC3Filter/stdafx.cpp
+++ b/src/filters/transform/AVI2AC3Filter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/AVI2AC3Filter/stdafx.h b/src/filters/transform/AVI2AC3Filter/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/transform/AVI2AC3Filter/stdafx.h
+++ b/src/filters/transform/AVI2AC3Filter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
index a75457d82..e4d902bac 100644
--- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
+++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -33,19 +33,30 @@
//
bool f_need_set_aspect;
-CBaseVideoFilter::CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers)
+CBaseVideoFilter::CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers)
: CTransformFilter(pName, lpunk, clsid)
, m_cBuffers(cBuffers)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput = DNew CBaseVideoInputPin(NAME("CBaseVideoInputPin"), this, phr, L"Video");
- if(!m_pInput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
m_pOutput = DNew CBaseVideoOutputPin(NAME("CBaseVideoOutputPin"), this, phr, L"Output");
- if(!m_pOutput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) {delete m_pInput, m_pInput = NULL; return;}
+ if(!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ delete m_pInput, m_pInput = NULL;
+ return;
+ }
m_wout = m_win = m_w = 0;
m_hout = m_hin = m_h = 0;
@@ -73,10 +84,11 @@ int CBaseVideoFilter::GetPinCount()
CBasePin* CBaseVideoFilter::GetPin(int n)
{
- switch(n)
- {
- case 0: return m_pInput;
- case 1: return m_pOutput;
+ switch(n) {
+ case 0:
+ return m_pInput;
+ case 1:
+ return m_pOutput;
}
return NULL;
}
@@ -92,20 +104,21 @@ HRESULT CBaseVideoFilter::Receive(IMediaSample* pIn)
HRESULT hr;
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
+ if(pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pInput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
- if(FAILED(hr = Transform(pIn)))
+ if(FAILED(hr = Transform(pIn))) {
return hr;
+ }
return S_OK;
}
@@ -116,15 +129,16 @@ HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut)
HRESULT hr;
- if(FAILED(hr = ReconnectOutput(w, h)))
+ if(FAILED(hr = ReconnectOutput(w, h))) {
return hr;
+ }
- if(FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0)))
+ if(FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0))) {
return hr;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -135,8 +149,9 @@ HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut)
// FIXME: hell knows why but without this the overlay mixer starts very skippy
// (don't enable this for other renderers, the old for example will go crazy if you do)
- if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer)
+ if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
(*ppOut)->SetDiscontinuity(TRUE);
+ }
return S_OK;
}
@@ -146,12 +161,10 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
CMediaType& mt = m_pOutput->CurrentMediaType();
bool m_update_aspect = false;
- if(f_need_set_aspect)
- {
+ if(f_need_set_aspect) {
int wout = 0, hout = 0, arxout = 0, aryout = 0;
ExtractDim(&mt, wout, hout, arxout, aryout);
- if(arxout != m_arx || aryout != m_ary)
- {
+ if(arxout != m_arx || aryout != m_ary) {
CString debug_s;
debug_s.Format(_T("\nCBaseVideoFilter::ReconnectOutput; wout = %d, hout = %d, current = %dx%d, set = %dx%d\n"), wout, hout, arxout, aryout, m_arx, m_ary);
TRACE(debug_s);
@@ -163,8 +176,7 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
int h_org = m_h;
bool fForceReconnection = false;
- if(w != m_w || h != m_h)
- {
+ if(w != m_w || h != m_h) {
fForceReconnection = true;
m_w = w;
m_h = h;
@@ -172,52 +184,39 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
HRESULT hr = S_OK;
- if(m_update_aspect || fForceReconnection || m_w != m_wout || m_h != m_hout || m_arx != m_arxout || m_ary != m_aryout)
- {
- if(GetCLSID(m_pOutput->GetConnected()) == CLSID_VideoRenderer)
- {
+ if(m_update_aspect || fForceReconnection || m_w != m_wout || m_h != m_hout || m_arx != m_arxout || m_ary != m_aryout) {
+ if(GetCLSID(m_pOutput->GetConnected()) == CLSID_VideoRenderer) {
NotifyEvent(EC_ERRORABORT, 0, 0);
return E_FAIL;
}
BITMAPINFOHEADER* bmi = NULL;
- if(mt.formattype == FORMAT_VideoInfo)
- {
+ if(mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.Format();
- if (realWidth != -1 && realHeight != -1)
- {
+ if (realWidth != -1 && realHeight != -1) {
SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
- }
- else
- {
+ } else {
SetRect(&vih->rcSource, 0, 0, m_w, m_h);
SetRect(&vih->rcTarget, 0, 0, m_w, m_h);
}
bmi = &vih->bmiHeader;
bmi->biXPelsPerMeter = m_w * m_ary;
bmi->biYPelsPerMeter = m_h * m_arx;
- }
- else if(mt.formattype == FORMAT_VideoInfo2)
- {
+ } else if(mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)mt.Format();
- if (realWidth != -1 && realHeight != -1)
- {
+ if (realWidth != -1 && realHeight != -1) {
SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
- }
- else
- {
+ } else {
SetRect(&vih->rcSource, 0, 0, m_w, m_h);
SetRect(&vih->rcTarget, 0, 0, m_w, m_h);
}
bmi = &vih->bmiHeader;
vih->dwPictAspectRatioX = m_arx;
vih->dwPictAspectRatioY = m_ary;
- }
- else
- {
+ } else {
return E_FAIL; //should never be here? prevent null pointer refs for bmi
}
@@ -229,27 +228,19 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
ASSERT(SUCCEEDED(hr)); // should better not fail, after all "mt" is the current media type, just with a different resolution
HRESULT hr1 = 0, hr2 = 0;
CComPtr<IMediaSample> pOut;
- if(SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt)))
- {
- if (bSendSample)
- {
- if (SUCCEEDED(hr2 = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0)))
- {
+ if(SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt))) {
+ if (bSendSample) {
+ if (SUCCEEDED(hr2 = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))) {
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
- }
- else // stupid overlay mixer won't let us know the new pitch...
- {
+ } else { // stupid overlay mixer won't let us know the new pitch...
long size = pOut->GetSize();
bmi->biWidth = size / bmi->biHeight * 8 / bmi->biBitCount;
}
- }
- else
- {
+ } else {
m_w = w_org;
m_h = h_org;
return E_FAIL;
@@ -285,20 +276,19 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int
int pitchOut = 0;
- if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
+ if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
- if(bihOut.biHeight > 0)
- {
+ if(bihOut.biHeight > 0) {
pOut += pitchOut*(h-1);
pitchOut = -pitchOut;
- if(h < 0) h = -h;
+ if(h < 0) {
+ h = -h;
+ }
}
}
- if(h < 0)
- {
+ if(h < 0) {
h = -h;
ppIn[0] += pitchIn*(h-1);
ppIn[1] += (pitchIn>>1)*((h>>1)-1);
@@ -306,79 +296,70 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int
pitchIn = -pitchIn;
}
- if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12)
- {
+ if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
BYTE* pIn = ppIn[0];
BYTE* pInU = ppIn[1];
BYTE* pInV = ppIn[2];
- if(subtype == MEDIASUBTYPE_YV12) {BYTE* tmp = pInU; pInU = pInV; pInV = tmp;}
+ if(subtype == MEDIASUBTYPE_YV12) {
+ BYTE* tmp = pInU;
+ pInU = pInV;
+ pInV = tmp;
+ }
BYTE* pOutU = pOut + bihOut.biWidth*h;
BYTE* pOutV = pOut + bihOut.biWidth*h*5/4;
- if(bihOut.biCompression == '21VY') {BYTE* tmp = pOutU; pOutU = pOutV; pOutV = tmp;}
+ if(bihOut.biCompression == '21VY') {
+ BYTE* tmp = pOutU;
+ pOutU = pOutV;
+ pOutV = tmp;
+ }
ASSERT(w <= abs(pitchIn));
- if(bihOut.biCompression == '2YUY')
- {
- if (!fInterlaced)
+ if(bihOut.biCompression == '2YUY') {
+ if (!fInterlaced) {
BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- else
+ } else {
BitBltFromI420ToYUY2Interlaced(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == '024I' || bihOut.biCompression == 'VUYI' || bihOut.biCompression == '21VY')
- {
+ }
+ } else if(bihOut.biCompression == '024I' || bihOut.biCompression == 'VUYI' || bihOut.biCompression == '21VY') {
BitBltFromI420ToI420(w, h, pOut, pOutU, pOutV, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
- if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn))
- {
- for(DWORD y = 0; y < h; y++, pOut += pitchOut)
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
+ for(DWORD y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
+ }
}
}
- }
- else if(subtype == MEDIASUBTYPE_YUY2)
- {
- if(bihOut.biCompression == '2YUY')
- {
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
+ if(bihOut.biCompression == '2YUY') {
BitBltFromYUY2ToYUY2(w, h, pOut, bihOut.biWidth*2, ppIn[0], pitchIn);
- }
- else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
- if(!BitBltFromYUY2ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn))
- {
- for(DWORD y = 0; y < h; y++, pOut += pitchOut)
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if(!BitBltFromYUY2ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn)) {
+ for(DWORD y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
+ }
}
}
- }
- else if(subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565)
- {
- int sbpp =
+ } else if(subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565) {
+ int sbpp =
subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 ? 32 :
subtype == MEDIASUBTYPE_RGB24 ? 24 :
subtype == MEDIASUBTYPE_RGB565 ? 16 : 0;
- if(bihOut.biCompression == '2YUY')
- {
+ if(bihOut.biCompression == '2YUY') {
// TODO
// BitBltFromRGBToYUY2();
- }
- else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
- if(!BitBltFromRGBToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn, sbpp))
- {
- for(DWORD y = 0; y < h; y++, pOut += pitchOut)
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if(!BitBltFromRGBToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn, sbpp)) {
+ for(DWORD y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
+ }
}
}
- }
- else
- {
+ } else {
return VFW_E_TYPE_NOT_ACCEPTED;
}
@@ -390,63 +371,62 @@ HRESULT CBaseVideoFilter::CheckInputType(const CMediaType* mtIn)
BITMAPINFOHEADER bih;
ExtractBIH(mtIn, &bih);
- return mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_YV12
- || mtIn->subtype == MEDIASUBTYPE_I420
- || mtIn->subtype == MEDIASUBTYPE_IYUV
- || mtIn->subtype == MEDIASUBTYPE_YUY2
- || mtIn->subtype == MEDIASUBTYPE_ARGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB24
- || mtIn->subtype == MEDIASUBTYPE_RGB565)
- && (mtIn->formattype == FORMAT_VideoInfo
- || mtIn->formattype == FORMAT_VideoInfo2)
- && bih.biHeight > 0
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_YV12
+ || mtIn->subtype == MEDIASUBTYPE_I420
+ || mtIn->subtype == MEDIASUBTYPE_IYUV
+ || mtIn->subtype == MEDIASUBTYPE_YUY2
+ || mtIn->subtype == MEDIASUBTYPE_ARGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB24
+ || mtIn->subtype == MEDIASUBTYPE_RGB565)
+ && (mtIn->formattype == FORMAT_VideoInfo
+ || mtIn->formattype == FORMAT_VideoInfo2)
+ && bih.biHeight > 0
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CBaseVideoFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if(FAILED(CheckInputType(mtIn)) || mtOut->majortype != MEDIATYPE_Video)
+ if(FAILED(CheckInputType(mtIn)) || mtOut->majortype != MEDIATYPE_Video) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_YV12
- || mtIn->subtype == MEDIASUBTYPE_I420
- || mtIn->subtype == MEDIASUBTYPE_IYUV))
- {
+ if(mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_YV12
+ || mtIn->subtype == MEDIASUBTYPE_I420
+ || mtIn->subtype == MEDIASUBTYPE_IYUV)) {
if(mtOut->subtype != MEDIASUBTYPE_YV12
- && mtOut->subtype != MEDIASUBTYPE_I420
- && mtOut->subtype != MEDIASUBTYPE_IYUV
- && mtOut->subtype != MEDIASUBTYPE_YUY2
- && mtOut->subtype != MEDIASUBTYPE_ARGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB24
- && mtOut->subtype != MEDIASUBTYPE_RGB565)
+ && mtOut->subtype != MEDIASUBTYPE_I420
+ && mtOut->subtype != MEDIASUBTYPE_IYUV
+ && mtOut->subtype != MEDIASUBTYPE_YUY2
+ && mtOut->subtype != MEDIASUBTYPE_ARGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB24
+ && mtOut->subtype != MEDIASUBTYPE_RGB565) {
return VFW_E_TYPE_NOT_ACCEPTED;
- }
- else if(mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_YUY2))
- {
+ }
+ } else if(mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_YUY2)) {
if(mtOut->subtype != MEDIASUBTYPE_YUY2
- && mtOut->subtype != MEDIASUBTYPE_ARGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB24
- && mtOut->subtype != MEDIASUBTYPE_RGB565)
+ && mtOut->subtype != MEDIASUBTYPE_ARGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB24
+ && mtOut->subtype != MEDIASUBTYPE_RGB565) {
return VFW_E_TYPE_NOT_ACCEPTED;
- }
- else if(mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_ARGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB24
- || mtIn->subtype == MEDIASUBTYPE_RGB565))
- {
+ }
+ } else if(mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_ARGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB24
+ || mtIn->subtype == MEDIASUBTYPE_RGB565)) {
if(mtOut->subtype != MEDIASUBTYPE_ARGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB24
- && mtOut->subtype != MEDIASUBTYPE_RGB565)
+ && mtOut->subtype != MEDIASUBTYPE_RGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB24
+ && mtOut->subtype != MEDIASUBTYPE_RGB565) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return S_OK;
@@ -456,15 +436,17 @@ HRESULT CBaseVideoFilter::CheckOutputType(const CMediaType& mtOut)
{
int wout = 0, hout = 0, arxout = 0, aryout = 0;
return ExtractDim(&mtOut, wout, hout, arxout, aryout)
- && m_h == abs((int)hout)
- && mtOut.subtype != MEDIASUBTYPE_ARGB32
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ && m_h == abs((int)hout)
+ && mtOut.subtype != MEDIASUBTYPE_ARGB32
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CBaseVideoFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
@@ -479,17 +461,17 @@ HRESULT CBaseVideoFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
}
-VIDEO_OUTPUT_FORMATS DefaultFormats[] =
-{
+VIDEO_OUTPUT_FORMATS DefaultFormats[] = {
{&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
{&MEDIASUBTYPE_I420, 3, 12, '024I'},
{&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
@@ -518,7 +500,9 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
VIDEO_OUTPUT_FORMATS* fmts;
int nFormatCount;
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
// this will make sure we won't connect to the old renderer in dvd mode
@@ -527,16 +511,22 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
bool fFoundDVDNavigator = false;
CComPtr<IBaseFilter> pBF = this;
CComPtr<IPin> pPin = m_pInput;
- for(; !fFoundDVDNavigator && (pBF = GetUpStreamFilter(pBF, pPin)); pPin = GetFirstPin(pBF))
- fFoundDVDNavigator = GetCLSID(pBF) == CLSID_DVDNavigator;
+ for(; !fFoundDVDNavigator && (pBF = GetUpStreamFilter(pBF, pPin)); pPin = GetFirstPin(pBF)) {
+ fFoundDVDNavigator = GetCLSID(pBF) == CLSID_DVDNavigator;
+ }
- if(fFoundDVDNavigator || m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2)
+ if(fFoundDVDNavigator || m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2) {
iPosition = iPosition*2;
+ }
//
GetOutputFormats (nFormatCount, &fmts);
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= 2*nFormatCount) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= 2*nFormatCount) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = *fmts[iPosition/2].subtype;
@@ -556,24 +546,23 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
bihOut.biCompression = fmts[iPosition/2].biCompression;
bihOut.biSizeImage = w*h*bihOut.biBitCount>>3;
- if(iPosition&1)
- {
+ if(iPosition&1) {
pmt->formattype = FORMAT_VideoInfo;
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
memset(vih, 0, sizeof(VIDEOINFOHEADER));
vih->bmiHeader = bihOut;
vih->bmiHeader.biXPelsPerMeter = vih->bmiHeader.biWidth * ary;
vih->bmiHeader.biYPelsPerMeter = vih->bmiHeader.biHeight * arx;
- }
- else
- {
+ } else {
pmt->formattype = FORMAT_VideoInfo2;
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
memset(vih, 0, sizeof(VIDEOINFOHEADER2));
vih->bmiHeader = bihOut;
vih->dwPictAspectRatioX = arx;
vih->dwPictAspectRatioY = ary;
- if(IsVideoInterlaced()) vih->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;
+ if(IsVideoInterlaced()) {
+ vih->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;
+ }
}
CMediaType& mt = m_pInput->CurrentMediaType();
@@ -590,29 +579,27 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->Format();
VIDEOINFOHEADER* vihInput = (VIDEOINFOHEADER*)pmtInput.Format();
- if (vih && vihInput && (vihInput->rcSource.right != 0) && (vihInput->rcSource.bottom != 0))
- {
+ if (vih && vihInput && (vihInput->rcSource.right != 0) && (vihInput->rcSource.bottom != 0)) {
vih->rcSource = vihInput->rcSource;
vih->rcTarget = vihInput->rcTarget;
- }
- else
- {
+ } else {
vih->rcSource.right = vih->rcTarget.right = m_win;
vih->rcSource.bottom = vih->rcTarget.bottom = m_hin;
}
- if (RealWidth != -1 && vih->rcSource.right > RealWidth)
+ if (RealWidth != -1 && vih->rcSource.right > RealWidth) {
vih->rcSource.right = RealWidth;
- if (RealHeight != -1 && vih->rcSource.bottom > RealHeight)
+ }
+ if (RealHeight != -1 && vih->rcSource.bottom > RealHeight) {
vih->rcSource.bottom = RealHeight;
+ }
return S_OK;
}
HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
m_w = m_h = m_arx = m_ary = 0;
ExtractDim(pmt, m_w, m_h, m_arx, m_ary);
m_win = m_w;
@@ -629,14 +616,13 @@ HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
a = b % tmp;
b = tmp;
}
- if(b) m_arx /= b, m_ary /= b;
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ if(b) {
+ m_arx /= b, m_ary /= b;
+ }
+ } else if(dir == PINDIR_OUTPUT) {
int wout = 0, hout = 0, arxout = 0, aryout = 0;
ExtractDim(pmt, wout, hout, arxout, aryout);
- if(m_w == wout && m_h == hout && m_arx == arxout && m_ary == aryout)
- {
+ if(m_w == wout && m_h == hout && m_arx == arxout && m_ary == aryout) {
m_wout = wout;
m_hout = hout;
m_arxout = arxout;
@@ -650,11 +636,13 @@ HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
//
// CBaseVideoInputAllocator
//
-
+
CBaseVideoInputAllocator::CBaseVideoInputAllocator(HRESULT* phr)
: CMemAllocator(NAME("CBaseVideoInputAllocator"), NULL, phr)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
void CBaseVideoInputAllocator::SetMediaType(const CMediaType& mt)
@@ -664,13 +652,13 @@ void CBaseVideoInputAllocator::SetMediaType(const CMediaType& mt)
STDMETHODIMP CBaseVideoInputAllocator::GetBuffer(IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags)
{
- if(!m_bCommitted)
- return VFW_E_NOT_COMMITTED;
+ if(!m_bCommitted) {
+ return VFW_E_NOT_COMMITTED;
+ }
HRESULT hr = __super::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
- if(SUCCEEDED(hr) && m_mt.majortype != GUID_NULL)
- {
+ if(SUCCEEDED(hr) && m_mt.majortype != GUID_NULL) {
(*ppBuffer)->SetMediaType(&m_mt);
m_mt.majortype = GUID_NULL;
}
@@ -682,7 +670,7 @@ STDMETHODIMP CBaseVideoInputAllocator::GetBuffer(IMediaSample** ppBuffer, REFERE
// CBaseVideoInputPin
//
-CBaseVideoInputPin::CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
+CBaseVideoInputPin::CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
: CTransformInputPin(pObjectName, pFilter, phr, pName)
, m_pAllocator(NULL)
{
@@ -695,54 +683,57 @@ CBaseVideoInputPin::~CBaseVideoInputPin()
STDMETHODIMP CBaseVideoInputPin::GetAllocator(IMemAllocator** ppAllocator)
{
- CheckPointer(ppAllocator, E_POINTER);
+ CheckPointer(ppAllocator, E_POINTER);
- if(m_pAllocator == NULL)
- {
+ if(m_pAllocator == NULL) {
HRESULT hr = S_OK;
- m_pAllocator = DNew CBaseVideoInputAllocator(&hr);
- m_pAllocator->AddRef();
- }
+ m_pAllocator = DNew CBaseVideoInputAllocator(&hr);
+ m_pAllocator->AddRef();
+ }
- (*ppAllocator = m_pAllocator)->AddRef();
+ (*ppAllocator = m_pAllocator)->AddRef();
- return S_OK;
-}
+ return S_OK;
+}
STDMETHODIMP CBaseVideoInputPin::ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt)
{
CAutoLock cObjectLock(m_pLock);
- if(m_Connected)
- {
+ if(m_Connected) {
CMediaType mt(*pmt);
- if(FAILED(CheckMediaType(&mt)))
+ if(FAILED(CheckMediaType(&mt))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
ALLOCATOR_PROPERTIES props, actual;
CComPtr<IMemAllocator> pMemAllocator;
if(FAILED(GetAllocator(&pMemAllocator))
- || FAILED(pMemAllocator->Decommit())
- || FAILED(pMemAllocator->GetProperties(&props)))
+ || FAILED(pMemAllocator->Decommit())
+ || FAILED(pMemAllocator->GetProperties(&props))) {
return E_FAIL;
+ }
BITMAPINFOHEADER bih;
- if(ExtractBIH(pmt, &bih) && bih.biSizeImage)
+ if(ExtractBIH(pmt, &bih) && bih.biSizeImage) {
props.cbBuffer = bih.biSizeImage;
+ }
if(FAILED(pMemAllocator->SetProperties(&props, &actual))
- || FAILED(pMemAllocator->Commit())
- || props.cbBuffer != actual.cbBuffer)
+ || FAILED(pMemAllocator->Commit())
+ || props.cbBuffer != actual.cbBuffer) {
return E_FAIL;
+ }
- if(m_pAllocator)
+ if(m_pAllocator) {
m_pAllocator->SetMediaType(mt);
+ }
return SetMediaType(&mt) == S_OK
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
return __super::ReceiveConnection(pConnector, pmt);
@@ -759,10 +750,11 @@ CBaseVideoOutputPin::CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* p
HRESULT CBaseVideoOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- if(IsConnected())
- {
+ if(IsConnected()) {
HRESULT hr = (static_cast<CBaseVideoFilter*>(m_pFilter))->CheckOutputType(*mtOut);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
return __super::CheckMediaType(mtOut);
diff --git a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
index 37ffdc049..cc5eccbb2 100644
--- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
+++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -22,8 +22,7 @@
#pragma once
-typedef struct
-{
+typedef struct {
const GUID* subtype;
WORD biPlanes;
WORD biBitCount;
@@ -33,7 +32,7 @@ typedef struct
class CBaseVideoFilter : public CTransformFilter
{
private:
- HRESULT Receive(IMediaSample* pIn);
+ HRESULT Receive(IMediaSample* pIn);
// these are private for a reason, don't bother them
int m_win, m_hin, m_arxin, m_aryin;
@@ -52,7 +51,9 @@ protected:
virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int &RealWidth, int &RealHeight) {}
virtual HRESULT Transform(IMediaSample* pIn) = 0;
- virtual bool IsVideoInterlaced() {return false;}
+ virtual bool IsVideoInterlaced() {
+ return false;
+ }
virtual void GetOutputFormats (int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
public:
@@ -63,11 +64,11 @@ public:
int GetPinCount();
CBasePin* GetPin(int n);
- HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckInputType(const CMediaType* mtIn);
HRESULT CheckOutputType(const CMediaType& mtOut);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt);
void SetAspect(CSize aspect);
@@ -100,5 +101,5 @@ class CBaseVideoOutputPin : public CTransformOutputPin
public:
CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
- HRESULT CheckMediaType(const CMediaType* mtOut);
+ HRESULT CheckMediaType(const CMediaType* mtOut);
};
diff --git a/src/filters/transform/BaseVideoFilter/stdafx.cpp b/src/filters/transform/BaseVideoFilter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/transform/BaseVideoFilter/stdafx.cpp
+++ b/src/filters/transform/BaseVideoFilter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/BaseVideoFilter/stdafx.h b/src/filters/transform/BaseVideoFilter/stdafx.h
index e0d4538b1..79bb9cc0d 100644
--- a/src/filters/transform/BaseVideoFilter/stdafx.h
+++ b/src/filters/transform/BaseVideoFilter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/BufferFilter/BufferFilter.cpp b/src/filters/transform/BufferFilter/BufferFilter.cpp
index e79e3b2a8..51f021b8a 100644
--- a/src/filters/transform/BufferFilter/BufferFilter.cpp
+++ b/src/filters/transform/BufferFilter/BufferFilter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -25,29 +25,24 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CBufferFilter), L"MPC - Buffer Filter", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CBufferFilter>, NULL, &sudFilter[0]}
};
@@ -73,25 +68,34 @@ CFilterApp theApp;
// CBufferFilter
//
-CBufferFilter::CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr)
+CBufferFilter::CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CBufferFilter"), lpunk, __uuidof(this))
, m_nSamplesToBuffer(2)
{
HRESULT hr = S_OK;
- do
- {
+ do {
m_pInput = DNew CTransformInputPin(NAME("Transform input pin"), this, &hr, L"In");
- if(!m_pInput) hr = E_OUTOFMEMORY;
- if(FAILED(hr)) break;
+ if(!m_pInput) {
+ hr = E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ break;
+ }
m_pOutput = DNew CBufferFilterOutputPin(this, &hr);
- if(!m_pOutput) hr = E_OUTOFMEMORY;
- if(FAILED(hr)) {delete m_pInput, m_pInput = NULL; break;}
- }
- while(false);
+ if(!m_pOutput) {
+ hr = E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ delete m_pInput, m_pInput = NULL;
+ break;
+ }
+ } while(false);
- if(phr) *phr = hr;
+ if(phr) {
+ *phr = hr;
+ }
}
CBufferFilter::~CBufferFilter()
@@ -109,11 +113,13 @@ STDMETHODIMP CBufferFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
STDMETHODIMP CBufferFilter::SetBuffers(int nBuffers)
{
- if(!m_pOutput)
+ if(!m_pOutput) {
return E_FAIL;
+ }
- if(m_pOutput->IsConnected()) // TODO: allow "on-the-fly" changes
+ if(m_pOutput->IsConnected()) { // TODO: allow "on-the-fly" changes
return VFW_E_ALREADY_CONNECTED;
+ }
m_nSamplesToBuffer = nBuffers;
@@ -143,8 +149,9 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample)
{
/* Check for other streams and pass them on */
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ if(pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pSample);
+ }
HRESULT hr;
ASSERT(pSample);
@@ -155,8 +162,9 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample)
// Set up the output sample
hr = InitializeOutputSample(pSample, &pOutSample);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
// Start timing the transform (if PERF is defined)
MSR_START(m_idTransform);
@@ -170,16 +178,14 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample)
if(FAILED(hr)) {
DbgLog((LOG_TRACE,1,TEXT("Error from transform")));
- }
- else {
+ } else {
// the Transform() function can return S_FALSE to indicate that the
// sample should not be delivered; we only deliver the sample if it's
// really S_OK (same as NOERROR, of course.)
if(hr == NOERROR) {
hr = m_pOutput->Deliver(pOutSample);
m_bSampleSkipped = FALSE; // last thing no longer dropped
- }
- else {
+ } else {
// S_FALSE returned from Transform is a PRIVATE agreement
// We should return NOERROR from Receive() in this cause because returning S_FALSE
// from Receive() means that this is the end of the stream and no more data should
@@ -218,10 +224,12 @@ HRESULT CBufferFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
long len = pIn->GetActualDataLength();
long size = pOut->GetSize();
- if(!pDataIn || !pDataOut || len > size || len <= 0) return S_FALSE;
+ if(!pDataIn || !pDataOut || len > size || len <= 0) {
+ return S_FALSE;
+ }
memcpy(pDataOut, pDataIn, min(len, size));
-
+
pOut->SetActualDataLength(min(len, size));
return S_OK;
@@ -239,11 +247,15 @@ HRESULT CBufferFilter::CheckTransform(const CMediaType* mtIn, const CMediaType*
HRESULT CBufferFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
pAllocatorIn->GetProperties(pProperties);
@@ -251,21 +263,28 @@ HRESULT CBufferFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
- return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CBufferFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
// TODO: offer all input types from upstream and allow reconnection at least in stopped state
- 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;
+ }
CopyMediaType(pMediaType, &m_pInput->CurrentMediaType());
@@ -275,10 +294,10 @@ HRESULT CBufferFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
HRESULT CBufferFilter::StopStreaming()
{
CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
- if(m_pInput && pPin && pPin->m_pOutputQueue)
- {
- while(!m_pInput->IsFlushing() && pPin->m_pOutputQueue->GetQueueCount() > 0)
+ if(m_pInput && pPin && pPin->m_pOutputQueue) {
+ while(!m_pInput->IsFlushing() && pPin->m_pOutputQueue->GetQueueCount() > 0) {
Sleep(50);
+ }
}
return __super::StopStreaming();
@@ -297,15 +316,15 @@ HRESULT CBufferFilterOutputPin::Active()
{
CAutoLock lock_it(m_pLock);
- if(m_Connected && !m_pOutputQueue)
- {
+ if(m_Connected && !m_pOutputQueue) {
HRESULT hr = NOERROR;
m_pOutputQueue.Attach(DNew CBufferFilterOutputQueue(m_Connected, &hr));
- if(!m_pOutputQueue) hr = E_OUTOFMEMORY;
+ if(!m_pOutputQueue) {
+ hr = E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
m_pOutputQueue.Free();
return hr;
}
@@ -323,7 +342,9 @@ HRESULT CBufferFilterOutputPin::Inactive()
HRESULT CBufferFilterOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if(!m_pOutputQueue) return NOERROR;
+ if(!m_pOutputQueue) {
+ return NOERROR;
+ }
pMediaSample->AddRef();
return m_pOutputQueue->Receive(pMediaSample);
}
@@ -332,7 +353,7 @@ HRESULT CBufferFilterOutputPin::Deliver(IMediaSample* pMediaSample)
if(!m_pOutputQueue) return NOERROR; \
m_pOutputQueue->##call; \
return NOERROR; \
-
+
HRESULT CBufferFilterOutputPin::DeliverEndOfStream()
{
CallQueue(EOS());
diff --git a/src/filters/transform/BufferFilter/BufferFilter.h b/src/filters/transform/BufferFilter/BufferFilter.h
index 7bba2767f..f95bb02bb 100644
--- a/src/filters/transform/BufferFilter/BufferFilter.h
+++ b/src/filters/transform/BufferFilter/BufferFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -24,8 +24,8 @@
#include <atlbase.h>
interface __declspec(uuid("63EF0035-3FFE-4c41-9230-4346E028BE20"))
-IBufferFilter : public IUnknown
-{
+IBufferFilter :
+public IUnknown {
STDMETHOD(SetBuffers) (int nBuffers) = 0;
STDMETHOD_(int, GetBuffers) () = 0;
STDMETHOD_(int, GetFreeBuffers) () = 0;
@@ -33,7 +33,7 @@ IBufferFilter : public IUnknown
};
class __declspec(uuid("DA2B3D77-2F29-4fd2-AC99-DEE4A8A13BF0"))
-CBufferFilter : public CTransformFilter, public IBufferFilter
+ CBufferFilter : public CTransformFilter, public IBufferFilter
{
int m_nSamplesToBuffer;
@@ -42,7 +42,7 @@ public:
virtual ~CBufferFilter();
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IBufferFilter
STDMETHODIMP SetBuffers(int nBuffers);
@@ -52,10 +52,10 @@ public:
HRESULT Receive(IMediaSample* pSample);
HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
HRESULT StopStreaming();
};
@@ -65,22 +65,19 @@ class CBufferFilterOutputPin : public CTransformOutputPin
{
public:
CBufferFilterOutputQueue(IPin* pInputPin, HRESULT* phr,
- DWORD dwPriority = THREAD_PRIORITY_NORMAL,
- BOOL bAuto = FALSE, BOOL bQueue = TRUE,
- LONG lBatchSize = 1, BOOL bBatchExact = FALSE,
- LONG lListSize = DEFAULTCACHE,
- bool bFlushingOpt = false)
- : COutputQueue(pInputPin, phr, bAuto, bQueue, lBatchSize, bBatchExact, lListSize, dwPriority, bFlushingOpt)
- {
+ DWORD dwPriority = THREAD_PRIORITY_NORMAL,
+ BOOL bAuto = FALSE, BOOL bQueue = TRUE,
+ LONG lBatchSize = 1, BOOL bBatchExact = FALSE,
+ LONG lListSize = DEFAULTCACHE,
+ bool bFlushingOpt = false)
+ : COutputQueue(pInputPin, phr, bAuto, bQueue, lBatchSize, bBatchExact, lListSize, dwPriority, bFlushingOpt) {
}
- int GetQueueCount()
- {
+ int GetQueueCount() {
return m_List ? m_List->GetCount() : -1;
}
- bool SetPriority(DWORD dwPriority)
- {
+ bool SetPriority(DWORD dwPriority) {
return m_hThread ? !!::SetThreadPriority(m_hThread, dwPriority) : false;
}
};
@@ -91,11 +88,11 @@ public:
CAutoPtr<CBufferFilterOutputQueue> m_pOutputQueue;
HRESULT Active();
- HRESULT Inactive();
+ HRESULT Inactive();
HRESULT Deliver(IMediaSample* pMediaSample);
- HRESULT DeliverEndOfStream();
- HRESULT DeliverBeginFlush();
+ HRESULT DeliverEndOfStream();
+ HRESULT DeliverBeginFlush();
HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
diff --git a/src/filters/transform/BufferFilter/stdafx.cpp b/src/filters/transform/BufferFilter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/transform/BufferFilter/stdafx.cpp
+++ b/src/filters/transform/BufferFilter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/BufferFilter/stdafx.h b/src/filters/transform/BufferFilter/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/transform/BufferFilter/stdafx.h
+++ b/src/filters/transform/BufferFilter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
index 0ee407ed1..511d32613 100644
--- a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
+++ b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -27,31 +27,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_NULL},
{&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CDeCSSFilter), L"MPC - DeCSSFilter", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDeCSSFilter>, NULL, &sudFilter[0]},
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDeCSSFilter>, NULL, &sudFilter[0]},
};
int g_cTemplates = countof(g_Templates);
@@ -79,44 +74,54 @@ CFilterApp theApp;
class CKsPSInputPin : public CDeCSSInputPin
{
public:
- CKsPSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(pObjectName, pFilter, phr, pName)
- {
+ CKsPSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
+ : CDeCSSInputPin(pObjectName, pFilter, phr, pName) {
}
// IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength)
- {
- if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected())
+ STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength) {
+ if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
return pKsPS->Set(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength);
+ }
return E_NOTIMPL;
}
- STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned)
- {
- if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected())
+ STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned) {
+ if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
return pKsPS->Get(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength, pBytesReturned);
+ }
return E_NOTIMPL;
}
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
- {
- if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected())
+ STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport) {
+ if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
+ }
return E_NOTIMPL;
}
};
-CDeCSSFilter::CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr)
+CDeCSSFilter::CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CDeCSSFilter"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput = DNew CKsPSInputPin(NAME("CKsPSInputPin"), this, phr, L"In");
- if(!m_pInput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
- if(!m_pOutput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) {delete m_pInput, m_pInput = NULL; return;}
+ if(!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ delete m_pInput, m_pInput = NULL;
+ return;
+ }
}
CDeCSSFilter::~CDeCSSFilter()
@@ -126,8 +131,7 @@ CDeCSSFilter::~CDeCSSFilter()
HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pInput->SetMediaType(&mt);
mt.majortype = m_pOutput->CurrentMediaType().majortype;
@@ -145,30 +149,38 @@ HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
long len = pIn->GetActualDataLength();
long size = pOut->GetSize();
- if(len == 0 || pDataIn == NULL) // format changes do not carry any data
- {
+ if(len == 0 || pDataIn == NULL) { // format changes do not carry any data
pOut->SetActualDataLength(0);
return S_OK;
}
- if(m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES)
- {
- if(*(DWORD*)pDataIn == 0xBA010000)
- {
- len -= 14; pDataIn += 14;
- if(int stuffing = (pDataIn[-1]&7)) {len -= stuffing; pDataIn += stuffing;}
+ if(m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES) {
+ if(*(DWORD*)pDataIn == 0xBA010000) {
+ len -= 14;
+ pDataIn += 14;
+ if(int stuffing = (pDataIn[-1]&7)) {
+ len -= stuffing;
+ pDataIn += stuffing;
+ }
+ }
+ if(len <= 0) {
+ return S_FALSE;
}
- if(len <= 0) return S_FALSE;
- if(*(DWORD*)pDataIn == 0xBB010000)
- {
- len -= 4; pDataIn += 4;
+ if(*(DWORD*)pDataIn == 0xBB010000) {
+ len -= 4;
+ pDataIn += 4;
int hdrlen = ((pDataIn[0]<<8)|pDataIn[1]) + 2;
- len -= hdrlen; pDataIn += hdrlen;
+ len -= hdrlen;
+ pDataIn += hdrlen;
+ }
+ if(len <= 0) {
+ return S_FALSE;
}
- if(len <= 0) return S_FALSE;
}
- if(!pDataIn || !pDataOut || len > size || len < 0) return S_FALSE;
+ if(!pDataIn || !pDataOut || len > size || len < 0) {
+ return S_FALSE;
+ }
memcpy(pDataOut, pDataIn, min(len, size));
pOut->SetActualDataLength(min(len, size));
@@ -179,21 +191,23 @@ HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT CDeCSSFilter::CheckInputType(const CMediaType* mtIn)
{
return mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CDeCSSFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_MPEG2_PACK || mtOut->majortype == MEDIATYPE_MPEG2_PES
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ && mtOut->majortype == MEDIATYPE_MPEG2_PACK || mtOut->majortype == MEDIATYPE_MPEG2_PES
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CDeCSSFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
pProperties->cbAlign = 1;
pProperties->cBuffers = 1;
@@ -202,24 +216,35 @@ HRESULT CDeCSSFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROP
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
- return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CDeCSSFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 1) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 1) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
CopyMediaType(pmt, &m_pInput->CurrentMediaType());
- if(iPosition == 0) pmt->majortype = MEDIATYPE_MPEG2_PACK;
- if(iPosition == 1) pmt->majortype = MEDIATYPE_MPEG2_PES;
+ if(iPosition == 0) {
+ pmt->majortype = MEDIATYPE_MPEG2_PACK;
+ }
+ if(iPosition == 1) {
+ pmt->majortype = MEDIATYPE_MPEG2_PES;
+ }
return S_OK;
}
diff --git a/src/filters/transform/DeCSSFilter/DeCSSFilter.h b/src/filters/transform/DeCSSFilter/DeCSSFilter.h
index 37c1aa0d0..58fbf1f2d 100644
--- a/src/filters/transform/DeCSSFilter/DeCSSFilter.h
+++ b/src/filters/transform/DeCSSFilter/DeCSSFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
@@ -22,7 +22,7 @@
#pragma once
class __declspec(uuid("7B3BD419-FE03-4820-BE94-A22A4F844895"))
-CDeCSSFilter : public CTransformFilter
+ CDeCSSFilter : public CTransformFilter
{
friend class CKsPSInputPin;
@@ -30,10 +30,10 @@ public:
CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr);
virtual ~CDeCSSFilter();
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
};
diff --git a/src/filters/transform/DeCSSFilter/stdafx.cpp b/src/filters/transform/DeCSSFilter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/transform/DeCSSFilter/stdafx.cpp
+++ b/src/filters/transform/DeCSSFilter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/DeCSSFilter/stdafx.h b/src/filters/transform/DeCSSFilter/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/transform/DeCSSFilter/stdafx.h
+++ b/src/filters/transform/DeCSSFilter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
index 771fbc212..374080e74 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
@@ -98,8 +98,9 @@ void CDXVADecoder::AllocExecuteParams (int nSize)
{
m_ExecuteParams.pCompressedBuffers = DNew DXVA2_DecodeBufferDesc[nSize];
- for (int i=0; i<nSize; i++)
+ for (int i=0; i<nSize; i++) {
memset (&m_ExecuteParams.pCompressedBuffers[i], 0, sizeof(DXVA2_DecodeBufferDesc));
+ }
}
void CDXVADecoder::SetExtraData (BYTE* pDataIn, UINT nSize)
@@ -117,8 +118,7 @@ void CDXVADecoder::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
void CDXVADecoder::Flush()
{
TRACE ("CDXVADecoder::Flush\n");
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
m_pPictureStore[i].bRefPicture = false;
m_pPictureStore[i].bInUse = false;
m_pPictureStore[i].bDisplayed = false;
@@ -139,8 +139,7 @@ HRESULT CDXVADecoder::ConfigureDXVA1()
HRESULT hr = S_FALSE;
DXVA_ConfigPictureDecode ConfigRequested;
- if (m_pAMVideoAccelerator)
- {
+ if (m_pAMVideoAccelerator) {
memset (&ConfigRequested, 0, sizeof(ConfigRequested));
ConfigRequested.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
ConfigRequested.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
@@ -167,13 +166,12 @@ HRESULT CDXVADecoder::ConfigureDXVA1()
m_DXVA2Config.ConfigSpecificIDCT = m_DXVA1Config.bConfigSpecificIDCT;
m_DXVA2Config.Config4GroupedCoefs = m_DXVA1Config.bConfig4GroupedCoefs;
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
writeDXVA_QueryOrReplyFunc (&m_DXVA1Config.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
hr = m_pAMVideoAccelerator->Execute (m_DXVA1Config.dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), 0, NULL);
// TODO : check config!
-// ASSERT (ConfigRequested.bConfigBitstreamRaw == 2);
+ // ASSERT (ConfigRequested.bConfigBitstreamRaw == 2);
AMVAUncompDataInfo DataInfo;
DWORD dwNum = COMP_BUFFER_COUNT;
@@ -190,14 +188,15 @@ CDXVADecoder* CDXVADecoder::CreateDecoder (CMPCVideoDecFilter* pFilter, IAMVideo
{
CDXVADecoder* pDecoder = NULL;
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo))
+ if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
pDecoder = DNew CDXVADecoderH264 (pFilter, pAMVideoAccelerator, H264_VLD, nPicEntryNumber);
- else if (*guidDecoder == DXVA2_ModeVC1_D || *guidDecoder == DXVA_Intel_VC1_ClearVideo)
+ } else if (*guidDecoder == DXVA2_ModeVC1_D || *guidDecoder == DXVA_Intel_VC1_ClearVideo) {
pDecoder = DNew CDXVADecoderVC1 (pFilter, pAMVideoAccelerator, VC1_VLD, nPicEntryNumber);
- else if (*guidDecoder == DXVA2_ModeMPEG2_VLD)
+ } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
pDecoder = DNew CDXVADecoderMpeg2 (pFilter, pAMVideoAccelerator, MPEG2_VLD, nPicEntryNumber);
- else
- ASSERT (FALSE); // Unknown decoder !!
+ } else {
+ ASSERT (FALSE); // Unknown decoder !!
+ }
return pDecoder;
}
@@ -207,14 +206,15 @@ CDXVADecoder* CDXVADecoder::CreateDecoder (CMPCVideoDecFilter* pFilter, IDirectX
{
CDXVADecoder* pDecoder = NULL;
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo))
+ if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
pDecoder = DNew CDXVADecoderH264 (pFilter, pDirectXVideoDec, H264_VLD, nPicEntryNumber, pDXVA2Config);
- else if (*guidDecoder == DXVA2_ModeVC1_D || *guidDecoder == DXVA_Intel_VC1_ClearVideo)
+ } else if (*guidDecoder == DXVA2_ModeVC1_D || *guidDecoder == DXVA_Intel_VC1_ClearVideo) {
pDecoder = DNew CDXVADecoderVC1 (pFilter, pDirectXVideoDec, VC1_VLD, nPicEntryNumber, pDXVA2Config);
- else if (*guidDecoder == DXVA2_ModeMPEG2_VLD)
+ } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
pDecoder = DNew CDXVADecoderMpeg2 (pFilter, pDirectXVideoDec, MPEG2_VLD, nPicEntryNumber, pDXVA2Config);
- else
- ASSERT (FALSE); // Unknown decoder !!
+ } else {
+ ASSERT (FALSE); // Unknown decoder !!
+ }
return pDecoder;
}
@@ -230,60 +230,61 @@ HRESULT CDXVADecoder::AddExecuteBuffer (DWORD CompressedBufferType, UINT nSize,
//if (CompressedBufferType != DXVA2_PictureParametersBufferType && CompressedBufferType != DXVA2_InverseQuantizationMatrixBufferType)
// dwNumMBs = FFGetMBNumber (m_pFilter->GetAVCtx());
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- DWORD dwTypeIndex;
- LONG lStride;
- dwTypeIndex = GetDXVA1CompressedType (CompressedBufferType);
-
-// TRACE ("Fill : %d - %d\n", dwTypeIndex, m_dwBufferIndex);
- hr = m_pAMVideoAccelerator->GetBuffer(dwTypeIndex, m_dwBufferIndex, FALSE, (void**)&pDXVABuffer, &lStride);
- ASSERT (SUCCEEDED (hr));
-
- if (SUCCEEDED (hr))
- {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType)
- CopyBitstream (pDXVABuffer, (BYTE*)pBuffer, nSize);
- else
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwDataSize = nSize;
-
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwDataSize = nSize;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwNumMBsInBuffer = dwNumMBs;
-
- m_dwNumBuffersInfo++;
- }
- break;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ DWORD dwTypeIndex;
+ LONG lStride;
+ dwTypeIndex = GetDXVA1CompressedType (CompressedBufferType);
- case ENGINE_DXVA2 :
- UINT nDXVASize;
- hr = m_pDirectXVideoDec->GetBuffer (CompressedBufferType, (void**)&pDXVABuffer, &nDXVASize);
- ASSERT (nSize <= nDXVASize);
+ // TRACE ("Fill : %d - %d\n", dwTypeIndex, m_dwBufferIndex);
+ hr = m_pAMVideoAccelerator->GetBuffer(dwTypeIndex, m_dwBufferIndex, FALSE, (void**)&pDXVABuffer, &lStride);
+ ASSERT (SUCCEEDED (hr));
- if (SUCCEEDED (hr) && (nSize <= nDXVASize))
- {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType)
- CopyBitstream (pDXVABuffer, (BYTE*)pBuffer, nSize);
- else
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
+ if (SUCCEEDED (hr)) {
+ if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
+ CopyBitstream (pDXVABuffer, (BYTE*)pBuffer, nSize);
+ } else {
+ memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
+ }
+ m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
+ m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
+ m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwDataSize = nSize;
+
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwDataSize = nSize;
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwNumMBsInBuffer = dwNumMBs;
+
+ m_dwNumBuffersInfo++;
+ }
+ break;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].CompressedBufferType = CompressedBufferType;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].DataSize = nSize;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].NumMBsInBuffer = dwNumMBs;
- m_ExecuteParams.NumCompBuffers++;
+ case ENGINE_DXVA2 :
+ UINT nDXVASize;
+ hr = m_pDirectXVideoDec->GetBuffer (CompressedBufferType, (void**)&pDXVABuffer, &nDXVASize);
+ ASSERT (nSize <= nDXVASize);
+
+ if (SUCCEEDED (hr) && (nSize <= nDXVASize)) {
+ if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
+ CopyBitstream (pDXVABuffer, (BYTE*)pBuffer, nSize);
+ } else {
+ memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
+ }
+
+ m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].CompressedBufferType = CompressedBufferType;
+ m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].DataSize = nSize;
+ m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].NumMBsInBuffer = dwNumMBs;
+ m_ExecuteParams.NumCompBuffers++;
- }
- break;
- default :
- ASSERT (FALSE);
- break;
+ }
+ break;
+ default :
+ ASSERT (FALSE);
+ break;
+ }
+ if (pRealSize) {
+ *pRealSize = nSize;
}
- if (pRealSize) *pRealSize = nSize;
return hr;
}
@@ -295,15 +296,13 @@ HRESULT CDXVADecoder::GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME r
CComPtr<IMediaSample> pNewSample;
// Change aspect ratio for DXVA2
- if (m_nEngine == ENGINE_DXVA2)
- {
+ if (m_nEngine == ENGINE_DXVA2) {
m_pFilter->UpdateAspectRatio();
m_pFilter->ReconnectOutput(m_pFilter->PictWidthRounded(), m_pFilter->PictHeightRounded(), true, m_pFilter->PictWidth(), m_pFilter->PictHeight());
}
hr = m_pFilter->GetOutputPin()->GetDeliveryBuffer(&pNewSample, 0, 0, 0);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
pNewSample->SetTime(&rtStart, &rtStop);
pNewSample->SetMediaTime(NULL, NULL);
*ppSampleToDeliver = pNewSample.Detach();
@@ -315,43 +314,40 @@ HRESULT CDXVADecoder::Execute()
{
HRESULT hr = E_INVALIDARG;
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- DWORD dwFunction;
- HRESULT hr2;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ DWORD dwFunction;
+ HRESULT hr2;
-// writeDXVA_QueryOrReplyFunc (&dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
-// hr = m_pAMVideoAccelerator->Execute (dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), NULL, 0, m_dwNumBuffersInfo, m_DXVA1BufferInfo);
+ // writeDXVA_QueryOrReplyFunc (&dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
+ // hr = m_pAMVideoAccelerator->Execute (dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), NULL, 0, m_dwNumBuffersInfo, m_DXVA1BufferInfo);
- DWORD dwResult;
- dwFunction = 0x01000000;
- hr = m_pAMVideoAccelerator->Execute (dwFunction, m_DXVA1BufferDesc, sizeof(DXVA_BufferDescription)*m_dwNumBuffersInfo,&dwResult, sizeof(dwResult), m_dwNumBuffersInfo, m_DXVA1BufferInfo);
- ASSERT (SUCCEEDED (hr));
+ DWORD dwResult;
+ dwFunction = 0x01000000;
+ hr = m_pAMVideoAccelerator->Execute (dwFunction, m_DXVA1BufferDesc, sizeof(DXVA_BufferDescription)*m_dwNumBuffersInfo,&dwResult, sizeof(dwResult), m_dwNumBuffersInfo, m_DXVA1BufferInfo);
+ ASSERT (SUCCEEDED (hr));
- for (DWORD i=0; i<m_dwNumBuffersInfo; i++)
- {
- hr2 = m_pAMVideoAccelerator->ReleaseBuffer (m_DXVA1BufferInfo[i].dwTypeIndex, m_DXVA1BufferInfo[i].dwBufferIndex);
- ASSERT (SUCCEEDED (hr2));
- }
+ for (DWORD i=0; i<m_dwNumBuffersInfo; i++) {
+ hr2 = m_pAMVideoAccelerator->ReleaseBuffer (m_DXVA1BufferInfo[i].dwTypeIndex, m_DXVA1BufferInfo[i].dwBufferIndex);
+ ASSERT (SUCCEEDED (hr2));
+ }
- m_dwNumBuffersInfo = 0;
- break;
+ m_dwNumBuffersInfo = 0;
+ break;
- case ENGINE_DXVA2 :
+ case ENGINE_DXVA2 :
- for (DWORD i=0; i<m_ExecuteParams.NumCompBuffers; i++)
- {
- hr2 = m_pDirectXVideoDec->ReleaseBuffer (m_ExecuteParams.pCompressedBuffers[i].CompressedBufferType);
- ASSERT (SUCCEEDED (hr2));
- }
+ for (DWORD i=0; i<m_ExecuteParams.NumCompBuffers; i++) {
+ hr2 = m_pDirectXVideoDec->ReleaseBuffer (m_ExecuteParams.pCompressedBuffers[i].CompressedBufferType);
+ ASSERT (SUCCEEDED (hr2));
+ }
- hr = m_pDirectXVideoDec->Execute(&m_ExecuteParams);
- m_ExecuteParams.NumCompBuffers = 0;
- break;
- default :
- ASSERT (FALSE);
- break;
+ hr = m_pDirectXVideoDec->Execute(&m_ExecuteParams);
+ m_ExecuteParams.NumCompBuffers = 0;
+ break;
+ default :
+ ASSERT (FALSE);
+ break;
}
return hr;
@@ -364,24 +360,23 @@ HRESULT CDXVADecoder::QueryStatus(PVOID LPDXVAStatus, UINT nSize)
DXVA2_DecodeExtensionData ExtensionData;
DWORD dwFunction = 0x07000000;
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- hr = m_pAMVideoAccelerator->Execute (dwFunction, NULL, 0, LPDXVAStatus, nSize, 0, NULL);
- break;
-
- case ENGINE_DXVA2 :
- memset (&ExecuteParams, 0, sizeof(ExecuteParams));
- memset (&ExtensionData, 0, sizeof(ExtensionData));
- ExecuteParams.pExtensionData = &ExtensionData;
- ExtensionData.pPrivateOutputData = LPDXVAStatus;
- ExtensionData.PrivateOutputDataSize = nSize;
- ExtensionData.Function = 7;
- hr = m_pDirectXVideoDec->Execute(&ExecuteParams);
- break;
- default :
- ASSERT (FALSE);
- break;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ hr = m_pAMVideoAccelerator->Execute (dwFunction, NULL, 0, LPDXVAStatus, nSize, 0, NULL);
+ break;
+
+ case ENGINE_DXVA2 :
+ memset (&ExecuteParams, 0, sizeof(ExecuteParams));
+ memset (&ExtensionData, 0, sizeof(ExtensionData));
+ ExecuteParams.pExtensionData = &ExtensionData;
+ ExtensionData.pPrivateOutputData = LPDXVAStatus;
+ ExtensionData.PrivateOutputDataSize = nSize;
+ ExtensionData.Function = 7;
+ hr = m_pDirectXVideoDec->Execute(&ExecuteParams);
+ break;
+ default :
+ ASSERT (FALSE);
+ break;
}
return hr;
@@ -389,21 +384,19 @@ HRESULT CDXVADecoder::QueryStatus(PVOID LPDXVAStatus, UINT nSize)
DWORD CDXVADecoder::GetDXVA1CompressedType (DWORD dwDXVA2CompressedType)
{
- if (dwDXVA2CompressedType <= DXVA2_BitStreamDateBufferType)
+ if (dwDXVA2CompressedType <= DXVA2_BitStreamDateBufferType) {
return dwDXVA2CompressedType + 1;
- else
- {
- switch (dwDXVA2CompressedType)
- {
- case DXVA2_MotionVectorBuffer :
- return DXVA_MOTION_VECTOR_BUFFER;
- break;
- case DXVA2_FilmGrainBuffer :
- return DXVA_FILM_GRAIN_BUFFER;
- break;
- default :
- ASSERT (FALSE);
- return DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED;
+ } else {
+ switch (dwDXVA2CompressedType) {
+ case DXVA2_MotionVectorBuffer :
+ return DXVA_MOTION_VECTOR_BUFFER;
+ break;
+ case DXVA2_FilmGrainBuffer :
+ return DXVA_FILM_GRAIN_BUFFER;
+ break;
+ default :
+ ASSERT (FALSE);
+ return DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED;
}
}
}
@@ -425,47 +418,47 @@ HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliv
HRESULT hr = E_INVALIDARG;
int nTry = 0;
- for (int i=0; i<20; i++)
- {
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- AMVABeginFrameInfo BeginFrameInfo;
+ for (int i=0; i<20; i++) {
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ AMVABeginFrameInfo BeginFrameInfo;
- BeginFrameInfo.dwDestSurfaceIndex = nSurfaceIndex;
- BeginFrameInfo.dwSizeInputData = sizeof(nSurfaceIndex);
- BeginFrameInfo.pInputData = &nSurfaceIndex;
- BeginFrameInfo.dwSizeOutputData = 0;
- BeginFrameInfo.pOutputData = NULL;
+ BeginFrameInfo.dwDestSurfaceIndex = nSurfaceIndex;
+ BeginFrameInfo.dwSizeInputData = sizeof(nSurfaceIndex);
+ BeginFrameInfo.pInputData = &nSurfaceIndex;
+ BeginFrameInfo.dwSizeOutputData = 0;
+ BeginFrameInfo.pOutputData = NULL;
- DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
+ DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
- ASSERT (SUCCEEDED (hr));
- // TRACE ("BeginFrame %d\n",nSurfaceIndex);
- if (SUCCEEDED (hr))
- hr = FindFreeDXVA1Buffer ((DWORD)-1, m_dwBufferIndex);
- break;
+ ASSERT (SUCCEEDED (hr));
+ // TRACE ("BeginFrame %d\n",nSurfaceIndex);
+ if (SUCCEEDED (hr)) {
+ hr = FindFreeDXVA1Buffer ((DWORD)-1, m_dwBufferIndex);
+ }
+ break;
- case ENGINE_DXVA2 :
- {
- CComQIPtr<IMFGetService> pSampleService;
- CComPtr<IDirect3DSurface9> pDecoderRenderTarget;
- pSampleService = pSampleToDeliver;
- if (pSampleService)
- {
- hr = pSampleService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**) &pDecoderRenderTarget);
- if (SUCCEEDED (hr))
- DO_DXVA_PENDING_LOOP (m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, NULL));
+ case ENGINE_DXVA2 : {
+ CComQIPtr<IMFGetService> pSampleService;
+ CComPtr<IDirect3DSurface9> pDecoderRenderTarget;
+ pSampleService = pSampleToDeliver;
+ if (pSampleService) {
+ hr = pSampleService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**) &pDecoderRenderTarget);
+ if (SUCCEEDED (hr)) {
+ DO_DXVA_PENDING_LOOP (m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, NULL));
+ }
+ }
}
- }
- break;
- default :
- ASSERT (FALSE);
break;
+ default :
+ ASSERT (FALSE);
+ break;
}
// For slow accelerator wait a little...
- if (SUCCEEDED (hr)) break;
+ if (SUCCEEDED (hr)) {
+ break;
+ }
Sleep(1);
}
@@ -478,24 +471,23 @@ HRESULT CDXVADecoder::EndFrame(int nSurfaceIndex)
HRESULT hr = E_INVALIDARG;
DWORD dwDummy = nSurfaceIndex;
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- AMVAEndFrameInfo EndFrameInfo;
-
- EndFrameInfo.dwSizeMiscData = sizeof (dwDummy); // TODO : usefull ??
- EndFrameInfo.pMiscData = &dwDummy;
- hr = m_pAMVideoAccelerator->EndFrame(&EndFrameInfo);
-// TRACE ("EndFrame %d\n",nSurfaceIndex);
- ASSERT (SUCCEEDED (hr));
- break;
-
- case ENGINE_DXVA2 :
- hr = m_pDirectXVideoDec->EndFrame(NULL);
- break;
- default :
- ASSERT (FALSE);
- break;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ AMVAEndFrameInfo EndFrameInfo;
+
+ EndFrameInfo.dwSizeMiscData = sizeof (dwDummy); // TODO : usefull ??
+ EndFrameInfo.pMiscData = &dwDummy;
+ hr = m_pAMVideoAccelerator->EndFrame(&EndFrameInfo);
+ // TRACE ("EndFrame %d\n",nSurfaceIndex);
+ ASSERT (SUCCEEDED (hr));
+ break;
+
+ case ENGINE_DXVA2 :
+ hr = m_pDirectXVideoDec->EndFrame(NULL);
+ break;
+ default :
+ ASSERT (FALSE);
+ break;
}
return hr;
@@ -506,8 +498,7 @@ bool CDXVADecoder::AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bR
REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField,
FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific)
{
- if (bIsField && (m_nFieldSurface == -1))
- {
+ if (bIsField && (m_nFieldSurface == -1)) {
m_nFieldSurface = nSurfaceIndex;
m_pFieldSample = pSample;
m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
@@ -515,9 +506,7 @@ bool CDXVADecoder::AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bR
m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
return false;
- }
- else
- {
+ } else {
//TRACE ("Add Stor: %10I64d - %10I64d Ind = %d Codec=%d\n", rtStart, rtStop, nSurfaceIndex, nCodecSpecific);
ASSERT (m_pPictureStore[nSurfaceIndex].pSample == NULL);
ASSERT (!m_pPictureStore[nSurfaceIndex].bInUse);
@@ -529,8 +518,7 @@ bool CDXVADecoder::AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bR
m_pPictureStore[nSurfaceIndex].pSample = pSample;
m_pPictureStore[nSurfaceIndex].nSliceType = nSliceType;
- if (!bIsField)
- {
+ if (!bIsField) {
m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
@@ -555,8 +543,9 @@ void CDXVADecoder::RemoveRefFrame (int nSurfaceIndex)
ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse);
m_pPictureStore[nSurfaceIndex].bRefPicture = false;
- if (m_pPictureStore[nSurfaceIndex].bDisplayed)
+ if (m_pPictureStore[nSurfaceIndex].bDisplayed) {
FreePictureSlot (nSurfaceIndex);
+ }
}
@@ -566,14 +555,11 @@ int CDXVADecoder::FindOldestFrame()
int nPos = -1;
// TODO : find better solution...
- if (m_nWaitingPics > m_nMaxWaiting)
- {
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ if (m_nWaitingPics > m_nMaxWaiting) {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
if (!m_pPictureStore[i].bDisplayed &&
- m_pPictureStore[i].bInUse &&
- (m_pPictureStore[i].rtStart < rtMin))
- {
+ m_pPictureStore[i].bInUse &&
+ (m_pPictureStore[i].rtStart < rtMin)) {
rtMin = m_pPictureStore[i].rtStart;
nPos = i;
}
@@ -584,36 +570,33 @@ int CDXVADecoder::FindOldestFrame()
void CDXVADecoder::SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS)
- {
+ if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props)))
- {
+ if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
props.dwTypeSpecificFlags &= ~0x7f;
- if(pPicture->n1FieldType == PICT_FRAME)
+ if(pPicture->n1FieldType == PICT_FRAME) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- else
- {
- if(pPicture->n1FieldType == PICT_TOP_FIELD)
+ } else {
+ if(pPicture->n1FieldType == PICT_TOP_FIELD) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ }
//if(m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD)
// props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
}
- switch (pPicture->nSliceType)
- {
- case I_TYPE :
- case SI_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case P_TYPE :
- case SP_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
+ switch (pPicture->nSliceType) {
+ case I_TYPE :
+ case SI_TYPE :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
+ break;
+ case P_TYPE :
+ case SP_TYPE :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
+ break;
+ default :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
+ break;
}
pMS2->SetProperties(sizeof(props), (BYTE*)&props);
@@ -630,24 +613,23 @@ HRESULT CDXVADecoder::DisplayNextFrame()
int nPicIndex;
nPicIndex = FindOldestFrame();
- if (nPicIndex != -1)
- {
- if (m_pPictureStore[nPicIndex].rtStart >= 0)
- {
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- // For DXVA1, query a media sample at the last time (only one in the allocator)
- hr = GetDeliveryBuffer (m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], pSampleToDeliver);
- if (SUCCEEDED (hr)) hr = m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
- break;
- case ENGINE_DXVA2 :
- // For DXVA2 media sample is in the picture store
- m_pPictureStore[nPicIndex].pSample->SetTime (&m_pPictureStore[nPicIndex].rtStart, &m_pPictureStore[nPicIndex].rtStop);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
- hr = m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
- break;
+ if (nPicIndex != -1) {
+ if (m_pPictureStore[nPicIndex].rtStart >= 0) {
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ // For DXVA1, query a media sample at the last time (only one in the allocator)
+ hr = GetDeliveryBuffer (m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver);
+ SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], pSampleToDeliver);
+ if (SUCCEEDED (hr)) {
+ hr = m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
+ }
+ break;
+ case ENGINE_DXVA2 :
+ // For DXVA2 media sample is in the picture store
+ m_pPictureStore[nPicIndex].pSample->SetTime (&m_pPictureStore[nPicIndex].rtStart, &m_pPictureStore[nPicIndex].rtStop);
+ SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
+ hr = m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
+ break;
}
@@ -665,8 +647,9 @@ HRESULT CDXVADecoder::DisplayNextFrame()
}
m_pPictureStore[nPicIndex].bDisplayed = true;
- if (!m_pPictureStore[nPicIndex].bRefPicture)
+ if (!m_pPictureStore[nPicIndex].bRefPicture) {
FreePictureSlot (nPicIndex);
+ }
}
return hr;
@@ -678,48 +661,42 @@ HRESULT CDXVADecoder::GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppS
int nPos = -1;
DWORD dwMinDisplay = MAXDWORD;
- if (m_nFieldSurface != -1)
- {
+ if (m_nFieldSurface != -1) {
nSurfaceIndex = m_nFieldSurface;
*ppSampleToDeliver = m_pFieldSample.Detach();
return S_FALSE;
}
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
- if (!m_pPictureStore[i].bInUse && m_pPictureStore[i].dwDisplayCount < dwMinDisplay)
- {
- dwMinDisplay = m_pPictureStore[i].dwDisplayCount;
- nPos = i;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ for (int i=0; i<m_nPicEntryNumber; i++) {
+ if (!m_pPictureStore[i].bInUse && m_pPictureStore[i].dwDisplayCount < dwMinDisplay) {
+ dwMinDisplay = m_pPictureStore[i].dwDisplayCount;
+ nPos = i;
+ }
}
- }
- if (nPos != -1)
- {
- nSurfaceIndex = nPos;
- return S_OK;
- }
+ if (nPos != -1) {
+ nSurfaceIndex = nPos;
+ return S_OK;
+ }
- // Ho ho...
- ASSERT (FALSE);
- Flush();
- break;
- case ENGINE_DXVA2 :
- CComPtr<IMediaSample> pNewSample;
- CComQIPtr<IMPCDXVA2Sample> pMPCDXVA2Sample;
- // TODO : test IDirect3DDeviceManager9::TestDevice !!!
-// TRACE ("==> Try get buffer...\n");
- if (SUCCEEDED (hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample)))
- {
- pMPCDXVA2Sample = pNewSample;
- nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
- *ppSampleToDeliver = pNewSample.Detach();
-// TRACE ("GetFreeSurfaceIndex : %d\n", nSurfaceIndex);
- }
- break;
+ // Ho ho...
+ ASSERT (FALSE);
+ Flush();
+ break;
+ case ENGINE_DXVA2 :
+ CComPtr<IMediaSample> pNewSample;
+ CComQIPtr<IMPCDXVA2Sample> pMPCDXVA2Sample;
+ // TODO : test IDirect3DDeviceManager9::TestDevice !!!
+ // TRACE ("==> Try get buffer...\n");
+ if (SUCCEEDED (hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample))) {
+ pMPCDXVA2Sample = pNewSample;
+ nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
+ *ppSampleToDeliver = pNewSample.Detach();
+ // TRACE ("GetFreeSurfaceIndex : %d\n", nSurfaceIndex);
+ }
+ break;
}
return hr;
@@ -728,7 +705,7 @@ HRESULT CDXVADecoder::GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppS
void CDXVADecoder::FreePictureSlot (int nSurfaceIndex)
{
-// TRACE ("Free : %d\n", nSurfaceIndex);
+ // TRACE ("Free : %d\n", nSurfaceIndex);
m_pPictureStore[nSurfaceIndex].dwDisplayCount = m_dwDisplayCount++;
m_pPictureStore[nSurfaceIndex].bInUse = false;
m_pPictureStore[nSurfaceIndex].bDisplayed = false;
@@ -740,12 +717,11 @@ void CDXVADecoder::FreePictureSlot (int nSurfaceIndex)
BYTE CDXVADecoder::GetConfigResidDiffAccelerator()
{
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- return m_DXVA1Config.bConfigResidDiffAccelerator;
- case ENGINE_DXVA2 :
- return m_DXVA2Config.ConfigResidDiffAccelerator;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ return m_DXVA1Config.bConfigResidDiffAccelerator;
+ case ENGINE_DXVA2 :
+ return m_DXVA2Config.ConfigResidDiffAccelerator;
}
return 0;
}
@@ -753,12 +729,11 @@ BYTE CDXVADecoder::GetConfigResidDiffAccelerator()
BYTE CDXVADecoder::GetConfigIntraResidUnsigned()
{
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- return m_DXVA1Config.bConfigIntraResidUnsigned;
- case ENGINE_DXVA2 :
- return m_DXVA2Config.ConfigIntraResidUnsigned;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ return m_DXVA1Config.bConfigIntraResidUnsigned;
+ case ENGINE_DXVA2 :
+ return m_DXVA2Config.ConfigIntraResidUnsigned;
}
return 0;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.h b/src/filters/transform/MPCVideoDec/DXVADecoder.h
index a8c92154b..6c776454e 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoder.h
@@ -26,28 +26,24 @@
#include <dxva2api.h>
#include <videoacc.h>
-typedef enum
-{
+typedef enum {
ENGINE_DXVA1,
ENGINE_DXVA2
} DXVA_ENGINE;
-typedef enum
-{
+typedef enum {
H264_VLD,
VC1_VLD,
MPEG2_VLD
} DXVAMode;
-typedef enum
-{
+typedef enum {
PICT_TOP_FIELD = 1,
PICT_BOTTOM_FIELD = 2,
PICT_FRAME = 3
} FF_FIELD_TYPE;
-typedef enum
-{
+typedef enum {
I_TYPE = 1, ///< Intra
P_TYPE = 2, ///< Predicted
B_TYPE = 3, ///< Bi-dir predicted
@@ -57,8 +53,7 @@ typedef enum
BI_TYPE = 7
} FF_SLICE_TYPE;
-typedef struct
-{
+typedef struct {
bool bRefPicture; // True if reference picture
bool bInUse; // Slot in use
bool bDisplayed; // True if picture have been presented
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
index 612168526..d75e7f310 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
@@ -60,18 +60,18 @@ void CDXVADecoderH264::Init()
memset (&m_pSliceShort, 0, sizeof (DXVA_Slice_H264_Short)*MAX_SLICES);
m_DXVAPicParams.MbsConsecutiveFlag = 1;
- if(m_pFilter->GetPCIVendor() == PCIV_Intel)
+ if(m_pFilter->GetPCIVendor() == PCIV_Intel) {
m_DXVAPicParams.Reserved16Bits = 0x534c;
- else
+ } else {
m_DXVAPicParams.Reserved16Bits = 0;
+ }
m_DXVAPicParams.ContinuationFlag = 1;
m_DXVAPicParams.Reserved8BitsA = 0;
m_DXVAPicParams.Reserved8BitsB = 0;
m_DXVAPicParams.MinLumaBipredSize8x8Flag = 1; // Improve accelerator performances
m_DXVAPicParams.StatusReportFeedbackNumber = 0; // Use to report status
- for (int i =0; i<16; i++)
- {
+ for (int i =0; i<16; i++) {
m_DXVAPicParams.RefFrameList[i].AssociatedFlag = 1;
m_DXVAPicParams.RefFrameList[i].bPicEntry = 255;
m_DXVAPicParams.RefFrameList[i].Index7Bits = 127;
@@ -81,13 +81,12 @@ void CDXVADecoderH264::Init()
m_nNALLength = 4;
m_nMaxSlices = 0;
- switch (GetMode())
- {
- case H264_VLD :
- AllocExecuteParams (3);
- break;
- default :
- ASSERT(FALSE);
+ switch (GetMode()) {
+ case H264_VLD :
+ AllocExecuteParams (3);
+ break;
+ default :
+ ASSERT(FALSE);
}
}
@@ -103,67 +102,62 @@ void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSi
#if 0
// Test to place Nal on multiple of 128 bytes (seems to be not necessary)
- if(!m_bUseLongSlice)
- {
- while (Nalu.ReadNext())
- {
- switch (Nalu.GetType())
- {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0]=pDXVABuffer[1]=0;
- pDXVABuffer[2]=1;
-
- // Copy NALU
- memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- // Complete with zero padding (buffer size should be a multiple of 128)
- nDummy = 128 - ((Nalu.GetDataLength()+3) %128);
- pDXVABuffer += Nalu.GetDataLength() + 3;
- memset (pDXVABuffer, 0, nDummy);
- pDXVABuffer += nDummy;
-
- // Update slice control buffer
- nDxvaNalLength = Nalu.GetDataLength()+3+nDummy;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
-
- nSize += nDxvaNalLength;
- nSlices++;
- break;
+ if(!m_bUseLongSlice) {
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ // For AVC1, put startcode 0x000001
+ pDXVABuffer[0]=pDXVABuffer[1]=0;
+ pDXVABuffer[2]=1;
+
+ // Copy NALU
+ memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
+
+ // Complete with zero padding (buffer size should be a multiple of 128)
+ nDummy = 128 - ((Nalu.GetDataLength()+3) %128);
+ pDXVABuffer += Nalu.GetDataLength() + 3;
+ memset (pDXVABuffer, 0, nDummy);
+ pDXVABuffer += nDummy;
+
+ // Update slice control buffer
+ nDxvaNalLength = Nalu.GetDataLength()+3+nDummy;
+ m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
+ m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
+
+ nSize += nDxvaNalLength;
+ nSlices++;
+ break;
}
}
- }
- else
+ } else
#endif
{
- while (Nalu.ReadNext())
- {
- switch (Nalu.GetType())
- {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- // Skip the NALU if the data length is below 0
- if(Nalu.GetDataLength() < 0)
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ // Skip the NALU if the data length is below 0
+ if(Nalu.GetDataLength() < 0) {
+ break;
+ }
+
+ // For AVC1, put startcode 0x000001
+ pDXVABuffer[0]=pDXVABuffer[1]=0;
+ pDXVABuffer[2]=1;
+
+ // Copy NALU
+ memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
+
+ // Update slice control buffer
+ nDxvaNalLength = Nalu.GetDataLength()+3;
+ m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
+ m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
+
+ nSize += nDxvaNalLength;
+ pDXVABuffer += nDxvaNalLength;
+ nSlices++;
break;
-
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0]=pDXVABuffer[1]=0;
- pDXVABuffer[2]=1;
-
- // Copy NALU
- memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- // Update slice control buffer
- nDxvaNalLength = Nalu.GetDataLength()+3;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
-
- nSize += nDxvaNalLength;
- pDXVABuffer += nDxvaNalLength;
- nSlices++;
- break;
}
}
@@ -204,39 +198,43 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
Nalu.SetBuffer (pDataIn, nSize, m_nNALLength);
FFH264DecodeBuffer (m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart);
- while (Nalu.ReadNext())
- {
- switch (Nalu.GetType())
- {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- if(m_bUseLongSlice)
- {
- m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
- m_pSliceLong[nSlices].SliceBytesInBuffer = Nalu.GetDataLength()+3; //.GetRoundedDataLength();
- m_pSliceLong[nSlices].slice_id = nSlices;
- FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
-
- if (nSlices>0)
- m_pSliceLong[nSlices-1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices-1].first_mb_in_slice;
- }
- nSlices++;
- nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
- if (nSlices > MAX_SLICES) break;
- break;
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ if(m_bUseLongSlice) {
+ m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
+ m_pSliceLong[nSlices].SliceBytesInBuffer = Nalu.GetDataLength()+3; //.GetRoundedDataLength();
+ m_pSliceLong[nSlices].slice_id = nSlices;
+ FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
+
+ if (nSlices>0) {
+ m_pSliceLong[nSlices-1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices-1].first_mb_in_slice;
+ }
+ }
+ nSlices++;
+ nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
+ if (nSlices > MAX_SLICES) {
+ break;
+ }
+ break;
}
}
- if (nSlices == 0) return S_FALSE;
+ if (nSlices == 0) {
+ return S_FALSE;
+ }
m_nMaxWaiting = min (max (m_DXVAPicParams.num_ref_frames, 3), 8);
// If parsing fail (probably no PPS/SPS), continue anyway it may arrived later (happen on truncated streams)
- if (FAILED (FFH264BuildPicParams (&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor())))
+ if (FAILED (FFH264BuildPicParams (&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor()))) {
return S_FALSE;
+ }
// Wait I frame after a flush
- if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag)
+ if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag) {
return S_FALSE;
+ }
CHECK_HR (GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop));
@@ -246,7 +244,7 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
m_DXVAPicParams.StatusReportFeedbackNumber++;
-// TRACE("CDXVADecoderH264 : Decode frame %u\n", m_DXVAPicParams.StatusReportFeedbackNumber);
+ // TRACE("CDXVADecoderH264 : Decode frame %u\n", m_DXVAPicParams.StatusReportFeedbackNumber);
// Send picture parameters
CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_DXVAPicParams), &m_DXVAPicParams));
@@ -255,12 +253,9 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
// Add bitstream, slice control and quantization matrix
CHECK_HR (AddExecuteBuffer (DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
- if (m_bUseLongSlice)
- {
+ if (m_bUseLongSlice) {
CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Long)*nSlices, m_pSliceLong));
- }
- else
- {
+ } else {
CHECK_HR (AddExecuteBuffer (DXVA2_SliceControlBufferType, sizeof (DXVA_Slice_H264_Short)*nSlices, m_pSliceShort));
}
@@ -272,7 +267,7 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
CHECK_HR (EndFrame(nSurfaceIndex));
#ifdef _DEBUG
-// DisplayStatus();
+ // DisplayStatus();
#endif
bool bAdded = AddToStore (nSurfaceIndex, pSampleToDeliver, m_DXVAPicParams.RefPicFlag, rtStart, rtStop,
@@ -282,12 +277,10 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
FFH264UpdateRefFramesList (&m_DXVAPicParams, m_pFilter->GetAVCtx());
ClearUnusedRefFrames();
- if (bAdded)
- {
+ if (bAdded) {
hr = DisplayNextFrame();
- if (nOutPOC != INT_MIN)
- {
+ if (nOutPOC != INT_MIN) {
m_nOutPOC = nOutPOC;
m_rtOutStart = rtOutStart;
}
@@ -299,10 +292,8 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
void CDXVADecoderH264::RemoveUndisplayedFrame(int nPOC)
{
// Find frame with given POC, and free the slot
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
- if (m_pPictureStore[i].bInUse && m_pPictureStore[i].nCodecSpecific == nPOC)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bInUse && m_pPictureStore[i].nCodecSpecific == nPOC) {
m_pPictureStore[i].bDisplayed = true;
RemoveRefFrame (i);
return;
@@ -313,11 +304,11 @@ void CDXVADecoderH264::RemoveUndisplayedFrame(int nPOC)
void CDXVADecoderH264::ClearUnusedRefFrames()
{
// Remove old reference frames (not anymore a short or long ref frame)
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
if (m_pPictureStore[i].bRefPicture && m_pPictureStore[i].bDisplayed)
- if (!FFH264IsRefFrameInUse (i, m_pFilter->GetAVCtx()))
+ if (!FFH264IsRefFrameInUse (i, m_pFilter->GetAVCtx())) {
RemoveRefFrame (i);
+ }
}
}
@@ -334,10 +325,8 @@ void CDXVADecoderH264::ClearRefFramesList()
{
int i;
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
- if (m_pPictureStore[i].bInUse)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bInUse) {
m_pPictureStore[i].bDisplayed = true;
RemoveRefFrame (i);
}
@@ -369,22 +358,17 @@ int CDXVADecoderH264::FindOldestFrame()
int nPos = -1;
REFERENCE_TIME rtPos = _I64_MAX;
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
- if (m_pPictureStore[i].bInUse && !m_pPictureStore[i].bDisplayed)
- {
- if (m_pPictureStore[i].nCodecSpecific == m_nOutPOC && m_pPictureStore[i].rtStart < rtPos)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bInUse && !m_pPictureStore[i].bDisplayed) {
+ if (m_pPictureStore[i].nCodecSpecific == m_nOutPOC && m_pPictureStore[i].rtStart < rtPos) {
nPos = i;
rtPos = m_pPictureStore[i].rtStart;
}
}
}
- if (nPos != -1)
- {
- if (m_rtOutStart == _I64_MIN)
- {
+ if (nPos != -1) {
+ if (m_rtOutStart == _I64_MIN) {
// If start time not set (no PTS for example), guess presentation time!
m_rtOutStart = m_rtLastFrameDisplayed;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
index 3012ae884..af5e4d9a6 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
@@ -67,13 +67,12 @@ void CDXVADecoderMpeg2::Init()
m_wRefPictureIndex[1] = NO_REF_FRAME;
m_nSliceCount = 0;
- switch (GetMode())
- {
- case MPEG2_VLD :
- AllocExecuteParams (4);
- break;
- default :
- ASSERT(FALSE);
+ switch (GetMode()) {
+ case MPEG2_VLD :
+ AllocExecuteParams (4);
+ break;
+ default :
+ ASSERT(FALSE);
}
}
@@ -90,12 +89,12 @@ HRESULT CDXVADecoderMpeg2::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIM
m_pFilter->GetFrame(), &m_nNextCodecIndex, &nFieldType, &nSliceType, pDataIn, nSize);
// Wait I frame after a flush
- if (m_bFlushed && ! m_PictureParams.bPicIntra)
+ if (m_bFlushed && ! m_PictureParams.bPicIntra) {
return S_FALSE;
+ }
hr = GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
- if (FAILED (hr))
- {
+ if (FAILED (hr)) {
ASSERT (hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
return hr;
}
@@ -134,9 +133,10 @@ void CDXVADecoderMpeg2::UpdatePictureParams(int nSurfaceIndex)
m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
// Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction)
- {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) RemoveRefFrame (m_wRefPictureIndex[0]);
+ if (!m_PictureParams.bPicBackwardPrediction) {
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame (m_wRefPictureIndex[0]);
+ }
m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
m_wRefPictureIndex[1] = nSurfaceIndex;
}
@@ -144,34 +144,37 @@ void CDXVADecoderMpeg2::UpdatePictureParams(int nSurfaceIndex)
m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
// Shall be 0 if bConfigResidDiffHost is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || m_PictureParams.bBPPminus1 > 7)
+ if (cpd->ConfigResidDiffHost == 0 || m_PictureParams.bBPPminus1 > 7) {
m_PictureParams.bPicSpatialResid8 = 0;
- else
- {
+ } else {
if (m_PictureParams.bBPPminus1 == 7 && m_PictureParams.bPicIntra && cpd->ConfigResidDiffHost)
// Shall be 1 if BPP is 8 and bPicIntra is 1 and bConfigResidDiffHost is 1
+ {
m_PictureParams.bPicSpatialResid8 = 1;
- else
+ } else
// Shall be 1 if bConfigSpatialResid8 is 1
+ {
m_PictureParams.bPicSpatialResid8 = cpd->ConfigSpatialResid8;
+ }
}
// Shall be 0 if bConfigResidDiffHost is 0 or if bConfigSpatialResid8 is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || cpd->ConfigSpatialResid8 == 0 || m_PictureParams.bBPPminus1 > 7)
+ if (cpd->ConfigResidDiffHost == 0 || cpd->ConfigSpatialResid8 == 0 || m_PictureParams.bBPPminus1 > 7) {
m_PictureParams.bPicOverflowBlocks = 0;
+ }
// Shall be 1 if bConfigHostInverseScan is 1 or if bConfigResidDiffAccelerator is 0.
- if (cpd->ConfigHostInverseScan == 1 || cpd->ConfigResidDiffAccelerator == 0)
- {
+ if (cpd->ConfigHostInverseScan == 1 || cpd->ConfigResidDiffAccelerator == 0) {
m_PictureParams.bPicScanFixed = 1;
- if (cpd->ConfigHostInverseScan != 0)
- m_PictureParams.bPicScanMethod = 3; // 11 = Arbitrary scan with absolute coefficient address.
- else if (FFGetAlternateScan(m_pFilter->GetAVCtx()))
- m_PictureParams.bPicScanMethod = 1; // 00 = Zig-zag scan (MPEG-2 Figure 7-2)
- else
- m_PictureParams.bPicScanMethod = 0; // 01 = Alternate-vertical (MPEG-2 Figure 7-3),
+ if (cpd->ConfigHostInverseScan != 0) {
+ m_PictureParams.bPicScanMethod = 3; // 11 = Arbitrary scan with absolute coefficient address.
+ } else if (FFGetAlternateScan(m_pFilter->GetAVCtx())) {
+ m_PictureParams.bPicScanMethod = 1; // 00 = Zig-zag scan (MPEG-2 Figure 7-2)
+ } else {
+ m_PictureParams.bPicScanMethod = 0; // 01 = Alternate-vertical (MPEG-2 Figure 7-3),
+ }
}
}
@@ -184,12 +187,13 @@ void CDXVADecoderMpeg2::SetExtraData (BYTE* pDataIn, UINT nSize)
void CDXVADecoderMpeg2::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
{
- while (*((DWORD*)pBuffer) != 0x01010000)
- {
+ while (*((DWORD*)pBuffer) != 0x01010000) {
pBuffer++;
nSize--;
- if (nSize <= 0) return;
+ if (nSize <= 0) {
+ return;
+ }
}
memcpy (pDXVABuffer, pBuffer, nSize);
@@ -200,8 +204,12 @@ void CDXVADecoderMpeg2::Flush()
{
m_nNextCodecIndex = INT_MIN;
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) RemoveRefFrame (m_wRefPictureIndex[0]);
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) RemoveRefFrame (m_wRefPictureIndex[1]);
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame (m_wRefPictureIndex[0]);
+ }
+ if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
+ RemoveRefFrame (m_wRefPictureIndex[1]);
+ }
m_wRefPictureIndex[0] = NO_REF_FRAME;
m_wRefPictureIndex[1] = NO_REF_FRAME;
@@ -214,19 +222,18 @@ int CDXVADecoderMpeg2::FindOldestFrame()
{
int nPos = -1;
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
if (!m_pPictureStore[i].bDisplayed &&
- m_pPictureStore[i].bInUse &&
- (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex))
- {
+ m_pPictureStore[i].bInUse &&
+ (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex)) {
m_nNextCodecIndex = INT_MIN;
nPos = i;
}
}
- if (nPos != -1)
+ if (nPos != -1) {
m_pFilter->UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
+ }
return nPos;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
index 2d55d0e84..212d18b6c 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
@@ -72,13 +72,12 @@ void CDXVADecoderVC1::Init()
m_wRefPictureIndex[0] = NO_REF_FRAME;
m_wRefPictureIndex[1] = NO_REF_FRAME;
- switch (GetMode())
- {
- case VC1_VLD :
- AllocExecuteParams (3);
- break;
- default :
- ASSERT(FALSE);
+ switch (GetMode()) {
+ case VC1_VLD :
+ AllocExecuteParams (3);
+ break;
+ default :
+ ASSERT(FALSE);
}
}
@@ -92,16 +91,17 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
int nSliceType;
FFVC1UpdatePictureParam (&m_PictureParams, m_pFilter->GetAVCtx(), &nFieldType, &nSliceType, pDataIn, nSize);
- if (FFIsSkipped (m_pFilter->GetAVCtx()))
+ if (FFIsSkipped (m_pFilter->GetAVCtx())) {
return S_OK;
+ }
// Wait I frame after a flush
- if (m_bFlushed && ! m_PictureParams.bPicIntra)
+ if (m_bFlushed && ! m_PictureParams.bPicIntra) {
return S_FALSE;
+ }
hr = GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
- if (FAILED (hr))
- {
+ if (FAILED (hr)) {
ASSERT (hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
return hr;
}
@@ -114,9 +114,10 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
m_PictureParams.wDeblockedPictureIndex = m_PictureParams.wDecodedPictureIndex;
// Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction)
- {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) RemoveRefFrame (m_wRefPictureIndex[0]);
+ if (!m_PictureParams.bPicBackwardPrediction) {
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame (m_wRefPictureIndex[0]);
+ }
m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
m_wRefPictureIndex[1] = nSurfaceIndex;
}
@@ -133,7 +134,7 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
// Send picture params to accelerator
m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
-// CHECK_HR (Execute());
+ // CHECK_HR (Execute());
// Send bitstream to accelerator
@@ -152,20 +153,16 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
#endif
// Re-order B frames
- if (m_pFilter->IsReorderBFrame())
- {
- if (m_PictureParams.bPicBackwardPrediction == 1)
- {
+ if (m_pFilter->IsReorderBFrame()) {
+ if (m_PictureParams.bPicBackwardPrediction == 1) {
SwapRT (rtStart, m_rtStartDelayed);
SwapRT (rtStop, m_rtStopDelayed);
- }
- else
- {
+ } else {
// Save I or P reference time (swap later)
- if (!m_bFlushed)
- {
- if (m_nDelayedSurfaceIndex != -1)
+ if (!m_bFlushed) {
+ if (m_nDelayedSurfaceIndex != -1) {
UpdateStore (m_nDelayedSurfaceIndex, m_rtStartDelayed, m_rtStopDelayed);
+ }
m_rtStartDelayed = m_rtStopDelayed = _I64_MAX;
SwapRT (rtStart, m_rtStartDelayed);
SwapRT (rtStop, m_rtStopDelayed);
@@ -209,8 +206,8 @@ void CDXVADecoderVC1::SetExtraData (BYTE* pDataIn, UINT nSize)
// iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
m_PictureParams.bBidirectionalAveragingMode = (1 << 7) |
- (GetConfigIntraResidUnsigned() <<6) | // i9IRU
- (GetConfigResidDiffAccelerator() <<5); // iOHIT
+ (GetConfigIntraResidUnsigned() <<6) | // i9IRU
+ (GetConfigResidDiffAccelerator() <<5); // iOHIT
}
@@ -218,29 +215,20 @@ BYTE* CDXVADecoderVC1::FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacke
{
BYTE* pStart = pBuffer;
BYTE bCode = 0;
- for (int i=0; i<nSize-4; i++)
- {
- if ( ((*((DWORD*)(pBuffer+i)) & 0x00FFFFFF) == 0x00010000) || (i >= nSize-5) )
- {
- if (bCode == 0)
- {
+ for (int i=0; i<nSize-4; i++) {
+ if ( ((*((DWORD*)(pBuffer+i)) & 0x00FFFFFF) == 0x00010000) || (i >= nSize-5) ) {
+ if (bCode == 0) {
bCode = pBuffer[i+3];
- if ((nSize == 5) && (bCode == 0x0D))
- {
+ if ((nSize == 5) && (bCode == 0x0D)) {
nPacketSize = nSize;
return pBuffer;
}
- }
- else
- {
- if (bCode == 0x0D)
- {
+ } else {
+ if (bCode == 0x0D) {
// Start code found!
nPacketSize = i - (pStart - pBuffer) + (i >= nSize-5 ? 5 : 1);
return pStart;
- }
- else
- {
+ } else {
// Other stuff, ignore it
pStart = pBuffer + i;
bCode = pBuffer[i+3];
@@ -257,8 +245,7 @@ void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSiz
{
int nDummy;
- if ( (*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000)
- {
+ if ( (*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000) {
// Some splitter have remove startcode (Haali)
pDXVABuffer[0]=pDXVABuffer[1]=0;
pDXVABuffer[2]=1;
@@ -267,15 +254,12 @@ void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSiz
// Copy bitstream buffer, with zero padding (buffer is rounded to multiple of 128)
memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
nSize +=4;
- }
- else
- {
+ } else {
BYTE* pStart;
UINT nPacketSize;
pStart = FindNextStartCode (pBuffer, nSize, nPacketSize);
- if (pStart)
- {
+ if (pStart) {
// Startcode already present
memcpy (pDXVABuffer, (BYTE*)pStart, nPacketSize);
nSize = nPacketSize;
@@ -295,8 +279,12 @@ void CDXVADecoderVC1::Flush()
m_rtStartDelayed = _I64_MAX;
m_rtStopDelayed = _I64_MAX;
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) RemoveRefFrame (m_wRefPictureIndex[0]);
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) RemoveRefFrame (m_wRefPictureIndex[1]);
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame (m_wRefPictureIndex[0]);
+ }
+ if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
+ RemoveRefFrame (m_wRefPictureIndex[1]);
+ }
m_wRefPictureIndex[0] = NO_REF_FRAME;
m_wRefPictureIndex[1] = NO_REF_FRAME;
@@ -311,8 +299,7 @@ HRESULT CDXVADecoderVC1::DisplayStatus()
memset (&Status, 0, sizeof(Status));
- if (SUCCEEDED (hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status))))
- {
+ if (SUCCEEDED (hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)))) {
Status.StatusReportFeedbackNumber = 0x00FF & Status.StatusReportFeedbackNumber;
TRACE_VC1 ("CDXVADecoderVC1 : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
index d08a6ffea..6c2e1873c 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
@@ -39,38 +39,33 @@ public:
virtual void CopyBitstream (BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
virtual void Flush();
- typedef enum
- {
+ typedef enum {
VC1_PS_TOP_FIELD = 1,
VC1_PS_BOTTOM_FIELD = 2,
VC1_PS_PROGRESSIVE = 3
};
- typedef enum
- {
+ typedef enum {
VC1_CHROMA_420 = 1,
VC1_CHROMA_422 = 2,
VC1_CHROMA_444 = 3
} VC1_CHROMA_FORMAT;
- typedef enum
- {
+ typedef enum {
VC1_CR_BICUBIC_QUARTER_CHROMA = 4,
VC1_CR_BICUBIC_HALF_CHROMA = 5,
VC1_CR_BILINEAR_QUARTER_CHROMA = 12,
VC1_CR_BILINEAR_HALF_CHROMA = 13,
};
- typedef enum
- {
+ typedef enum {
VC1_SCAN_ZIGZAG = 0,
VC1_SCAN_ALTERNATE_VERTICAL = 1,
VC1_SCAN_ALTERNATE_HORIZONTAL = 2,
VC1_SCAN_ARBITRARY = 3 // Use when bConfigHostInverseScan = 1
} VC1_PIC_SCAN_METHOD;
- typedef enum // Values for bPicDeblockConfined when bConfigBitstreamRaw = 1
- {
+ typedef enum { // Values for bPicDeblockConfined when bConfigBitstreamRaw = 1
VC1_EXTENDED_DMV = 0x0001,
VC1_PSF = 0x0002,
VC1_REFPICFLAG = 0x0004,
@@ -81,8 +76,7 @@ public:
VC1_POSTPROCFLAG = 0x0080
} VC1_DEBLOCK_CONFINED;
- typedef enum // Values for bPicSpatialResid8
- {
+ typedef enum { // Values for bPicSpatialResid8
VC1_VSTRANSFORM = 0x0001,
VC1_DQUANT = 0x0002,
VC1_EXTENDED_MV = 0x0004,
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.c b/src/filters/transform/MPCVideoDec/FfmpegContext.c
index 596f0973d..08566ca83 100644
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.c
+++ b/src/filters/transform/MPCVideoDec/FfmpegContext.c
@@ -42,15 +42,15 @@ int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rt
int av_vc1_decode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size);
void av_init_packet(AVPacket *pkt);
-const byte ZZ_SCAN[16] =
-{ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
+const byte ZZ_SCAN[16] = {
+ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
};
-const byte ZZ_SCAN8[64] =
-{ 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
+const byte ZZ_SCAN8[64] = {
+ 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
};
// FIXME : remove duplicate declaration with ffmpeg ??
@@ -75,16 +75,16 @@ BOOL IsVistaOrAbove()
static BOOL result = FALSE;
OSVERSIONINFO osver;
- if (!checked)
- {
+ if (!checked) {
checked = TRUE;
osver.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
if (GetVersionEx( &osver ) &&
- osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
- (osver.dwMajorVersion >= 6 ) )
+ osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
+ (osver.dwMajorVersion >= 6 ) ) {
result = TRUE;
+ }
}
return result;
@@ -103,16 +103,15 @@ inline MpegEncContext* GetMpegEncContext(struct AVCodecContext* pAVCtx)
Mpeg1Context* s1;
MpegEncContext* s = NULL;
- switch (pAVCtx->codec_id)
- {
- case CODEC_ID_VC1 :
- case CODEC_ID_H264 :
- s = (MpegEncContext*) pAVCtx->priv_data;
- break;
- case CODEC_ID_MPEG2VIDEO:
- s1 = (Mpeg1Context*)pAVCtx->priv_data;
- s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- break;
+ switch (pAVCtx->codec_id) {
+ case CODEC_ID_VC1 :
+ case CODEC_ID_H264 :
+ s = (MpegEncContext*) pAVCtx->priv_data;
+ break;
+ case CODEC_ID_MPEG2VIDEO:
+ s1 = (Mpeg1Context*)pAVCtx->priv_data;
+ s = (MpegEncContext*)&s1->mpeg_enc_ctx;
+ break;
}
return s;
}
@@ -120,38 +119,29 @@ inline MpegEncContext* GetMpegEncContext(struct AVCodecContext* pAVCtx)
void FFH264DecodeBuffer (struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, int* pFramePOC, int* pOutPOC, REFERENCE_TIME* pOutrtStart)
{
- if (pBuffer != NULL)
- {
+ if (pBuffer != NULL) {
H264Context* h = (H264Context*) pAVCtx->priv_data;
av_h264_decode_frame (pAVCtx, pOutPOC, pOutrtStart, pBuffer, nSize);
- if (h->s.current_picture_ptr != NULL && pFramePOC) *pFramePOC = h->s.current_picture_ptr->field_poc[0];
+ if (h->s.current_picture_ptr != NULL && pFramePOC) {
+ *pFramePOC = h->s.current_picture_ptr->field_poc[0];
+ }
}
}
// returns TRUE if version is equal to or higher than A.B.C.D, returns FALSE otherwise
BOOL DriverVersionCheck(LARGE_INTEGER VideoDriverVersion, int A, int B, int C, int D)
{
- if (HIWORD(VideoDriverVersion.HighPart) > A)
- {
+ if (HIWORD(VideoDriverVersion.HighPart) > A) {
return TRUE;
- }
- else if (HIWORD(VideoDriverVersion.HighPart) == A)
- {
- if (LOWORD(VideoDriverVersion.HighPart) > B)
- {
+ } else if (HIWORD(VideoDriverVersion.HighPart) == A) {
+ if (LOWORD(VideoDriverVersion.HighPart) > B) {
return TRUE;
- }
- else if (LOWORD(VideoDriverVersion.HighPart) == B)
- {
- if (HIWORD(VideoDriverVersion.LowPart) > C)
- {
+ } else if (LOWORD(VideoDriverVersion.HighPart) == B) {
+ if (HIWORD(VideoDriverVersion.LowPart) > C) {
return TRUE;
- }
- else if (HIWORD(VideoDriverVersion.LowPart) == C)
- {
- if (LOWORD(VideoDriverVersion.LowPart) >= D)
- {
+ } else if (HIWORD(VideoDriverVersion.LowPart) == C) {
+ if (LOWORD(VideoDriverVersion.LowPart) >= D) {
return TRUE;
}
}
@@ -173,61 +163,45 @@ int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAV
int max_ref_frames = 0;
int max_ref_frames_dpb41 = min(11, 8388608/(nWidth * nHeight) );
- if (pBuffer != NULL)
- {
+ if (pBuffer != NULL) {
av_h264_decode_frame (pAVCtx, NULL, NULL, pBuffer, nSize);
}
cur_sps = pContext->sps_buffers[0];
cur_pps = pContext->pps_buffers[0];
- if (cur_sps != NULL)
- {
+ if (cur_sps != NULL) {
video_is_level51 = cur_sps->level_idc >= 51 ? 1 : 0;
profile_higher_than_high = (cur_sps->profile_idc > 100);
max_ref_frames = max_ref_frames_dpb41; // default value is calculate
- if (nPCIVendor == PCIV_nVidia)
- {
+ if (nPCIVendor == PCIV_nVidia) {
// nVidia cards support level 5.1 since drivers v6.14.11.7800 for XP and drivers v7.15.11.7800 for Vista/7
- if (IsVistaOrAbove())
- {
- if (DriverVersionCheck(VideoDriverVersion, 7, 15, 11, 7800))
- {
+ if (IsVistaOrAbove()) {
+ if (DriverVersionCheck(VideoDriverVersion, 7, 15, 11, 7800)) {
no_level51_support = 0;
// max ref frames is 16 for HD and 11 otherwise
if(nWidth >= 1280) {
max_ref_frames = 16;
- }
- else
- {
+ } else {
max_ref_frames = 11;
}
}
- }
- else
- {
- if (DriverVersionCheck(VideoDriverVersion, 6, 14, 11, 7800))
- {
+ } else {
+ if (DriverVersionCheck(VideoDriverVersion, 6, 14, 11, 7800)) {
no_level51_support = 0;
// max ref frames is 14
max_ref_frames = 14;
}
}
- }
- else if (nPCIVendor == PCIV_S3_Graphics)
- {
+ } else if (nPCIVendor == PCIV_S3_Graphics) {
no_level51_support = 0;
- }
- else if (nPCIVendor == PCIV_ATI)
- {
+ } else if (nPCIVendor == PCIV_ATI) {
// HD4xxx and HD5xxx ATI cards support level 5.1 since drivers v8.14.1.6105 (Catalyst 10.4)
- if((nPCIDevice >> 8 == 0x68) || (nPCIDevice >> 8 == 0x94))
- {
- if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105))
- {
+ if((nPCIDevice >> 8 == 0x68) || (nPCIDevice >> 8 == 0x94)) {
+ if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105)) {
no_level51_support = 0;
max_ref_frames = 16;
}
@@ -235,8 +209,7 @@ int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAV
}
// Check maximum allowed number reference frames
- if (cur_sps->ref_frame_count > max_ref_frames)
- {
+ if (cur_sps->ref_frame_count > max_ref_frames) {
too_much_ref_frames = 1;
}
}
@@ -249,37 +222,38 @@ void CopyScalingMatrix(DXVA_Qmatrix_H264* pDest, DXVA_Qmatrix_H264* pSource, int
{
int i,j;
- switch (nPCIVendor)
- {
- case PCIV_ATI :
- // The ATI way
- memcpy (pDest, pSource, sizeof (DXVA_Qmatrix_H264));
- break;
-
- default :
- // The nVidia way (and other manufacturers compliant with specifications....)
- for (i=0; i<6; i++)
- for (j=0; j<16; j++)
- pDest->bScalingLists4x4[i][j] = pSource->bScalingLists4x4[i][ZZ_SCAN[j]];
-
- for (i=0; i<2; i++)
- for (j=0; j<64; j++)
- pDest->bScalingLists8x8[i][j] = pSource->bScalingLists8x8[i][ZZ_SCAN8[j]];
- break;
+ switch (nPCIVendor) {
+ case PCIV_ATI :
+ // The ATI way
+ memcpy (pDest, pSource, sizeof (DXVA_Qmatrix_H264));
+ break;
+
+ default :
+ // The nVidia way (and other manufacturers compliant with specifications....)
+ for (i=0; i<6; i++)
+ for (j=0; j<16; j++) {
+ pDest->bScalingLists4x4[i][j] = pSource->bScalingLists4x4[i][ZZ_SCAN[j]];
+ }
+
+ for (i=0; i<2; i++)
+ for (j=0; j<64; j++) {
+ pDest->bScalingLists8x8[i][j] = pSource->bScalingLists8x8[i][ZZ_SCAN8[j]];
+ }
+ break;
}
}
USHORT FFH264FindRefFrameIndex(USHORT num_frame, DXVA_PicParams_H264* pDXVAPicParams)
{
int i;
- for (i=0; i<pDXVAPicParams->num_ref_frames; i++)
- {
- if (pDXVAPicParams->FrameNumList[i] == num_frame)
+ for (i=0; i<pDXVAPicParams->num_ref_frames; i++) {
+ if (pDXVAPicParams->FrameNumList[i] == num_frame) {
return pDXVAPicParams->RefFrameList[i].Index7Bits;
+ }
}
#ifdef _DEBUG
-// DebugBreak(); // Ref frame not found !
+ // DebugBreak(); // Ref frame not found !
#endif
return 127;
@@ -299,34 +273,33 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_
cur_sps = &h->sps;
cur_pps = &h->pps;
- if (cur_sps && cur_pps)
- {
+ if (cur_sps && cur_pps) {
*nFieldType = h->s.picture_structure;
- if (h->sps.pic_struct_present_flag)
- {
- switch (h->sei_pic_struct)
- {
- case SEI_PIC_STRUCT_TOP_FIELD:
- case SEI_PIC_STRUCT_TOP_BOTTOM:
- case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
- *nFieldType = PICT_TOP_FIELD;
- break;
- case SEI_PIC_STRUCT_BOTTOM_FIELD:
- case SEI_PIC_STRUCT_BOTTOM_TOP:
- case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
- *nFieldType = PICT_BOTTOM_FIELD;
- break;
- case SEI_PIC_STRUCT_FRAME_DOUBLING:
- case SEI_PIC_STRUCT_FRAME_TRIPLING:
- case SEI_PIC_STRUCT_FRAME:
- *nFieldType = PICT_FRAME;
- break;
+ if (h->sps.pic_struct_present_flag) {
+ switch (h->sei_pic_struct) {
+ case SEI_PIC_STRUCT_TOP_FIELD:
+ case SEI_PIC_STRUCT_TOP_BOTTOM:
+ case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
+ *nFieldType = PICT_TOP_FIELD;
+ break;
+ case SEI_PIC_STRUCT_BOTTOM_FIELD:
+ case SEI_PIC_STRUCT_BOTTOM_TOP:
+ case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
+ *nFieldType = PICT_BOTTOM_FIELD;
+ break;
+ case SEI_PIC_STRUCT_FRAME_DOUBLING:
+ case SEI_PIC_STRUCT_FRAME_TRIPLING:
+ case SEI_PIC_STRUCT_FRAME:
+ *nFieldType = PICT_FRAME;
+ break;
}
}
*nSliceType = h->slice_type;
- if (cur_sps->mb_width==0 || cur_sps->mb_height==0) return VFW_E_INVALID_FILE_FORMAT;
+ if (cur_sps->mb_width==0 || cur_sps->mb_height==0) {
+ return VFW_E_INVALID_FILE_FORMAT;
+ }
pDXVAPicParams->wFrameWidthInMbsMinus1 = cur_sps->mb_width - 1; // pic_width_in_mbs_minus1;
pDXVAPicParams->wFrameHeightInMbsMinus1 = cur_sps->mb_height * (2 - cur_sps->frame_mbs_only_flag) - 1; // pic_height_in_map_units_minus1;
pDXVAPicParams->num_ref_frames = cur_sps->ref_frame_count; // num_ref_frames;
@@ -346,16 +319,16 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_
pDXVAPicParams->bit_depth_luma_minus8 = cur_sps->bit_depth_luma - 8; // bit_depth_luma_minus8
pDXVAPicParams->bit_depth_chroma_minus8 = cur_sps->bit_depth_chroma - 8; // bit_depth_chroma_minus8
- // pDXVAPicParams->StatusReportFeedbackNumber = SET IN DecodeFrame;
+ // pDXVAPicParams->StatusReportFeedbackNumber = SET IN DecodeFrame;
- // pDXVAPicParams->CurrFieldOrderCnt = SET IN UpdateRefFramesList;
- // pDXVAPicParams->FieldOrderCntList = SET IN UpdateRefFramesList;
- // pDXVAPicParams->FrameNumList = SET IN UpdateRefFramesList;
- // pDXVAPicParams->UsedForReferenceFlags = SET IN UpdateRefFramesList;
- // pDXVAPicParams->NonExistingFrameFlags
+ // pDXVAPicParams->CurrFieldOrderCnt = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->FieldOrderCntList = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->FrameNumList = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->UsedForReferenceFlags = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->NonExistingFrameFlags
pDXVAPicParams->frame_num = h->frame_num;
- // pDXVAPicParams->SliceGroupMap
+ // pDXVAPicParams->SliceGroupMap
pDXVAPicParams->log2_max_frame_num_minus4 = cur_sps->log2_max_frame_num - 4; // log2_max_frame_num_minus4;
@@ -378,25 +351,19 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_
pDXVAPicParams->pic_init_qp_minus26 = cur_pps->init_qp - 26;
pDXVAPicParams->pic_init_qs_minus26 = cur_pps->init_qs - 26;
- if (field_pic_flag)
- {
+ if (field_pic_flag) {
pDXVAPicParams->CurrPic.AssociatedFlag = (h->s.picture_structure == PICT_BOTTOM_FIELD);
- if (pDXVAPicParams->CurrPic.AssociatedFlag)
- {
+ if (pDXVAPicParams->CurrPic.AssociatedFlag) {
// Bottom field
pDXVAPicParams->CurrFieldOrderCnt[0] = 0;
pDXVAPicParams->CurrFieldOrderCnt[1] = h->poc_lsb + h->poc_msb;
- }
- else
- {
+ } else {
// Top field
pDXVAPicParams->CurrFieldOrderCnt[0] = h->poc_lsb + h->poc_msb;
pDXVAPicParams->CurrFieldOrderCnt[1] = 0;
}
- }
- else
- {
+ } else {
pDXVAPicParams->CurrPic.AssociatedFlag = 0;
pDXVAPicParams->CurrFieldOrderCnt[0] = h->poc_lsb + h->poc_msb;
pDXVAPicParams->CurrFieldOrderCnt[1] = h->poc_lsb + h->poc_msb;
@@ -416,8 +383,9 @@ void FFH264SetCurrentPicture (int nIndex, DXVA_PicParams_H264* pDXVAPicParams, s
pDXVAPicParams->CurrPic.Index7Bits = nIndex;
- if (h->s.current_picture_ptr)
+ if (h->s.current_picture_ptr) {
h->s.current_picture_ptr->opaque = (void*)nIndex;
+ }
}
@@ -429,51 +397,40 @@ void FFH264UpdateRefFramesList (DXVA_PicParams_H264* pDXVAPicParams, struct AVCo
Picture* pic;
UCHAR AssociatedFlag;
- for(i=0; i<16; i++)
- {
- if (i < h->short_ref_count)
- {
+ for(i=0; i<16; i++) {
+ if (i < h->short_ref_count) {
// Short list reference frames
pic = h->short_ref[h->short_ref_count - i - 1];
AssociatedFlag = pic->long_ref != 0;
- }
- else if (i >= h->short_ref_count && i < h->long_ref_count)
- {
+ } else if (i >= h->short_ref_count && i < h->long_ref_count) {
// Long list reference frames
pic = h->short_ref[h->short_ref_count + h->long_ref_count - i - 1];
AssociatedFlag = 1;
- }
- else
+ } else {
pic = NULL;
+ }
- if (pic != NULL)
- {
+ if (pic != NULL) {
pDXVAPicParams->FrameNumList[i] = pic->long_ref ? pic->pic_id : pic->frame_num;
- if (pic->field_poc[0] != INT_MAX)
- {
+ if (pic->field_poc[0] != INT_MAX) {
pDXVAPicParams->FieldOrderCntList[i][0] = pic->field_poc [0];
nUsedForReferenceFlags |= 1<<(i*2);
- }
- else
+ } else {
pDXVAPicParams->FieldOrderCntList[i][0] = 0;
+ }
- if (pic->field_poc[1] != INT_MAX)
- {
+ if (pic->field_poc[1] != INT_MAX) {
pDXVAPicParams->FieldOrderCntList[i][1] = pic->field_poc [1];
nUsedForReferenceFlags |= 2<<(i*2);
- }
- else
- {
+ } else {
pDXVAPicParams->FieldOrderCntList[i][1] = 0;
}
pDXVAPicParams->RefFrameList[i].AssociatedFlag = AssociatedFlag;
pDXVAPicParams->RefFrameList[i].Index7Bits = (UCHAR)pic->opaque;
- }
- else
- {
+ } else {
pDXVAPicParams->FrameNumList[i] = 0;
pDXVAPicParams->FieldOrderCntList[i][0] = 0;
pDXVAPicParams->FieldOrderCntList[i][1] = 0;
@@ -490,16 +447,16 @@ BOOL FFH264IsRefFrameInUse (int nFrameNum, struct AVCodecContext* pAVCtx)
H264Context* h = (H264Context*) pAVCtx->priv_data;
int i;
- for (i=0; i<h->short_ref_count; i++)
- {
- if ((int)h->short_ref[i]->opaque == nFrameNum)
+ for (i=0; i<h->short_ref_count; i++) {
+ if ((int)h->short_ref[i]->opaque == nFrameNum) {
return TRUE;
+ }
}
- for (i=0; i<h->long_ref_count; i++)
- {
- if ((int)h->long_ref[i]->opaque == nFrameNum)
+ for (i=0; i<h->long_ref_count; i++) {
+ if ((int)h->long_ref[i]->opaque == nFrameNum) {
return TRUE;
+ }
}
return FALSE;
@@ -513,8 +470,8 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic
HRESULT hr = E_FAIL;
unsigned int i;
- for(i=0; i<32; i++)
- { pSlice->RefPicList[0][i].AssociatedFlag = 1;
+ for(i=0; i<32; i++) {
+ pSlice->RefPicList[0][i].AssociatedFlag = 1;
pSlice->RefPicList[0][i].bPicEntry = 255;
pSlice->RefPicList[0][i].Index7Bits = 127;
pSlice->RefPicList[1][i].AssociatedFlag = 1;
@@ -522,56 +479,54 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic
pSlice->RefPicList[1][i].Index7Bits = 127;
}
- if(h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE)
- {
+ if(h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE) {
if(h->ref_count[0] > 0) {
for(i=0; i < h->ref_count[0]; i++) {
pSlice->RefPicList[0][i].Index7Bits = FFH264FindRefFrameIndex (h->ref_list[0][i].frame_num, pDXVAPicParams);
pSlice->RefPicList[0][i].AssociatedFlag = 0;
if((h->s.picture_structure != PICT_FRAME)) {
if((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
pSlice->RefPicList[0][i].AssociatedFlag = 1;
}
}
}
}
- }
- else
+ } else {
pSlice->num_ref_idx_l0_active_minus1 = 0;
+ }
- if(h->slice_type == FF_B_TYPE || h->slice_type == FF_S_TYPE || h->slice_type == FF_BI_TYPE)
- {
+ if(h->slice_type == FF_B_TYPE || h->slice_type == FF_S_TYPE || h->slice_type == FF_BI_TYPE) {
if(h->ref_count[1] > 0) {
for(i=0; i < h->ref_count[1]; i++) {
pSlice->RefPicList[1][i].Index7Bits = FFH264FindRefFrameIndex (h->ref_list[1][i].frame_num, pDXVAPicParams);
pSlice->RefPicList[1][i].AssociatedFlag = 0;
if((h->s.picture_structure != PICT_FRAME)) {
if((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
pSlice->RefPicList[1][i].AssociatedFlag = 1;
}
}
}
}
- }
- else
+ } else {
pSlice->num_ref_idx_l1_active_minus1 = 0;
+ }
- if(h->slice_type == FF_I_TYPE || h->slice_type == FF_SI_TYPE)
- {
- for(i = 0; i<16; i++)
+ if(h->slice_type == FF_I_TYPE || h->slice_type == FF_SI_TYPE) {
+ for(i = 0; i<16; i++) {
pSlice->RefPicList[0][i].bPicEntry = 0xff;
+ }
}
if(h->slice_type == FF_P_TYPE || h->slice_type == FF_I_TYPE ||
- h->slice_type ==FF_SP_TYPE || h->slice_type == FF_SI_TYPE)
- {
- for(i = 0; i < 16; i++)
- pSlice->RefPicList[1][i].bPicEntry = 0xff;
+ h->slice_type ==FF_SP_TYPE || h->slice_type == FF_SI_TYPE) {
+ for(i = 0; i < 16; i++) {
+ pSlice->RefPicList[1][i].bPicEntry = 0xff;
+ }
}
}
@@ -585,16 +540,16 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo
{
VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- if (pBuffer)
- {
+ if (pBuffer) {
av_vc1_decode_frame (pAVCtx, pBuffer, nSize);
}
// WARNING : vc1->interlace is not reliable (always set for progressive video on HD-DVD material)
- if (vc1->fcm == 0)
+ if (vc1->fcm == 0) {
*nFieldType = PICT_FRAME;
- else // fcm : 2 or 3 frame or field interlaced
+ } else { // fcm : 2 or 3 frame or field interlaced
*nFieldType = (vc1->tff ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD);
+ }
pPicParams->bPicIntra = (vc1->s.pict_type == FF_I_TYPE);
pPicParams->bPicBackwardPrediction = (vc1->s.pict_type == FF_B_TYPE);
@@ -602,8 +557,8 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo
// Init Init Init Todo
// iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
pPicParams->bBidirectionalAveragingMode = (pPicParams->bBidirectionalAveragingMode & 0xE0) | // init in SetExtraData
- ((vc1->lumshift!=0 || vc1->lumscale!=32) ? 0x10 : 0)| // iINSO
- ((vc1->profile == PROFILE_ADVANCED) <<3 ); // iWMVA
+ ((vc1->lumshift!=0 || vc1->lumscale!=32) ? 0x10 : 0)| // iINSO
+ ((vc1->profile == PROFILE_ADVANCED) <<3 ); // iWMVA
// Section 3.2.20.3
pPicParams->bPicSpatialResid8 = (vc1->panscanflag << 7) | (vc1->refdist_flag << 6) |
@@ -637,9 +592,9 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo
// TODO : not finish...
pPicParams->bMVprecisionAndChromaRelation = ((vc1->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) | // 0 for non-bilinear luma motion, 1 for bilinear
- (1 << 2) | // 0 for WMV8, 1 for WMV9 motion
- (0 << 1) | // 1 for WMV8 quarter sample luma motion
- (0); // 0 for quarter sample chroma motion, 1 for half sample chroma
+ (1 << 2) | // 0 for WMV8, 1 for WMV9 motion
+ (0 << 1) | // 1 for WMV8 quarter sample luma motion
+ (0); // 0 for quarter sample chroma motion, 1 for half sample chroma
// Cf §7.1.1.25 in VC1 specification, §3.2.14.3 in DXVA spec
pPicParams->bRcontrol = vc1->rnd;
@@ -660,11 +615,10 @@ HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData
int got_picture = 0;
Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- AVPacket avpkt;
+ AVPacket avpkt;
- if (pBuffer)
- {
- av_init_packet(&avpkt);
+ if (pBuffer) {
+ av_init_packet(&avpkt);
avpkt.data = pBuffer;
avpkt.size = nSize;
// HACK for CorePNG to decode as normal PNG by default
@@ -718,13 +672,13 @@ HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData
// pPicParams->bReservedBits; // ??
pPicParams->wBitstreamFcodes = (s->mpeg_f_code[0][0]<<12) | (s->mpeg_f_code[0][1]<<8) |
- (s->mpeg_f_code[1][0]<<4) | (s->mpeg_f_code[1][1]);
+ (s->mpeg_f_code[1][0]<<4) | (s->mpeg_f_code[1][1]);
pPicParams->wBitstreamPCEelements = (s->intra_dc_precision<<14) | (s->picture_structure<<12) |
- (s->top_field_first<<11) | (s->frame_pred_frame_dct<<10)|
- (s->concealment_motion_vectors<<9) | (s->q_scale_type<<8)|
- (s->intra_vlc_format<<7) | (s->alternate_scan<<6)|
- (s->repeat_first_field<<5) | (s->chroma_420_type<<4)|
- (s->progressive_frame<<3);
+ (s->top_field_first<<11) | (s->frame_pred_frame_dct<<10)|
+ (s->concealment_motion_vectors<<9) | (s->q_scale_type<<8)|
+ (s->intra_vlc_format<<7) | (s->alternate_scan<<6)|
+ (s->repeat_first_field<<5) | (s->chroma_420_type<<4)|
+ (s->progressive_frame<<3);
// TODO : could be interesting to parameter concealment method?
// pPicParams->bBitstreamConcealmentNeed;
@@ -734,16 +688,16 @@ HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData
pQMatrixData->bNewQmatrix[1] = 1;
pQMatrixData->bNewQmatrix[2] = 1;
pQMatrixData->bNewQmatrix[3] = 1;
- for (i=0; i<64; i++) // intra Y, inter Y, intra chroma, inter chroma
- {
+ for (i=0; i<64; i++) { // intra Y, inter Y, intra chroma, inter chroma
pQMatrixData->Qmatrix[0][i] = s->intra_matrix[ZZ_SCAN8[i]];
pQMatrixData->Qmatrix[1][i] = s->inter_matrix[ZZ_SCAN8[i]];
pQMatrixData->Qmatrix[2][i] = s->chroma_intra_matrix[ZZ_SCAN8[i]];
pQMatrixData->Qmatrix[3][i] = s->chroma_inter_matrix[ZZ_SCAN8[i]];
}
- if (got_picture)
+ if (got_picture) {
*nNextCodecIndex = pFrame->coded_picture_number;
+ }
return S_OK;
}
@@ -764,18 +718,16 @@ int FFIsSkipped(struct AVCodecContext* pAVCtx)
int FFIsInterlaced(struct AVCodecContext* pAVCtx, int nHeight)
{
- if (pAVCtx->codec_id == CODEC_ID_H264)
- {
+ if (pAVCtx->codec_id == CODEC_ID_H264) {
H264Context* h = (H264Context*) pAVCtx->priv_data;
SPS* cur_sps = h->sps_buffers[0];
- if (cur_sps && !cur_sps->frame_mbs_only_flag)
+ if (cur_sps && !cur_sps->frame_mbs_only_flag) {
return 1;
- else
+ } else {
return 0;
- }
- else if (pAVCtx->codec_id == CODEC_ID_VC1)
- {
+ }
+ } else if (pAVCtx->codec_id == CODEC_ID_VC1) {
VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
return vc1->interlace;
}
@@ -785,25 +737,24 @@ int FFIsInterlaced(struct AVCodecContext* pAVCtx, int nHeight)
void FFSetThreadNumber(struct AVCodecContext* pAVCtx, int nThreadCount)
{
- if (pAVCtx->thread_count > 1)
- {
+ if (pAVCtx->thread_count > 1) {
avcodec_thread_free (pAVCtx);
pAVCtx->thread_count = 1;
}
- if (nThreadCount > 1)
+ if (nThreadCount > 1) {
avcodec_thread_init(pAVCtx, nThreadCount);
+ }
}
BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx)
{
- if (pAVCtx->codec_id == CODEC_ID_VC1)
- {
+ if (pAVCtx->codec_id == CODEC_ID_VC1) {
VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
return !vc1->interlace;
- }
- else
+ } else {
return TRUE;
+ }
}
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.h b/src/filters/transform/MPCVideoDec/FfmpegContext.h
index 958b9a16d..1477d329b 100644
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.h
+++ b/src/filters/transform/MPCVideoDec/FfmpegContext.h
@@ -27,8 +27,7 @@
struct AVCodecContext;
struct AVFrame;
-enum PCI_Vendors
-{
+enum PCI_Vendors {
PCIV_ATI = 0x1002,
PCIV_nVidia = 0x10DE,
PCIV_Intel = 0x8086,
diff --git a/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h b/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h
index b05941919..011363214 100644
--- a/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h
+++ b/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h
@@ -22,8 +22,7 @@
#pragma once
-typedef enum
-{
+typedef enum {
Flat16,
JVTMatrix,
QMatrix,
@@ -31,59 +30,64 @@ typedef enum
} QMatrixH264Type;
-const byte ZZ_SCAN[16] =
-{ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
+const byte ZZ_SCAN[16] = {
+ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
};
-const byte ZZ_SCAN8[64] =
-{ 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
+const byte ZZ_SCAN8[64] = {
+ 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
};
-const DXVA_Qmatrix_H264 g_QMatrixH264[] =
-{
+const DXVA_Qmatrix_H264 g_QMatrixH264[] = {
// 1) #flat 16
{
{
// INTRA4X4_LUMA =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTRA4X4_CHROMAU =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTRA4X4_CHROMAV =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTER4X4_LUMA =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTER4X4_CHROMAU =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTER4X4_CHROMAV =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
@@ -91,7 +95,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA =
- { 16,16,16,16,16,16,16,16,
+ {
+ 16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
@@ -102,7 +107,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA =
- { 16,16,16,16,16,16,16,16,
+ {
+ 16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
@@ -117,42 +123,48 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
{
{
// INTRA4X4_LUMA
- { 6,13,20,28,
+ {
+ 6,13,20,28,
13,20,28,32,
20,28,32,37,
28,32,37,42
},
// INTRA4X4_CHROMAU
- { 6,13,20,28,
+ {
+ 6,13,20,28,
13,20,28,32,
20,28,32,37,
28,32,37,42
},
// INTRA4X4_CHROMAV
- { 6,13,20,28,
+ {
+ 6,13,20,28,
13,20,28,32,
20,28,32,37,
28,32,37,42
},
// INTER4X4_LUMA
- { 10,14,20,24,
+ {
+ 10,14,20,24,
14,20,24,27,
20,24,27,30,
24,27,30,34
},
// INTER4X4_CHROMAU
- { 10,14,20,24,
+ {
+ 10,14,20,24,
14,20,24,27,
20,24,27,30,
24,27,30,34
},
// INTER4X4_CHROMAV
- { 10,14,20,24,
+ {
+ 10,14,20,24,
14,20,24,27,
20,24,27,30,
24,27,30,34
@@ -160,7 +172,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA
- { 6,10,13,16,18,23,25,27,
+ {
+ 6,10,13,16,18,23,25,27,
10,11,16,18,23,25,27,29,
13,16,18,23,25,27,29,31,
16,18,23,25,27,29,31,33,
@@ -171,7 +184,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA
- { 9,13,15,17,19,21,22,24,
+ {
+ 9,13,15,17,19,21,22,24,
13,13,17,19,21,22,24,25,
15,17,19,21,22,24,25,27,
17,19,21,22,24,25,27,28,
@@ -187,42 +201,48 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
{
{
// INTRA4X4_LUMA =
- { 6,12,19,26,
+ {
+ 6,12,19,26,
12,19,26,31,
19,26,31,35,
26,31,35,39
},
// INTRA4X4_CHROMAU =
- { 6,12,19,26,
+ {
+ 6,12,19,26,
12,19,26,31,
19,26,31,35,
26,31,35,39
},
// INTRA4X4_CHROMAV =
- { 6,12,19,26,
+ {
+ 6,12,19,26,
12,19,26,31,
19,26,31,35,
26,31,35,39
},
// INTER4X4_LUMA =
- { 9,13,18,21,
+ {
+ 9,13,18,21,
13,18,21,24,
18,21,24,27,
21,24,27,30
},
// INTER4X4_CHROMAU =
- { 9,13,18,21,
+ {
+ 9,13,18,21,
13,18,21,24,
18,21,24,27,
21,24,27,30
},
// INTER4X4_CHROMAV =
- { 9,13,18,21,
+ {
+ 9,13,18,21,
13,18,21,24,
18,21,24,27,
21,24,27,30
@@ -230,7 +250,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA =
- { 6,10,13,16,19,24,26,28,
+ {
+ 6,10,13,16,19,24,26,28,
10,12,16,19,24,26,28,31,
13,16,19,24,26,28,31,33,
16,19,24,26,28,31,33,35,
@@ -241,7 +262,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA =
- { 9,12,14,16,18,19,21,22,
+ {
+ 9,12,14,16,18,19,21,22,
12,13,16,18,19,21,22,24,
14,16,18,19,21,22,24,25,
16,18,19,21,22,24,25,27,
@@ -257,42 +279,48 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
{
{
// INTRA4X4_LUMA =
- { 7,16,22,24,
+ {
+ 7,16,22,24,
16,22,24,28,
18,22,27,33,
22,24,32,47
},
// INTRA4X4_CHROMAU =
- { 7,16,22,24,
+ {
+ 7,16,22,24,
16,22,24,28,
18,22,27,33,
22,24,32,47
},
// INTRA4X4_CHROMAV =
- { 7,16,22,24,
+ {
+ 7,16,22,24,
16,22,24,28,
18,22,27,33,
22,24,32,47
},
// INTER4X4_LUMA =
- { 13,15,17,18,
+ {
+ 13,15,17,18,
15,17,18,20,
17,18,21,22,
18,20,22,25
},
// INTER4X4_CHROMAU =
- { 13,15,17,18,
+ {
+ 13,15,17,18,
15,17,18,20,
17,18,21,22,
18,20,22,25
},
// INTER4X4_CHROMAV =
- { 13,15,17,18,
+ {
+ 13,15,17,18,
15,17,18,20,
17,18,21,22,
18,20,22,25
@@ -300,7 +328,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA =
- { 7,13,16,18,22,22,24,28,
+ {
+ 7,13,16,18,22,22,24,28,
13,13,18,20,22,24,28,31,
16,18,22,22,24,28,28,32,
18,18,22,22,24,28,31,33,
@@ -311,7 +340,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA =
- { 13,14,15,16,17,17,18,19,
+ {
+ 13,14,15,16,17,17,18,19,
14,15,16,17,17,18,19,20,
15,16,17,17,18,19,20,21,
16,17,17,18,19,20,21,22,
diff --git a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
index 45b204c33..dfd8ad5ec 100644
--- a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
+++ b/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
@@ -24,8 +24,7 @@
#pragma once
// Internal codec list (use to enable/disable codec in standalone mode)
-typedef enum
-{
+typedef enum {
MPCVD_H264 = 1,
MPCVD_VC1 = MPCVD_H264<<1,
MPCVD_XVID = MPCVD_VC1<<1,
@@ -45,8 +44,7 @@ typedef enum
interface __declspec(uuid("CDC3B5B3-A8B0-4c70-A805-9FC80CDEF262"))
IMPCVideoDecFilter :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(Apply()) = 0;
STDMETHOD(SetThreadNumber(int nValue)) = 0;
diff --git a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp
index ce310b302..b8c5891d2 100644
--- a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp
@@ -37,29 +37,25 @@
#include <moreuuids.h>
-typedef struct
-{
+typedef struct {
const CLSID* clsMinorType;
const enum CodecID nFFCodec;
const int fourcc;
} FFMPEG_CODECS;
-const FFMPEG_CODECS ffCodecs[] =
-{
+const FFMPEG_CODECS ffCodecs[] = {
// AMVA
{ &MEDIASUBTYPE_IMA_AMV, CODEC_ID_ADPCM_IMA_AMV, MAKEFOURCC('A','M','V','A') },
};
-const AMOVIESETUP_MEDIATYPE CMPCAudioDecFilter::sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE CMPCAudioDecFilter::sudPinTypesIn[] = {
{ &MEDIATYPE_Audio, &MEDIASUBTYPE_IMA_AMV },
};
const int CMPCAudioDecFilter::sudPinTypesInCount = countof(CMPCAudioDecFilter::sudPinTypesIn);
-const AMOVIESETUP_MEDIATYPE CMPCAudioDecFilter::sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE CMPCAudioDecFilter::sudPinTypesOut[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM}
};
const int CMPCAudioDecFilter::sudPinTypesOutCount = countof(CMPCAudioDecFilter::sudPinTypesOut);
@@ -68,10 +64,16 @@ const int CMPCAudioDecFilter::sudPinTypesOutCount = countof(CMPCAudioDecFilter::
CMPCAudioDecFilter::CMPCAudioDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CMPCAudioDecFilter"), lpunk, __uuidof(this))
{
- if(!(m_pInput = new CTransformInputPin(NAME("CAudioDecInputPin"), this, phr, L"In"))) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!(m_pInput = new CTransformInputPin(NAME("CAudioDecInputPin"), this, phr, L"In"))) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
- if(!(m_pOutput = new CTransformOutputPin(NAME("CAudioDecOutputPin"), this, phr, L"Out"))) *phr = E_OUTOFMEMORY;
+ if(!(m_pOutput = new CTransformOutputPin(NAME("CAudioDecOutputPin"), this, phr, L"Out"))) {
+ *phr = E_OUTOFMEMORY;
+ }
if(FAILED(*phr)) {
delete m_pInput, m_pInput = NULL;
return;
@@ -97,12 +99,13 @@ CMPCAudioDecFilter::~CMPCAudioDecFilter(void)
void CMPCAudioDecFilter::Cleanup()
{
- if (m_pAVCtx)
- {
+ if (m_pAVCtx) {
avcodec_thread_free (m_pAVCtx);
av_free(m_pAVCtx);
}
- if (m_pFrame) av_free(m_pFrame);
+ if (m_pFrame) {
+ av_free(m_pFrame);
+ }
m_pAVCodec = NULL;
m_pAVCtx = NULL;
@@ -124,9 +127,9 @@ void CMPCAudioDecFilter::LogLibAVCodec(void* par,int level,const char *fmt,va_li
STDMETHODIMP CMPCAudioDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
return
-// QI(IMPCVideoDecFilter)
-// QI(ISpecifyPropertyPages)
-// QI(ISpecifyPropertyPages2)
+ // QI(IMPCVideoDecFilter)
+ // QI(ISpecifyPropertyPages)
+ // QI(ISpecifyPropertyPages2)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -146,11 +149,11 @@ HRESULT CMPCAudioDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATO
HRESULT CMPCAudioDecFilter::CheckInputType(const CMediaType* mtIn)
{
- for (int i=0; i<sizeof(sudPinTypesIn)/sizeof(AMOVIESETUP_MEDIATYPE); i++)
- {
+ for (int i=0; i<sizeof(sudPinTypesIn)/sizeof(AMOVIESETUP_MEDIATYPE); i++) {
if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
- (mtIn->subtype == *sudPinTypesIn[i].clsMinorType))
+ (mtIn->subtype == *sudPinTypesIn[i].clsMinorType)) {
return S_OK;
+ }
}
return VFW_E_TYPE_NOT_ACCEPTED;
@@ -158,10 +161,16 @@ HRESULT CMPCAudioDecFilter::CheckInputType(const CMediaType* mtIn)
HRESULT CMPCAudioDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- 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;
+ }
CMediaType mt = m_pInput->CurrentMediaType();
const GUID& subtype = mt.subtype;
@@ -178,7 +187,7 @@ HRESULT CMPCAudioDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
//}
//else
//{
- *pmt = CreateMediaType(GetSampleFormat(), wfe->nSamplesPerSec, min(2, wfe->nChannels));
+ *pmt = CreateMediaType(GetSampleFormat(), wfe->nSamplesPerSec, min(2, wfe->nChannels));
//}
return S_OK;
@@ -193,12 +202,10 @@ HRESULT CMPCAudioDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pRece
{
int nNewCodec;
- if (direction == PINDIR_OUTPUT)
- {
+ if (direction == PINDIR_OUTPUT) {
CMediaType& mt = m_pInput->CurrentMediaType();
nNewCodec = FindCodec(&mt);
- if ((direction == PINDIR_OUTPUT) && (nNewCodec != -1) && (nNewCodec != m_nCodecNb))
- {
+ if ((direction == PINDIR_OUTPUT) && (nNewCodec != -1) && (nNewCodec != m_nCodecNb)) {
WAVEFORMATEX* wfex = (WAVEFORMATEX*) mt.pbFormat;
Cleanup();
@@ -256,8 +263,9 @@ HRESULT CMPCAudioDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pRece
}
*/
- if (avcodec_open(m_pAVCtx, m_pAVCodec)<0)
+ if (avcodec_open(m_pAVCtx, m_pAVCodec)<0) {
return VFW_E_INVALIDMEDIATYPE;
+ }
}
}
@@ -321,15 +329,16 @@ HRESULT CMPCAudioDecFilter::Transform(IMediaSample* pIn)
int CMPCAudioDecFilter::FindCodec(const CMediaType* mtIn)
{
for (int i=0; i<countof(ffCodecs); i++)
- if (mtIn->subtype == *ffCodecs[i].clsMinorType)
+ if (mtIn->subtype == *ffCodecs[i].clsMinorType) {
return i;
+ }
return -1;
}
STDMETHODIMP_(SampleFormat) CMPCAudioDecFilter::GetSampleFormat()
{
-// CAutoLock cAutoLock(&m_csProps);
+ // CAutoLock cAutoLock(&m_csProps);
return m_iSampleFormat;
}
@@ -347,26 +356,25 @@ CMediaType CMPCAudioDecFilter::CreateMediaType(SampleFormat sf, DWORD nSamplesPe
wfe->wFormatTag = (WORD)mt.subtype.Data1;
wfe->nChannels = nChannels;
wfe->nSamplesPerSec = nSamplesPerSec;
- switch(sf)
- {
- default:
- case SAMPLE_FMT_S16:
- wfe->wBitsPerSample = 16;
- break;
- case SAMPLE_FMT_S32:
- case SAMPLE_FMT_FLT:
- wfe->wBitsPerSample = 32;
- break;
+ switch(sf) {
+ default:
+ case SAMPLE_FMT_S16:
+ wfe->wBitsPerSample = 16;
+ break;
+ case SAMPLE_FMT_S32:
+ case SAMPLE_FMT_FLT:
+ wfe->wBitsPerSample = 32;
+ break;
}
wfe->nBlockAlign = wfe->nChannels*wfe->wBitsPerSample/8;
wfe->nAvgBytesPerSec = wfe->nSamplesPerSec*wfe->nBlockAlign;
// FIXME: 32 bit only seems to work with WAVE_FORMAT_EXTENSIBLE
- if(dwChannelMask == 0 && (sf == SAMPLE_FMT_S32))
+ if(dwChannelMask == 0 && (sf == SAMPLE_FMT_S32)) {
dwChannelMask = nChannels == 2 ? (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;
+ }
- if(dwChannelMask)
- {
+ if(dwChannelMask) {
wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);
wfex.dwChannelMask = dwChannelMask;
diff --git a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h b/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h
index 938870ae1..ea1737c6c 100644
--- a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h
+++ b/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h
@@ -49,7 +49,7 @@ public:
HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
-// HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ // HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
HRESULT CMPCAudioDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin);
STDMETHODIMP_(SampleFormat) GetSampleFormat();
diff --git a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
index 41ab0c7af..bbfd7beee 100644
--- a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
@@ -29,21 +29,18 @@
// Workaround: graphedit crashes when a filter exposes more than 115 input MediaTypes!
-const AMOVIESETUP_PIN sudpPinsVideoDec[] =
-{
+const AMOVIESETUP_PIN sudpPinsVideoDec[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, CMPCVideoDecFilter::sudPinTypesInCount > 115 ? 115 : CMPCVideoDecFilter::sudPinTypesInCount, CMPCVideoDecFilter::sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, CMPCVideoDecFilter::sudPinTypesOutCount, CMPCVideoDecFilter::sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilters[] =
-{
+const AMOVIESETUP_FILTER sudFilters[] = {
{&__uuidof(CMPCVideoDecFilter), L"MPC - Video decoder", /*MERIT_DO_NOT_USE*/0x40000001, countof(sudpPinsVideoDec), sudpPinsVideoDec, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilters[0].strName, &__uuidof(CMPCVideoDecFilter), CreateInstance<CMPCVideoDecFilter>, NULL, &sudFilters[0]},
{L"CMPCVideoDecPropertyPage", &__uuidof(CMPCVideoDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd> >},
{L"CMPCVideoDecPropertyPage2", &__uuidof(CMPCVideoDecCodecWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecCodecWnd> >},
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
index 1832b7802..27932d76a 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
@@ -52,35 +52,34 @@ extern "C"
#define ROUND_FRAMERATE(var,FrameRate) if (labs ((long)(var - FrameRate)) < FrameRate*1/100) var = FrameRate;
-typedef struct
-{
+typedef struct {
const int PicEntryNumber;
const UINT PreferedConfigBitstream;
const GUID* Decoder[MAX_SUPPORTED_MODE];
const WORD RestrictedMode[MAX_SUPPORTED_MODE];
} DXVA_PARAMS;
-typedef struct
-{
+typedef struct {
const CLSID* clsMinorType;
const enum CodecID nFFCodec;
const int fourcc;
const DXVA_PARAMS* DXVAModes;
- int DXVAModeCount()
- {
- if (!DXVAModes) return 0;
- for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- {
- if (DXVAModes->Decoder[i] == &GUID_NULL) return i;
+ int DXVAModeCount() {
+ if (!DXVAModes) {
+ return 0;
+ }
+ for (int i=0; i<MAX_SUPPORTED_MODE; i++) {
+ if (DXVAModes->Decoder[i] == &GUID_NULL) {
+ return i;
+ }
}
return MAX_SUPPORTED_MODE;
}
} FFMPEG_CODECS;
-typedef enum
-{
+typedef enum {
ffYCbCr_RGB_coeff_ITUR_BT601 = 0,
ffYCbCr_RGB_coeff_ITUR_BT709 = 1,
ffYCbCr_RGB_coeff_SMPTE240M = 2,
@@ -105,8 +104,7 @@ struct TYCbCr2RGB_coeffs {
int cspOptionsBlackCutoff,
int cspOptionsChromaCutoff,
double cspOptionsRGB_WhiteLevel,
- double cspOptionsRGB_BlackLevel)
- {
+ double cspOptionsRGB_BlackLevel) {
if (cspOptionsIturBt == ffYCbCr_RGB_coeff_ITUR_BT601) {
Kr = 0.299;
Kg = 0.587;
@@ -139,8 +137,7 @@ struct TYCbCr2RGB_coeffs {
// DXVA modes supported for Mpeg2
-DXVA_PARAMS DXVA_Mpeg2 =
-{
+DXVA_PARAMS DXVA_Mpeg2 = {
9, // PicEntryNumber
1, // PreferedConfigBitstream
{ &DXVA2_ModeMPEG2_VLD, &GUID_NULL },
@@ -148,16 +145,14 @@ DXVA_PARAMS DXVA_Mpeg2 =
};
// DXVA modes supported for H264
-DXVA_PARAMS DXVA_H264 =
-{
+DXVA_PARAMS DXVA_H264 = {
16, // PicEntryNumber
2, // PreferedConfigBitstream
{ &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
{ DXVA_RESTRICTED_MODE_H264_E, 0}
};
-DXVA_PARAMS DXVA_H264_VISTA =
-{
+DXVA_PARAMS DXVA_H264_VISTA = {
22, // PicEntryNumber
2, // PreferedConfigBitstream
{ &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
@@ -165,16 +160,14 @@ DXVA_PARAMS DXVA_H264_VISTA =
};
// DXVA modes supported for VC1
-DXVA_PARAMS DXVA_VC1 =
-{
+DXVA_PARAMS DXVA_VC1 = {
14, // PicEntryNumber
1, // PreferedConfigBitstream
{ &DXVA2_ModeVC1_D, &GUID_NULL },
{ DXVA_RESTRICTED_MODE_VC1_D, 0}
};
-FFMPEG_CODECS ffCodecs[] =
-{
+FFMPEG_CODECS ffCodecs[] = {
#if HAS_FFMPEG_VIDEO_DECODERS
// Flash video
{ &MEDIASUBTYPE_FLV1, CODEC_ID_FLV1, MAKEFOURCC('F','L','V','1'), NULL },
@@ -348,8 +341,7 @@ FFMPEG_CODECS ffCodecs[] =
};
/* Important: the order should be exactly the same as in ffCodecs[] */
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesIn[] = {
#if HAS_FFMPEG_VIDEO_DECODERS
// Flash video
{ &MEDIATYPE_Video, &MEDIASUBTYPE_FLV1 },
@@ -530,8 +522,7 @@ bool* CMPCVideoDecFilter::FFmpegFilters = NULL;
bool* CMPCVideoDecFilter::DXVAFilters = NULL;
bool CMPCVideoDecFilter::m_ref_frame_count_check_skip = false;
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_NV12},
{&MEDIATYPE_Video, &MEDIASUBTYPE_NV24}
};
@@ -545,8 +536,7 @@ BOOL CALLBACK EnumFindProcessWnd (HWND hwnd, LPARAM lParam)
GetWindowThreadProcessId (hwnd, &procid);
GetClassName (hwnd, WindowClass, countof(WindowClass));
- if (procid == GetCurrentProcessId() && _tcscmp (WindowClass, _T("MediaPlayerClassicW")) == 0)
- {
+ if (procid == GetCurrentProcessId() && _tcscmp (WindowClass, _T("MediaPlayerClassicW")) == 0) {
HWND* pWnd = (HWND*) lParam;
*pWnd = hwnd;
return FALSE;
@@ -559,20 +549,25 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
{
HWND hWnd = NULL;
- if(IsVistaOrAbove())
- {
- for (int i=0; i<countof(ffCodecs); i++)
- {
- if(ffCodecs[i].nFFCodec == CODEC_ID_H264)
+ if(IsVistaOrAbove()) {
+ for (int i=0; i<countof(ffCodecs); i++) {
+ if(ffCodecs[i].nFFCodec == CODEC_ID_H264) {
ffCodecs[i].DXVAModes = &DXVA_H264_VISTA;
+ }
}
}
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
- if (m_pOutput) delete m_pOutput;
+ if (m_pOutput) {
+ delete m_pOutput;
+ }
m_pOutput = DNew CVideoDecOutputPin(NAME("CVideoDecOutputPin"), this, phr, L"Output");
- if(!m_pOutput) *phr = E_OUTOFMEMORY;
+ if(!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
m_pCpuId = DNew CCpuId();
m_pAVCodec = NULL;
@@ -618,20 +613,37 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
m_sar.SetSize(1,1);
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ)) {
DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ThreadNumber"), dw)) m_nThreadNumber = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) m_nDiscardMode = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ErrorRecognition"), dw)) m_nErrorRecognition = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("IDCTAlgo"), dw)) m_nIDCTAlgo = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ActiveCodecs"), dw)) m_nActiveCodecs = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ARMode"), dw)) m_nARMode = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DXVACheckCompatibility"), dw)) m_nDXVACheckCompatibility = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DisableDXVA_SD"), dw)) m_nDXVA_SD = dw;
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ThreadNumber"), dw)) {
+ m_nThreadNumber = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) {
+ m_nDiscardMode = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ErrorRecognition"), dw)) {
+ m_nErrorRecognition = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("IDCTAlgo"), dw)) {
+ m_nIDCTAlgo = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ActiveCodecs"), dw)) {
+ m_nActiveCodecs = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ARMode"), dw)) {
+ m_nARMode = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DXVACheckCompatibility"), dw)) {
+ m_nDXVACheckCompatibility = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DisableDXVA_SD"), dw)) {
+ m_nDXVA_SD = dw;
+ }
}
- if(m_nDXVACheckCompatibility > 3) m_nDXVACheckCompatibility = 1; // skip level check by default
+ if(m_nDXVACheckCompatibility > 3) {
+ m_nDXVACheckCompatibility = 1; // skip level check by default
+ }
ff_avcodec_default_get_buffer = avcodec_default_get_buffer;
ff_avcodec_default_release_buffer = avcodec_default_release_buffer;
@@ -649,23 +661,28 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
int nCodecs = countof(ffCodecs);
int nPinTypes = countof(sudPinTypesIn);
ASSERT (nCodecs == nPinTypes);
- for (int i=0; i<nPinTypes; i++)
+ for (int i=0; i<nPinTypes; i++) {
ASSERT (ffCodecs[i].clsMinorType == sudPinTypesIn[i].clsMinorType);
+ }
#endif
}
UINT CMPCVideoDecFilter::GetAdapter(IDirect3D9* pD3D, HWND hWnd)
{
- if(hWnd == NULL || pD3D == NULL)
+ if(hWnd == NULL || pD3D == NULL) {
return D3DADAPTER_DEFAULT;
+ }
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor == NULL) return D3DADAPTER_DEFAULT;
+ if(hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor) return adp;
+ if(hAdpMon == hMonitor) {
+ return adp;
+ }
}
return D3DADAPTER_DEFAULT;
@@ -680,11 +697,9 @@ void CMPCVideoDecFilter::DetectVideoCard(HWND hWnd)
m_VideoDriverVersion.LowPart = 0;
pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D9)
- {
+ if (pD3D9) {
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK)
- {
+ if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK) {
m_nPCIVendor = adapterIdentifier.VendorId;
m_nPCIDevice = adapterIdentifier.DeviceId;
m_VideoDriverVersion = adapterIdentifier.DriverVersion;
@@ -712,15 +727,12 @@ bool CMPCVideoDecFilter::IsVideoInterlaced()
void CMPCVideoDecFilter::UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- if (rtStart == _I64_MIN)
- {
+ if (rtStart == _I64_MIN) {
// If reference time has not been set by splitter, extrapolate start time
// from last known start time already delivered
rtStart = m_rtLastStart + m_rtAvrTimePerFrame*m_nCountEstimated;
m_nCountEstimated++;
- }
- else
- {
+ } else {
// Known start time, set as new reference
m_rtLastStart = rtStart;
m_nCountEstimated = 1;
@@ -738,13 +750,10 @@ void CMPCVideoDecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int &
w = PictWidthRounded();
h = PictHeightRounded();
#else
- if (m_nDXVAMode == MODE_SOFTWARE)
- {
+ if (m_nDXVAMode == MODE_SOFTWARE) {
w = m_nWidth;
h = m_nHeight;
- }
- else
- {
+ } else {
// DXVA surface are multiple of 16 pixels!
w = PictWidthRounded();
h = PictHeightRounded();
@@ -778,111 +787,105 @@ int CMPCVideoDecFilter::PictHeightRounded()
int CMPCVideoDecFilter::FindCodec(const CMediaType* mtIn)
{
for (int i=0; i<countof(ffCodecs); i++)
- if (mtIn->subtype == *ffCodecs[i].clsMinorType)
- {
+ if (mtIn->subtype == *ffCodecs[i].clsMinorType) {
#ifndef REGISTER_FILTER
- switch (ffCodecs[i].nFFCodec)
- {
- case CODEC_ID_H264 :
- #if INTERNAL_DECODER_H264_DXVA
- m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_H264];
- #else
- m_bUseDXVA = false;
- #endif
- #if INTERNAL_DECODER_H264
- m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_H264];
- #else
- m_bUseFFmpeg = false;
- #endif
- break;
- case CODEC_ID_VC1 :
- #if INTERNAL_DECODER_VC1_DXVA
- m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_VC1];
- #else
- m_bUseDXVA = false;
- #endif
- #if INTERNAL_DECODER_VC1
- m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_VC1];
- #else
- m_bUseFFmpeg = false;
- #endif
- break;
- case CODEC_ID_MPEG2VIDEO :
- #if INTERNAL_DECODER_MPEG2_DXVA
- m_bUseDXVA = true;
- #endif
- m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
- break;
- default :
- m_bUseDXVA = false;
+ switch (ffCodecs[i].nFFCodec) {
+ case CODEC_ID_H264 :
+#if INTERNAL_DECODER_H264_DXVA
+ m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_H264];
+#else
+ m_bUseDXVA = false;
+#endif
+#if INTERNAL_DECODER_H264
+ m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_H264];
+#else
+ m_bUseFFmpeg = false;
+#endif
+ break;
+ case CODEC_ID_VC1 :
+#if INTERNAL_DECODER_VC1_DXVA
+ m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_VC1];
+#else
+ m_bUseDXVA = false;
+#endif
+#if INTERNAL_DECODER_VC1
+ m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_VC1];
+#else
+ m_bUseFFmpeg = false;
+#endif
+ break;
+ case CODEC_ID_MPEG2VIDEO :
+#if INTERNAL_DECODER_MPEG2_DXVA
+ m_bUseDXVA = true;
+#endif
+ m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
+ break;
+ default :
+ m_bUseDXVA = false;
}
return ((m_bUseDXVA || m_bUseFFmpeg) ? i : -1);
#else
bool bCodecActivated = false;
- switch (ffCodecs[i].nFFCodec)
- {
- case CODEC_ID_FLV1 :
- case CODEC_ID_VP6F :
- bCodecActivated = (m_nActiveCodecs & MPCVD_FLASH) != 0;
- break;
- case CODEC_ID_MPEG4 :
- if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_XVID) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvid) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_XVIX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvix) )
- {
- bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0;
- }
- else if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx) )
- {
- bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
- }
- break;
- case CODEC_ID_WMV1 :
- case CODEC_ID_WMV2 :
- case CODEC_ID_WMV3 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
- break;
- case CODEC_ID_MSMPEG4V3 :
- case CODEC_ID_MSMPEG4V2 :
- case CODEC_ID_MSMPEG4V1 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_MSMPEG4) != 0;
- break;
- case CODEC_ID_H264 :
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_H264_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_H264) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case CODEC_ID_SVQ3 :
- case CODEC_ID_SVQ1 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_SVQ3) != 0;
- break;
- case CODEC_ID_H263 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_H263) != 0;
- break;
- case CODEC_ID_THEORA :
- bCodecActivated = (m_nActiveCodecs & MPCVD_THEORA) != 0;
- break;
- case CODEC_ID_VC1 :
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_VC1_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_VC1) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case CODEC_ID_AMV :
- bCodecActivated = (m_nActiveCodecs & MPCVD_AMVV) != 0;
- break;
- case CODEC_ID_VP5 :
- case CODEC_ID_VP6 :
- case CODEC_ID_VP6A :
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP6) != 0;
- break;
- case CODEC_ID_VP8 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
- break;
+ switch (ffCodecs[i].nFFCodec) {
+ case CODEC_ID_FLV1 :
+ case CODEC_ID_VP6F :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_FLASH) != 0;
+ break;
+ case CODEC_ID_MPEG4 :
+ if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_XVID) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvid) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_XVIX) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvix) ) {
+ bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0;
+ } else if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx) ) {
+ bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
+ }
+ break;
+ case CODEC_ID_WMV1 :
+ case CODEC_ID_WMV2 :
+ case CODEC_ID_WMV3 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
+ break;
+ case CODEC_ID_MSMPEG4V3 :
+ case CODEC_ID_MSMPEG4V2 :
+ case CODEC_ID_MSMPEG4V1 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_MSMPEG4) != 0;
+ break;
+ case CODEC_ID_H264 :
+ m_bUseDXVA = (m_nActiveCodecs & MPCVD_H264_DXVA) != 0;
+ m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_H264) != 0;
+ bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
+ break;
+ case CODEC_ID_SVQ3 :
+ case CODEC_ID_SVQ1 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_SVQ3) != 0;
+ break;
+ case CODEC_ID_H263 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_H263) != 0;
+ break;
+ case CODEC_ID_THEORA :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_THEORA) != 0;
+ break;
+ case CODEC_ID_VC1 :
+ m_bUseDXVA = (m_nActiveCodecs & MPCVD_VC1_DXVA) != 0;
+ m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_VC1) != 0;
+ bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
+ break;
+ case CODEC_ID_AMV :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_AMVV) != 0;
+ break;
+ case CODEC_ID_VP5 :
+ case CODEC_ID_VP6 :
+ case CODEC_ID_VP6A :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_VP6) != 0;
+ break;
+ case CODEC_ID_VP8 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
+ break;
}
return (bCodecActivated ? i : -1);
#endif
@@ -896,26 +899,38 @@ void CMPCVideoDecFilter::Cleanup()
SAFE_DELETE (m_pDXVADecoder);
// Release FFMpeg
- if (m_pAVCtx)
- {
- if (m_pAVCtx->intra_matrix) free(m_pAVCtx->intra_matrix);
- if (m_pAVCtx->inter_matrix) free(m_pAVCtx->inter_matrix);
- if (m_pAVCtx->extradata) free((unsigned char*)m_pAVCtx->extradata);
- if (m_pFFBuffer) free(m_pFFBuffer);
+ if (m_pAVCtx) {
+ if (m_pAVCtx->intra_matrix) {
+ free(m_pAVCtx->intra_matrix);
+ }
+ if (m_pAVCtx->inter_matrix) {
+ free(m_pAVCtx->inter_matrix);
+ }
+ if (m_pAVCtx->extradata) {
+ free((unsigned char*)m_pAVCtx->extradata);
+ }
+ if (m_pFFBuffer) {
+ free(m_pFFBuffer);
+ }
- if (m_pAVCtx->slice_offset) av_free(m_pAVCtx->slice_offset);
- if (m_pAVCtx->codec) avcodec_close(m_pAVCtx);
+ if (m_pAVCtx->slice_offset) {
+ av_free(m_pAVCtx->slice_offset);
+ }
+ if (m_pAVCtx->codec) {
+ avcodec_close(m_pAVCtx);
+ }
// Free thread resource if necessary
FFSetThreadNumber (m_pAVCtx, 0);
av_free(m_pAVCtx);
}
- if (m_pFrame) av_free(m_pFrame);
+ if (m_pFrame) {
+ av_free(m_pFrame);
+ }
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_pSwsContext)
- {
+ if (m_pSwsContext) {
sws_freeContext(m_pSwsContext);
m_pSwsContext = NULL;
}
@@ -932,8 +947,7 @@ void CMPCVideoDecFilter::Cleanup()
SAFE_DELETE_ARRAY (m_pVideoOutputFormat);
// Release DXVA ressources
- if (m_hDevice != INVALID_HANDLE_VALUE)
- {
+ if (m_hDevice != INVALID_HANDLE_VALUE) {
m_pDeviceManager->CloseDeviceHandle(m_hDevice);
m_hDevice = INVALID_HANDLE_VALUE;
}
@@ -946,16 +960,15 @@ void CMPCVideoDecFilter::Cleanup()
void CMPCVideoDecFilter::CalcAvgTimePerFrame()
{
CMediaType &mt = m_pInput->CurrentMediaType();
- if (mt.formattype==FORMAT_VideoInfo)
+ if (mt.formattype==FORMAT_VideoInfo) {
m_rtAvrTimePerFrame = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- else if (mt.formattype==FORMAT_VideoInfo2)
+ } else if (mt.formattype==FORMAT_VideoInfo2) {
m_rtAvrTimePerFrame = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
- else if (mt.formattype==FORMAT_MPEGVideo)
+ } else if (mt.formattype==FORMAT_MPEGVideo) {
m_rtAvrTimePerFrame = ((MPEG1VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- else if (mt.formattype==FORMAT_MPEG2Video)
+ } else if (mt.formattype==FORMAT_MPEG2Video) {
m_rtAvrTimePerFrame = ((MPEG2VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- else
- {
+ } else {
ASSERT (FALSE);
m_rtAvrTimePerFrame = 1;
}
@@ -975,7 +988,7 @@ void CMPCVideoDecFilter::LogLibAVCodec(void* par,int level,const char *fmt,va_li
void CMPCVideoDecFilter::OnGetBuffer(AVFrame *pic)
{
// Callback from FFMpeg to store Ref Time in frame (needed to have correct rtStart after avcodec_decode_video calls)
-// pic->rtStart = m_rtStart;
+ // pic->rtStart = m_rtStart;
}
STDMETHODIMP CMPCVideoDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
@@ -992,11 +1005,11 @@ STDMETHODIMP CMPCVideoDecFilter::NonDelegatingQueryInterface(REFIID riid, void**
HRESULT CMPCVideoDecFilter::CheckInputType(const CMediaType* mtIn)
{
- for (int i=0; i<sizeof(sudPinTypesIn)/sizeof(AMOVIESETUP_MEDIATYPE); i++)
- {
+ for (int i=0; i<sizeof(sudPinTypesIn)/sizeof(AMOVIESETUP_MEDIATYPE); i++) {
if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
- (mtIn->subtype == *sudPinTypesIn[i].clsMinorType))
+ (mtIn->subtype == *sudPinTypesIn[i].clsMinorType)) {
return S_OK;
+ }
}
return VFW_E_TYPE_NOT_ACCEPTED;
@@ -1013,13 +1026,13 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
{
int nNewCodec;
- if (direction == PINDIR_INPUT)
- {
+ if (direction == PINDIR_INPUT) {
nNewCodec = FindCodec(pmt);
- if (nNewCodec == -1) return VFW_E_TYPE_NOT_ACCEPTED;
+ if (nNewCodec == -1) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if (nNewCodec != m_nCodecNb)
- {
+ if (nNewCodec != m_nCodecNb) {
m_nCodecNb = nNewCodec;
m_bReorderBFrame = true;
@@ -1029,45 +1042,36 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
m_pAVCtx = avcodec_alloc_context();
CheckPointer (m_pAVCtx, E_POINTER);
- if ((m_nThreadNumber > 1) && IsMultiThreadSupported (ffCodecs[m_nCodecNb].nFFCodec))
+ if ((m_nThreadNumber > 1) && IsMultiThreadSupported (ffCodecs[m_nCodecNb].nFFCodec)) {
FFSetThreadNumber(m_pAVCtx, m_nThreadNumber);
+ }
m_pFrame = avcodec_alloc_frame();
CheckPointer (m_pFrame, E_POINTER);
- if(pmt->formattype == FORMAT_VideoInfo)
- {
+ if(pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
m_pAVCtx->width = vih->bmiHeader.biWidth;
m_pAVCtx->height = abs(vih->bmiHeader.biHeight);
m_pAVCtx->codec_tag = vih->bmiHeader.biCompression;
- }
- else if(pmt->formattype == FORMAT_VideoInfo2)
- {
+ } else if(pmt->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
m_pAVCtx->width = vih2->bmiHeader.biWidth;
m_pAVCtx->height = abs(vih2->bmiHeader.biHeight);
m_pAVCtx->codec_tag = vih2->bmiHeader.biCompression;
- }
- else if(pmt->formattype == FORMAT_MPEGVideo)
- {
+ } else if(pmt->formattype == FORMAT_MPEGVideo) {
MPEG1VIDEOINFO* mpgv = (MPEG1VIDEOINFO*)pmt->pbFormat;
m_pAVCtx->width = mpgv->hdr.bmiHeader.biWidth;
m_pAVCtx->height = abs(mpgv->hdr.bmiHeader.biHeight);
m_pAVCtx->codec_tag = mpgv->hdr.bmiHeader.biCompression;
- }
- else if(pmt->formattype == FORMAT_MPEG2Video)
- {
+ } else if(pmt->formattype == FORMAT_MPEG2Video) {
MPEG2VIDEOINFO* mpg2v = (MPEG2VIDEOINFO*)pmt->pbFormat;
m_pAVCtx->width = mpg2v->hdr.bmiHeader.biWidth;
m_pAVCtx->height = abs(mpg2v->hdr.bmiHeader.biHeight);
m_pAVCtx->codec_tag = mpg2v->hdr.bmiHeader.biCompression;
- if (mpg2v->hdr.bmiHeader.biCompression == NULL)
- {
+ if (mpg2v->hdr.bmiHeader.biCompression == NULL) {
m_pAVCtx->codec_tag = pmt->subtype.Data1;
- }
- else if ( (m_pAVCtx->codec_tag == MAKEFOURCC('a','v','c','1')) || (m_pAVCtx->codec_tag == MAKEFOURCC('A','V','C','1')))
- {
+ } else if ( (m_pAVCtx->codec_tag == MAKEFOURCC('a','v','c','1')) || (m_pAVCtx->codec_tag == MAKEFOURCC('A','V','C','1'))) {
m_pAVCtx->nal_length_size = mpg2v->dwFlags;
m_bReorderBFrame = false;
}
@@ -1087,9 +1091,9 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
m_pAVCtx->postgain = 1.0f;
m_pAVCtx->debug_mv = 0;
- #ifdef _DEBUG
+#ifdef _DEBUG
//m_pAVCtx->debug = FF_DEBUG_PICT_INFO | FF_DEBUG_STARTCODE | FF_DEBUG_PTS;
- #endif
+#endif
m_pAVCtx->opaque = this;
m_pAVCtx->get_buffer = get_buffer;
@@ -1098,53 +1102,52 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
ConnectTo (m_pAVCtx);
CalcAvgTimePerFrame();
- if (avcodec_open(m_pAVCtx, m_pAVCodec)<0)
+ if (avcodec_open(m_pAVCtx, m_pAVCodec)<0) {
return VFW_E_INVALIDMEDIATYPE;
+ }
- switch (ffCodecs[m_nCodecNb].nFFCodec)
- {
- case CODEC_ID_H264 :
- if((m_nDXVA_SD) && (PictWidthRounded() < 1280))
- {
- m_bDXVACompatible = false;
- }
- else
- {
- if(m_nDXVACheckCompatibility != 3)
- {
- // non-zero value indicates that an incompatibility was detected
- int nCompat = FFH264CheckCompatibility (PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
-
- if(nCompat > 0)
- {
- switch(m_nDXVACheckCompatibility)
- {
- case 0 :
- // full check
- m_bDXVACompatible = false;
- break;
- case 1 :
- // skip level check
- if(nCompat != DXVA_UNSUPPORTED_LEVEL) m_bDXVACompatible = false;
- break;
- case 2 :
- // skip reference frame check
- if(nCompat != DXVA_TOO_MANY_REF_FRAMES) m_bDXVACompatible = false;
- break;
+ switch (ffCodecs[m_nCodecNb].nFFCodec) {
+ case CODEC_ID_H264 :
+ if((m_nDXVA_SD) && (PictWidthRounded() < 1280)) {
+ m_bDXVACompatible = false;
+ } else {
+ if(m_nDXVACheckCompatibility != 3) {
+ // non-zero value indicates that an incompatibility was detected
+ int nCompat = FFH264CheckCompatibility (PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
+
+ if(nCompat > 0) {
+ switch(m_nDXVACheckCompatibility) {
+ case 0 :
+ // full check
+ m_bDXVACompatible = false;
+ break;
+ case 1 :
+ // skip level check
+ if(nCompat != DXVA_UNSUPPORTED_LEVEL) {
+ m_bDXVACompatible = false;
+ }
+ break;
+ case 2 :
+ // skip reference frame check
+ if(nCompat != DXVA_TOO_MANY_REF_FRAMES) {
+ m_bDXVACompatible = false;
+ }
+ break;
+ }
}
}
}
- }
- break;
- case CODEC_ID_MPEG2VIDEO :
- // DSP is disable for DXVA decoding (to keep default idct_permutation)
- m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
- break;
+ break;
+ case CODEC_ID_MPEG2VIDEO :
+ // DSP is disable for DXVA decoding (to keep default idct_permutation)
+ m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
+ break;
}
// Force single thread for DXVA !
- if (IsDXVASupported())
+ if (IsDXVASupported()) {
FFSetThreadNumber(m_pAVCtx, 1);
+ }
BuildDXVAOutputFormat();
}
@@ -1154,16 +1157,14 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
}
-VIDEO_OUTPUT_FORMATS DXVAFormats[] =
-{
+VIDEO_OUTPUT_FORMATS DXVAFormats[] = {
{&MEDIASUBTYPE_NV12, 1, 12, 'avxd'}, // DXVA2
{&MEDIASUBTYPE_NV12, 1, 12, 'AVXD'},
{&MEDIASUBTYPE_NV12, 1, 12, 'AVxD'},
{&MEDIASUBTYPE_NV12, 1, 12, 'AvXD'}
};
-VIDEO_OUTPUT_FORMATS SoftwareFormats[] =
-{
+VIDEO_OUTPUT_FORMATS SoftwareFormats[] = {
{&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
{&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'}, // Software
{&MEDIASUBTYPE_I420, 3, 12, '024I'},
@@ -1200,11 +1201,9 @@ void CMPCVideoDecFilter::BuildDXVAOutputFormat()
m_pVideoOutputFormat = DNew VIDEO_OUTPUT_FORMATS[m_nVideoOutputCount];
- if (IsDXVASupported())
- {
+ if (IsDXVASupported()) {
// Dynamic DXVA media types for DXVA1
- for (nPos=0; nPos<ffCodecs[m_nCodecNb].DXVAModeCount(); nPos++)
- {
+ for (nPos=0; nPos<ffCodecs[m_nCodecNb].DXVAModeCount(); nPos++) {
m_pVideoOutputFormat[nPos].subtype = ffCodecs[m_nCodecNb].DXVAModes->Decoder[nPos];
m_pVideoOutputFormat[nPos].biCompression = 'avxd';
m_pVideoOutputFormat[nPos].biBitCount = 12;
@@ -1217,17 +1216,19 @@ void CMPCVideoDecFilter::BuildDXVAOutputFormat()
}
// Software rendering
- if (m_bUseFFmpeg)
+ if (m_bUseFFmpeg) {
memcpy (&m_pVideoOutputFormat[nPos], SoftwareFormats, sizeof(SoftwareFormats));
+ }
}
int CMPCVideoDecFilter::GetPicEntryNumber()
{
- if (IsDXVASupported())
+ if (IsDXVASupported()) {
return ffCodecs[m_nCodecNb].DXVAModes->PicEntryNumber;
- else
+ } else {
return 0;
+ }
}
@@ -1244,44 +1245,32 @@ void CMPCVideoDecFilter::AllocExtradata(AVCodecContext* pAVCtx, const CMediaType
const BYTE* data = NULL;
unsigned int size = 0;
- if (pmt->formattype==FORMAT_VideoInfo)
- {
+ if (pmt->formattype==FORMAT_VideoInfo) {
size = pmt->cbFormat-sizeof(VIDEOINFOHEADER);
data = size?pmt->pbFormat+sizeof(VIDEOINFOHEADER):NULL;
- }
- else if (pmt->formattype==FORMAT_VideoInfo2)
- {
+ } else if (pmt->formattype==FORMAT_VideoInfo2) {
size = pmt->cbFormat-sizeof(VIDEOINFOHEADER2);
data = size?pmt->pbFormat+sizeof(VIDEOINFOHEADER2):NULL;
- }
- else if (pmt->formattype==FORMAT_MPEGVideo)
- {
+ } else if (pmt->formattype==FORMAT_MPEGVideo) {
MPEG1VIDEOINFO* mpeg1info = (MPEG1VIDEOINFO*)pmt->pbFormat;
- if (mpeg1info->cbSequenceHeader)
- {
+ if (mpeg1info->cbSequenceHeader) {
size = mpeg1info->cbSequenceHeader;
data = mpeg1info->bSequenceHeader;
}
- }
- else if (pmt->formattype==FORMAT_MPEG2Video)
- {
+ } else if (pmt->formattype==FORMAT_MPEG2Video) {
MPEG2VIDEOINFO* mpeg2info = (MPEG2VIDEOINFO*)pmt->pbFormat;
- if (mpeg2info->cbSequenceHeader)
- {
+ if (mpeg2info->cbSequenceHeader) {
size = mpeg2info->cbSequenceHeader;
data = (const uint8_t*)mpeg2info->dwSequenceHeader;
}
- }
- else if (pmt->formattype==FORMAT_VorbisFormat2)
- {
+ } else if (pmt->formattype==FORMAT_VorbisFormat2) {
const VORBISFORMAT2 *vf2=(const VORBISFORMAT2*)pmt->pbFormat;
UNUSED_ALWAYS(vf2);
size=pmt->cbFormat-sizeof(VORBISFORMAT2);
data=size?pmt->pbFormat+sizeof(VORBISFORMAT2):NULL;
}
- if (size)
- {
+ if (size) {
pAVCtx->extradata_size = size;
pAVCtx->extradata = (const unsigned char*)calloc(1,size+FF_INPUT_BUFFER_PADDING_SIZE);
memcpy((void*)pAVCtx->extradata, data, size);
@@ -1293,31 +1282,31 @@ HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pRece
{
LOG(_T("CMPCVideoDecFilter::CompleteConnect"));
- if (direction==PINDIR_INPUT && m_pOutput->IsConnected())
- {
+ if (direction==PINDIR_INPUT && m_pOutput->IsConnected()) {
ReconnectOutput (m_nWidth, m_nHeight);
- }
- else if (direction==PINDIR_OUTPUT)
- {
- if (IsDXVASupported())
- {
- if (m_nDXVAMode == MODE_DXVA1)
+ } else if (direction==PINDIR_OUTPUT) {
+ if (IsDXVASupported()) {
+ if (m_nDXVAMode == MODE_DXVA1) {
m_pDXVADecoder->ConfigureDXVA1();
- else if (SUCCEEDED (ConfigureDXVA2 (pReceivePin)) && SUCCEEDED (SetEVRForDXVA2 (pReceivePin)) )
+ } else if (SUCCEEDED (ConfigureDXVA2 (pReceivePin)) && SUCCEEDED (SetEVRForDXVA2 (pReceivePin)) ) {
m_nDXVAMode = MODE_DXVA2;
+ }
}
- if (m_nDXVAMode == MODE_SOFTWARE && !FFSoftwareCheckCompatibility(m_pAVCtx))
+ if (m_nDXVAMode == MODE_SOFTWARE && !FFSoftwareCheckCompatibility(m_pAVCtx)) {
return VFW_E_INVALIDMEDIATYPE;
+ }
CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter)))
+ if((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
m_bReorderBFrame = false;
+ }
}
// Cannot use YUY2 if horizontal or vertical resolution is not even
if ( ((m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_NV12) && (m_nDXVAMode == MODE_SOFTWARE)) ||
- ((m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_YUY2) && (m_pAVCtx->width&1 || m_pAVCtx->height&1)) )
+ ((m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_YUY2) && (m_pAVCtx->width&1 || m_pAVCtx->height&1)) ) {
return VFW_E_INVALIDMEDIATYPE;
+ }
return __super::CompleteConnect (direction, pReceivePin);
}
@@ -1325,24 +1314,26 @@ HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pRece
HRESULT CMPCVideoDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (UseDXVA2())
- {
+ if (UseDXVA2()) {
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
pProperties->cBuffers = GetPicEntryNumber();
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
: NOERROR;
- }
- else
+ } else {
return __super::DecideBufferSize (pAllocator, pProperties);
+ }
}
@@ -1356,19 +1347,20 @@ HRESULT CMPCVideoDecFilter::NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rt
ResetBuffer();
- if (m_pAVCtx)
+ if (m_pAVCtx) {
avcodec_flush_buffers (m_pAVCtx);
+ }
- if (m_pDXVADecoder)
+ if (m_pDXVADecoder) {
m_pDXVADecoder->Flush();
+ }
return __super::NewSegment (rtStart, rtStop, dRate);
}
HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir)
{
- if (dir == PINDIR_INPUT)
- {
+ if (dir == PINDIR_INPUT) {
Cleanup();
}
@@ -1377,34 +1369,31 @@ HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir)
void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS)
- {
+ if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props)))
- {
+ if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
props.dwTypeSpecificFlags &= ~0x7f;
- if(!m_pFrame->interlaced_frame)
+ if(!m_pFrame->interlaced_frame) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- else
- {
- if(m_pFrame->top_field_first)
+ } else {
+ if(m_pFrame->top_field_first) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ }
}
- switch (m_pFrame->pict_type)
- {
- case FF_I_TYPE :
- case FF_SI_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case FF_P_TYPE :
- case FF_SP_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
+ switch (m_pFrame->pict_type) {
+ case FF_I_TYPE :
+ case FF_SI_TYPE :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
+ break;
+ case FF_P_TYPE :
+ case FF_SP_TYPE :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
+ break;
+ default :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
+ break;
}
pMS2->SetProperties(sizeof(props), (BYTE*)&props);
@@ -1415,11 +1404,12 @@ void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
#if HAS_FFMPEG_VIDEO_DECODERS
int CMPCVideoDecFilter::GetCspFromMediaType(GUID& subtype)
{
- if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12)
+ if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ;
- else if (subtype == MEDIASUBTYPE_YUY2)
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
return FF_CSP_YUY2;
-// else if (subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565)
+ }
+ // else if (subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565)
ASSERT (FALSE);
return FF_CSP_NULL;
@@ -1428,15 +1418,18 @@ int CMPCVideoDecFilter::GetCspFromMediaType(GUID& subtype)
void CMPCVideoDecFilter::InitSwscale()
{
- if (m_pSwsContext == NULL)
- {
+ if (m_pSwsContext == NULL) {
TYCbCr2RGB_coeffs coeffs(ffYCbCr_RGB_coeff_ITUR_BT601,0, 235, 16, 255.0, 0.0);
int32_t swscaleTable[7];
SwsParams params;
memset(&params,0,sizeof(params));
- if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_MMX) params.cpu |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
- if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_3DNOW) params.cpu |= SWS_CPU_CAPS_3DNOW;
+ if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_MMX) {
+ params.cpu |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
+ }
+ if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_3DNOW) {
+ params.cpu |= SWS_CPU_CAPS_3DNOW;
+ }
params.methodLuma.method=params.methodChroma.method=SWS_POINT;
@@ -1487,10 +1480,8 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int
AVPacket avpkt;
av_init_packet(&avpkt);
- while (nSize > 0)
- {
- if (nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize)
- {
+ while (nSize > 0) {
+ if (nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
m_nFFBufferSize = nSize+FF_INPUT_BUFFER_PADDING_SIZE;
m_pFFBuffer = (BYTE*)realloc(m_pFFBuffer, m_nFFBufferSize);
}
@@ -1509,15 +1500,20 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int
avpkt.flags = AV_PKT_FLAG_KEY;
used_bytes = avcodec_decode_video2 (m_pAVCtx, m_pFrame, &got_picture, &avpkt);
- if (!got_picture || !m_pFrame->data[0]) return S_OK;
- if(pIn->IsPreroll() == S_OK || rtStart < 0) return S_OK;
+ if (!got_picture || !m_pFrame->data[0]) {
+ return S_OK;
+ }
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
+ return S_OK;
+ }
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
UpdateAspectRatio();
- if(FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ if(FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
rtStart = m_pFrame->reordered_opaque;
rtStop = m_pFrame->reordered_opaque + m_rtAvrTimePerFrame;
@@ -1527,34 +1523,37 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int
pOut->SetMediaTime(NULL, NULL);
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_pSwsContext == NULL) InitSwscale();
+ if (m_pSwsContext == NULL) {
+ InitSwscale();
+ }
// TODO : quick and dirty patch to fix convertion to YUY2 with swscale
- if (m_nOutCsp == FF_CSP_YUY2)
+ if (m_nOutCsp == FF_CSP_YUY2) {
CopyBuffer(pDataOut, m_pFrame->data, m_pAVCtx->width, m_pAVCtx->height, m_pFrame->linesize[0], MEDIASUBTYPE_I420, false);
+ }
- else if (m_pSwsContext != NULL)
- {
+ else if (m_pSwsContext != NULL) {
uint8_t* dst[4];
stride_t srcStride[4];
stride_t dstStride[4];
const TcspInfo *outcspInfo=csp_getInfo(m_nOutCsp);
- for (int i=0; i<4; i++)
- {
+ for (int i=0; i<4; i++) {
srcStride[i]=(stride_t)m_pFrame->linesize[i];
dstStride[i]=m_pOutSize.cx>>outcspInfo->shiftX[i];
- if (i==0)
+ if (i==0) {
dst[i]=pDataOut;
- else
+ } else {
dst[i]=dst[i-1]+dstStride[i-1]*(m_pOutSize.cy>>outcspInfo->shiftY[i-1]);
+ }
}
int nTempCsp = m_nOutCsp;
- if(outcspInfo->id==FF_CSP_420P)
+ if(outcspInfo->id==FF_CSP_420P) {
csp_yuv_adj_to_plane(nTempCsp,outcspInfo,odd2even(m_pOutSize.cy),(unsigned char**)dst,dstStride);
- else
+ } else {
csp_yuv_adj_to_plane(nTempCsp,outcspInfo,m_pAVCtx->height,(unsigned char**)dst,dstStride);
+ }
sws_scale_ordered (m_pSwsContext, m_pFrame->data, srcStride, 0, m_pAVCtx->height, dst, dstStride);
}
@@ -1667,24 +1666,17 @@ bool CMPCVideoDecFilter::FindPicture(int nIndex, int nStartCode)
{
DWORD dw = 0;
- for (int i=0; i<m_nFFBufferPos-nIndex; i++)
- {
+ for (int i=0; i<m_nFFBufferPos-nIndex; i++) {
dw = (dw<<8) + m_pFFBuffer[i+nIndex];
- if (i >= 4)
- {
- if (m_nFFPicEnd == INT_MIN)
- {
+ if (i >= 4) {
+ if (m_nFFPicEnd == INT_MIN) {
if ( (dw & 0xffffff00) == 0x00000100 &&
- (dw & 0x000000FF) == (DWORD)nStartCode )
- {
+ (dw & 0x000000FF) == (DWORD)nStartCode ) {
m_nFFPicEnd = i+nIndex-3;
}
- }
- else
- {
+ } else {
if ( (dw & 0xffffff00) == 0x00000100 &&
- ( (dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3 ))
- {
+ ( (dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3 )) {
m_nFFPicEnd = i+nIndex-3;
return true;
}
@@ -1702,8 +1694,7 @@ void CMPCVideoDecFilter::ResetBuffer()
m_nFFBufferPos = 0;
m_nFFPicEnd = INT_MIN;
- for (int i=0; i<MAX_BUFF_TIME; i++)
- {
+ for (int i=0; i<MAX_BUFF_TIME; i++) {
m_FFBufferTime[i].nBuffPos = INT_MIN;
m_FFBufferTime[i].rtStart = _I64_MIN;
m_FFBufferTime[i].rtStop = _I64_MIN;
@@ -1712,10 +1703,8 @@ void CMPCVideoDecFilter::ResetBuffer()
void CMPCVideoDecFilter::PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- for (int i=0; i<MAX_BUFF_TIME; i++)
- {
- if (m_FFBufferTime[i].nBuffPos == INT_MIN)
- {
+ for (int i=0; i<MAX_BUFF_TIME; i++) {
+ if (m_FFBufferTime[i].nBuffPos == INT_MIN) {
m_FFBufferTime[i].nBuffPos = nPos;
m_FFBufferTime[i].rtStart = rtStart;
m_FFBufferTime[i].rtStop = rtStop;
@@ -1730,10 +1719,8 @@ void CMPCVideoDecFilter::PopBufferTime(int nPos)
int i = 0;
// Shift buffer time list
- while (i<MAX_BUFF_TIME && m_FFBufferTime[i].nBuffPos!=INT_MIN)
- {
- if (m_FFBufferTime[i].nBuffPos >= nPos)
- {
+ while (i<MAX_BUFF_TIME && m_FFBufferTime[i].nBuffPos!=INT_MIN) {
+ if (m_FFBufferTime[i].nBuffPos >= nPos) {
m_FFBufferTime[nDestPos].nBuffPos = m_FFBufferTime[i].nBuffPos - nPos;
m_FFBufferTime[nDestPos].rtStart = m_FFBufferTime[i].rtStart;
m_FFBufferTime[nDestPos].rtStop = m_FFBufferTime[i].rtStop;
@@ -1743,8 +1730,7 @@ void CMPCVideoDecFilter::PopBufferTime(int nPos)
}
// Free unused slots
- for (i=nDestPos; i<MAX_BUFF_TIME; i++)
- {
+ for (i=nDestPos; i<MAX_BUFF_TIME; i++) {
m_FFBufferTime[i].nBuffPos = INT_MIN;
m_FFBufferTime[i].rtStart = _I64_MIN;
m_FFBufferTime[i].rtStop = _I64_MIN;
@@ -1753,11 +1739,11 @@ void CMPCVideoDecFilter::PopBufferTime(int nPos)
bool CMPCVideoDecFilter::AppendBuffer (BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- if (rtStart != _I64_MIN)
+ if (rtStart != _I64_MIN) {
PushBufferTime (m_nFFBufferPos, rtStart, rtStop);
+ }
- if (m_nFFBufferPos+nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize)
- {
+ if (m_nFFBufferPos+nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
m_nFFBufferSize = m_nFFBufferPos+nSize+FF_INPUT_BUFFER_PADDING_SIZE;
m_pFFBuffer = (BYTE*)realloc(m_pFFBuffer, m_nFFBufferSize);
}
@@ -1792,8 +1778,9 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
REFERENCE_TIME rtStart = _I64_MIN;
REFERENCE_TIME rtStop = _I64_MIN;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
nSize = pIn->GetActualDataLength();
pIn->GetTime(&rtStart, &rtStop);
@@ -1818,23 +1805,23 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
// m_nCountEstimated++;
// rtStart = rtStop = m_rtLastStart + m_nCountEstimated*m_rtAvrTimePerFrame;
//}
- if (rtStop <= rtStart && rtStop != _I64_MIN)
+ if (rtStop <= rtStart && rtStop != _I64_MIN) {
rtStop = rtStart + m_rtAvrTimePerFrame;
+ }
m_pAVCtx->reordered_opaque = rtStart;
m_pAVCtx->reordered_opaque2 = rtStop;
- if (m_pAVCtx->has_b_frames)
- {
+ if (m_pAVCtx->has_b_frames) {
m_BFrames[m_nPosB].rtStart = rtStart;
m_BFrames[m_nPosB].rtStop = rtStop;
m_nPosB = 1-m_nPosB;
}
-// m_rtStart = rtStart;
+ // m_rtStart = rtStart;
-// DumpBuffer (pDataIn, nSize);
-// TRACE ("Receive : %10I64d - %10I64d (%10I64d) Size=%d\n", rtStart, rtStop, rtStop - rtStart, nSize);
+ // DumpBuffer (pDataIn, nSize);
+ // TRACE ("Receive : %10I64d - %10I64d (%10I64d) Size=%d\n", rtStart, rtStop, rtStop - rtStart, nSize);
//char strMsg[300];
//FILE* hFile = fopen ("d:\\receive.txt", "at");
@@ -1847,49 +1834,42 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
//fwrite (pDataIn, nSize, 1, hFile);
//fclose (hFile);
- switch (m_nDXVAMode)
- {
- case MODE_SOFTWARE :
- hr = SoftwareDecode (pIn, pDataIn, nSize, rtStart, rtStop);
- break;
- case MODE_DXVA1 :
- case MODE_DXVA2 :
- CheckPointer (m_pDXVADecoder, E_UNEXPECTED);
- UpdateAspectRatio();
+ switch (m_nDXVAMode) {
+ case MODE_SOFTWARE :
+ hr = SoftwareDecode (pIn, pDataIn, nSize, rtStart, rtStop);
+ break;
+ case MODE_DXVA1 :
+ case MODE_DXVA2 :
+ CheckPointer (m_pDXVADecoder, E_UNEXPECTED);
+ UpdateAspectRatio();
+
+ // Change aspect ratio for DXVA1
+ if ((m_nDXVAMode == MODE_DXVA1) &&
+ ReconnectOutput(PictWidthRounded(), PictHeightRounded(), true, PictWidth(), PictHeight()) == S_OK) {
+ m_pDXVADecoder->ConfigureDXVA1();
+ }
- // Change aspect ratio for DXVA1
- if ((m_nDXVAMode == MODE_DXVA1) &&
- ReconnectOutput(PictWidthRounded(), PictHeightRounded(), true, PictWidth(), PictHeight()) == S_OK)
- {
- m_pDXVADecoder->ConfigureDXVA1();
- }
+ if (m_pAVCtx->codec_id == CODEC_ID_MPEG2VIDEO) {
+ AppendBuffer (pDataIn, nSize, rtStart, rtStop);
+ hr = S_OK;
- if (m_pAVCtx->codec_id == CODEC_ID_MPEG2VIDEO)
- {
- AppendBuffer (pDataIn, nSize, rtStart, rtStop);
- hr = S_OK;
-
- while (FindPicture (max (m_nFFBufferPos-nSize-4, 0), 0x00))
- {
- if (m_FFBufferTime[0].nBuffPos != INT_MIN && m_FFBufferTime[0].nBuffPos < m_nFFPicEnd)
- {
- rtStart = m_FFBufferTime[0].rtStart;
- rtStop = m_FFBufferTime[0].rtStop;
+ while (FindPicture (max (m_nFFBufferPos-nSize-4, 0), 0x00)) {
+ if (m_FFBufferTime[0].nBuffPos != INT_MIN && m_FFBufferTime[0].nBuffPos < m_nFFPicEnd) {
+ rtStart = m_FFBufferTime[0].rtStart;
+ rtStop = m_FFBufferTime[0].rtStop;
+ } else {
+ rtStart = rtStop = _I64_MIN;
+ }
+ hr = m_pDXVADecoder->DecodeFrame (m_pFFBuffer, m_nFFPicEnd, rtStart, rtStop);
+ ShrinkBuffer();
}
- else
- rtStart = rtStop = _I64_MIN;
- hr = m_pDXVADecoder->DecodeFrame (m_pFFBuffer, m_nFFPicEnd, rtStart, rtStop);
- ShrinkBuffer();
+ } else {
+ hr = m_pDXVADecoder->DecodeFrame (pDataIn, nSize, rtStart, rtStop);
}
- }
- else
- {
- hr = m_pDXVADecoder->DecodeFrame (pDataIn, nSize, rtStart, rtStop);
- }
- break;
- default :
- ASSERT (FALSE);
- hr = E_UNEXPECTED;
+ break;
+ default :
+ ASSERT (FALSE);
+ hr = E_UNEXPECTED;
}
return hr;
@@ -1898,15 +1878,15 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
void CMPCVideoDecFilter::UpdateAspectRatio()
{
- if(((m_nARMode) && (m_pAVCtx)) && ((m_pAVCtx->sample_aspect_ratio.num>0) && (m_pAVCtx->sample_aspect_ratio.den>0)))
- {
+ if(((m_nARMode) && (m_pAVCtx)) && ((m_pAVCtx->sample_aspect_ratio.num>0) && (m_pAVCtx->sample_aspect_ratio.den>0))) {
CSize SAR(m_pAVCtx->sample_aspect_ratio.num, m_pAVCtx->sample_aspect_ratio.den);
- if(m_sar != SAR)
- {
+ if(m_sar != SAR) {
m_sar = SAR;
CSize aspect(m_nWidth * SAR.cx, m_nHeight * SAR.cy);
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) aspect.cx /= lnko, aspect.cy /= lnko;
+ if(lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
SetAspect(aspect);
}
}
@@ -1915,8 +1895,7 @@ void CMPCVideoDecFilter::UpdateAspectRatio()
void CMPCVideoDecFilter::ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
// Re-order B-frames if needed
- if (m_pAVCtx->has_b_frames && m_bReorderBFrame)
- {
+ if (m_pAVCtx->has_b_frames && m_bReorderBFrame) {
rtStart = m_BFrames [m_nPosB].rtStart;
rtStop = m_BFrames [m_nPosB].rtStop;
}
@@ -1933,14 +1912,13 @@ void CMPCVideoDecFilter::FillInVideoDescription(DXVA2_VideoDesc *pDesc)
BOOL CMPCVideoDecFilter::IsSupportedDecoderMode(const GUID& mode)
{
- if (IsDXVASupported())
- {
- for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == GUID_NULL)
+ if (IsDXVASupported()) {
+ for (int i=0; i<MAX_SUPPORTED_MODE; i++) {
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == GUID_NULL) {
break;
- else if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == mode)
+ } else if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == mode) {
return true;
+ }
}
}
@@ -1959,9 +1937,9 @@ BOOL CMPCVideoDecFilter::IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, co
}
HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService *pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode *pSelectedConfig,
- BOOL *pbFoundDXVA2Configuration)
+ const GUID& guidDecoder,
+ DXVA2_ConfigPictureDecode *pSelectedConfig,
+ BOOL *pbFoundDXVA2Configuration)
{
HRESULT hr = S_OK;
UINT cFormats = 0;
@@ -1975,11 +1953,9 @@ HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderSe
hr = pDecoderService->GetDecoderRenderTargets(guidDecoder, &cFormats, &pFormats);
LOG (_T("GetDecoderRenderTargets => %d"), cFormats);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Look for a format that matches our output format.
- for (UINT iFormat = 0; iFormat < cFormats; iFormat++)
- {
+ for (UINT iFormat = 0; iFormat < cFormats; iFormat++) {
LOG (_T("Try to negociate => 0x%08x"), pFormats[iFormat]);
// Fill in the video description. Set the width, height, format, and frame rate.
@@ -1989,24 +1965,22 @@ HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderSe
// Get the available configurations.
hr = pDecoderService->GetDecoderConfigurations(guidDecoder, &m_VideoDesc, NULL, &cConfigurations, &pConfig);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
continue;
}
// Find a supported configuration.
- for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++)
- {
- if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered))
- {
+ for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
+ if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered)) {
// This configuration is good.
- if (bIsPrefered || !*pbFoundDXVA2Configuration)
- {
+ if (bIsPrefered || !*pbFoundDXVA2Configuration) {
*pbFoundDXVA2Configuration = TRUE;
*pSelectedConfig = pConfig[iConfig];
}
- if (bIsPrefered) break;
+ if (bIsPrefered) {
+ break;
+ }
}
}
@@ -2041,70 +2015,61 @@ HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin *pPin)
hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
// Get the Direct3D device manager.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirect3DDeviceManager9),
- (void**)&pDeviceManager);
+ MR_VIDEO_ACCELERATION_SERVICE,
+ __uuidof(IDirect3DDeviceManager9),
+ (void**)&pDeviceManager);
}
// Open a new device handle.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDeviceManager->OpenDeviceHandle(&hDevice);
}
// Get the video decoder service.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDeviceManager->GetVideoService(
- hDevice,
- __uuidof(IDirectXVideoDecoderService),
- (void**)&pDecoderService);
+ hDevice,
+ __uuidof(IDirectXVideoDecoderService),
+ (void**)&pDecoderService);
}
// Get the decoder GUIDs.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Look for the decoder GUIDs we want.
- for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++)
- {
+ for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
// Do we support this mode?
- if (!IsSupportedDecoderMode(pDecoderGuids[iGuid]))
- {
+ if (!IsSupportedDecoderMode(pDecoderGuids[iGuid])) {
continue;
}
// Find a configuration that we support.
hr = FindDXVA2DecoderConfiguration(pDecoderService, pDecoderGuids[iGuid], &config, &bFoundDXVA2Configuration);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
break;
}
- if (bFoundDXVA2Configuration)
- {
+ if (bFoundDXVA2Configuration) {
// Found a good configuration. Save the GUID.
guidDecoder = pDecoderGuids[iGuid];
}
}
}
- if (pDecoderGuids) CoTaskMemFree(pDecoderGuids);
- if (!bFoundDXVA2Configuration)
- {
+ if (pDecoderGuids) {
+ CoTaskMemFree(pDecoderGuids);
+ }
+ if (!bFoundDXVA2Configuration) {
hr = E_FAIL; // Unable to find a configuration.
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Store the things we will need later.
m_pDeviceManager = pDeviceManager;
m_pDecoderService = pDecoderService;
@@ -2114,10 +2079,8 @@ HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin *pPin)
m_hDevice = hDevice;
}
- if (FAILED(hr))
- {
- if (hDevice != INVALID_HANDLE_VALUE)
- {
+ if (FAILED(hr)) {
+ if (hDevice != INVALID_HANDLE_VALUE) {
pDeviceManager->CloseDeviceHandle(hDevice);
}
}
@@ -2138,37 +2101,32 @@ HRESULT CMPCVideoDecFilter::SetEVRForDXVA2(IPin *pPin)
hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
// Get the IDirectXVideoMemoryConfiguration interface.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirectXVideoMemoryConfiguration),
- (void**)&pVideoConfig);
+ MR_VIDEO_ACCELERATION_SERVICE,
+ __uuidof(IDirectXVideoMemoryConfiguration),
+ (void**)&pVideoConfig);
- if (SUCCEEDED (pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc)))
- {
+ if (SUCCEEDED (pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc))) {
HWND hWnd;
- if (SUCCEEDED (pVdc->GetVideoWindow(&hWnd)))
- {
+ if (SUCCEEDED (pVdc->GetVideoWindow(&hWnd))) {
DetectVideoCard(hWnd);
}
}
}
// Notify the EVR.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
DXVA2_SurfaceType surfaceType;
- for (DWORD iTypeIndex = 0; ; iTypeIndex++)
- {
+ for (DWORD iTypeIndex = 0; ; iTypeIndex++) {
hr = pVideoConfig->GetAvailableSurfaceTypeByIndex(iTypeIndex, &surfaceType);
- if (FAILED(hr))
+ if (FAILED(hr)) {
break;
+ }
- if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget)
- {
+ if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget) {
hr = pVideoConfig->SetSurfaceType(DXVA2_SurfaceType_DecoderRenderTarget);
break;
}
@@ -2186,17 +2144,19 @@ HRESULT CMPCVideoDecFilter::CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3D
m_pDecoderRenderTarget = NULL;
- if (m_pDXVADecoder) m_pDXVADecoder->SetDirectXVideoDec (NULL);
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->SetDirectXVideoDec (NULL);
+ }
hr = m_pDecoderService->CreateVideoDecoder (m_DXVADecoderGUID, &m_VideoDesc, &m_DXVA2Config,
- pDecoderRenderTargets, nNumRenderTargets, &pDirectXVideoDec);
+ pDecoderRenderTargets, nNumRenderTargets, &pDirectXVideoDec);
- if (SUCCEEDED (hr))
- {
- if (!m_pDXVADecoder)
- {
+ if (SUCCEEDED (hr)) {
+ if (!m_pDXVADecoder) {
m_pDXVADecoder = CDXVADecoder::CreateDecoder (this, pDirectXVideoDec, &m_DXVADecoderGUID, GetPicEntryNumber(), &m_DXVA2Config);
- if (m_pDXVADecoder) m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ }
}
m_pDXVADecoder->SetDirectXVideoDec (pDirectXVideoDec);
@@ -2214,18 +2174,14 @@ HRESULT CMPCVideoDecFilter::FindDXVA1DecoderConfiguration(IAMVideoAccelerator* p
pAMVideoAccelerator->GetUncompFormatsSupported (guidDecoder, &dwFormats, NULL);
- if (dwFormats > 0)
- {
+ if (dwFormats > 0) {
// Find the valid render target formats for this decoder GUID.
pPixelFormats = DNew DDPIXELFORMAT[dwFormats];
hr = pAMVideoAccelerator->GetUncompFormatsSupported (guidDecoder, &dwFormats, pPixelFormats);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Look for a format that matches our output format.
- for (DWORD iFormat = 0; iFormat < dwFormats; iFormat++)
- {
- if (pPixelFormats[iFormat].dwFourCC == MAKEFOURCC ('N', 'V', '1', '2'))
- {
+ for (DWORD iFormat = 0; iFormat < dwFormats; iFormat++) {
+ if (pPixelFormats[iFormat].dwFourCC == MAKEFOURCC ('N', 'V', '1', '2')) {
memcpy (pPixelFormat, &pPixelFormats[iFormat], sizeof(DDPIXELFORMAT));
SAFE_DELETE_ARRAY(pPixelFormats)
return S_OK;
@@ -2242,11 +2198,11 @@ HRESULT CMPCVideoDecFilter::FindDXVA1DecoderConfiguration(IAMVideoAccelerator* p
HRESULT CMPCVideoDecFilter::CheckDXVA1Decoder(const GUID *pGuid)
{
- if (m_nCodecNb != -1)
- {
+ if (m_nCodecNb != -1) {
for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid)
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid) {
return S_OK;
+ }
}
return E_INVALIDARG;
@@ -2260,11 +2216,11 @@ void CMPCVideoDecFilter::SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixel
WORD CMPCVideoDecFilter::GetDXVA1RestrictedMode()
{
- if (m_nCodecNb != -1)
- {
+ if (m_nCodecNb != -1) {
for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID)
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID) {
return ffCodecs[m_nCodecNb].DXVAModes->RestrictedMode [i];
+ }
}
return DXVA_RESTRICTED_MODE_UNRESTRICTED;
@@ -2272,16 +2228,21 @@ WORD CMPCVideoDecFilter::GetDXVA1RestrictedMode()
HRESULT CMPCVideoDecFilter::CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount)
{
- if (m_pDXVADecoder && m_DXVADecoderGUID == *pDecoderGuid)
+ if (m_pDXVADecoder && m_DXVADecoderGUID == *pDecoderGuid) {
return S_OK;
+ }
SAFE_DELETE (m_pDXVADecoder);
- if (!m_bUseDXVA) return E_FAIL;
+ if (!m_bUseDXVA) {
+ return E_FAIL;
+ }
m_nDXVAMode = MODE_DXVA1;
m_DXVADecoderGUID = *pDecoderGuid;
m_pDXVADecoder = CDXVADecoder::CreateDecoder (this, pAMVideoAccelerator, &m_DXVADecoderGUID, dwSurfaceCount);
- if (m_pDXVADecoder) m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ }
return S_OK;
}
@@ -2302,7 +2263,9 @@ STDMETHODIMP CMPCVideoDecFilter::GetPages(CAUUID* pPages)
pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
pPages->pElems[0] = __uuidof(CMPCVideoDecSettingsWnd);
- if (pPages->cElems>1) pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
+ if (pPages->cElems>1) {
+ pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
+ }
return S_OK;
}
@@ -2311,16 +2274,15 @@ STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** pp
{
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
HRESULT hr;
- if(guid == __uuidof(CMPCVideoDecSettingsWnd))
- {
+ if(guid == __uuidof(CMPCVideoDecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>(NULL, &hr))->AddRef();
- }
- else if(guid == __uuidof(CMPCVideoDecCodecWnd))
- {
+ } else if(guid == __uuidof(CMPCVideoDecCodecWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>(NULL, &hr))->AddRef();
}
@@ -2332,8 +2294,7 @@ STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** pp
STDMETHODIMP CMPCVideoDecFilter::Apply()
{
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder")))
- {
+ if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"))) {
key.SetDWORDValue(_T("ThreadNumber"), m_nThreadNumber);
key.SetDWORDValue(_T("DiscardMode"), m_nDiscardMode);
key.SetDWORDValue(_T("ErrorRecognition"), m_nErrorRecognition);
@@ -2392,10 +2353,11 @@ STDMETHODIMP_(int) CMPCVideoDecFilter::GetIDCTAlgo()
}
STDMETHODIMP_(GUID*) CMPCVideoDecFilter::GetDXVADecoderGuid()
{
- if (m_pGraph == NULL)
+ if (m_pGraph == NULL) {
return NULL;
- else
+ } else {
return &m_DXVADecoderGUID;
+ }
}
STDMETHODIMP CMPCVideoDecFilter::SetActiveCodecs(MPC_VIDEO_CODEC nValue)
{
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
index 7800a0e16..846a8cab2 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
@@ -44,22 +44,19 @@ class CCpuId;
#define MAX_BUFF_TIME 20
-typedef enum
-{
+typedef enum {
MODE_SOFTWARE,
MODE_DXVA1,
MODE_DXVA2
} DXVA_MODE;
-typedef struct
-{
+typedef struct {
REFERENCE_TIME rtStart;
REFERENCE_TIME rtStop;
} B_FRAME;
-typedef struct
-{
+typedef struct {
REFERENCE_TIME rtStart;
REFERENCE_TIME rtStop;
int nBuffPos;
@@ -162,8 +159,8 @@ protected:
void SetTypeSpecificFlags(IMediaSample* pMS);
HRESULT SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
-//void FindStartCodeVC1 (BYTE** pDataIn, int& nSize);
-//void FindStartCodeH264 (BYTE** pDataIn, int& nSize);
+ //void FindStartCodeVC1 (BYTE** pDataIn, int& nSize);
+ //void FindStartCodeH264 (BYTE** pDataIn, int& nSize);
bool AppendBuffer (BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
bool FindPicture(int nIndex, int nStartCode);
void ShrinkBuffer();
@@ -190,7 +187,9 @@ public:
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
virtual bool IsVideoInterlaced();
virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int &RealWidth, int &RealHeight);
- CTransformOutputPin* GetOutputPin() {return m_pOutput;}
+ CTransformOutputPin* GetOutputPin() {
+ return m_pOutput;
+ }
void UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
// === Overriden DirectShow functions
@@ -241,19 +240,37 @@ public:
int PictHeight();
int PictWidthRounded();
int PictHeightRounded();
- inline bool UseDXVA2() {return (m_nDXVAMode == MODE_DXVA2);};
- void FlushDXVADecoder() {if (m_pDXVADecoder) m_pDXVADecoder->Flush();}
- inline AVCodecContext* GetAVCtx() {return m_pAVCtx;};
- inline AVFrame* GetFrame() {return m_pFrame;}
+ inline bool UseDXVA2() {
+ return (m_nDXVAMode == MODE_DXVA2);
+ };
+ void FlushDXVADecoder() {
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->Flush();
+ }
+ }
+ inline AVCodecContext* GetAVCtx() {
+ return m_pAVCtx;
+ };
+ inline AVFrame* GetFrame() {
+ return m_pFrame;
+ }
bool IsDXVASupported();
- inline bool IsReorderBFrame() { return m_bReorderBFrame;};
- inline int GetPCIVendor() {return m_nPCIVendor;};
- inline REFERENCE_TIME GetAvrTimePerFrame() {return m_rtAvrTimePerFrame;};
+ inline bool IsReorderBFrame() {
+ return m_bReorderBFrame;
+ };
+ inline int GetPCIVendor() {
+ return m_nPCIVendor;
+ };
+ inline REFERENCE_TIME GetAvrTimePerFrame() {
+ return m_rtAvrTimePerFrame;
+ };
void UpdateAspectRatio();
void ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
// === DXVA1 functions
- DDPIXELFORMAT* GetPixelFormat() {return &m_PixelFormat;}
+ DDPIXELFORMAT* GetPixelFormat() {
+ return &m_PixelFormat;
+ }
HRESULT FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat);
HRESULT CheckDXVA1Decoder(const GUID *pGuid);
void SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat);
@@ -263,12 +280,14 @@ public:
// === DXVA2 functions
void FillInVideoDescription(DXVA2_VideoDesc *pDesc);
- DXVA2_ConfigPictureDecode* GetDXVA2Config() {return &m_DXVA2Config;};
+ DXVA2_ConfigPictureDecode* GetDXVA2Config() {
+ return &m_DXVA2Config;
+ };
HRESULT ConfigureDXVA2(IPin *pPin);
HRESULT SetEVRForDXVA2(IPin *pPin);
HRESULT FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService *pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode *pSelectedConfig,
- BOOL *pbFoundDXVA2Configuration);
+ const GUID& guidDecoder,
+ DXVA2_ConfigPictureDecode *pSelectedConfig,
+ BOOL *pbFoundDXVA2Configuration);
HRESULT CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets);
};
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
index 81b74bbf7..11f7d613a 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
@@ -37,20 +37,21 @@
// CMPCVideoDecSettingsWnd
//
-int g_AVDiscard[] =
-{
+int g_AVDiscard[] = {
-16, ///< AVDISCARD_NONE discard nothing
- 0, ///< AVDISCARD_DEFAULT discard useless packets like 0 size packets in avi
- 8, ///< AVDISCARD_NONREF discard all non reference
- 16, ///< AVDISCARD_BIDIR discard all bidirectional frames
- 32, ///< AVDISCARD_NONKEY discard all frames except keyframes
- 48, ///< AVDISCARD_ALL discard all
+ 0, ///< AVDISCARD_DEFAULT discard useless packets like 0 size packets in avi
+ 8, ///< AVDISCARD_NONREF discard all non reference
+ 16, ///< AVDISCARD_BIDIR discard all bidirectional frames
+ 32, ///< AVDISCARD_NONKEY discard all frames except keyframes
+ 48, ///< AVDISCARD_ALL discard all
};
int FindDiscardIndex(int nValue)
{
for (int i=0; i<countof (g_AVDiscard); i++)
- if (g_AVDiscard[i] == nValue) return i;
+ if (g_AVDiscard[i] == nValue) {
+ return i;
+ }
return 1;
}
@@ -66,9 +67,13 @@ bool CMPCVideoDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnk
m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos)));
+ while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if(!m_pMDF) return false;
+ if(!m_pMDF) {
+ return false;
+ }
return true;
}
@@ -86,7 +91,7 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
#if HAS_FFMPEG_VIDEO_DECODERS
m_grpFFMpeg.Create (ResStr (IDS_VDF_FFSETTINGS), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10, nPosY, 350, nPosY+150), this, (UINT)IDC_STATIC);
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
// Decoding threads
nPosY += VERTICAL_SPACING;
@@ -101,9 +106,9 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
m_cbThreadNumber.AddString (_T("7"));
m_cbThreadNumber.AddString (_T("8"));
- #endif /* INTERNAL_DECODER_H264 */
+#endif /* INTERNAL_DECODER_H264 */
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
// H264 deblocking mode
nPosY += VERTICAL_SPACING;
@@ -116,7 +121,7 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONKFRM));
m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_ALL));
- #endif /* INTERNAL_DECODER_H264 */
+#endif /* INTERNAL_DECODER_H264 */
// Error recognition
nPosY += VERTICAL_SPACING;
@@ -172,27 +177,24 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
DxvaGui = m_pMDF->GetDXVADecoderGuid();
- if (DxvaGui != NULL)
- {
+ if (DxvaGui != NULL) {
CString DXVAMode = GetDXVAMode (DxvaGui);
m_edtDXVAMode.SetWindowText (DXVAMode);
- }
- else
- {
+ } else {
m_txtDXVAMode.ShowWindow (SW_HIDE);
m_edtDXVAMode.ShowWindow (SW_HIDE);
}
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
- if (m_pMDF)
- {
+ if (m_pMDF) {
#if HAS_FFMPEG_VIDEO_DECODERS
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
m_cbThreadNumber.SetCurSel (m_pMDF->GetThreadNumber() - 1);
m_cbDiscardMode.SetCurSel (FindDiscardIndex (m_pMDF->GetDiscardMode()));
- #endif
+#endif
m_cbErrorRecognition.SetCurSel (m_pMDF->GetErrorRecognition()-1);
m_cbIDCTAlgo.SetCurSel (m_pMDF->GetIDCTAlgo());
@@ -214,13 +216,12 @@ bool CMPCVideoDecSettingsWnd::OnApply()
{
OnDeactivate();
- if(m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd)
- {
+ if(m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
#if HAS_FFMPEG_VIDEO_DECODERS
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
m_pMDF->SetThreadNumber (m_cbThreadNumber.GetCurSel() + 1);
m_pMDF->SetDiscardMode (g_AVDiscard[m_cbDiscardMode.GetCurSel()]);
- #endif /* INTERNAL_DECODER_H264 */
+#endif /* INTERNAL_DECODER_H264 */
m_pMDF->SetErrorRecognition (m_cbErrorRecognition.GetCurSel()+1);
m_pMDF->SetIDCTAlgo (m_cbIDCTAlgo.GetCurSel());
@@ -257,9 +258,13 @@ bool CMPCVideoDecCodecWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknow
m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos)));
+ while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if(!m_pMDF) return false;
+ if(!m_pMDF) {
+ return false;
+ }
return true;
}
@@ -320,8 +325,9 @@ bool CMPCVideoDecCodecWnd::OnActivate()
m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_THEORA) != 0);
#endif
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
return true;
}
@@ -334,35 +340,64 @@ bool CMPCVideoDecCodecWnd::OnApply()
{
OnDeactivate();
- if(m_pMDF)
- {
+ if(m_pMDF) {
int nActiveCodecs = 0;
int nPos = 0;
#if INTERNAL_DECODER_H264_DXVA
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_H264_DXVA;
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_H264_DXVA;
+ }
#endif
#if INTERNAL_DECODER_H264
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_H264;
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_H264;
+ }
#endif
#if INTERNAL_DECODER_VC1_DXVA
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_VC1_DXVA;
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_VC1_DXVA;
+ }
#endif
#if INTERNAL_DECODER_VC1
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_VC1;
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_VC1;
+ }
#endif
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_XVID;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_DIVX;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_MSMPEG4;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_FLASH;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_VP6;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_VP8;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_WMV;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_H263;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_SVQ3;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_AMVV;
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_THEORA;
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_XVID;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_DIVX;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_MSMPEG4;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_FLASH;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_VP6;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_VP8;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_WMV;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_H263;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_SVQ3;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_AMVV;
+ }
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_THEORA;
+ }
#endif
m_pMDF->SetActiveCodecs ((MPC_VIDEO_CODEC)nActiveCodecs);
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
index 289b206b9..a6b372002 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
@@ -54,8 +54,7 @@ class __declspec(uuid("D5AA0389-D274-48e1-BF50-ACB05A56DDE0"))
CButton m_cbDXVA_SD;
- enum
- {
+ enum {
IDC_PP_THREAD_NUMBER = 10000,
IDC_PP_ENABLE_DEBLOCKING,
IDC_PP_DISCARD_MODE,
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
index af7c78397..2ea37a49b 100644
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
+++ b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
@@ -40,15 +40,17 @@ void TlibavcodecExt::ConnectTo(AVCodecContext *pAVCtx)
int TlibavcodecExt::get_buffer(AVCodecContext *c, AVFrame *pic)
{
int ret=c->opaque->ff_avcodec_default_get_buffer(c,pic);
- if (ret==0)
+ if (ret==0) {
c->opaque->OnGetBuffer(pic);
+ }
return ret;
}
int TlibavcodecExt::reget_buffer(AVCodecContext *c, AVFrame *pic)
{
int ret=c->opaque->ff_avcodec_default_reget_buffer(c,pic);
- if (ret==0)
+ if (ret==0) {
c->opaque->OnRegetBuffer(pic);
+ }
return ret;
}
void TlibavcodecExt::release_buffer(AVCodecContext *c, AVFrame *pic)
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
index 7e7d5c051..37b7ccf8e 100644
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
+++ b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
@@ -36,8 +36,7 @@ typedef void (*FUNC_AV_DEFAULT_RELEASE_BUFFER)(AVCodecContext *s, AVFrame *pic
typedef int (*FUNC_AV_DEFAULT_REGET_BUFFER)(AVCodecContext *s, AVFrame *pic);
-struct TlibavcodecExt
-{
+struct TlibavcodecExt {
protected:
static int get_buffer(AVCodecContext *s, AVFrame *pic);
static void release_buffer(AVCodecContext *s, AVFrame *pic);
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
index 4cfcc495a..1d8579612 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
+++ b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
@@ -40,16 +40,12 @@ STDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void **ppv)
CheckPointer(ppv,E_POINTER);
ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == __uuidof(IMFGetService))
- {
+ if (riid == __uuidof(IMFGetService)) {
return GetInterface((IMFGetService*) this, ppv);
}
- if (riid == __uuidof(IMPCDXVA2Sample))
- {
+ if (riid == __uuidof(IMPCDXVA2Sample)) {
return GetInterface((IMPCDXVA2Sample*) this, ppv);
- }
- else
- {
+ } else {
return CMediaSample::QueryInterface(riid, ppv);
}
}
@@ -70,16 +66,11 @@ STDMETHODIMP_(ULONG) CDXVA2Sample::Release()
// IMFGetService::GetService
STDMETHODIMP CDXVA2Sample::GetService(REFGUID guidService, REFIID riid, LPVOID *ppv)
{
- if (guidService != MR_BUFFER_SERVICE)
- {
+ if (guidService != MR_BUFFER_SERVICE) {
return MF_E_UNSUPPORTED_SERVICE;
- }
- else if (m_pSurface == NULL)
- {
+ } else if (m_pSurface == NULL) {
return E_NOINTERFACE;
- }
- else
- {
+ } else {
return m_pSurface->QueryInterface(riid, ppv);
}
}
@@ -131,8 +122,7 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
hr = __super::Alloc();
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Free the old resources.
Free();
@@ -140,20 +130,16 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
// Allocate a new array of pointers.
m_ppRTSurfaceArray = DNew IDirect3DSurface9*[m_lCount];
- if (m_ppRTSurfaceArray == NULL)
- {
+ if (m_ppRTSurfaceArray == NULL) {
hr = E_OUTOFMEMORY;
- }
- else
- {
+ } else {
ZeroMemory(m_ppRTSurfaceArray, sizeof(IDirect3DSurface9*) * m_lCount);
}
}
// Allocate the surfaces.
D3DFORMAT m_dwFormat = m_pVideoDecFilter->m_VideoDesc.Format;
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDXVA2Service->CreateSurface(
m_pVideoDecFilter->PictWidthRounded(),
m_pVideoDecFilter->PictHeightRounded(),
@@ -167,19 +153,15 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
);
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Important : create samples in reverse order !
- for (m_lAllocated = m_lCount-1; m_lAllocated >= 0; m_lAllocated--)
- {
+ for (m_lAllocated = m_lCount-1; m_lAllocated >= 0; m_lAllocated--) {
CDXVA2Sample *pSample = DNew CDXVA2Sample(this, &hr);
- if (pSample == NULL)
- {
+ if (pSample == NULL) {
hr = E_OUTOFMEMORY;
break;
}
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
break;
}
// Assign the Direct3D surface pointer and the index.
@@ -190,11 +172,12 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
}
hr = m_pVideoDecFilter->CreateDXVA2Decoder (m_lCount, m_ppRTSurfaceArray);
- if (FAILED (hr)) Free();
+ if (FAILED (hr)) {
+ Free();
+ }
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
m_bChanged = FALSE;
}
return hr;
@@ -205,22 +188,19 @@ void CVideoDecDXVAAllocator::Free()
CMediaSample *pSample = NULL;
m_pVideoDecFilter->FlushDXVADecoder();
-// m_FreeSurface.RemoveAll();
- do
- {
+ // m_FreeSurface.RemoveAll();
+ do {
pSample = m_lFree.RemoveHead();
- if (pSample)
- {
+ if (pSample) {
delete pSample;
}
} while (pSample);
- if (m_ppRTSurfaceArray)
- {
- for (long i = 0; i < m_nSurfaceArrayCount; i++)
- {
- if (m_ppRTSurfaceArray[i] != NULL)
+ if (m_ppRTSurfaceArray) {
+ for (long i = 0; i < m_nSurfaceArrayCount; i++) {
+ if (m_ppRTSurfaceArray[i] != NULL) {
m_ppRTSurfaceArray[i]->Release();
+ }
}
delete [] m_ppRTSurfaceArray;
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
index 0f20d4383..7b3206112 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
+++ b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
@@ -33,8 +33,7 @@ class CVideoDecDXVAAllocator;
interface __declspec(uuid("AE7EC2A2-1913-4a80-8DD6-DF1497ABA494"))
IMPCDXVA2Sample :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(int, GetDXSurfaceId()) = 0;
};
@@ -80,13 +79,13 @@ public:
CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr);
virtual ~CVideoDecDXVAAllocator();
-// STDMETHODIMP GetBuffer(__deref_out IMediaSample **ppBuffer, // Try for a circular buffer!
-// __in_opt REFERENCE_TIME * pStartTime,
-// __in_opt REFERENCE_TIME * pEndTime,
-// DWORD dwFlags);
-//
-// STDMETHODIMP ReleaseBuffer(IMediaSample *pBuffer);
-// CAtlList<int> m_FreeSurface;
+ // STDMETHODIMP GetBuffer(__deref_out IMediaSample **ppBuffer, // Try for a circular buffer!
+ // __in_opt REFERENCE_TIME * pStartTime,
+ // __in_opt REFERENCE_TIME * pEndTime,
+ // DWORD dwFlags);
+ //
+ // STDMETHODIMP ReleaseBuffer(IMediaSample *pBuffer);
+ // CAtlList<int> m_FreeSurface;
protected:
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
index 06dbbbd4e..4fcc513dd 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
+++ b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
@@ -44,24 +44,21 @@ CVideoDecOutputPin::~CVideoDecOutputPin(void)
HRESULT CVideoDecOutputPin::InitAllocator(IMemAllocator **ppAlloc)
{
TRACE("CVideoDecOutputPin::InitAllocator");
- if (m_pVideoDecFilter->UseDXVA2())
- {
+ if (m_pVideoDecFilter->UseDXVA2()) {
HRESULT hr = S_FALSE;
m_pDXVA2Allocator = DNew CVideoDecDXVAAllocator(m_pVideoDecFilter, &hr);
- if (!m_pDXVA2Allocator)
- {
+ if (!m_pDXVA2Allocator) {
return E_OUTOFMEMORY;
}
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
delete m_pDXVA2Allocator;
return hr;
}
// Return the IMemAllocator interface.
return m_pDXVA2Allocator->QueryInterface(__uuidof(IMemAllocator), (void **)ppAlloc);
- }
- else
+ } else {
return __super::InitAllocator(ppAlloc);
+ }
}
STDMETHODIMP CVideoDecOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
@@ -77,18 +74,15 @@ STDMETHODIMP CVideoDecOutputPin::GetUncompSurfacesInfo(const GUID *pGuid, LPAMVA
{
HRESULT hr = E_INVALIDARG;
- if (SUCCEEDED (m_pVideoDecFilter->CheckDXVA1Decoder (pGuid)))
- {
+ if (SUCCEEDED (m_pVideoDecFilter->CheckDXVA1Decoder (pGuid))) {
CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
- if (pAMVideoAccelerator)
- {
+ if (pAMVideoAccelerator) {
pUncompBufferInfo->dwMaxNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
pUncompBufferInfo->dwMinNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
hr = m_pVideoDecFilter->FindDXVA1DecoderConfiguration (pAMVideoAccelerator, pGuid, &pUncompBufferInfo->ddUncompPixelFormat);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
memcpy (&m_ddUncompPixelFormat, &pUncompBufferInfo->ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
m_GuidDecoderDXVA1 = *pGuid;
}
@@ -112,19 +106,16 @@ STDMETHODIMP CVideoDecOutputPin::GetCreateVideoAcceleratorData(const GUID *pGuid
CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
DXVA_ConnectMode* pConnectMode;
- if (pAMVideoAccelerator)
- {
+ if (pAMVideoAccelerator) {
memcpy (&UncompInfo.ddUncompPixelFormat, &m_ddUncompPixelFormat, sizeof (DDPIXELFORMAT));
UncompInfo.dwUncompWidth = m_pVideoDecFilter->PictWidthRounded();
UncompInfo.dwUncompHeight = m_pVideoDecFilter->PictHeightRounded();
hr = pAMVideoAccelerator->GetCompBufferInfo(&m_GuidDecoderDXVA1, &UncompInfo, &dwNumTypesCompBuffers, CompInfo);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
hr = m_pVideoDecFilter->CreateDXVA1Decoder (pAMVideoAccelerator, pGuid, m_dwDXVA1SurfaceCount);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
m_pVideoDecFilter->SetDXVA1Params (&m_GuidDecoderDXVA1, &m_ddUncompPixelFormat);
pConnectMode = (DXVA_ConnectMode*)CoTaskMemAlloc (sizeof(DXVA_ConnectMode));
diff --git a/src/filters/transform/MPCVideoDec/stdafx.cpp b/src/filters/transform/MPCVideoDec/stdafx.cpp
index 1734bc03d..5008ff8b5 100644
--- a/src/filters/transform/MPCVideoDec/stdafx.cpp
+++ b/src/filters/transform/MPCVideoDec/stdafx.cpp
@@ -31,11 +31,9 @@ void LOG(LPCTSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
- if(TCHAR* buff = new TCHAR[_vsctprintf(fmt, args) + 1])
- {
+ if(TCHAR* buff = new TCHAR[_vsctprintf(fmt, args) + 1]) {
_vstprintf(buff, fmt, args);
- if(FILE* f = _tfopen(LOG_FILE, _T("at")))
- {
+ if(FILE* f = _tfopen(LOG_FILE, _T("at"))) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
diff --git a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h b/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
index 718755179..6c933d6bd 100644
--- a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
+++ b/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
@@ -26,8 +26,7 @@
enum MPCSampleFormat {SF_PCM16, SF_PCM24, SF_PCM32, SF_FLOAT32};
enum {AAC_ASIS, AAC_STEREO};
-enum DolbyDigitalMode
-{
+enum DolbyDigitalMode {
DD_Unknown,
DD_AC3, // Standard AC3
DD_EAC3, // Dolby Digital +
@@ -38,8 +37,7 @@ enum DolbyDigitalMode
interface __declspec(uuid("2067C60F-752F-4EBD-B0B1-4CBC5E00741C"))
IMpaDecFilter :
-public IUnknown
-{
+public IUnknown {
enum enctype {ac3, dts, aac, etlast};
STDMETHOD(SetSampleFormat(MPCSampleFormat sf)) = 0;
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
index e5c0e565f..eaf64c305 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
+++ b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
@@ -43,8 +43,7 @@
#define EAC3_FRAME_TYPE_RESERVED 3
#define AC3_HEADER_SIZE 7
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Payload},
@@ -119,24 +118,20 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMpaDecFilter), L"MPC - MPA Decoder Filter", /*MERIT_DO_NOT_USE*/0x40000001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, &__uuidof(CMpaDecFilter), CreateInstance<CMpaDecFilter>, NULL, &sudFilter[0]},
{L"CMpaDecPropertyPage", &__uuidof(CMpaDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpaDecSettingsWnd> >},
};
@@ -168,14 +163,12 @@ CFilterApp theApp;
// lets see how we can map these things to dshow (oh the joy!)
#pragma warning(disable : 4245)
-static struct scmap_t
-{
+static struct scmap_t {
WORD nChannels;
BYTE ch[8];
DWORD dwChannelMask;
}
-s_scmap_ac3[2*11] =
-{
+s_scmap_ac3[2*11] = {
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // A52_CHANNEL
{1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // A52_MONO
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // A52_STEREO
@@ -200,8 +193,7 @@ s_scmap_ac3[2*11] =
{2, {1, 0,-1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // A52_CHANNEL2|A52_LFE
{3, {1, 2, 0,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // A52_DOLBY|A52_LFE
},
-s_scmap_dts[2*10] =
-{
+s_scmap_dts[2*10] = {
{1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_MONO
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_CHANNEL
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_STEREO
@@ -224,8 +216,7 @@ s_scmap_dts[2*10] =
{5, {0, 1, 4, 2, 3,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // DTS_2F2R|DTS_LFE
{6, {1, 2, 0, 5, 3, 4,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // DTS_3F2R|DTS_LFE
},
-s_scmap_vorbis[6] =
-{
+s_scmap_vorbis[6] = {
{1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // 1F
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // 2F
{3, {0, 2, 1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER}, // 2F1R
@@ -233,9 +224,8 @@ s_scmap_vorbis[6] =
{5, {0, 2, 1, 3, 4,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // 3F2R
{6, {0, 2, 1, 5, 3, 4,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // 3F2R + LFE
},
-s_scmap_hdmv[] =
-{
-// FL FR FC LFe BL BR FLC FRC
+s_scmap_hdmv[] = {
+ // FL FR FC LFe BL BR FLC FRC
{0, {-1,-1,-1,-1,-1,-1,-1,-1 }, 0}, // INVALID
{1, { 0,-1,-1,-1,-1,-1,-1,-1 }, 0}, // Mono M1, 0
{0, {-1,-1,-1,-1,-1,-1,-1,-1 }, 0}, // INVALID
@@ -249,9 +239,8 @@ s_scmap_hdmv[] =
{8, { 0, 1, 2, 3, 6, 4, 5,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT}, // 3/4 FL, FR, FC, BL, Bls, Brs, BR
{8, { 0, 1, 2, 7, 4, 5, 3, 6 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT},// 3/4+LFe FL, FR, FC, BL, Bls, Brs, BR, LFe
},
-m_scmap_default[] =
-{
-// FL FR FC LFe BL BR FLC FRC
+m_scmap_default[] = {
+ // FL FR FC LFe BL BR FLC FRC
{1, { 0,-1,-1,-1,-1,-1,-1,-1 }, 0}, // Mono M1, 0
{2, { 0, 1,-1,-1,-1,-1,-1,-1 }, 0}, // Stereo FL, FR
{3, { 0, 1, 2,-1,-1,-1,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER}, // 3/0 FL, FR, FC
@@ -261,9 +250,8 @@ m_scmap_default[] =
{7, { 0, 1, 2, 3, 4, 5, 6,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT|SPEAKER_BACK_CENTER}, // 3/4 FL, FR, FC, BL, Bls, Brs, BR
{8, { 0, 1, 2, 3, 6, 7, 4, 5 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT},// 3/4+LFe FL, FR, FC, BL, Bls, Brs, BR, LFe
},
-m_ffmpeg_ac3[] =
-{
-// FL FR FC LFe BL BR FLC FRC
+m_ffmpeg_ac3[] = {
+ // FL FR FC LFe BL BR FLC FRC
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // AC3_CHMODE_DUALMONO
{1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // AC3_CHMODE_MONO
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // AC3_CHMODE_STEREO
@@ -284,14 +272,22 @@ CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
, m_fNormalize(false)
, m_boost(1)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput = DNew CMpaDecInputPin(this, phr, L"In");
- if(!m_pInput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
- if(!m_pOutput) *phr = E_OUTOFMEMORY;
+ if(!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
if(FAILED(*phr)) {
delete m_pInput, m_pInput = NULL;
return;
@@ -320,25 +316,44 @@ CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
#endif
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"), KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"), KEY_READ)) {
DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("SampleFormat"), dw)) m_iSampleFormat = (MPCSampleFormat)dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Normalize"), dw)) m_fNormalize = !!dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Boost"), dw)) m_boost = *(float*)&dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3SpeakerConfig"), dw)) m_iSpeakerConfig[ac3] = (int)dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsSpeakerConfig"), dw)) m_iSpeakerConfig[dts] = (int)dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("AacSpeakerConfig"), dw)) m_iSpeakerConfig[aac] = (int)dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3DynamicRangeControl"), dw)) m_fDynamicRangeControl[ac3] = !!dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsDynamicRangeControl"), dw)) m_fDynamicRangeControl[dts] = !!dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("AacDynamicRangeControl"), dw)) m_fDynamicRangeControl[aac] = !!dw;
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("SampleFormat"), dw)) {
+ m_iSampleFormat = (MPCSampleFormat)dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Normalize"), dw)) {
+ m_fNormalize = !!dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Boost"), dw)) {
+ m_boost = *(float*)&dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3SpeakerConfig"), dw)) {
+ m_iSpeakerConfig[ac3] = (int)dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsSpeakerConfig"), dw)) {
+ m_iSpeakerConfig[dts] = (int)dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("AacSpeakerConfig"), dw)) {
+ m_iSpeakerConfig[aac] = (int)dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3DynamicRangeControl"), dw)) {
+ m_fDynamicRangeControl[ac3] = !!dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsDynamicRangeControl"), dw)) {
+ m_fDynamicRangeControl[dts] = !!dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("AacDynamicRangeControl"), dw)) {
+ m_fDynamicRangeControl[aac] = !!dw;
+ }
}
}
CMpaDecFilter::~CMpaDecFilter()
{
#if defined(REGISTER_FILTER) | HAS_FFMPEG_AUDIO_DECODERS
- if (m_pFFBuffer) free(m_pFFBuffer);
+ if (m_pFFBuffer) {
+ free(m_pFFBuffer);
+ }
m_nFFBufferSize = 0;
#endif
@@ -395,12 +410,14 @@ HRESULT CMpaDecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, d
m_ps2_state.sync = false;
m_DolbyDigitalMode = DD_Unknown;
#if defined(REGISTER_FILTER) | HAS_FFMPEG_AUDIO_DECODERS
- if (m_pAVCtx)
+ if (m_pAVCtx) {
avcodec_flush_buffers (m_pAVCtx);
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- if (m_flac.pDecoder)
+ if (m_flac.pDecoder) {
FLAC__stream_decoder_flush((FLAC__StreamDecoder*) m_flac.pDecoder);
+ }
#endif
return __super::NewSegment(tStart, tStop, dRate);
}
@@ -412,12 +429,12 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ if(pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pInput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -433,7 +450,9 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
}
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
long len = pIn->GetActualDataLength();
@@ -442,8 +461,7 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
hr = pIn->GetTime(&rtStart, &rtStop);
- if(pIn->IsDiscontinuity() == S_OK)
- {
+ if(pIn->IsDiscontinuity() == S_OK) {
m_fDiscontinuity = true;
m_buff.RemoveAll();
m_sample_max = 0.1f;
@@ -458,13 +476,11 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
const GUID& subtype = m_pInput->CurrentMediaType().subtype;
BOOL bNoJitterControl = false;
- if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR || subtype == MEDIASUBTYPE_SAWB)
- {
+ if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR || subtype == MEDIASUBTYPE_SAWB) {
bNoJitterControl = true;
}
- if(SUCCEEDED(hr) && _abs64((m_rtStart - rtStart)) > 1000000i64 && !bNoJitterControl) // +-100ms jitter is allowed for now
- {
+ if(SUCCEEDED(hr) && _abs64((m_rtStart - rtStart)) > 1000000i64 && !bNoJitterControl) { // +-100ms jitter is allowed for now
m_buff.RemoveAll();
m_rtStart = rtStart;
}
@@ -475,51 +491,60 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
len += bufflen;
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AMR
- if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR)
+ if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR) {
hr = ProcessFFmpeg(CODEC_ID_AMR_NB);
- else if(subtype == MEDIASUBTYPE_SAWB)
+ } else if(subtype == MEDIASUBTYPE_SAWB) {
hr = ProcessFFmpeg(CODEC_ID_AMR_WB);
+ }
#else
if(0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_LPCM
- else if(subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)
+ else if(subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
hr = ProcessLPCM();
- else if(subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)
+ } else if(subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
hr = ProcessHdmvLPCM(pIn->IsSyncPoint());
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AC3
else if(subtype == MEDIASUBTYPE_DOLBY_AC3 ||
subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
- subtype == MEDIASUBTYPE_DOLBY_TRUEHD)
+ subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
hr = ProcessAC3();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_DTS
- else if(subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)
+ else if(subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS) {
hr = ProcessDTS();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AAC
- else if(subtype == MEDIASUBTYPE_AAC || subtype == MEDIASUBTYPE_MP4A || subtype == MEDIASUBTYPE_mp4a)
+ else if(subtype == MEDIASUBTYPE_AAC || subtype == MEDIASUBTYPE_MP4A || subtype == MEDIASUBTYPE_mp4a) {
hr = ProcessAAC();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PS2AUDIO
- else if(subtype == MEDIASUBTYPE_PS2_PCM)
+ else if(subtype == MEDIASUBTYPE_PS2_PCM) {
hr = ProcessPS2PCM();
- else if(subtype == MEDIASUBTYPE_PS2_ADPCM)
+ } else if(subtype == MEDIASUBTYPE_PS2_ADPCM) {
hr = ProcessPS2ADPCM();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
- else if(subtype == MEDIASUBTYPE_Vorbis2)
+ else if(subtype == MEDIASUBTYPE_Vorbis2) {
hr = ProcessVorbis();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- else if(subtype == MEDIASUBTYPE_FLAC_FRAMED)
+ else if(subtype == MEDIASUBTYPE_FLAC_FRAMED) {
hr = ProcessFlac();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_NELLYMOSER
- else if(subtype == MEDIASUBTYPE_NELLYMOSER)
+ else if(subtype == MEDIASUBTYPE_NELLYMOSER) {
hr = ProcessFFmpeg(CODEC_ID_NELLYMOSER);
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PCM
else if(subtype == MEDIASUBTYPE_PCM_NONE ||
@@ -528,42 +553,36 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
return S_OK;
}
hr = ProcessPCMraw();
- }
- else if(subtype == MEDIASUBTYPE_PCM_TWOS) {
+ } else if(subtype == MEDIASUBTYPE_PCM_TWOS) {
if(m_buff.GetCount() < 960) {
return S_OK;
}
hr = ProcessPCMintBE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_SOWT) {
+ } else if(subtype == MEDIASUBTYPE_PCM_SOWT) {
if(m_buff.GetCount() < 960) {
return S_OK;
}
hr = ProcessPCMintLE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_IN24 ||
- subtype == MEDIASUBTYPE_PCM_IN32) {
+ } else if(subtype == MEDIASUBTYPE_PCM_IN24 ||
+ subtype == MEDIASUBTYPE_PCM_IN32) {
if(m_buff.GetCount() < 1920) {
return S_OK;
}
hr = ProcessPCMintBE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_IN24_le ||
- subtype == MEDIASUBTYPE_PCM_IN32_le) {
+ } else if(subtype == MEDIASUBTYPE_PCM_IN24_le ||
+ subtype == MEDIASUBTYPE_PCM_IN32_le) {
if(m_buff.GetCount() < 1920) {
return S_OK;
}
hr = ProcessPCMintLE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_FL32 ||
- subtype == MEDIASUBTYPE_PCM_FL64) {
+ } else if(subtype == MEDIASUBTYPE_PCM_FL32 ||
+ subtype == MEDIASUBTYPE_PCM_FL64) {
if(m_buff.GetCount() < 3840) {
return S_OK;
}
hr = ProcessPCMfloatBE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_FL32_le ||
- subtype == MEDIASUBTYPE_PCM_FL64_le) {
+ } else if(subtype == MEDIASUBTYPE_PCM_FL32_le ||
+ subtype == MEDIASUBTYPE_PCM_FL64_le) {
if(m_buff.GetCount() < 3840) {
return S_OK;
}
@@ -571,12 +590,14 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_IMA4
- else if(subtype == MEDIASUBTYPE_IMA4)
+ else if(subtype == MEDIASUBTYPE_IMA4) {
hr = ProcessFFmpeg(CODEC_ID_ADPCM_IMA_QT);
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_MPEGAUDIO
- else // if(.. the rest ..)
+ else { // if(.. the rest ..)
hr = ProcessMPA();
+ }
#endif
return hr;
@@ -587,8 +608,9 @@ HRESULT CMpaDecFilter::ProcessLPCM()
{
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- if (wfein->nChannels < 1 || wfein->nChannels > 8)
+ if (wfein->nChannels < 1 || wfein->nChannels > 8) {
return ERROR_NOT_SUPPORTED;
+ }
scmap_t* remap = &m_scmap_default [wfein->nChannels-1];
int nChannels = wfein->nChannels;
@@ -604,144 +626,122 @@ HRESULT CMpaDecFilter::ProcessLPCM()
float* pDataOut = pBuff.GetData();
- switch (wfein->wBitsPerSample)
- {
- case 16 :
- {
- long nSamples = len/(BytesPerDoubleChannelSample);
- int16 Temp[2][8];
- for (int i=0; i<nSamples; i++)
- {
- for(int j = 0; j < nChannels; j++)
- {
- uint16 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
- Temp[0][j] = Part1;
- }
- for(int j = 0; j < nChannels; j++)
- {
- uint16 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
- Temp[1][j] = Part1;
- }
+ switch (wfein->wBitsPerSample) {
+ case 16 : {
+ long nSamples = len/(BytesPerDoubleChannelSample);
+ int16 Temp[2][8];
+ for (int i=0; i<nSamples; i++) {
+ for(int j = 0; j < nChannels; j++) {
+ uint16 All = *((uint16 *)pDataIn);
+ pDataIn += 2;
+ int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
+ Temp[0][j] = Part1;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ uint16 All = *((uint16 *)pDataIn);
+ pDataIn += 2;
+ int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
+ Temp[1][j] = Part1;
+ }
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[0][nRemap]) / float(SHRT_MAX);
- ++pDataOut;
- }
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[1][nRemap]) / float(SHRT_MAX);
- ++pDataOut;
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[0][nRemap]) / float(SHRT_MAX);
+ ++pDataOut;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[1][nRemap]) / float(SHRT_MAX);
+ ++pDataOut;
+ }
}
}
- }
- break;
+ break;
- case 24 :
- {
- long nSamples = len/(BytesPerDoubleChannelSample);
- int32 Temp[2][8];
- for (int i=0; i<nSamples; i++)
- {
- // Start by upper 16 bits
- for(int j = 0; j < nChannels; j++)
- {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[0][j] = Part1;
- }
- for(int j = 0; j < nChannels; j++)
- {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[1][j] = Part1;
- }
+ case 24 : {
+ long nSamples = len/(BytesPerDoubleChannelSample);
+ int32 Temp[2][8];
+ for (int i=0; i<nSamples; i++) {
+ // Start by upper 16 bits
+ for(int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16 *)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[0][j] = Part1;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16 *)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[1][j] = Part1;
+ }
- // Continue with lower bits
- for(int j = 0; j < nChannels; j++)
- {
- uint32 All = *((uint8 *)pDataIn);
- pDataIn += 1;
- Temp[0][j] = int32(Temp[0][j] | (All << 8)) >> 8;
- }
- for(int j = 0; j < nChannels; j++)
- {
- uint32 All = *((uint8 *)pDataIn);
- pDataIn += 1;
- Temp[1][j] = int32(Temp[1][j] | (All << 8)) >> 8;
- }
+ // Continue with lower bits
+ for(int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint8 *)pDataIn);
+ pDataIn += 1;
+ Temp[0][j] = int32(Temp[0][j] | (All << 8)) >> 8;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint8 *)pDataIn);
+ pDataIn += 1;
+ Temp[1][j] = int32(Temp[1][j] | (All << 8)) >> 8;
+ }
- // Convert into float
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
- ++pDataOut;
- }
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
- ++pDataOut;
+ // Convert into float
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
+ ++pDataOut;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
+ ++pDataOut;
+ }
}
}
- }
- break;
- case 20 :
- {
- long nSamples = len/(BytesPerDoubleChannelSample);
- int32 Temp[2][8];
- for (int i=0; i<nSamples; i++)
- {
- // Start by upper 16 bits
- for(int j = 0; j < nChannels; j++)
- {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[0][j] = Part1;
- }
- for(int j = 0; j < nChannels; j++)
- {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[1][j] = Part1;
- }
+ break;
+ case 20 : {
+ long nSamples = len/(BytesPerDoubleChannelSample);
+ int32 Temp[2][8];
+ for (int i=0; i<nSamples; i++) {
+ // Start by upper 16 bits
+ for(int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16 *)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[0][j] = Part1;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16 *)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[1][j] = Part1;
+ }
- // Continue with lower bits
- for(int j = 0; j < nChannels; j++)
- {
- uint32 All = *((uint8 *)pDataIn);
- pDataIn += 1;
- Temp[0][j] = int32(Temp[0][j] | ((All&0xf0) << 8)) >> 8;
- Temp[1][j] = int32(Temp[1][j] | ((All&0x0f) << 12)) >> 8;
- }
+ // Continue with lower bits
+ for(int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint8 *)pDataIn);
+ pDataIn += 1;
+ Temp[0][j] = int32(Temp[0][j] | ((All&0xf0) << 8)) >> 8;
+ Temp[1][j] = int32(Temp[1][j] | ((All&0x0f) << 12)) >> 8;
+ }
- // Convert into float
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
- ++pDataOut;
- }
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
- ++pDataOut;
+ // Convert into float
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
+ ++pDataOut;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
+ ++pDataOut;
+ }
}
}
- }
- break;
+ break;
}
memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len );
@@ -760,8 +760,7 @@ HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM
int BytesPerSample = wfein->nChannels*BytesPerChannelSample; // Beliyaal: Old calculation only worked if nChannel*bytespersample is power of 2
int oldlen = m_buff.GetCount();
int len = (oldlen / BytesPerSample) * BytesPerSample;
- if (bAlignOldBuffer)
- {
+ if (bAlignOldBuffer) {
m_buff.SetCount(len);
}
scmap_t* remap = &s_scmap_hdmv [wfein->channel_conf];
@@ -771,39 +770,34 @@ HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM
float* pDataOut = pBuff.GetData();
- switch (wfein->wBitsPerSample)
- {
- case 16 :
- for (int i=0; i<len/wfein->nChannels/2; i++)
- {
- for(int j = 0; j < wfein->nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = (float)(short)((pDataIn[nRemap*2]<<8)|pDataIn[nRemap*2+1]) / SHRT_MAX;
- pDataOut++;
+ switch (wfein->wBitsPerSample) {
+ case 16 :
+ for (int i=0; i<len/wfein->nChannels/2; i++) {
+ for(int j = 0; j < wfein->nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = (float)(short)((pDataIn[nRemap*2]<<8)|pDataIn[nRemap*2+1]) / SHRT_MAX;
+ pDataOut++;
+ }
+ pDataIn += wfein->nChannels*2;
}
- pDataIn += wfein->nChannels*2;
- }
- break;
+ break;
- case 24 :
- case 20 :
- long lSample;
+ case 24 :
+ case 20 :
+ long lSample;
- for (int i=0; i<len/wfein->nChannels/3; i++)
- {
- for(int j = 0; j < wfein->nChannels; j++)
- {
- BYTE nRemap = remap->ch[j];
+ for (int i=0; i<len/wfein->nChannels/3; i++) {
+ for(int j = 0; j < wfein->nChannels; j++) {
+ BYTE nRemap = remap->ch[j];
- lSample = (long)pDataIn[nRemap*3]<<24 | (long)pDataIn[nRemap*3+1]<<16 | (long)pDataIn[nRemap*3+2]<<8;
- *pDataOut = (float)(long)lSample / 0x80000000;
+ lSample = (long)pDataIn[nRemap*3]<<24 | (long)pDataIn[nRemap*3+1]<<16 | (long)pDataIn[nRemap*3+2]<<8;
+ *pDataOut = (float)(long)lSample / 0x80000000;
- pDataOut++;
+ pDataOut++;
+ }
+ pDataIn += wfein->nChannels*3;
}
- pDataIn += wfein->nChannels*3;
- }
- break;
+ break;
}
memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len );
@@ -818,34 +812,30 @@ HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoug
{
int flags, sample_rate, bit_rate;
- if((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0)
- {
-// TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
+ if((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
+ // TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
fEnoughData = size <= buffsize;
- if(fEnoughData)
- {
+ if(fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(ac3);
- if(iSpeakerConfig < 0)
- {
+ if(iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001)))
+ if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001))) {
return hr;
- }
- else
- {
+ }
+ } else {
flags = iSpeakerConfig&(A52_CHANNEL_MASK|A52_LFE);
flags |= A52_ADJUST_LEVEL;
sample_t level = 1, gain = 1, bias = 0;
level *= gain;
- if(a52_frame(m_a52_state, p, &flags, &level, bias) == 0)
- {
- if(GetDynamicRangeControl(ac3))
+ if(a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
+ if(GetDynamicRangeControl(ac3)) {
a52_dynrng(m_a52_state, NULL, NULL);
+ }
int scmapidx = min(flags&A52_CHANNEL_MASK, countof(s_scmap_ac3)/2);
scmap_t& scmap = s_scmap_ac3[scmapidx + ((flags&A52_LFE)?(countof(s_scmap_ac3)/2):0)];
@@ -856,25 +846,22 @@ HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoug
int i = 0;
- for(; i < 6 && a52_block(m_a52_state) == 0; i++)
- {
+ for(; i < 6 && a52_block(m_a52_state) == 0; i++) {
sample_t* samples = a52_samples(m_a52_state);
- for(int j = 0; j < 256; j++, samples++)
- {
- for(int ch = 0; ch < scmap.nChannels; ch++)
- {
+ for(int j = 0; j < 256; j++, samples++) {
+ for(int ch = 0; ch < scmap.nChannels; ch++) {
ASSERT(scmap.ch[ch] != -1);
*p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
}
}
}
- if(i == 6)
- {
+ if(i == 6) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
+ }
}
}
}
@@ -892,38 +879,33 @@ HRESULT CMpaDecFilter::ProcessAC3()
BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= 7)
- {
+ while(end - p >= 7) {
int size = 0, flags, sample_rate, bit_rate;
- if((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0)
- {
-// TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
+ if((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
+ // TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
bool fEnoughData = p + size <= end;
- if(fEnoughData)
- {
+ if(fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(ac3);
- if(iSpeakerConfig < 0)
- {
+ if(iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001)))
+ if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001))) {
return hr;
- }
- else
- {
+ }
+ } else {
flags = iSpeakerConfig&(A52_CHANNEL_MASK|A52_LFE);
flags |= A52_ADJUST_LEVEL;
sample_t level = 1, gain = 1, bias = 0;
level *= gain;
- if(a52_frame(m_a52_state, p, &flags, &level, bias) == 0)
- {
- if(GetDynamicRangeControl(ac3))
+ if(a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
+ if(GetDynamicRangeControl(ac3)) {
a52_dynrng(m_a52_state, NULL, NULL);
+ }
int scmapidx = min(flags&A52_CHANNEL_MASK, countof(s_scmap_ac3)/2);
scmap_t& scmap = s_scmap_ac3[scmapidx + ((flags&A52_LFE)?(countof(s_scmap_ac3)/2):0)];
@@ -934,25 +916,22 @@ HRESULT CMpaDecFilter::ProcessAC3()
int i = 0;
- for(; i < 6 && a52_block(m_a52_state) == 0; i++)
- {
+ for(; i < 6 && a52_block(m_a52_state) == 0; i++) {
sample_t* samples = a52_samples(m_a52_state);
- for(int j = 0; j < 256; j++, samples++)
- {
- for(int ch = 0; ch < scmap.nChannels; ch++)
- {
+ for(int j = 0; j < 256; j++, samples++) {
+ for(int ch = 0; ch < scmap.nChannels; ch++) {
ASSERT(scmap.ch[ch] != -1);
*p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
}
}
}
- if(i == 6)
- {
+ if(i == 6) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
+ }
}
}
}
@@ -964,11 +943,10 @@ HRESULT CMpaDecFilter::ProcessAC3()
end = base + (end - p);
p = base;
- if(!fEnoughData)
+ if(!fEnoughData) {
break;
- }
- else
- {
+ }
+ } else {
p++;
}
}
@@ -987,76 +965,70 @@ HRESULT CMpaDecFilter::ProcessAC3()
BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= AC3_HEADER_SIZE)
- {
+ while(end - p >= AC3_HEADER_SIZE) {
int size = 0;
bool fEnoughData = true;
- if (m_DolbyDigitalMode != DD_TRUEHD && m_DolbyDigitalMode != DD_MLP && (*((__int16*)p) == 0x770b)) /* AC3-EAC3 syncword */
- {
+ if (m_DolbyDigitalMode != DD_TRUEHD && m_DolbyDigitalMode != DD_MLP && (*((__int16*)p) == 0x770b)) { /* AC3-EAC3 syncword */
BYTE bsid = p[5] >> 3;
- if ((m_DolbyDigitalMode != DD_EAC3) && bsid <= 12)
- {
+ if ((m_DolbyDigitalMode != DD_EAC3) && bsid <= 12) {
m_DolbyDigitalMode = DD_AC3;
- if (FAILED (hr = ProcessA52 (p, end-p, size, fEnoughData))) return hr;
- }
- else if (bsid <= 16)
- {
+ if (FAILED (hr = ProcessA52 (p, end-p, size, fEnoughData))) {
+ return hr;
+ }
+ } else if (bsid <= 16) {
DeliverFFmpeg(CODEC_ID_EAC3, p, end-p, size);
- if (size > 0)
+ if (size > 0) {
m_DolbyDigitalMode = DD_EAC3;
- }
- else
- {
+ }
+ } else {
p++;
continue;
}
- }
- else if ( (*((__int32*)(p+4)) == 0xba6f72f8) || // True HD major sync frame
- m_DolbyDigitalMode == DD_TRUEHD )
- {
+ } else if ( (*((__int32*)(p+4)) == 0xba6f72f8) || // True HD major sync frame
+ m_DolbyDigitalMode == DD_TRUEHD ) {
int nLenght = (((p[0]<<8) + p[1]) & 0x0FFF)*2;
m_DolbyDigitalMode = DD_TRUEHD;
- if (nLenght >= 4)
- {
+ if (nLenght >= 4) {
DeliverFFmpeg(CODEC_ID_TRUEHD, p, end-p, size);
- if (size<0) size = end-p;
+ if (size<0) {
+ size = end-p;
+ }
}
- }
- else if ( (*((__int32*)(p+4)) == 0xbb6f72f8) ||
- m_DolbyDigitalMode == DD_MLP ) // MLP
- {
+ } else if ( (*((__int32*)(p+4)) == 0xbb6f72f8) ||
+ m_DolbyDigitalMode == DD_MLP ) { // MLP
int nLenght = (((p[0]<<8) + p[1]) & 0x0FFF)*2;
m_DolbyDigitalMode = DD_MLP;
- if (nLenght >= 4)
- {
+ if (nLenght >= 4) {
DeliverFFmpeg(CODEC_ID_MLP, p, end-p, size);
- if (size<0) size = end-p;
+ if (size<0) {
+ size = end-p;
+ }
}
- }
- else
- {
+ } else {
p++;
continue;
}
// Update buffer position
- if (fEnoughData)
- {
+ if (fEnoughData) {
ASSERT (size <= end-p);
- if (size <= 0) break;
+ if (size <= 0) {
+ break;
+ }
p += size;
}
memmove(base, p, end - p);
end = base + (end - p);
p = base;
- if(!fEnoughData)
+ if(!fEnoughData) {
break;
+ }
}
m_buff.SetCount(end - p);
@@ -1077,7 +1049,9 @@ HRESULT CMpaDecFilter::ProcessFFmpeg(int nCodecId)
int size = 0;
hr = DeliverFFmpeg(nCodecId, p, end-p, size);
- if (size <= 0) return S_OK;
+ if (size <= 0) {
+ return S_OK;
+ }
p += size;
memmove(base, p, end - p);
end = base + (end - p);
@@ -1095,38 +1069,33 @@ HRESULT CMpaDecFilter::ProcessDTS()
BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= 14)
- {
+ while(end - p >= 14) {
int size = 0, flags, sample_rate, bit_rate, frame_length;
- if((size = dts_syncinfo(m_dts_state, p, &flags, &sample_rate, &bit_rate, &frame_length)) > 0)
- {
-// TRACE(_T("dts: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d, frame_length=%d\n"), size, flags, sample_rate, bit_rate, frame_length);
+ if((size = dts_syncinfo(m_dts_state, p, &flags, &sample_rate, &bit_rate, &frame_length)) > 0) {
+ // TRACE(_T("dts: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d, frame_length=%d\n"), size, flags, sample_rate, bit_rate, frame_length);
bool fEnoughData = p + size <= end;
- if(fEnoughData)
- {
+ if(fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(dts);
- if(iSpeakerConfig < 0)
- {
+ if(iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = Deliver(p, size, bit_rate, 0x000b)))
+ if(S_OK != (hr = Deliver(p, size, bit_rate, 0x000b))) {
return hr;
- }
- else
- {
+ }
+ } else {
flags = iSpeakerConfig&(DTS_CHANNEL_MASK|DTS_LFE);
flags |= DTS_ADJUST_LEVEL;
sample_t level = 1, gain = 1, bias = 0;
level *= gain;
- if(dts_frame(m_dts_state, p, &flags, &level, bias) == 0)
- {
- if(GetDynamicRangeControl(dts))
+ if(dts_frame(m_dts_state, p, &flags, &level, bias) == 0) {
+ if(GetDynamicRangeControl(dts)) {
dts_dynrng(m_dts_state, NULL, NULL);
+ }
int scmapidx = min(flags&DTS_CHANNEL_MASK, countof(s_scmap_dts)/2);
scmap_t& scmap = s_scmap_dts[scmapidx + ((flags&DTS_LFE)?(countof(s_scmap_dts)/2):0)];
@@ -1139,25 +1108,22 @@ HRESULT CMpaDecFilter::ProcessDTS()
int i = 0;
- for(; i < blocks && dts_block(m_dts_state) == 0; i++)
- {
+ for(; i < blocks && dts_block(m_dts_state) == 0; i++) {
sample_t* samples = dts_samples(m_dts_state);
- for(int j = 0; j < 256; j++, samples++)
- {
- for(int ch = 0; ch < scmap.nChannels; ch++)
- {
+ for(int j = 0; j < 256; j++, samples++) {
+ for(int ch = 0; ch < scmap.nChannels; ch++) {
ASSERT(scmap.ch[ch] != -1);
*p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
}
}
}
- if(i == blocks)
- {
+ if(i == blocks) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
+ }
}
}
}
@@ -1169,11 +1135,10 @@ HRESULT CMpaDecFilter::ProcessDTS()
end = base + (end - p);
p = base;
- if(!fEnoughData)
+ if(!fEnoughData) {
break;
- }
- else
- {
+ }
+ } else {
p++;
}
}
@@ -1197,12 +1162,15 @@ HRESULT CMpaDecFilter::ProcessAAC()
float* src = (float*)NeAACDecDecode(m_aac_state.h, &info, m_buff.GetData(), m_buff.GetCount());
m_buff.RemoveAll();
//if(!src) return E_FAIL;
- if(info.error) m_aac_state.init(m_pInput->CurrentMediaType());
- if(!src || info.samples == 0) return S_OK;
+ if(info.error) {
+ m_aac_state.init(m_pInput->CurrentMediaType());
+ }
+ if(!src || info.samples == 0) {
+ return S_OK;
+ }
// HACK: bug in faad2 with mono sources?
- if(info.channels == 2 && info.channel_position[1] == UNKNOWN_CHANNEL)
- {
+ if(info.channels == 2 && info.channel_position[1] == UNKNOWN_CHANNEL) {
info.channel_position[0] = FRONT_CHANNEL_LEFT;
info.channel_position[1] = FRONT_CHANNEL_RIGHT;
}
@@ -1223,8 +1191,7 @@ HRESULT CMpaDecFilter::ProcessAAC()
chmask[LFE_CHANNEL] = SPEAKER_LOW_FREQUENCY;
DWORD dwChannelMask = 0;
- for(int i = 0; i < info.channels; i++)
- {
+ for(int i = 0; i < info.channels; i++) {
if(info.channel_position[i] == UNKNOWN_CHANNEL) {
ASSERT(0);
return E_FAIL;
@@ -1235,14 +1202,11 @@ HRESULT CMpaDecFilter::ProcessAAC()
int chmap[countof(info.channel_position)];
memset(chmap, 0, sizeof(chmap));
- for(int i = 0; i < info.channels; i++)
- {
+ for(int i = 0; i < info.channels; i++) {
unsigned int ch = 0, mask = chmask[info.channel_position[i]];
- for(int j = 0; j < 32; j++)
- {
- if(dwChannelMask & (1 << j))
- {
+ for(int j = 0; j < 32; j++) {
+ if(dwChannelMask & (1 << j)) {
if((1 << j) == mask) {
chmap[i] = ch;
break;
@@ -1252,15 +1216,19 @@ HRESULT CMpaDecFilter::ProcessAAC()
}
}
- if(info.channels <= 2) dwChannelMask = 0;
+ if(info.channels <= 2) {
+ dwChannelMask = 0;
+ }
for(int j = 0; j < info.samples; j += info.channels, dst += info.channels)
- for(int i = 0; i < info.channels; i++)
+ for(int i = 0; i < info.channels; i++) {
dst[chmap[i]] = *src++;
+ }
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, info.samplerate, info.channels, dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, info.samplerate, info.channels, dwChannelMask))) {
return hr;
+ }
return S_OK;
}
@@ -1276,20 +1244,20 @@ HRESULT CMpaDecFilter::ProcessPCMraw() //'raw '
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 8: //unsigned 8-bit
- { BYTE* b = m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(CHAR)(b[i] - 128) / 128;
+ case 8: { //unsigned 8-bit
+ BYTE* b = m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(CHAR)(b[i] - 128) / 128;
+ }
}
- }
- break;
- case 16: //signed big-endian 16 bit
- { USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ break;
+ case 16: { //signed big-endian 16 bit
+ USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1311,39 +1279,39 @@ HRESULT CMpaDecFilter::ProcessPCMintBE() //'twos', big-endian 'in24' and 'in32'
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 8: //signed 8-bit
- { CHAR* b = (CHAR*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)b[i] / 128;
+ case 8: { //signed 8-bit
+ CHAR* b = (CHAR*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)b[i] / 128;
+ }
}
- }
- break;
- case 16: //signed big-endian 16-bit
- { USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ break;
+ case 16: { //signed big-endian 16-bit
+ USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ }
}
- }
- break;
- case 24: //signed big-endian 24-bit
- { BYTE* b = (BYTE*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(signed int)((unsigned int)b[3*i] << 24 |
- (unsigned int)b[3*i+1] << 16 |
- (unsigned int)b[3*i+2] << 8) / 2147483648;
+ break;
+ case 24: { //signed big-endian 24-bit
+ BYTE* b = (BYTE*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(signed int)((unsigned int)b[3*i] << 24 |
+ (unsigned int)b[3*i+1] << 16 |
+ (unsigned int)b[3*i+2] << 8) / 2147483648;
+ }
}
- }
- break;
- case 32: //signed big-endian 32-bit
- { UINT* q = (UINT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(INT)(q[i] >> 24 |
- (q[i] & 0x00ff0000) >> 8 |
- (q[i] & 0x0000ff00) << 8 |
- q[i] << 24) / 2147483648;
+ break;
+ case 32: { //signed big-endian 32-bit
+ UINT* q = (UINT*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(INT)(q[i] >> 24 |
+ (q[i] & 0x00ff0000) >> 8 |
+ (q[i] & 0x0000ff00) << 8 |
+ q[i] << 24) / 2147483648;
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1365,36 +1333,36 @@ HRESULT CMpaDecFilter::ProcessPCMintLE() //'sowt', little-endian 'in24' and 'in3
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 8: //signed 8-bit
- { CHAR* b = (CHAR*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)b[i] / 128;
+ case 8: { //signed 8-bit
+ CHAR* b = (CHAR*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)b[i] / 128;
+ }
}
- }
- break;
- case 16: //signed little-endian 16-bit
- { SHORT* d = (SHORT*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)d[i] / 32768;
+ break;
+ case 16: { //signed little-endian 16-bit
+ SHORT* d = (SHORT*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)d[i] / 32768;
+ }
}
- }
- break;
- case 24: //signed little-endian 32-bit
- { BYTE* b = (BYTE*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(signed int)((unsigned int)b[3*i] << 8 |
- (unsigned int)b[3*i+1] << 16 |
- (unsigned int)b[3*i+2] << 24) / 2147483648;
+ break;
+ case 24: { //signed little-endian 32-bit
+ BYTE* b = (BYTE*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(signed int)((unsigned int)b[3*i] << 8 |
+ (unsigned int)b[3*i+1] << 16 |
+ (unsigned int)b[3*i+2] << 24) / 2147483648;
+ }
}
- }
- break;
- case 32: //signed little-endian 32-bit
- { INT* q = (INT*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)q[i] / 2147483648;
+ break;
+ case 32: { //signed little-endian 32-bit
+ INT* q = (INT*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)q[i] / 2147483648;
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1416,33 +1384,33 @@ HRESULT CMpaDecFilter::ProcessPCMfloatBE() //big-endian 'fl32' and 'fl64'
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 32:
- { unsigned int* q = (unsigned int*)m_buff.GetData();
- unsigned int* vf = (unsigned int*)f;
- for(int i = 0; i < nSamples; i++) {
- vf[i] = q[i] >> 24 |
- (q[i] & 0x00ff0000) >> 8 |
- (q[i] & 0x0000ff00) << 8 |
- q[i] << 24;
- }
- }
- break;
- case 64:
- { unsigned __int64* q = (unsigned __int64*)m_buff.GetData();
- unsigned __int64 x;
- for(int i = 0; i < nSamples; i++) {
- x = q[i] >>56 |
- (q[i] & 0x00FF000000000000) >> 40 |
- (q[i] & 0x0000FF0000000000) >> 24 |
- (q[i] & 0x000000FF00000000) >> 8 |
- (q[i] & 0x00000000FF000000) << 8 |
- (q[i] & 0x0000000000FF0000) << 24 |
- (q[i] & 0x000000000000FF00) << 40 |
- q[i] << 56;
- f[i] = (float)*(double*)&x;
- }
- }
- break;
+ case 32: {
+ unsigned int* q = (unsigned int*)m_buff.GetData();
+ unsigned int* vf = (unsigned int*)f;
+ for(int i = 0; i < nSamples; i++) {
+ vf[i] = q[i] >> 24 |
+ (q[i] & 0x00ff0000) >> 8 |
+ (q[i] & 0x0000ff00) << 8 |
+ q[i] << 24;
+ }
+ }
+ break;
+ case 64: {
+ unsigned __int64* q = (unsigned __int64*)m_buff.GetData();
+ unsigned __int64 x;
+ for(int i = 0; i < nSamples; i++) {
+ x = q[i] >>56 |
+ (q[i] & 0x00FF000000000000) >> 40 |
+ (q[i] & 0x0000FF0000000000) >> 24 |
+ (q[i] & 0x000000FF00000000) >> 8 |
+ (q[i] & 0x00000000FF000000) << 8 |
+ (q[i] & 0x0000000000FF0000) << 24 |
+ (q[i] & 0x000000000000FF00) << 40 |
+ q[i] << 56;
+ f[i] = (float)*(double*)&x;
+ }
+ }
+ break;
}
HRESULT hr;
@@ -1464,20 +1432,20 @@ HRESULT CMpaDecFilter::ProcessPCMfloatLE() //little-endian 'fl32' and 'fl64'
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 32:
- { float* q = (float*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = q[i];
+ case 32: {
+ float* q = (float*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = q[i];
+ }
}
- }
- break;
- case 64:
- { double* q = (double*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)q[i];
+ break;
+ case 64: {
+ double* q = (double*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)q[i];
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1504,38 +1472,32 @@ HRESULT CMpaDecFilter::ProcessPS2PCM()
pBuff.SetCount(samples*channels);
float* f = pBuff.GetData();
- while(end - p >= size)
- {
+ while(end - p >= size) {
DWORD* dw = (DWORD*)p;
- if(dw[0] == 'dhSS')
- {
+ if(dw[0] == 'dhSS') {
p += dw[1] + 8;
- }
- else if(dw[0] == 'dbSS')
- {
+ } else if(dw[0] == 'dbSS') {
p += 8;
m_ps2_state.sync = true;
- }
- else
- {
- if(m_ps2_state.sync)
- {
+ } else {
+ if(m_ps2_state.sync) {
short* s = (short*)p;
for(int i = 0; i < samples; i++)
- for(int j = 0; j < channels; j++)
+ for(int j = 0; j < channels; j++) {
f[i*channels+j] = (float)s[j*samples+i] / 32768;
- }
- else
- {
- for(int i = 0, j = samples*channels; i < j; i++)
+ }
+ } else {
+ for(int i = 0, j = samples*channels; i < j; i++) {
f[i] = 0;
+ }
}
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels)))
+ if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
+ }
p += size;
@@ -1563,8 +1525,7 @@ static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, double* pout)
}
// if(unk == 7) {ASSERT(0); return;} // ???
- static double s_tbl[] =
- {
+ static double s_tbl[] = {
0.0, 0.0, 0.9375, 0.0, 1.796875, -0.8125, 1.53125, -0.859375, 1.90625, -0.9375,
0.0, 0.0, -0.9375, 0.0, -1.796875, 0.8125, -1.53125, 0.859375 -1.90625, 0.9375
};
@@ -1573,8 +1534,7 @@ static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, double* pout)
double& a = s.a[channel];
double& b = s.b[channel];
- for(int i = 0; i < 28; i++)
- {
+ for(int i = 0; i < 28; i++) {
short input = (short)(((pin[2+i/2] >> ((i&1) << 2)) & 0xf) << 12) >> shift;
double output = a * tbl[1] + b * tbl[0] + input;
@@ -1600,44 +1560,39 @@ HRESULT CMpaDecFilter::ProcessPS2ADPCM()
pBuff.SetCount(samples*channels);
float* f = pBuff.GetData();
- while(end - p >= size)
- {
+ while(end - p >= size) {
DWORD* dw = (DWORD*)p;
- if(dw[0] == 'dhSS')
- {
+ if(dw[0] == 'dhSS') {
p += dw[1] + 8;
- }
- else if(dw[0] == 'dbSS')
- {
+ } else if(dw[0] == 'dbSS') {
p += 8;
m_ps2_state.sync = true;
- }
- else
- {
- if(m_ps2_state.sync)
- {
+ } else {
+ if(m_ps2_state.sync) {
double* tmp = DNew double[samples*channels];
for(int channel = 0, j = 0, k = 0; channel < channels; channel++, j += wfe->dwInterleave)
- for(int i = 0; i < wfe->dwInterleave; i += 16, k += 28)
+ for(int i = 0; i < wfe->dwInterleave; i += 16, k += 28) {
decodeps2adpcm(m_ps2_state, channel, p + i + j, tmp + k);
+ }
for(int i = 0, k = 0; i < samples; i++)
- for(int j = 0; j < channels; j++, k++)
+ for(int j = 0; j < channels; j++, k++) {
f[k] = (float)tmp[j*samples+i];
+ }
delete [] tmp;
- }
- else
- {
- for(int i = 0, j = samples*channels; i < j; i++)
+ } else {
+ for(int i = 0, j = samples*channels; i < j; i++) {
f[i] = 0;
+ }
}
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels)))
+ if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
+ }
p += size;
}
@@ -1655,11 +1610,13 @@ HRESULT CMpaDecFilter::ProcessPS2ADPCM()
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
HRESULT CMpaDecFilter::ProcessVorbis()
{
- if(m_vorbis.vi.channels < 1 || m_vorbis.vi.channels > 6)
+ if(m_vorbis.vi.channels < 1 || m_vorbis.vi.channels > 6) {
return E_FAIL;
+ }
- if(m_buff.IsEmpty())
+ if(m_buff.IsEmpty()) {
return S_OK;
+ }
HRESULT hr = S_OK;
@@ -1670,31 +1627,30 @@ HRESULT CMpaDecFilter::ProcessVorbis()
op.b_o_s = 0;
op.packetno = m_vorbis.packetno++;
- if(vorbis_synthesis(&m_vorbis.vb, &op) == 0)
- {
+ if(vorbis_synthesis(&m_vorbis.vb, &op) == 0) {
vorbis_synthesis_blockin(&m_vorbis.vd, &m_vorbis.vb);
int samples;
float** pcm;
- while((samples = vorbis_synthesis_pcmout(&m_vorbis.vd, &pcm)) > 0)
- {
+ while((samples = vorbis_synthesis_pcmout(&m_vorbis.vd, &pcm)) > 0) {
const scmap_t& scmap = s_scmap_vorbis[m_vorbis.vi.channels-1];
CAtlArray<float> pBuff;
pBuff.SetCount(samples * scmap.nChannels);
float* dst = pBuff.GetData();
- for(int j = 0, ch = scmap.nChannels; j < ch; j++)
- {
+ for(int j = 0, ch = scmap.nChannels; j < ch; j++) {
float* src = pcm[scmap.ch[j]];
- for(int i = 0; i < samples; i++)
+ for(int i = 0; i < samples; i++) {
dst[j + i*ch] = src[i];
+ }
// dst[j + i*ch] = (float)max(min(src[i], 1<<24), -1<<24) / (1<<24);
}
- if(S_OK != (hr = Deliver(pBuff, m_vorbis.vi.rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, m_vorbis.vi.rate, scmap.nChannels, scmap.dwChannelMask))) {
break;
+ }
vorbis_synthesis_read(&m_vorbis.vd, samples);
}
@@ -1708,8 +1664,11 @@ HRESULT CMpaDecFilter::ProcessVorbis()
static inline float fscale(mad_fixed_t sample)
{
- if(sample >= MAD_F_ONE) sample = MAD_F_ONE - 1;
- else if(sample < -MAD_F_ONE) sample = -MAD_F_ONE;
+ if(sample >= MAD_F_ONE) {
+ sample = MAD_F_ONE - 1;
+ } else if(sample < -MAD_F_ONE) {
+ sample = -MAD_F_ONE;
+ }
return (float)sample / (1 << MAD_F_FRACBITS);
}
@@ -1730,12 +1689,9 @@ HRESULT CMpaDecFilter::ProcessMPA()
{
mad_stream_buffer(&m_stream, m_buff.GetData(), m_buff.GetCount());
- while(1)
- {
- if(mad_frame_decode(&m_frame, &m_stream) == -1)
- {
- if(m_stream.error == MAD_ERROR_BUFLEN)
- {
+ while(1) {
+ if(mad_frame_decode(&m_frame, &m_stream) == -1) {
+ if(m_stream.error == MAD_ERROR_BUFLEN) {
memmove(m_buff.GetData(), m_stream.this_frame, m_stream.bufend - m_stream.this_frame);
m_buff.SetCount(m_stream.bufend - m_stream.this_frame);
break;
@@ -1747,8 +1703,7 @@ HRESULT CMpaDecFilter::ProcessMPA()
}
- if(!MAD_RECOVERABLE(m_stream.error))
- {
+ if(!MAD_RECOVERABLE(m_stream.error)) {
TRACE(_T("*m_stream.error == %d\n"), m_stream.error);
return E_FAIL;
}
@@ -1772,8 +1727,7 @@ HRESULT CMpaDecFilter::ProcessMPA()
mad_synth_frame(&m_synth, &m_frame);
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- if(wfein->nChannels != m_synth.pcm.channels || wfein->nSamplesPerSec != m_synth.pcm.samplerate)
- {
+ if(wfein->nChannels != m_synth.pcm.channels || wfein->nSamplesPerSec != m_synth.pcm.samplerate) {
TRACE(_T("MAD channels %d %d samplerate %d %d \n"),wfein->nChannels , m_synth.pcm.channels, wfein->nSamplesPerSec , m_synth.pcm.samplerate);
//Some time this does happened - need more testing ...
//continue;
@@ -1786,15 +1740,17 @@ HRESULT CMpaDecFilter::ProcessMPA()
pBuff.SetCount(m_synth.pcm.length*m_synth.pcm.channels);
float* pDataOut = pBuff.GetData();
- for(unsigned short i = 0; i < m_synth.pcm.length; i++)
- {
+ for(unsigned short i = 0; i < m_synth.pcm.length; i++) {
*pDataOut++ = fscale(*left_ch++);
- if(m_synth.pcm.channels == 2) *pDataOut++ = fscale(*right_ch++);
+ if(m_synth.pcm.channels == 2) {
+ *pDataOut++ = fscale(*right_ch++);
+ }
}
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, m_synth.pcm.samplerate, m_synth.pcm.channels)))
+ if(S_OK != (hr = Deliver(pBuff, m_synth.pcm.samplerate, m_synth.pcm.channels))) {
return hr;
+ }
}
return S_OK;
@@ -1807,12 +1763,12 @@ HRESULT CMpaDecFilter::GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData)
*pData = NULL;
if(FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, NULL, NULL, 0))
- || FAILED(hr = (*pSample)->GetPointer(pData)))
+ || FAILED(hr = (*pSample)->GetPointer(pData))) {
return hr;
+ }
AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -1833,23 +1789,25 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO
int nSamples = pBuff.GetCount()/wfe->nChannels;
- if(FAILED(hr = ReconnectOutput(nSamples, mt)))
+ if(FAILED(hr = ReconnectOutput(nSamples, mt))) {
return hr;
+ }
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut)))
+ if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
return E_FAIL;
+ }
REFERENCE_TIME rtDur = 10000000i64*nSamples/wfe->nSamplesPerSec;
REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
m_rtStart += rtDur;
-//TRACE(_T("CMpaDecFilter: %I64d - %I64d\n"), rtStart/10000, rtStop/10000);
- if(rtStart < 0 /*200000*/ /* < 0, FIXME: 0 makes strange noises */)
+ //TRACE(_T("CMpaDecFilter: %I64d - %I64d\n"), rtStart/10000, rtStop/10000);
+ if(rtStart < 0 /*200000*/ /* < 0, FIXME: 0 makes strange noises */) {
return S_OK;
+ }
- if(hr == S_OK)
- {
+ if(hr == S_OK) {
m_pOutput->SetMediaType(&mt);
pOut->SetMediaType(&mt);
}
@@ -1872,13 +1830,15 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO
// TODO: move this into the audio switcher
float sample_mul = 1;
- if(m_fNormalize)
- {
- for(int i = 0, len = pBuff.GetCount(); i < len; i++)
- {
+ if(m_fNormalize) {
+ for(int i = 0, len = pBuff.GetCount(); i < len; i++) {
float f = *pDataIn++;
- if(f < 0) f = -f;
- if(m_sample_max < f) m_sample_max = f;
+ if(f < 0) {
+ f = -f;
+ }
+ if(m_sample_max < f) {
+ m_sample_max = f;
+ }
}
sample_mul = 1.0f / m_sample_max;
pDataIn = pBuff.GetData();
@@ -1887,45 +1847,48 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO
bool fBoost = m_boost > 1;
double boost = 1+log10(m_boost);
- for(int i = 0, len = pBuff.GetCount(); i < len; i++)
- {
+ for(int i = 0, len = pBuff.GetCount(); i < len; i++) {
float f = *pDataIn++;
// TODO: move this into the audio switcher
- if(m_fNormalize)
+ if(m_fNormalize) {
f *= sample_mul;
+ }
- if(fBoost)
+ if(fBoost) {
f *= boost;
+ }
- if(f < -1) f = -1;
- else if(f > 1) f = 1;
+ if(f < -1) {
+ f = -1;
+ } else if(f > 1) {
+ f = 1;
+ }
#define round(x) ((x) > 0 ? (x) + 0.5 : (x) - 0.5)
- switch(sf)
- {
- default:
- case SF_PCM16:
- *(short*)pDataOut = (short)round(f * SHRT_MAX);
- pDataOut += sizeof(short);
- break;
- case SF_PCM24:
- { DWORD i24 = (DWORD)(int)round(f * ((1<<23)-1));
- *pDataOut++ = (BYTE)(i24);
- *pDataOut++ = (BYTE)(i24>>8);
- *pDataOut++ = (BYTE)(i24>>16);
- }
- break;
- case SF_PCM32:
- *(int*)pDataOut = (int)round(f * INT_MAX);
- pDataOut += sizeof(int);
- break;
- case SF_FLOAT32:
- *(float*)pDataOut = f;
- pDataOut += sizeof(float);
+ switch(sf) {
+ default:
+ case SF_PCM16:
+ *(short*)pDataOut = (short)round(f * SHRT_MAX);
+ pDataOut += sizeof(short);
+ break;
+ case SF_PCM24: {
+ DWORD i24 = (DWORD)(int)round(f * ((1<<23)-1));
+ *pDataOut++ = (BYTE)(i24);
+ *pDataOut++ = (BYTE)(i24>>8);
+ *pDataOut++ = (BYTE)(i24>>16);
+ }
break;
+ case SF_PCM32:
+ *(int*)pDataOut = (int)round(f * INT_MAX);
+ pDataOut += sizeof(int);
+ break;
+ case SF_FLOAT32:
+ *(float*)pDataOut = f;
+ pDataOut += sizeof(float);
+ break;
}
}
@@ -1941,19 +1904,26 @@ HRESULT CMpaDecFilter::Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type)
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
int length = 0;
- while(length < size+sizeof(WORD)*4) length += 0x800;
+ while(length < size+sizeof(WORD)*4) {
+ length += 0x800;
+ }
int size2 = 1i64 * wfe->nBlockAlign * wfe->nSamplesPerSec * size*8 / bit_rate;
- while(length < size2) length += 0x800;
- if(length > size2)
+ while(length < size2) {
+ length += 0x800;
+ }
+ if(length > size2) {
padded = true;
+ }
- if(FAILED(hr = ReconnectOutput(length / wfe->nBlockAlign, mt)))
+ if(FAILED(hr = ReconnectOutput(length / wfe->nBlockAlign, mt))) {
return hr;
+ }
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut)))
+ if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
return E_FAIL;
+ }
WORD* pDataOutW = (WORD*)pDataOut;
pDataOutW[0] = 0xf872;
@@ -1962,14 +1932,11 @@ HRESULT CMpaDecFilter::Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type)
REFERENCE_TIME rtDur;
- if(!padded)
- {
+ if(!padded) {
rtDur = 10000000i64 * size*8 / bit_rate;
pDataOutW[3] = size*8;
_swab((char*)pBuff, (char*)&pDataOutW[4], size);
- }
- else
- {
+ } else {
const size_t blocks = (size + length - 1) / length;
rtDur = 10000000i64 * blocks * length*8 / bit_rate;
pDataOutW[3] = length*8;
@@ -1978,11 +1945,11 @@ HRESULT CMpaDecFilter::Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type)
REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
m_rtStart += rtDur;
- if(rtStart < 0)
+ if(rtStart < 0) {
return S_OK;
+ }
- if(hr == S_OK)
- {
+ if(hr == S_OK) {
m_pOutput->SetMediaType(&mt);
pOut->SetMediaType(&mt);
}
@@ -2005,35 +1972,37 @@ HRESULT CMpaDecFilter::ReconnectOutput(int nSamples, CMediaType& mt)
HRESULT hr;
CComQIPtr<IMemInputPin> pPin = m_pOutput->GetConnected();
- if(!pPin) return E_NOINTERFACE;
+ if(!pPin) {
+ return E_NOINTERFACE;
+ }
CComPtr<IMemAllocator> pAllocator;
- if(FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator)
+ if(FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator) {
return hr;
+ }
ALLOCATOR_PROPERTIES props, actual;
- if(FAILED(hr = pAllocator->GetProperties(&props)))
+ if(FAILED(hr = pAllocator->GetProperties(&props))) {
return hr;
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
long cbBuffer = nSamples * wfe->nBlockAlign;
- if(mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer)
- {
- if(cbBuffer > props.cbBuffer)
- {
+ if(mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer) {
+ if(cbBuffer > props.cbBuffer) {
props.cBuffers = 4;
props.cbBuffer = cbBuffer*3/2;
if(FAILED(hr = m_pOutput->DeliverBeginFlush())
- || FAILED(hr = m_pOutput->DeliverEndFlush())
- || FAILED(hr = pAllocator->Decommit())
- || FAILED(hr = pAllocator->SetProperties(&props, &actual))
- || FAILED(hr = pAllocator->Commit()))
+ || FAILED(hr = m_pOutput->DeliverEndFlush())
+ || FAILED(hr = pAllocator->Decommit())
+ || FAILED(hr = pAllocator->SetProperties(&props, &actual))
+ || FAILED(hr = pAllocator->Commit())) {
return hr;
+ }
- if(props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer)
- {
+ if(props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer) {
NotifyEvent(EC_ERRORABORT, hr, 0);
return E_FAIL;
}
@@ -2059,30 +2028,29 @@ CMediaType CMpaDecFilter::CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerS
wfe->wFormatTag = (WORD)mt.subtype.Data1;
wfe->nChannels = nChannels;
wfe->nSamplesPerSec = nSamplesPerSec;
- switch(sf)
- {
- default:
- case SF_PCM16:
- wfe->wBitsPerSample = 16;
- break;
- case SF_PCM24:
- wfe->wBitsPerSample = 24;
- break;
- case SF_PCM32:
- case SF_FLOAT32:
- wfe->wBitsPerSample = 32;
- break;
+ switch(sf) {
+ default:
+ case SF_PCM16:
+ wfe->wBitsPerSample = 16;
+ break;
+ case SF_PCM24:
+ wfe->wBitsPerSample = 24;
+ break;
+ case SF_PCM32:
+ case SF_FLOAT32:
+ wfe->wBitsPerSample = 32;
+ break;
}
wfe->nBlockAlign = wfe->nChannels*wfe->wBitsPerSample/8;
wfe->nAvgBytesPerSec = wfe->nSamplesPerSec*wfe->nBlockAlign;
mt.SetSampleSize (wfe->wBitsPerSample*wfe->nChannels/8);
// FIXME: 24/32 bit only seems to work with WAVE_FORMAT_EXTENSIBLE
- if(dwChannelMask == 0 && (sf == SF_PCM24 || sf == SF_PCM32))
+ if(dwChannelMask == 0 && (sf == SF_PCM24 || sf == SF_PCM32)) {
dwChannelMask = nChannels == 2 ? (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;
+ }
- if(dwChannelMask)
- {
+ if(dwChannelMask) {
wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);
wfex.dwChannelMask = dwChannelMask;
@@ -2105,14 +2073,12 @@ CMediaType CMpaDecFilter::CreateMediaTypeSPDIF()
HRESULT CMpaDecFilter::CheckInputType(const CMediaType* mtIn)
{
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_LPCM
- if(mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)
- {
+ if(mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
- if(wfe->nChannels < 1 || wfe->nChannels > 8 || (wfe->wBitsPerSample != 16 && wfe->wBitsPerSample != 20 && wfe->wBitsPerSample != 24))
+ if(wfe->nChannels < 1 || wfe->nChannels > 8 || (wfe->wBitsPerSample != 16 && wfe->wBitsPerSample != 20 && wfe->wBitsPerSample != 24)) {
return VFW_E_TYPE_NOT_ACCEPTED;
- }
- else if(mtIn->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)
- {
+ }
+ } else if(mtIn->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
UNUSED_ALWAYS(wfe);
return S_OK;
@@ -2121,46 +2087,45 @@ HRESULT CMpaDecFilter::CheckInputType(const CMediaType* mtIn)
if(0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PS2AUD
- else if(mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM) {
WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)mtIn->Format();
UNUSED_ALWAYS(wfe);
- if(wfe->dwInterleave & 0xf) // has to be a multiple of the block size (16 bytes)
+ if(wfe->dwInterleave & 0xf) { // has to be a multiple of the block size (16 bytes)
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
- else if(mtIn->subtype == MEDIASUBTYPE_Vorbis2)
- {
- if(!m_vorbis.init(*mtIn))
+ else if(mtIn->subtype == MEDIASUBTYPE_Vorbis2) {
+ if(!m_vorbis.init(*mtIn)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- else if(mtIn->subtype == MEDIASUBTYPE_FLAC_FRAMED)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_FLAC_FRAMED) {
return S_OK;
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_NELLYMOSER
- else if(mtIn->subtype == MEDIASUBTYPE_NELLYMOSER)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_NELLYMOSER) {
return S_OK;
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AAC
- else if(mtIn->subtype == MEDIASUBTYPE_AAC)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_AAC) {
// Reject invalid AAC stream on connection
- if (!m_aac_state.init(*mtIn)) return VFW_E_TYPE_NOT_ACCEPTED;
+ if (!m_aac_state.init(*mtIn)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
#endif
- for(int i = 0; i < countof(sudPinTypesIn); i++)
- {
+ for(int i = 0; i < countof(sudPinTypesIn); i++) {
if(*sudPinTypesIn[i].clsMajorType == mtIn->majortype
- && *sudPinTypesIn[i].clsMinorType == mtIn->subtype)
+ && *sudPinTypesIn[i].clsMinorType == mtIn->subtype) {
return S_OK;
+ }
}
return VFW_E_TYPE_NOT_ACCEPTED;
@@ -2177,7 +2142,9 @@ HRESULT CMpaDecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType*
HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
CMediaType& mt = m_pInput->CurrentMediaType();
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
@@ -2191,8 +2158,9 @@ HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
@@ -2201,36 +2169,41 @@ HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO
HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- 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;
+ }
CMediaType mt = m_pInput->CurrentMediaType();
const GUID& subtype = mt.subtype;
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- if (wfe == NULL) return E_INVALIDARG;
+ if (wfe == NULL) {
+ return E_INVALIDARG;
+ }
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AC3 | INTERNAL_DECODER_DTS
if(GetSpeakerConfig(ac3) < 0 && (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
subtype == MEDIASUBTYPE_DOLBY_TRUEHD)
- || GetSpeakerConfig(dts) < 0 && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS))
- {
+ || GetSpeakerConfig(dts) < 0 && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)) {
*pmt = CreateMediaTypeSPDIF();
}
#else
if(0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
- else if(subtype == MEDIASUBTYPE_Vorbis2)
- {
+ else if(subtype == MEDIASUBTYPE_Vorbis2) {
*pmt = CreateMediaType(GetSampleFormat(), m_vorbis.vi.rate, m_vorbis.vi.channels);
}
#endif
- else
- {
+ else {
*pmt = CreateMediaType(GetSampleFormat(), wfe->nSamplesPerSec, min(2, wfe->nChannels));
}
@@ -2240,7 +2213,9 @@ HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
HRESULT CMpaDecFilter::StartStreaming()
{
HRESULT hr = __super::StartStreaming();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AC3
m_a52_state = a52_init(0);
@@ -2316,7 +2291,9 @@ STDMETHODIMP_(MPCSampleFormat) CMpaDecFilter::GetSampleFormat()
STDMETHODIMP CMpaDecFilter::SetNormalize(bool fNormalize)
{
CAutoLock cAutoLock(&m_csProps);
- if(m_fNormalize != fNormalize) m_sample_max = 0.1f;
+ if(m_fNormalize != fNormalize) {
+ m_sample_max = 0.1f;
+ }
m_fNormalize = fNormalize;
return S_OK;
}
@@ -2330,29 +2307,38 @@ STDMETHODIMP_(bool) CMpaDecFilter::GetNormalize()
STDMETHODIMP CMpaDecFilter::SetSpeakerConfig(enctype et, int sc)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) m_iSpeakerConfig[et] = sc;
+ if(et >= 0 && et < etlast) {
+ m_iSpeakerConfig[et] = sc;
+ }
return S_OK;
}
STDMETHODIMP_(int) CMpaDecFilter::GetSpeakerConfig(enctype et)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) return m_iSpeakerConfig[et];
+ if(et >= 0 && et < etlast) {
+ return m_iSpeakerConfig[et];
+ }
return -1;
}
STDMETHODIMP CMpaDecFilter::SetDynamicRangeControl(enctype et, bool fDRC)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) m_fDynamicRangeControl[et] = fDRC;
- else return E_INVALIDARG;
+ if(et >= 0 && et < etlast) {
+ m_fDynamicRangeControl[et] = fDRC;
+ } else {
+ return E_INVALIDARG;
+ }
return S_OK;
}
STDMETHODIMP_(bool) CMpaDecFilter::GetDynamicRangeControl(enctype et)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) return m_fDynamicRangeControl[et];
+ if(et >= 0 && et < etlast) {
+ return m_fDynamicRangeControl[et];
+ }
return false;
}
@@ -2379,8 +2365,7 @@ STDMETHODIMP CMpaDecFilter::SaveSettings()
{
CAutoLock cAutoLock(&m_csProps);
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder")))
- {
+ if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"))) {
key.SetDWORDValue(_T("SampleFormat"), m_iSampleFormat);
key.SetDWORDValue(_T("Normalize"), m_fNormalize);
key.SetDWORDValue(_T("Boost"), *(DWORD*)&m_boost);
@@ -2411,12 +2396,13 @@ STDMETHODIMP CMpaDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
HRESULT hr;
- if(guid == __uuidof(CMpaDecSettingsWnd))
- {
+ if(guid == __uuidof(CMpaDecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpaDecSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -2437,10 +2423,12 @@ CMpaDecInputPin::CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR
// aac_state_t
//
-aac_state_t::aac_state_t() : h(NULL), freq(0), channels(0) {
+aac_state_t::aac_state_t() : h(NULL), freq(0), channels(0)
+{
open();
}
-aac_state_t::~aac_state_t() {
+aac_state_t::~aac_state_t()
+{
close();
}
@@ -2448,7 +2436,9 @@ bool aac_state_t::open()
{
close();
h = NeAACDecOpen();
- if(!h) return false;
+ if(!h) {
+ return false;
+ }
NeAACDecConfigurationPtr c = NeAACDecGetCurrentConfiguration(h);
c->outputFormat = FAAD_FMT_FLOAT;
NeAACDecSetConfiguration(h, c);
@@ -2457,16 +2447,19 @@ bool aac_state_t::open()
void aac_state_t::close()
{
- if(h) NeAACDecClose(h);
+ if(h) {
+ NeAACDecClose(h);
+ }
h = NULL;
}
bool aac_state_t::init(const CMediaType& mt)
{
if(mt.subtype != MEDIASUBTYPE_AAC
- && mt.subtype != MEDIASUBTYPE_MP4A
- && mt.subtype != MEDIASUBTYPE_mp4a)
- return true; // nothing to do
+ && mt.subtype != MEDIASUBTYPE_MP4A
+ && mt.subtype != MEDIASUBTYPE_mp4a) {
+ return true; // nothing to do
+ }
open();
const WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
@@ -2502,8 +2495,9 @@ void vorbis_state_t::clear()
bool vorbis_state_t::init(const CMediaType& mt)
{
- if(mt.subtype != MEDIASUBTYPE_Vorbis2)
- return true; // nothing to do
+ if(mt.subtype != MEDIASUBTYPE_Vorbis2) {
+ return true; // nothing to do
+ }
clear();
@@ -2521,8 +2515,9 @@ bool vorbis_state_t::init(const CMediaType& mt)
op.b_o_s = 1;
op.packetno = packetno++;
- if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
+ if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0) {
return false;
+ }
memset(&op, 0, sizeof(op));
op.packet = (fmt += vf->HeaderSize[0]);
@@ -2530,8 +2525,9 @@ bool vorbis_state_t::init(const CMediaType& mt)
op.b_o_s = 0;
op.packetno = packetno++;
- if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
+ if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0) {
return false;
+ }
memset(&op, 0, sizeof(op));
op.packet = (fmt += vf->HeaderSize[1]);
@@ -2539,19 +2535,23 @@ bool vorbis_state_t::init(const CMediaType& mt)
op.b_o_s = 0;
op.packetno = packetno++;
- if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
+ if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0) {
return false;
+ }
postgain = 1.0;
- if(vorbis_comment_query_count(&vc, "LWING_GAIN"))
+ if(vorbis_comment_query_count(&vc, "LWING_GAIN")) {
postgain = atof(vorbis_comment_query(&vc, "LWING_GAIN", 0));
+ }
- if(vorbis_comment_query_count(&vc, "POSTGAIN"))
+ if(vorbis_comment_query_count(&vc, "POSTGAIN")) {
postgain = atof(vorbis_comment_query(&vc, "POSTGAIN", 0));
+ }
- if(vorbis_comment_query_count(&vc, "REPLAYGAIN_TRACK_GAIN"))
+ if(vorbis_comment_query_count(&vc, "REPLAYGAIN_TRACK_GAIN")) {
postgain = pow(10.0, atof(vorbis_comment_query(&vc, "REPLAYGAIN_TRACK_GAIN", 0)) / 20.0);
+ }
vorbis_synthesis_init(&vd, &vi);
vorbis_block_init(&vd, &vb);
@@ -2568,8 +2568,7 @@ void CMpaDecFilter::FlacFillBuffer(BYTE buffer[], size_t *bytes)
{
UINT nSize = min (*bytes, m_buff.GetCount());
- if (nSize > 0)
- {
+ if (nSize > 0) {
memcpy_s (buffer, *bytes, m_buff.GetData(), nSize);
memmove(m_buff.GetData(), m_buff.GetData() + nSize, m_buff.GetCount() - nSize);
m_buff.SetCount(m_buff.GetCount() - nSize);
@@ -2588,31 +2587,26 @@ void CMpaDecFilter::FlacDeliverBuffer (unsigned blocksize, const __int32 * cons
scmap_t& scmap = m_scmap_default[wfein->nChannels-1];
- switch (wfein->wBitsPerSample)
- {
- case 16 :
- for(unsigned i = 0; i < blocksize; i++)
- {
- for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++)
- {
- FLAC__int16 nVal = (FLAC__int16)buffer[nChannel][i];
- *pDataOut = (float)nVal / SHRT_MAX;
- pDataOut++;
+ switch (wfein->wBitsPerSample) {
+ case 16 :
+ for(unsigned i = 0; i < blocksize; i++) {
+ for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
+ FLAC__int16 nVal = (FLAC__int16)buffer[nChannel][i];
+ *pDataOut = (float)nVal / SHRT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
- case 20 :
- case 24 :
- for(unsigned i = 0; i < blocksize; i++)
- {
- for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++)
- {
- FLAC__int32 nVal = (FLAC__int32)buffer[nChannel][i];
- *pDataOut = (float)nVal / INT24_MAX;
- pDataOut++;
+ break;
+ case 20 :
+ case 24 :
+ for(unsigned i = 0; i < blocksize; i++) {
+ for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
+ FLAC__int32 nVal = (FLAC__int32)buffer[nChannel][i];
+ *pDataOut = (float)nVal / INT24_MAX;
+ pDataOut++;
+ }
}
- }
- break;
+ break;
}
m_flac.hr = Deliver(pBuff, wfein->nSamplesPerSec, wfein->nChannels, scmap.dwChannelMask);
@@ -2648,11 +2642,9 @@ static void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, const FLAC
void CMpaDecFilter::FlacInitDecoder()
{
- if (!m_flac.pDecoder)
- {
+ if (!m_flac.pDecoder) {
m_flac.pDecoder = FLAC__stream_decoder_new();
- if (m_flac.pDecoder)
- {
+ if (m_flac.pDecoder) {
FLAC__stream_decoder_init_stream ((FLAC__StreamDecoder*)m_flac.pDecoder,
StreamDecoderRead,
NULL,
@@ -2664,9 +2656,7 @@ void CMpaDecFilter::FlacInitDecoder()
StreamDecoderError,
this);
}
- }
- else
- {
+ } else {
FLAC__stream_decoder_reset ((FLAC__StreamDecoder*)m_flac.pDecoder);
}
}
@@ -2674,8 +2664,7 @@ void CMpaDecFilter::FlacInitDecoder()
void CMpaDecFilter::flac_stream_finish()
{
- if (m_flac.pDecoder)
- {
+ if (m_flac.pDecoder) {
FLAC__stream_decoder_delete ((FLAC__StreamDecoder*)m_flac.pDecoder);
m_flac.pDecoder = NULL;
}
@@ -2697,93 +2686,86 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
size = 0;
if (!m_pAVCtx || nCodecId != m_pAVCtx->codec_id)
- if (!InitFFmpeg (nCodecId)) return E_FAIL;
+ if (!InitFFmpeg (nCodecId)) {
+ return E_FAIL;
+ }
- while (buffsize > 0)
- {
+ while (buffsize > 0) {
BYTE* pParserData;
int nParserLength = AVCODEC_MAX_AUDIO_FRAME_SIZE;
int nPCMLength = AVCODEC_MAX_AUDIO_FRAME_SIZE;
int nRet;
- if (m_pAVCtx->codec_id != CODEC_ID_MLP)
- {
+ if (m_pAVCtx->codec_id != CODEC_ID_MLP) {
// Parse buffer
nRet = av_parser_parse( m_pParser, m_pAVCtx, (uint8_t**)&pParserData, &nParserLength,
(const uint8_t*)p, buffsize, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
- if (nRet<0 || (nRet==0 && nParserLength==0))
+ if (nRet<0 || (nRet==0 && nParserLength==0)) {
return S_OK;
+ }
buffsize -= nRet;
p += nRet;
size += nRet;
// Decode frame
- if (nParserLength > 0)
- {
+ if (nParserLength > 0) {
nRet = avcodec_decode_audio2(m_pAVCtx, (int16_t*)m_pPCMData, &nPCMLength, (const uint8_t*)pParserData, nParserLength);
- if (nRet<0 || (nRet==0 &&nPCMLength==0))
+ if (nRet<0 || (nRet==0 &&nPCMLength==0)) {
continue;
- }
- else
+ }
+ } else {
continue;
- }
- else
- {
+ }
+ } else {
// No parsing for MLP : decode only
nRet = avcodec_decode_audio2(m_pAVCtx, (int16_t*)m_pPCMData, &nPCMLength, (const uint8_t*)p, buffsize);
- if (nRet<0 || (nRet==0 && nParserLength==0))
+ if (nRet<0 || (nRet==0 && nParserLength==0)) {
return S_OK;
+ }
buffsize -= nRet;
p += nRet;
size += nRet;
}
- if (nPCMLength > 0)
- {
+ if (nPCMLength > 0) {
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
CAtlArray<float> pBuff;
int nRemap;
float* pDataOut;
nRemap = FFGetChannelMap (m_pAVCtx);
- if (nRemap >=0)
- {
+ if (nRemap >=0) {
scmap_t& scmap = s_scmap_ac3[nRemap];
- switch (m_pAVCtx->sample_fmt)
- {
- case SAMPLE_FMT_S16 :
- pBuff.SetCount (nPCMLength / 2);
- pDataOut = pBuff.GetData();
-
- for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int16_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
- pDataOut++;
+ switch (m_pAVCtx->sample_fmt) {
+ case SAMPLE_FMT_S16 :
+ pBuff.SetCount (nPCMLength / 2);
+ pDataOut = pBuff.GetData();
+
+ for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int16_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
+ break;
- case SAMPLE_FMT_S32 :
- pBuff.SetCount (nPCMLength / 4);
- pDataOut = pBuff.GetData();
+ case SAMPLE_FMT_S32 :
+ pBuff.SetCount (nPCMLength / 4);
+ pDataOut = pBuff.GetData();
- for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int32_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
- pDataOut++;
+ for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int32_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
- default :
- ASSERT(FALSE);
- break;
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
}
hr = Deliver(pBuff, m_pAVCtx->sample_rate, m_pAVCtx->channels, scmap.dwChannelMask);
}
@@ -2801,8 +2783,7 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
HRESULT hr = S_OK;
int nPCMLength = 0;
if (!m_pAVCtx || nCodecId != m_pAVCtx->codec_id)
- if (!InitFFmpeg (nCodecId))
- {
+ if (!InitFFmpeg (nCodecId)) {
size = 0;
return E_FAIL;
}
@@ -2810,14 +2791,12 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
CAtlArray<float> pBuffOut;
scmap_t* scmap = NULL;
- AVPacket avpkt;
- av_init_packet(&avpkt);
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
- while (buffsize > 0)
- {
+ while (buffsize > 0) {
nPCMLength = AVCODEC_MAX_AUDIO_FRAME_SIZE;
- if (buffsize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize)
- {
+ if (buffsize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
m_nFFBufferSize = buffsize+FF_INPUT_BUFFER_PADDING_SIZE;
m_pFFBuffer = (BYTE*)realloc(m_pFFBuffer, m_nFFBufferSize);
@@ -2846,60 +2825,52 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
}
size += used_byte;//
- if ( nPCMLength>0)
- {
+ if ( nPCMLength>0) {
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
CAtlArray<float> pBuff;
int nRemap;
float* pDataOut;
nRemap = FFGetChannelMap (m_pAVCtx);
- if (nRemap >=0)
- {
+ if (nRemap >=0) {
- switch (nCodecId)
- {
- case CODEC_ID_EAC3 :
- scmap = &m_ffmpeg_ac3[FFGetChannelMap(m_pAVCtx)];
- break;
- default :
- scmap = &m_scmap_default[m_pAVCtx->channels-1];
- break;
+ switch (nCodecId) {
+ case CODEC_ID_EAC3 :
+ scmap = &m_ffmpeg_ac3[FFGetChannelMap(m_pAVCtx)];
+ break;
+ default :
+ scmap = &m_scmap_default[m_pAVCtx->channels-1];
+ break;
}
- switch (m_pAVCtx->sample_fmt)
- {
- case SAMPLE_FMT_S16 :
- pBuff.SetCount (nPCMLength / 2);
- pDataOut = pBuff.GetData();
-
- for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int16_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
- pDataOut++;
+ switch (m_pAVCtx->sample_fmt) {
+ case SAMPLE_FMT_S16 :
+ pBuff.SetCount (nPCMLength / 2);
+ pDataOut = pBuff.GetData();
+
+ for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int16_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
+ break;
- case SAMPLE_FMT_S32 :
- pBuff.SetCount (nPCMLength / 4);
- pDataOut = pBuff.GetData();
+ case SAMPLE_FMT_S32 :
+ pBuff.SetCount (nPCMLength / 4);
+ pDataOut = pBuff.GetData();
- for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int32_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
- pDataOut++;
+ for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int32_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
- default :
- ASSERT(FALSE);
- break;
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
}
if(pBuff.GetCount() > 0) {
@@ -2916,8 +2887,9 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
buffsize -= used_byte;
pDataInBuff += used_byte;
}
- if(pBuffOut.GetCount() > 0 && scmap)
+ if(pBuffOut.GetCount() > 0 && scmap) {
hr = Deliver(pBuffOut, m_pAVCtx->sample_rate, scmap->nChannels, scmap->dwChannelMask);
+ }
return hr;
}
#endif
@@ -2933,13 +2905,13 @@ bool CMpaDecFilter::InitFFmpeg(int nCodecId)
av_log_set_callback(LogLibAVCodec);
#endif
- if (m_pAVCodec) ffmpeg_stream_finish();
+ if (m_pAVCodec) {
+ ffmpeg_stream_finish();
+ }
m_pAVCodec = avcodec_find_decoder((CodecID)nCodecId);
- if (m_pAVCodec)
- {
- if (nCodecId==CODEC_ID_AMR_NB || nCodecId== CODEC_ID_AMR_WB)
- {
+ if (m_pAVCodec) {
+ if (nCodecId==CODEC_ID_AMR_NB || nCodecId== CODEC_ID_AMR_WB) {
wfein->nChannels = 1;
wfein->nSamplesPerSec = 8000;
}
@@ -2955,14 +2927,15 @@ bool CMpaDecFilter::InitFFmpeg(int nCodecId)
m_pAVCtx->codec_id = (CodecID)nCodecId;
m_pParser = av_parser_init(nCodecId);
- if (avcodec_open(m_pAVCtx,m_pAVCodec)>=0)
- {
+ if (avcodec_open(m_pAVCtx,m_pAVCodec)>=0) {
m_pPCMData = (BYTE*)FF_aligned_malloc (AVCODEC_MAX_AUDIO_FRAME_SIZE+FF_INPUT_BUFFER_PADDING_SIZE, 64);
bRet = true;
}
}
- if (!bRet) ffmpeg_stream_finish();
+ if (!bRet) {
+ ffmpeg_stream_finish();
+ }
return bRet;
}
@@ -2977,20 +2950,20 @@ void CMpaDecFilter::LogLibAVCodec(void* par,int level,const char *fmt,va_list va
void CMpaDecFilter::ffmpeg_stream_finish()
{
m_pAVCodec = NULL;
- if (m_pAVCtx)
- {
+ if (m_pAVCtx) {
avcodec_close (m_pAVCtx);
av_free (m_pAVCtx);
m_pAVCtx = NULL;
}
- if (m_pParser)
- {
+ if (m_pParser) {
av_parser_close (m_pParser);
m_pParser = NULL;
}
- if (m_pPCMData) FF_aligned_free (m_pPCMData);
+ if (m_pPCMData) {
+ FF_aligned_free (m_pPCMData);
+ }
}
#pragma endregion
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.h b/src/filters/transform/MpaDecFilter/MpaDecFilter.h
index 16dc0c509..b26f98c82 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.h
+++ b/src/filters/transform/MpaDecFilter/MpaDecFilter.h
@@ -38,8 +38,7 @@
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AAC
-struct aac_state_t
-{
+struct aac_state_t {
void* h; // NeAACDecHandle h;
DWORD freq;
BYTE channels;
@@ -52,8 +51,7 @@ struct aac_state_t
};
#endif
-struct ps2_state_t
-{
+struct ps2_state_t {
bool sync;
double a[2], b[2];
ps2_state_t() {
@@ -66,8 +64,7 @@ struct ps2_state_t
};
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
-struct vorbis_state_t
-{
+struct vorbis_state_t {
vorbis_info vi;
vorbis_comment vc;
vorbis_block vb;
@@ -84,8 +81,7 @@ struct vorbis_state_t
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
-struct flac_state_t
-{
+struct flac_state_t {
void* pDecoder;
HRESULT hr;
};
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
index cf56cd629..cf5bc2a91 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
+++ b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
@@ -48,9 +48,13 @@ bool CMpaDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>
m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos)));
+ while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if(!m_pMDF) return false;
+ if(!m_pMDF) {
+ return false;
+ }
m_outputformat = m_pMDF->GetSampleFormat();
m_ac3spkcfg = m_pMDF->GetSpeakerConfig(IMpaDecFilter::ac3);
@@ -70,18 +74,17 @@ void CMpaDecSettingsWnd::OnDisconnect()
LPCTSTR CMpaDecSettingsWnd::GetDolbyMode (DolbyDigitalMode ddmode)
{
- switch (ddmode)
- {
- case DD_AC3 :
- return _T(" (AC3)");
- case DD_EAC3 :
- return _T(" (Dolby Digital Plus)");
- case DD_TRUEHD :
- return _T(" (Dolby True HD)");
- case DD_MLP :
- return _T(" (MLP)");
- default :
- return _T("");
+ switch (ddmode) {
+ case DD_AC3 :
+ return _T(" (AC3)");
+ case DD_EAC3 :
+ return _T(" (Dolby Digital Plus)");
+ case DD_TRUEHD :
+ return _T(" (Dolby True HD)");
+ case DD_MLP :
+ return _T(" (MLP)");
+ default :
+ return _T("");
}
}
@@ -105,8 +108,9 @@ bool CMpaDecSettingsWnd::OnActivate()
m_outputformat_combo.SetCurSel(0);
for(int i = 0; i < m_outputformat_combo.GetCount(); i++)
- if((int)m_outputformat_combo.GetItemData(i) == m_outputformat)
+ if((int)m_outputformat_combo.GetItemData(i) == m_outputformat) {
m_outputformat_combo.SetCurSel(i);
+ }
p.y += 30;
@@ -130,8 +134,9 @@ bool CMpaDecSettingsWnd::OnActivate()
m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_2)), A52_CHANNEL2);
for(int i = 0, sel = abs(m_ac3spkcfg) & A52_CHANNEL_MASK; i < m_ac3spkcfg_combo.GetCount(); i++)
- if((int)m_ac3spkcfg_combo.GetItemData(i) == sel)
+ if((int)m_ac3spkcfg_combo.GetItemData(i) == sel) {
m_ac3spkcfg_combo.SetCurSel(i);
+ }
m_ac3spkcfg_combo.GetWindowRect(r);
ScreenToClient(r);
@@ -139,8 +144,7 @@ bool CMpaDecSettingsWnd::OnActivate()
m_ac3lfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK4);
m_ac3lfe_check.SetCheck(!!(abs(m_ac3spkcfg) & A52_LFE));
- for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_ac3spkcfg_radio); i++, p.y += h)
- {
+ for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_ac3spkcfg_radio); i++, p.y += h) {
static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
m_ac3spkcfg_radio[i].Create(labels[i], dwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO1+i);
}
@@ -171,8 +175,9 @@ bool CMpaDecSettingsWnd::OnActivate()
m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), DTS_3F2R);
for(int i = 0, sel = abs(m_dtsspkcfg) & DTS_CHANNEL_MASK; i < m_dtsspkcfg_combo.GetCount(); i++)
- if((int)m_dtsspkcfg_combo.GetItemData(i) == sel)
+ if((int)m_dtsspkcfg_combo.GetItemData(i) == sel) {
m_dtsspkcfg_combo.SetCurSel(i);
+ }
m_dtsspkcfg_combo.GetWindowRect(r);
ScreenToClient(r);
@@ -180,8 +185,7 @@ bool CMpaDecSettingsWnd::OnActivate()
m_dtslfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK5);
m_dtslfe_check.SetCheck(!!(abs(m_dtsspkcfg) & DTS_LFE));
- for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_dtsspkcfg_radio); i++, p.y += h)
- {
+ for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_dtsspkcfg_radio); i++, p.y += h) {
static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
m_dtsspkcfg_radio[i].Create(labels[i], dwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO3+i);
}
@@ -202,8 +206,9 @@ bool CMpaDecSettingsWnd::OnActivate()
m_aacdownmix_check.Create(ResStr(IDS_MPADECSETTINGSWND_12), dwStyle|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(150, m_fontheight)), this, IDC_PP_CHECK3);
m_aacdownmix_check.SetCheck(m_aacdownmix);
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
return true;
}
@@ -212,12 +217,20 @@ void CMpaDecSettingsWnd::OnDeactivate()
{
m_outputformat = m_outputformat_combo.GetItemData(m_outputformat_combo.GetCurSel());
m_ac3spkcfg = m_ac3spkcfg_combo.GetItemData(m_ac3spkcfg_combo.GetCurSel());
- if(!!m_ac3lfe_check.GetCheck()) m_ac3spkcfg |= A52_LFE;
- if(IsDlgButtonChecked(IDC_PP_RADIO2)) m_ac3spkcfg = -m_ac3spkcfg;
+ if(!!m_ac3lfe_check.GetCheck()) {
+ m_ac3spkcfg |= A52_LFE;
+ }
+ if(IsDlgButtonChecked(IDC_PP_RADIO2)) {
+ m_ac3spkcfg = -m_ac3spkcfg;
+ }
m_ac3drc = !!m_ac3spkcfg_check.GetCheck();
m_dtsspkcfg = m_dtsspkcfg_combo.GetItemData(m_dtsspkcfg_combo.GetCurSel());
- if(!!m_dtslfe_check.GetCheck()) m_dtsspkcfg |= DTS_LFE;
- if(IsDlgButtonChecked(IDC_PP_RADIO4)) m_dtsspkcfg = -m_dtsspkcfg;
+ if(!!m_dtslfe_check.GetCheck()) {
+ m_dtsspkcfg |= DTS_LFE;
+ }
+ if(IsDlgButtonChecked(IDC_PP_RADIO4)) {
+ m_dtsspkcfg = -m_dtsspkcfg;
+ }
m_dtsdrc = !!m_dtsspkcfg_check.GetCheck();
m_aacdownmix = !!m_aacdownmix_check.GetCheck();
}
@@ -226,8 +239,7 @@ bool CMpaDecSettingsWnd::OnApply()
{
OnDeactivate();
- if(m_pMDF)
- {
+ if(m_pMDF) {
m_pMDF->SetSampleFormat((MPCSampleFormat)m_outputformat);
m_pMDF->SetSpeakerConfig(IMpaDecFilter::ac3, m_ac3spkcfg);
m_pMDF->SetDynamicRangeControl(IMpaDecFilter::ac3, m_ac3drc);
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
index 143369335..7e1ab6b2c 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
+++ b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
@@ -40,8 +40,7 @@ class __declspec(uuid("24103041-884B-4772-B0D3-A600E7CBFEC7"))
bool m_aacdownmix;
DolbyDigitalMode m_ddmode;
- enum
- {
+ enum {
IDC_PP_RADIO1 = 10000,
IDC_PP_RADIO2,
IDC_PP_RADIO3,
diff --git a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
index a36174c94..054337be6 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,12 +6,12 @@
* 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.
@@ -24,8 +24,8 @@
typedef enum {DIAuto, DIWeave, DIBlend, DIBob, DIFieldShift, DIELA} ditype;
interface __declspec(uuid("0ABEAA65-0317-47B9-AE1D-D9EA905AFD25"))
-IMpeg2DecFilter : public IUnknown
-{
+IMpeg2DecFilter :
+public IUnknown {
STDMETHOD(SetDeinterlaceMethod(ditype di)) = 0;
STDMETHOD_(ditype, GetDeinterlaceMethod()) = 0;
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
index 75f777984..d2e74b47e 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,12 +6,12 @@
* 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.
@@ -40,8 +40,7 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
{&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
{&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_VIDEO},
@@ -52,29 +51,25 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
#endif
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
- #ifdef MPEG2ONLY
+const AMOVIESETUP_FILTER sudFilter[] = {
+#ifdef MPEG2ONLY
{&__uuidof(CMpeg2DecFilter), L"MPC - MPEG-2 Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- #else
+#else
{&__uuidof(CMpeg2DecFilter), L"MPC - MPEG Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- #endif
+#endif
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, NULL, &sudFilter[0]},
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, NULL, &sudFilter[0]},
{L"CMpeg2DecPropertyPage", &__uuidof(CMpeg2DecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpeg2DecSettingsWnd> >},
};
@@ -95,48 +90,42 @@ 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;
+ LPDEVMODEA a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+= ChangeDisplaySettingsExA;
LONG (__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
- LPDEVMODEW a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExW;
+ 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"));
+ 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)
- {
+ 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)
- {
+ && (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)
- {
+ } else if(vp->dwCommand == VP_COMMAND_SET) {
TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
return 0;
}
@@ -161,11 +150,12 @@ LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpD
class CMpeg2DecFilterApp : public CFilterApp
{
public:
- BOOL InitInstance()
- {
+ BOOL InitInstance() {
long lError;
- if(!__super::InitInstance()) return FALSE;
+ if(!__super::InitInstance()) {
+ return FALSE;
+ }
DetourRestoreAfterWith();
DetourTransactionBegin();
@@ -190,31 +180,45 @@ CMpeg2DecFilterApp theApp;
// CMpeg2DecFilter
//
-CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
+CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
: CBaseVideoFilter(NAME("CMpeg2DecFilter"), lpunk, phr, __uuidof(this), 1)
, m_fWaitForKeyFrame(true)
, m_fInitializedBuffer(true)
{
delete m_pInput;
-// delete m_pOutput;
+ // delete m_pOutput;
- if(FAILED(*phr)) return;
+ if(FAILED(*phr)) {
+ return;
+ }
m_pInput = DNew CMpeg2DecInputPin(this, phr, L"Video");
- if(!m_pInput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
-// m_pOutput = DNew CMpeg2DecOutputPin(this, phr, L"Output");
-// if(!m_pOutput) *phr = E_OUTOFMEMORY;
-// if(FAILED(*phr)) return;
+ // m_pOutput = DNew CMpeg2DecOutputPin(this, phr, L"Output");
+ // if(!m_pOutput) *phr = E_OUTOFMEMORY;
+ // if(FAILED(*phr)) return;
m_pSubpicInput = DNew CSubpicInputPin(this, phr);
- if(!m_pSubpicInput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!m_pSubpicInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
m_pClosedCaptionOutput = DNew CClosedCaptionOutputPin(this, m_pLock, phr);
- if(!m_pClosedCaptionOutput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ if(!m_pClosedCaptionOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
SetDeinterlaceMethod(DIAuto);
SetBrightness(0.0f);
@@ -227,18 +231,35 @@ CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
EnableReadARFromStream(true);
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ))
- {
+ 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);
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ReadARFromStream"), dw)) EnableReadARFromStream(!!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);
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ReadARFromStream"), dw)) {
+ EnableReadARFromStream(!!dw);
+ }
}
m_rate.Rate = 10000;
@@ -250,8 +271,7 @@ CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
CMpeg2DecFilter::~CMpeg2DecFilter()
{
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder")))
- {
+ 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);
@@ -273,7 +293,7 @@ STDMETHODIMP CMpeg2DecFilter::NonDelegatingQueryInterface(REFIID riid, void** pp
QI(IMpeg2DecFilter)
QI(ISpecifyPropertyPages)
QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
int CMpeg2DecFilter::GetPinCount()
@@ -283,12 +303,15 @@ int CMpeg2DecFilter::GetPinCount()
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;
+ switch(n) {
+ case 0:
+ return m_pInput;
+ case 1:
+ return m_pOutput;
+ case 2:
+ return m_pSubpicInput;
+ case 3:
+ return m_pClosedCaptionOutput;
}
return NULL;
}
@@ -323,11 +346,10 @@ HRESULT CMpeg2DecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop,
void CMpeg2DecFilter::InputTypeChanged()
{
CAutoLock cAutoLock(&m_csReceive);
-
+
TRACE(_T("ResetMpeg2Decoder()\n"));
- for(int i = 0; i < countof(m_dec->m_pictures); i++)
- {
+ 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;
@@ -338,13 +360,10 @@ void CMpeg2DecFilter::InputTypeChanged()
BYTE* pSequenceHeader = NULL;
DWORD cbSequenceHeader = 0;
- if(mt.formattype == FORMAT_MPEGVideo)
- {
+ if(mt.formattype == FORMAT_MPEGVideo) {
pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
- }
- else if(mt.formattype == FORMAT_MPEG2_VIDEO)
- {
+ } else if(mt.formattype == FORMAT_MPEG2_VIDEO) {
pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
}
@@ -369,17 +388,13 @@ void CMpeg2DecFilter::SetDeinterlaceMethod()
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))
- {
+ 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))
- {
+ } else if(m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
TRACE(_T("m_fFilm = false\n"));
m_fFilm = false;
}
@@ -387,28 +402,26 @@ void CMpeg2DecFilter::SetDeinterlaceMethod()
const CMediaType& mt = m_pOutput->CurrentMediaType();
- if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
- {
+ if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
m_fb.di = DIWeave;
- }
- else
- {
+ } 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 && m_fb.di != DIELA)
- {
- 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
+ if(m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift && m_fb.di != DIELA) {
+ 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
+ // 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;
+ }
}
}
@@ -417,32 +430,35 @@ void CMpeg2DecFilter::SetDeinterlaceMethod()
void CMpeg2DecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS)
- {
+ if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&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))
- {
+ 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)
+ 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)
+ if(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- if(m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD)
+ }
+ 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)
+ 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)
+ }
+ 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)
+ }
+ 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);
@@ -455,58 +471,61 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
HRESULT hr;
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
long len = pIn->GetActualDataLength();
(static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
- if(pIn->IsDiscontinuity() == S_OK)
- {
+ 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;
+ if(FAILED(hr)) {
+ rtStart = rtStop = _I64_MIN;
+ }
- while(len >= 0)
- {
+ 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
#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:
- {
+ 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)
- {
+ if(picture && !(picture->flags&PIC_FLAG_SKIP) && fbuf) {
ASSERT(!picture->fDelivered);
picture->fDelivered = true;
@@ -517,8 +536,7 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
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)
- {
+ if(m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch) {
m_fb.Alloc(w, h, pitch);
m_fInitializedBuffer = false;
}
@@ -526,7 +544,9 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
// start - end
m_fb.rtStart = picture->rtStart;
- if(m_fb.rtStart == _I64_MIN) m_fb.rtStart = m_fb.rtStop;
+ 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;
@@ -540,19 +560,22 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
UpdateAspectRatio();
hr = DeliverFast();
- if(hr != S_OK)
+ if(hr != S_OK) {
hr = DeliverNormal();
- if(hr != S_OK)
+ }
+ if(hr != S_OK) {
return hr;
- if(hr == S_OK && !m_fWaitForKeyFrame)
+ }
+ if(hr == S_OK && !m_fWaitForKeyFrame) {
m_fInitializedBuffer = true;
+ }
}
}
break;
- default:
- break;
+ default:
+ break;
}
- }
+ }
return S_OK;
}
@@ -564,14 +587,15 @@ bool CMpeg2DecFilter::IsVideoInterlaced()
void CMpeg2DecFilter::UpdateAspectRatio()
{
- if(m_bReadARFromStream && (m_par.cx != m_dec->m_info.m_sequence->pixel_width || m_par.cy != m_dec->m_info.m_sequence->pixel_height))
- {
+ if(m_bReadARFromStream && (m_par.cx != m_dec->m_info.m_sequence->pixel_width || m_par.cy != m_dec->m_info.m_sequence->pixel_height)) {
m_par.cx = m_dec->m_info.m_sequence->pixel_width;
m_par.cy = m_dec->m_info.m_sequence->pixel_height;
CSize dar(m_dec->m_info.m_sequence->picture_width * m_par.cx,
- m_dec->m_info.m_sequence->picture_height * m_par.cy);
+ m_dec->m_info.m_sequence->picture_height * m_par.cy);
int lnko = LNKO(dar.cx, dar.cy);
- if(lnko > 1) dar.cx /= lnko, dar.cy /= lnko;
+ if(lnko > 1) {
+ dar.cx /= lnko, dar.cy /= lnko;
+ }
SetAspect(dar);
}
}
@@ -583,38 +607,46 @@ HRESULT CMpeg2DecFilter::DeliverFast()
CAutoLock cAutoLock(&m_csReceive);
mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) return S_FALSE;
+ 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(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)
+ if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
m_fWaitForKeyFrame = false;
+ }
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
+ if(m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
return S_OK;
+ }
const CMediaType& mt = m_pOutput->CurrentMediaType();
-
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
+
+ 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)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
+ if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
return S_FALSE;
+ }
BITMAPINFOHEADER bihOut;
ExtractBIH(&mt, &bihOut);
@@ -628,36 +660,32 @@ HRESULT CMpeg2DecFilter::DeliverFast()
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)
- {
+ 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)
- {
+ } 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
- {
+ } else { // TODO
return S_FALSE;
}
- if(h == 1088)
- {
+ 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))
- {
+ if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate)
- {
+ if(m_rate.Rate != pPin->m_ratechange.Rate) {
m_rate.Rate = pPin->m_ratechange.Rate;
m_rate.StartTime = m_fb.rtStart;
}
@@ -688,7 +716,9 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
CAutoLock cAutoLock(&m_csReceive);
mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) return S_FALSE;
+ if(!fbuf) {
+ return S_FALSE;
+ }
int w = m_fb.w;
int h = m_fb.h;
@@ -702,35 +732,26 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
// deinterlace
- if(m_fb.di == DIWeave)
- {
+ 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)
- {
+ } 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)
- {
+ } 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)
- {
+ } 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);
- }
- else if(m_fb.di == DIELA)
- {
+ } else if(m_fb.di == DIELA) {
DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, tff);
DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, tff);
@@ -742,15 +763,14 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
// deliver
- if (m_fb.di == DIWeave || m_fInitializedBuffer)
- {
+ if (m_fb.di == DIWeave || m_fInitializedBuffer) {
hr = Deliver(false);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
}
- if(m_fb.di == DIBob)
- {
+ 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);
@@ -765,24 +785,21 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
// deliver
hr = Deliver(false);
- }
- else if(m_fb.di == DIFieldShift)
- {
+ } 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);
- }
- else if(m_fb.di == DIELA)
- {
+ } else if(m_fb.di == DIELA) {
DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, !tff);
DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, !tff);
}
- if (!m_fInitializedBuffer)
+ if (!m_fInitializedBuffer) {
hr = Deliver(false);
+ }
return hr;
}
@@ -792,22 +809,24 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
{
CAutoLock cAutoLock(&m_csReceive);
- if((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
+ if((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
m_fWaitForKeyFrame = false;
+ }
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
+ if(m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
return S_OK;
+ }
HRESULT hr;
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
- if(m_fb.h == 1088)
- {
+ 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);
@@ -815,11 +834,10 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
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];
@@ -830,12 +848,10 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
//
- if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput))
- {
+ if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate)
- {
+ if(m_rate.Rate != pPin->m_ratechange.Rate) {
m_rate.Rate = pPin->m_ratechange.Rate;
m_rate.StartTime = m_fb.rtStart;
}
@@ -865,29 +881,29 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if(dir == PINDIR_OUTPUT)
- {
- if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator)
- {
+ 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))
+ 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
+ /*&& 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;
+ }
}
}
@@ -896,11 +912,11 @@ HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
{
- if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat)
- {
+ if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
- if(vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000)
+ 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
@@ -909,20 +925,20 @@ HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
|| 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;
+ ? 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;
+ && (!fPlanarYUV || IsPlanarYUVEnabled())
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
DWORD g_clock;
@@ -930,25 +946,29 @@ DWORD g_clock;
HRESULT CMpeg2DecFilter::StartStreaming()
{
HRESULT hr = __super::StartStreaming();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
m_dec.Attach(DNew CMpeg2Dec());
- if(!m_dec) return E_OUTOFMEMORY;
+ if(!m_dec) {
+ return E_OUTOFMEMORY;
+ }
InputTypeChanged();
-// g_clock = clock();
+ // g_clock = clock();
return S_OK;
}
HRESULT CMpeg2DecFilter::StopStreaming()
{
-/*
- CString str;
- str.Format(_T("%d"), clock()-g_clock);
- AfxMessageBox(str);
-*/
+ /*
+ CString str;
+ str.Format(_T("%d"), clock()-g_clock);
+ AfxMessageBox(str);
+ */
m_dec.Free();
return __super::StopStreaming();
@@ -956,10 +976,13 @@ HRESULT CMpeg2DecFilter::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);
+ // TRACE(_T("CMpeg2DecFilter::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
return S_OK;
}
@@ -980,12 +1003,13 @@ STDMETHODIMP CMpeg2DecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPag
{
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
HRESULT hr;
- if(guid == __uuidof(CMpeg2DecSettingsWnd))
- {
+ if(guid == __uuidof(CMpeg2DecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -1012,11 +1036,10 @@ void CMpeg2DecFilter::CalcBrCont(BYTE* YTbl, float bright, float cont)
int Cont = (int)(cont * 512);
int Bright = (int)bright;
- for(int i = 0; i < 256; i++)
- {
+ 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);
+ // YTbl[i] = min(max(y, 16), 235);
}
}
@@ -1027,11 +1050,9 @@ void CMpeg2DecFilter::CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat)
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;
+ 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;
@@ -1049,12 +1070,10 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
{
CAutoLock cAutoLock(&m_csProps);
- if(fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON)
- {
+ 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)
- {
+ 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);
@@ -1064,8 +1083,7 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
__m128i _16 = _mm_set1_epi16(16);
__m128i _512 = _mm_set1_epi16(512);
- for(int i = 0, j = size>>4; i < j; i++)
- {
+ 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);
@@ -1101,8 +1119,7 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
size &= 15;
}
- for(; size > 0; size--)
- {
+ for(; size > 0; size--) {
*srcy++ = m_YTbl[*srcy];
}
}
@@ -1111,10 +1128,8 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
w /= 2;
h /= 2;
- if(fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON)
- {
- for(int size = pitch*h; size > 0; size--)
- {
+ 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];
@@ -1242,175 +1257,172 @@ CMpeg2DecInputPin::CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LP
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*/)
+ 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;
+ 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;
}
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
-/*
- if(PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch(Id)
- {
- case AM_RATE_ChangeRate:
+ /*
+ if(PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch(Id)
{
- AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
+ case AM_RATE_ChangeRate:
+ {
+ AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
}
- 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*/)
+ 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;
- UNUSED_ALWAYS(p);
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- case AM_RATE_MaxFullDataRate:
- {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- UNUSED_ALWAYS(p);
- *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);
+ switch(Id) {
+ case AM_RATE_SimpleRateChange: {
+ AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
+ UNUSED_ALWAYS(p);
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ break;
+ case AM_RATE_MaxFullDataRate: {
+ AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
+ UNUSED_ALWAYS(p);
+ *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;
}
- break;
- case AM_RATE_QueryLastRateSegPTS:
+ /*
+ if(PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch(Id)
{
- REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;
+ 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;
}
- 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*/)
+ 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;
- }
-*/
+ 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;
}
@@ -1429,15 +1441,15 @@ HRESULT CMpeg2DecOutputPin::Active()
// TODO
- if(m_Connected && !m_pOutputQueue)
- {
+ if(m_Connected && !m_pOutputQueue) {
HRESULT hr = NOERROR;
m_pOutputQueue.Attach(DNew COutputQueue(m_Connected, &hr));
- if(!m_pOutputQueue) hr = E_OUTOFMEMORY;
+ if(!m_pOutputQueue) {
+ hr = E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
m_pOutputQueue.Free();
return hr;
}
@@ -1455,7 +1467,9 @@ HRESULT CMpeg2DecOutputPin::Inactive()
HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if(!m_pOutputQueue) return NOERROR;
+ if(!m_pOutputQueue) {
+ return NOERROR;
+ }
pMediaSample->AddRef();
return m_pOutputQueue->Receive(pMediaSample);
}
@@ -1464,7 +1478,7 @@ HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
if(!m_pOutputQueue) return NOERROR; \
m_pOutputQueue->##call; \
return NOERROR; \
-
+
HRESULT CMpeg2DecOutputPin::DeliverEndOfStream()
{
CallQueue(EOS());
@@ -1492,7 +1506,7 @@ HRESULT CMpeg2DecOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_T
#define PTS2RT(pts) (10000i64*pts/90)
-CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
+CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
: CMpeg2DecInputPin(pFilter, phr, L"SubPicture")
, m_spon(TRUE)
, m_fsppal(false)
@@ -1512,12 +1526,12 @@ 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;
+ || 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)
@@ -1527,16 +1541,18 @@ HRESULT CSubpicInputPin::SetMediaType(const CMediaType* mtIn)
bool CSubpicInputPin::HasAnythingToRender(REFERENCE_TIME rt)
{
- if(!IsConnected()) return(false);
+ if(!IsConnected()) {
+ return(false);
+ }
CAutoLock cAutoLock(&m_csReceive);
POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ 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))
+ if(sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon)) {
return(true);
+ }
}
return(false);
@@ -1550,20 +1566,21 @@ void CSubpicInputPin::RenderSubpics(REFERENCE_TIME rt, BYTE** yuv, int w, int h)
// remove no longer needed things first
pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStop <= rt) m_sps.RemoveAt(cur);
+ if(sp->m_rtStop <= rt) {
+ m_sps.RemoveAt(cur);
+ }
}
pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ 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)))
+ 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);
+ }
}
}
@@ -1572,29 +1589,33 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
HRESULT hr;
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && 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;
+ if(FAILED(hr = pSample->GetPointer(&pDataIn))) {
+ return hr;
+ }
long len = pSample->GetActualDataLength();
StripPacket(pDataIn, len);
- if(len <= 0) return S_FALSE;
+ if(len <= 0) {
+ return S_FALSE;
+ }
- if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
pDataIn += 4;
len -= 4;
}
- if(len <= 0) return S_FALSE;
+ if(len <= 0) {
+ return S_FALSE;
+ }
CAutoLock cAutoLock(&m_csReceive);
@@ -1603,23 +1624,17 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
bool fRefresh = false;
- if(FAILED(hr))
- {
- if(!m_sps.IsEmpty())
- {
+ 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
- {
+ } else {
POSITION pos = m_sps.GetTailPosition();
- while(pos)
- {
+ while(pos) {
spu* sp = m_sps.GetPrev(pos);
- if(sp->m_rtStop == _I64_MAX)
- {
+ if(sp->m_rtStop == _I64_MAX) {
sp->m_rtStop = rtStart;
break;
}
@@ -1627,10 +1642,15 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
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;
+ 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;
@@ -1638,8 +1658,7 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
p->SetCount(len);
memcpy(p->GetData(), pDataIn, len);
- if(m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM))
- {
+ if(m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM)) {
p->m_psphli = m_sphli;
fRefresh = true;
}
@@ -1647,14 +1666,12 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
m_sps.AddTail(p);
}
- if(!m_sps.IsEmpty())
- {
+ if(!m_sps.IsEmpty()) {
m_sps.GetTail()->Parse();
}
- if(fRefresh)
- {
-// ((CMpeg2DecFilter*)m_pFilter)->Deliver(true);
+ if(fRefresh) {
+ // ((CMpeg2DecFilter*)m_pFilter)->Deliver(true);
}
return S_FALSE;
@@ -1671,15 +1688,14 @@ STDMETHODIMP CSubpicInputPin::EndFlush()
STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic)
+ if(PropSet != AM_KSPROPSETID_DvdSubPic) {
return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+ }
bool fRefresh = false;
- switch(Id)
- {
- case AM_PROPERTY_DVDSUBPIC_PALETTE:
- {
+ switch(Id) {
+ case AM_PROPERTY_DVDSUBPIC_PALETTE: {
CAutoLock cAutoLock(&m_csReceive);
AM_PROPERTY_SPPAL* pSPPAL = (AM_PROPERTY_SPPAL*)pPropertyData;
@@ -1689,22 +1705,18 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
DbgLog((LOG_TRACE, 0, _T("new palette")));
}
break;
- case AM_PROPERTY_DVDSUBPIC_HLI:
- {
+ case AM_PROPERTY_DVDSUBPIC_HLI: {
CAutoLock cAutoLock(&m_csReceive);
AM_PROPERTY_SPHLI* pSPHLI = (AM_PROPERTY_SPHLI*)pPropertyData;
m_sphli.Free();
- if(pSPHLI->HLISS)
- {
+ if(pSPHLI->HLISS) {
POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop)
- {
+ 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);
@@ -1712,17 +1724,13 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
}
}
- if(!fRefresh) // save it for later, a subpic might be late for this hli
- {
+ 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
- {
+ } else {
POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
spu* sp = m_sps.GetNext(pos);
fRefresh |= !!sp->m_psphli;
sp->m_psphli.Free();
@@ -1730,25 +1738,23 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
}
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));
+ 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:
- {
+ 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;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
}
- if(fRefresh)
- {
+ if(fRefresh) {
(static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
}
@@ -1757,24 +1763,24 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
STDMETHODIMP CSubpicInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic)
+ 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;
+ 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;
}
@@ -1785,26 +1791,32 @@ static __inline BYTE GetNibble(BYTE* p, DWORD* offset, int& nField, int& fAligne
BYTE ret = (p[offset[nField]] >> (fAligned << 2)) & 0x0f;
offset[nField] += 1-fAligned;
fAligned = !fAligned;
- return ret;
+ 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]++;
+ if(!n) {
+ offset[nField]++;
+ }
n = (n-1+4)&3;
- return ret;
+ 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];
-// *p = (*p*(15-contrast) + sppal[color].Y*contrast)>>4;
+ // *p = (*p*(15-contrast) + sppal[color].Y*contrast)>>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
@@ -1813,11 +1825,11 @@ static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
// 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 = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].V-0x80)*contrast) >> 4) + 0x80);
+ // *p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].V-0x80)*contrast) >> 4) + 0x80);
*p -= (*p - c.V) * c.Reserved >> 4;
p = &yuv[2][pt.y*pitch + pt.x];
-// *p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].U-0x80)*contrast) >> 4) + 0x80);
+ // *p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].U-0x80)*contrast) >> 4) + 0x80);
*p -= (*p - c.U) * c.Reserved >> 4;
// Neighter of the blending formulas are accurate (">>4" should be "/15").
@@ -1827,23 +1839,32 @@ static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
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.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(c.Reserved == 0)
- {
- if(rc.IsRectEmpty())
+ 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)
+ if(pt.y < rc.top || pt.y >= rc.bottom
+ || pt.x+len < rc.left || pt.x >= rc.right) {
return;
+ }
}
- while(len-- > 0)
- {
+ while(len-- > 0) {
DrawPixel(yuv, pt, pitch, c);
pt.x++;
}
@@ -1860,50 +1881,65 @@ bool CSubpicInputPin::dvdspu::Parse()
WORD packetsize = (p[0]<<8)|p[1];
WORD datasize = (p[2]<<8)|p[3];
- if(packetsize > GetCount() || datasize > packetsize)
+ if(packetsize > GetCount() || datasize > packetsize) {
return(false);
+ }
int i, next = datasize;
- #define GetWORD (p[i]<<8)|p[i+1]; i += 2
+#define GetWORD (p[i]<<8)|p[i+1]; i += 2
- do
- {
+ do {
i = next;
int pts = GetWORD;
next = GetWORD;
- if(next > packetsize || next < datasize)
+ if(next > packetsize || next < datasize) {
return(false);
+ }
REFERENCE_TIME rt = m_rtStart + 1024*PTS2RT(pts);
- for(bool fBreak = false; !fBreak; )
- {
+ 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;
+ 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)
- {
+ if(i+len >= packetsize) {
TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
break;
}
- switch(p[i++])
- {
+ switch(p[i++]) {
case 0x00: // forced start displaying
m_fForced = true;
break;
@@ -1952,8 +1988,7 @@ bool CSubpicInputPin::dvdspu::Parse()
offset_t o = {rt, m_sphli};
m_offsets.AddTail(o); // is it always going to be sorted?
- }
- while(i <= next && i < packetsize);
+ } while(i <= next && i < packetsize);
return(true);
}
@@ -1970,18 +2005,17 @@ void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
CRect rcclip(0, 0, w, h);
rcclip &= rc;
- if(m_psphli)
- {
+ 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)
- {
+ } else if(m_offsets.GetCount() > 1) {
POSITION pos = m_offsets.GetTailPosition();
- while(pos)
- {
+ while(pos) {
const offset_t& o = m_offsets.GetPrev(pos);
- if(rt >= o.rt) {sphli = o.sphli; break;}
+ if(rt >= o.rt) {
+ sphli = o.sphli;
+ break;
+ }
}
}
@@ -2000,22 +2034,24 @@ void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
+ 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)
- {
+ || (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;
+ 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
+ if(!fAligned) {
+ GetNibble(p, offset, nField, fAligned); // align to byte
+ }
pt.x = rc.left;
pt.y++;
@@ -2032,58 +2068,63 @@ bool CSubpicInputPin::cvdspu::Parse()
WORD packetsize = (p[0]<<8)|p[1];
WORD datasize = (p[2]<<8)|p[3];
- if(packetsize > GetCount() || datasize > packetsize)
+ 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;
+ 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;
}
}
@@ -2111,12 +2152,10 @@ void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
+ while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
BYTE code;
- if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4)
- {
+ 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;
@@ -2125,7 +2164,9 @@ void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
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++;
@@ -2140,41 +2181,48 @@ bool CSubpicInputPin::svcdspu::Parse()
BYTE* p = GetData();
BYTE* p0 = p;
- if(GetCount() < 2)
+ 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())
+ if(packetsize > GetCount()) {
return(false);
+ }
bool duration = !!(*p++&0x04);
*p++; // unknown
- if(duration)
- {
+ 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;
+ 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++)
- {
+ 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];
@@ -2203,16 +2251,18 @@ void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int
DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
+ 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;
+ 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++;
@@ -2232,14 +2282,18 @@ CClosedCaptionOutputPin::CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec*
HRESULT CClosedCaptionOutputPin::CheckMediaType(const CMediaType* mtOut)
{
return mtOut->majortype == MEDIATYPE_AUXLine21Data && mtOut->subtype == MEDIASUBTYPE_Line21_GOPPacket
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? 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;
@@ -2258,20 +2312,20 @@ HRESULT CClosedCaptionOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALL
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
}
HRESULT CClosedCaptionOutputPin::Deliver(const void* ptr, int len)
{
HRESULT hr = S_FALSE;
- if(len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected())
- {
+ if(len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected()) {
CComPtr<IMediaSample> pSample;
GetDeliveryBuffer(&pSample, NULL, NULL, 0);
BYTE* pData = NULL;
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
index 829ec6fa3..a6d5f10d2 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,12 +6,12 @@
* 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.
@@ -33,7 +33,7 @@ class CClosedCaptionOutputPin;
class CMpeg2Dec;
class __declspec(uuid("39F498AF-1A09-4275-B193-673B0BA3D478"))
-CMpeg2DecFilter
+ CMpeg2DecFilter
: public CBaseVideoFilter
, public IMpeg2DecFilter
, public ISpecifyPropertyPages2
@@ -48,39 +48,47 @@ CMpeg2DecFilter
bool m_fInitializedBuffer;
CSize m_par;
- struct framebuf
- {
+ struct framebuf {
int w, h, pitch;
BYTE* buf_base;
BYTE* buf[6];
REFERENCE_TIME rtStart, rtStop;
DWORD flags;
ditype di;
- framebuf()
- {
+ 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;
+ ~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;
+ 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);
+ void Free() {
+ if(buf_base) {
+ _aligned_free(buf_base);
+ }
buf_base = NULL;
}
} m_fb;
@@ -102,7 +110,7 @@ public:
virtual ~CMpeg2DecFilter();
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
HRESULT DeliverFast();
HRESULT DeliverNormal();
@@ -111,13 +119,13 @@ public:
int GetPinCount();
CBasePin* GetPin(int n);
- HRESULT EndOfStream();
+ HRESULT EndOfStream();
HRESULT BeginFlush();
HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
- HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckInputType(const CMediaType* mtIn);
HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
HRESULT StartStreaming();
@@ -139,7 +147,7 @@ protected:
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
@@ -181,15 +189,15 @@ class CMpeg2DecInputPin : public CDeCSSInputPin
LONG m_CorrectTS;
public:
- CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
+ CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
CCritSec m_csRateLock;
AM_SimpleRateChange m_ratechange;
// 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);
+ 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);
};
class CMpeg2DecOutputPin : public CBaseVideoOutputPin
@@ -200,13 +208,13 @@ public:
CAutoPtr<COutputQueue> m_pOutputQueue;
HRESULT Active();
- HRESULT Inactive();
+ HRESULT Inactive();
HRESULT Deliver(IMediaSample* pMediaSample);
- HRESULT DeliverEndOfStream();
- HRESULT DeliverBeginFlush();
+ HRESULT DeliverEndOfStream();
+ HRESULT DeliverBeginFlush();
HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
class CSubpicInputPin : public CMpeg2DecInputPin
@@ -222,11 +230,15 @@ class CSubpicInputPin : public CMpeg2DecInputPin
{
public:
bool m_fForced;
- REFERENCE_TIME m_rtStart, m_rtStop;
+ 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;}
+ 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;
@@ -235,7 +247,10 @@ class CSubpicInputPin : public CMpeg2DecInputPin
class dvdspu : public spu
{
public:
- struct offset_t {REFERENCE_TIME rt; AM_PROPERTY_SPHLI sphli;};
+ 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);
@@ -245,7 +260,9 @@ class CSubpicInputPin : public CMpeg2DecInputPin
{
public:
AM_DVD_YUV m_sppal[2][4];
- cvdspu() {memset(m_sppal, 0, sizeof(m_sppal));}
+ 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);
};
@@ -254,7 +271,9 @@ class CSubpicInputPin : public CMpeg2DecInputPin
{
public:
AM_DVD_YUV m_sppal[4];
- svcdspu() {memset(m_sppal, 0, sizeof(m_sppal));}
+ 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);
};
@@ -270,18 +289,24 @@ public:
bool HasAnythingToRender(REFERENCE_TIME rt);
void RenderSubpics(REFERENCE_TIME rt, BYTE** p, int w, int h);
- HRESULT CheckMediaType(const CMediaType* mtIn);
+ 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;}
- STDMETHODIMP EndFlush();
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) {return S_OK;}
+ 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;
+ }
// IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
+ STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
+ STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
};
class CClosedCaptionOutputPin : public CBaseOutputPin
@@ -289,11 +314,13 @@ class CClosedCaptionOutputPin : public CBaseOutputPin
public:
CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- HRESULT CheckMediaType(const CMediaType* mtOut);
+ HRESULT CheckMediaType(const CMediaType* mtOut);
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- CMediaType& CurrentMediaType() {return m_mt;}
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
HRESULT Deliver(const void* ptr, int len);
};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
index c8de3e7ea..4be2a2f54 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,12 +6,12 @@
* 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.
@@ -51,9 +51,13 @@ bool CMpeg2DecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknow
m_pM2DF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pM2DF = pUnks.GetNext(pos)));
-
- if(!m_pM2DF) return false;
+ while(pos && !(m_pM2DF = pUnks.GetNext(pos))) {
+ ;
+ }
+
+ if(!m_pM2DF) {
+ return false;
+ }
m_ditype = m_pM2DF->GetDeinterlaceMethod();
m_procamp[0] = m_pM2DF->GetBrightness();
@@ -107,15 +111,15 @@ bool CMpeg2DecSettingsWnd::OnActivate()
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("ELA")), (DWORD)DIELA);
m_ditype_combo.SetCurSel(0);
for(int i = 0; i < m_ditype_combo.GetCount(); i++)
- if((int)m_ditype_combo.GetItemData(i) == m_ditype)
+ if((int)m_ditype_combo.GetItemData(i) == m_ditype) {
m_ditype_combo.SetCurSel(i);
+ }
m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
p.y += m_fontheight + 20;
- for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_procamp_slider); i++, p.y += h)
- {
+ 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);
@@ -149,8 +153,9 @@ bool CMpeg2DecSettingsWnd::OnActivate()
ResStr(IDS_MPEG2DECSETTINGSWND_8),
dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
return true;
}
@@ -172,8 +177,7 @@ bool CMpeg2DecSettingsWnd::OnApply()
{
OnDeactivate();
- if(m_pM2DF)
- {
+ if(m_pM2DF) {
m_pM2DF->SetDeinterlaceMethod(m_ditype);
m_pM2DF->SetBrightness(m_procamp[0]);
m_pM2DF->SetContrast(m_procamp[1]);
@@ -205,7 +209,7 @@ void CMpeg2DecSettingsWnd::UpdateProcampValues()
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_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
ON_WM_HSCROLL()
END_MESSAGE_MAP()
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
index a358fdb8a..9a3e25939 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,12 +6,12 @@
* 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.
@@ -26,7 +26,7 @@
#include <afxcmn.h>
class __declspec(uuid("E5FB6957-65E6-491B-BB37-B25C9FE3BEA7"))
-CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
+ CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
{
CComQIPtr<IMpeg2DecFilter> m_pM2DF;
@@ -37,8 +37,7 @@ CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
bool m_forcedsubs;
bool m_readARFromStream;
- enum
- {
+ enum {
IDC_PP_COMBO1 = 10000,
IDC_PP_SLIDER1,
IDC_PP_SLIDER2,
@@ -69,15 +68,19 @@ CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
public:
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()
diff --git a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
index 134707c76..7eab60218 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
*
@@ -47,276 +47,276 @@ static __align16(const short,M128_tg_2_16[8]) = {27146, 27146, 27146, 27146, 271
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)
{
- 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)
+ __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)
{
-__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();
+ __m128i zero = _mm_setzero_si128();
- __m128i r0 = _mm_packus_epi16(_mm_load_si128(&src0), _mm_load_si128(&src1));
- __m128i r1 = _mm_packus_epi16(_mm_load_si128(&src2), _mm_load_si128(&src3));
- __m128i r2 = _mm_packus_epi16(_mm_load_si128(&src4), _mm_load_si128(&src5));
- __m128i r3 = _mm_packus_epi16(_mm_load_si128(&src6), _mm_load_si128(&src7));
+ __m128i r0 = _mm_packus_epi16(_mm_load_si128(&src0), _mm_load_si128(&src1));
+ __m128i r1 = _mm_packus_epi16(_mm_load_si128(&src2), _mm_load_si128(&src3));
+ __m128i r2 = _mm_packus_epi16(_mm_load_si128(&src4), _mm_load_si128(&src5));
+ __m128i r3 = _mm_packus_epi16(_mm_load_si128(&src6), _mm_load_si128(&src7));
- _mm_storel_pi((__m64*)&dest[0*stride], *(__m128*)&r0);
- _mm_storeh_pi((__m64*)&dest[1*stride], *(__m128*)&r0);
- _mm_storel_pi((__m64*)&dest[2*stride], *(__m128*)&r1);
- _mm_storeh_pi((__m64*)&dest[3*stride], *(__m128*)&r1);
- _mm_storel_pi((__m64*)&dest[4*stride], *(__m128*)&r2);
- _mm_storeh_pi((__m64*)&dest[5*stride], *(__m128*)&r2);
- _mm_storel_pi((__m64*)&dest[6*stride], *(__m128*)&r3);
- _mm_storeh_pi((__m64*)&dest[7*stride], *(__m128*)&r3);
+ _mm_storel_pi((__m64*)&dest[0*stride], *(__m128*)&r0);
+ _mm_storeh_pi((__m64*)&dest[1*stride], *(__m128*)&r0);
+ _mm_storel_pi((__m64*)&dest[2*stride], *(__m128*)&r1);
+ _mm_storeh_pi((__m64*)&dest[3*stride], *(__m128*)&r1);
+ _mm_storel_pi((__m64*)&dest[4*stride], *(__m128*)&r2);
+ _mm_storeh_pi((__m64*)&dest[5*stride], *(__m128*)&r2);
+ _mm_storel_pi((__m64*)&dest[6*stride], *(__m128*)&r3);
+ _mm_storeh_pi((__m64*)&dest[7*stride], *(__m128*)&r3);
- _mm_store_si128(&src0, zero);
- _mm_store_si128(&src1, zero);
- _mm_store_si128(&src2, zero);
- _mm_store_si128(&src3, zero);
- _mm_store_si128(&src4, zero);
- _mm_store_si128(&src5, zero);
- _mm_store_si128(&src6, zero);
- _mm_store_si128(&src7, zero);
+ _mm_store_si128(&src0, zero);
+ _mm_store_si128(&src1, zero);
+ _mm_store_si128(&src2, zero);
+ _mm_store_si128(&src3, zero);
+ _mm_store_si128(&src4, zero);
+ _mm_store_si128(&src5, zero);
+ _mm_store_si128(&src6, zero);
+ _mm_store_si128(&src7, zero);
}
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();
+ __m128i zero = _mm_setzero_si128();
- __m128i r0 = _mm_load_si128(&src0);
- __m128i r1 = _mm_load_si128(&src1);
- __m128i r2 = _mm_load_si128(&src2);
- __m128i r3 = _mm_load_si128(&src3);
- __m128i r4 = _mm_load_si128(&src4);
- __m128i r5 = _mm_load_si128(&src5);
- __m128i r6 = _mm_load_si128(&src6);
- __m128i r7 = _mm_load_si128(&src7);
+ __m128i r0 = _mm_load_si128(&src0);
+ __m128i r1 = _mm_load_si128(&src1);
+ __m128i r2 = _mm_load_si128(&src2);
+ __m128i r3 = _mm_load_si128(&src3);
+ __m128i r4 = _mm_load_si128(&src4);
+ __m128i r5 = _mm_load_si128(&src5);
+ __m128i r6 = _mm_load_si128(&src6);
+ __m128i r7 = _mm_load_si128(&src7);
- __m128 q0 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[0*stride]);
- __m128 q1 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[1*stride]);
- __m128 q2 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[2*stride]);
- __m128 q3 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[3*stride]);
- __m128 q4 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[4*stride]);
- __m128 q5 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[5*stride]);
- __m128 q6 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[6*stride]);
- __m128 q7 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[7*stride]);
+ __m128 q0 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[0*stride]);
+ __m128 q1 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[1*stride]);
+ __m128 q2 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[2*stride]);
+ __m128 q3 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[3*stride]);
+ __m128 q4 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[4*stride]);
+ __m128 q5 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[5*stride]);
+ __m128 q6 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[6*stride]);
+ __m128 q7 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[7*stride]);
- r0 = _mm_adds_epi16(r0, _mm_unpacklo_epi8(*(__m128i*)&q0, zero));
- r1 = _mm_adds_epi16(r1, _mm_unpacklo_epi8(*(__m128i*)&q1, zero));
- r2 = _mm_adds_epi16(r2, _mm_unpacklo_epi8(*(__m128i*)&q2, zero));
- r3 = _mm_adds_epi16(r3, _mm_unpacklo_epi8(*(__m128i*)&q3, zero));
- r4 = _mm_adds_epi16(r4, _mm_unpacklo_epi8(*(__m128i*)&q4, zero));
- r5 = _mm_adds_epi16(r5, _mm_unpacklo_epi8(*(__m128i*)&q5, zero));
- r6 = _mm_adds_epi16(r6, _mm_unpacklo_epi8(*(__m128i*)&q6, zero));
- r7 = _mm_adds_epi16(r7, _mm_unpacklo_epi8(*(__m128i*)&q7, zero));
+ r0 = _mm_adds_epi16(r0, _mm_unpacklo_epi8(*(__m128i*)&q0, zero));
+ r1 = _mm_adds_epi16(r1, _mm_unpacklo_epi8(*(__m128i*)&q1, zero));
+ r2 = _mm_adds_epi16(r2, _mm_unpacklo_epi8(*(__m128i*)&q2, zero));
+ r3 = _mm_adds_epi16(r3, _mm_unpacklo_epi8(*(__m128i*)&q3, zero));
+ r4 = _mm_adds_epi16(r4, _mm_unpacklo_epi8(*(__m128i*)&q4, zero));
+ r5 = _mm_adds_epi16(r5, _mm_unpacklo_epi8(*(__m128i*)&q5, zero));
+ r6 = _mm_adds_epi16(r6, _mm_unpacklo_epi8(*(__m128i*)&q6, zero));
+ r7 = _mm_adds_epi16(r7, _mm_unpacklo_epi8(*(__m128i*)&q7, zero));
- r0 = _mm_packus_epi16(r0, r1);
- r1 = _mm_packus_epi16(r2, r3);
- r2 = _mm_packus_epi16(r4, r5);
- r3 = _mm_packus_epi16(r6, r7);
+ r0 = _mm_packus_epi16(r0, r1);
+ r1 = _mm_packus_epi16(r2, r3);
+ r2 = _mm_packus_epi16(r4, r5);
+ r3 = _mm_packus_epi16(r6, r7);
- _mm_storel_pi((__m64*)&dest[0*stride], *(__m128*)&r0);
- _mm_storeh_pi((__m64*)&dest[1*stride], *(__m128*)&r0);
- _mm_storel_pi((__m64*)&dest[2*stride], *(__m128*)&r1);
- _mm_storeh_pi((__m64*)&dest[3*stride], *(__m128*)&r1);
- _mm_storel_pi((__m64*)&dest[4*stride], *(__m128*)&r2);
- _mm_storeh_pi((__m64*)&dest[5*stride], *(__m128*)&r2);
- _mm_storel_pi((__m64*)&dest[6*stride], *(__m128*)&r3);
- _mm_storeh_pi((__m64*)&dest[7*stride], *(__m128*)&r3);
+ _mm_storel_pi((__m64*)&dest[0*stride], *(__m128*)&r0);
+ _mm_storeh_pi((__m64*)&dest[1*stride], *(__m128*)&r0);
+ _mm_storel_pi((__m64*)&dest[2*stride], *(__m128*)&r1);
+ _mm_storeh_pi((__m64*)&dest[3*stride], *(__m128*)&r1);
+ _mm_storel_pi((__m64*)&dest[4*stride], *(__m128*)&r2);
+ _mm_storeh_pi((__m64*)&dest[5*stride], *(__m128*)&r2);
+ _mm_storel_pi((__m64*)&dest[6*stride], *(__m128*)&r3);
+ _mm_storeh_pi((__m64*)&dest[7*stride], *(__m128*)&r3);
- _mm_store_si128(&src0, zero);
- _mm_store_si128(&src1, zero);
- _mm_store_si128(&src2, zero);
- _mm_store_si128(&src3, zero);
- _mm_store_si128(&src4, zero);
- _mm_store_si128(&src5, zero);
- _mm_store_si128(&src6, zero);
- _mm_store_si128(&src7, zero);
+ _mm_store_si128(&src0, zero);
+ _mm_store_si128(&src1, zero);
+ _mm_store_si128(&src2, zero);
+ _mm_store_si128(&src3, zero);
+ _mm_store_si128(&src4, zero);
+ _mm_store_si128(&src5, zero);
+ _mm_store_si128(&src6, zero);
+ _mm_store_si128(&src7, zero);
}
void mpeg2_idct_init_sse2()
diff --git a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
index 3d5061bd0..c71dad156 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
*
@@ -31,459 +31,452 @@ 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}
+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
+ }
};
diff --git a/src/filters/transform/Mpeg2DecFilter/stdafx.cpp b/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
index 13934d005..bea3f980a 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,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/Mpeg2DecFilter/stdafx.h b/src/filters/transform/Mpeg2DecFilter/stdafx.h
index e1b753d82..2e566de2c 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,12 +6,12 @@
* 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.
diff --git a/src/filters/transform/VSFilter/AvgLines.cpp b/src/filters/transform/VSFilter/AvgLines.cpp
index 19e80a305..2a0b89311 100644
--- a/src/filters/transform/VSFilter/AvgLines.cpp
+++ b/src/filters/transform/VSFilter/AvgLines.cpp
@@ -20,28 +20,26 @@
void AvgLines8(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
BYTE* tmp = s;
#ifndef _WIN64
- if((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)tmp&0xf) && !((DWORD)pitch&0xf))
- {
- __asm
- {
+ if((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)tmp&0xf) && !((DWORD)pitch&0xf)) {
+ __asm {
mov esi, tmp
mov ebx, pitch
mov ecx, ebx
shr ecx, 4
-AvgLines8_sse2_loop:
+ AvgLines8_sse2_loop:
movdqa xmm0, [esi]
pavgb xmm0, [esi+ebx*2]
movdqa [esi+ebx], xmm0
@@ -53,15 +51,11 @@ AvgLines8_sse2_loop:
mov tmp, esi
}
- for(ptrdiff_t i = pitch&7; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch&7; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
- }
- else if(g_cpuid.m_flags & CCpuID::mmx)
- {
- __asm
- {
+ } else if(g_cpuid.m_flags & CCpuID::mmx) {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -69,7 +63,7 @@ AvgLines8_sse2_loop:
shr ecx, 3
pxor mm7, mm7
-AvgLines8_mmx_loop:
+ AvgLines8_mmx_loop:
movq mm0, [esi]
movq mm1, mm0
@@ -100,23 +94,19 @@ AvgLines8_mmx_loop:
mov tmp, esi
}
- for(ptrdiff_t i = pitch&7; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch&7; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
- }
- else
+ } else
#endif
{
- for(ptrdiff_t i = pitch; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
@@ -128,8 +118,9 @@ AvgLines8_mmx_loop:
void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
unsigned __int64 __0x03e003e003e003e0 = 0x03e003e003e003e0;
unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
@@ -137,13 +128,11 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
BYTE* tmp = s;
#ifndef _WIN64
- __asm
- {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -153,7 +142,7 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
movq mm6, __0x03e003e003e003e0
movq mm7, __0x001f001f001f001f
-AvgLines555_loop:
+ AvgLines555_loop:
movq mm0, [esi]
movq mm1, mm0
movq mm2, mm0
@@ -196,8 +185,7 @@ AvgLines555_loop:
}
#endif
- for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
- {
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++) {
tmp[pitch] =
((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
((((*tmp&0x03e0) + (tmp[pitch<<1]&0x03e0)) >> 1)&0x03e0)|
@@ -205,8 +193,7 @@ AvgLines555_loop:
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
@@ -218,8 +205,9 @@ AvgLines555_loop:
void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
unsigned __int64 __0x07e007e007e007e0 = 0x07e007e007e007e0;
unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
@@ -227,13 +215,11 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
WORD* tmp = (WORD*)s;
#ifndef _WIN64
- __asm
- {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -243,7 +229,7 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
movq mm6, __0x07e007e007e007e0
movq mm7, __0x001f001f001f001f
-AvgLines565_loop:
+ AvgLines565_loop:
movq mm0, [esi]
movq mm1, mm0
movq mm2, mm0
@@ -285,8 +271,7 @@ AvgLines565_loop:
mov tmp, esi
}
#else
- for(ptrdiff_t wd=(pitch>>3); wd--; tmp++)
- {
+ for(ptrdiff_t wd=(pitch>>3); wd--; tmp++) {
tmp[0] =
((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
@@ -294,8 +279,7 @@ AvgLines565_loop:
}
#endif
- for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
- {
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++) {
tmp[pitch] =
((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
@@ -303,8 +287,7 @@ AvgLines565_loop:
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
diff --git a/src/filters/transform/VSFilter/Copy.cpp b/src/filters/transform/VSFilter/Copy.cpp
index 7c6e077ea..575b2103d 100644
--- a/src/filters/transform/VSFilter/Copy.cpp
+++ b/src/filters/transform/VSFilter/Copy.cpp
@@ -33,82 +33,62 @@ extern void ColorConvInit();
void BltLineRGB32(DWORD* d, BYTE* sub, int w, const GUID& subtype)
{
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
- {
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
BYTE* db = (BYTE*)d;
BYTE* dbtend = db + w;
- for(; db < dbtend; sub+=4, db++)
- {
- if(sub[3] < 0xff)
- {
+ for(; db < dbtend; sub+=4, db++) {
+ if(sub[3] < 0xff) {
int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
*db = y; // w/o colors
}
}
- }
- else if(subtype == MEDIASUBTYPE_YUY2)
- {
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ for(; ds < dstend; sub+=4, ds++) {
+ if(sub[3] < 0xff) {
int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
*ds = 0x8000|y; // w/o colors
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB555)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ for(; ds < dstend; sub+=4, ds++) {
+ if(sub[3] < 0xff) {
*ds = ((*((DWORD*)sub)>>9)&0x7c00)|((*((DWORD*)sub)>>6)&0x03e0)|((*((DWORD*)sub)>>3)&0x001f);
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB565)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ for(; ds < dstend; sub+=4, ds++) {
+ if(sub[3] < 0xff) {
*ds = ((*((DWORD*)sub)>>8)&0xf800)|((*((DWORD*)sub)>>5)&0x07e0)|((*((DWORD*)sub)>>3)&0x001f);
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB24)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB24) {
BYTE* dt = (BYTE*)d;
BYTE* dstend = dt + w*3;
- for(; dt < dstend; sub+=4, dt+=3)
- {
- if(sub[3] < 0xff)
- {
+ for(; dt < dstend; sub+=4, dt+=3) {
+ if(sub[3] < 0xff) {
dt[0] = sub[0];
dt[1] = sub[1];
dt[2] = sub[2];
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
DWORD* dstend = d + w;
- for(; d < dstend; sub+=4, d++)
- {
- if(sub[3] < 0xff) *d = *((DWORD*)sub)&0xffffff;
+ for(; d < dstend; sub+=4, d++) {
+ if(sub[3] < 0xff) {
+ *d = *((DWORD*)sub)&0xffffff;
+ }
}
}
}
@@ -119,7 +99,9 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
int wSub = sub.cx, hSub = sub.cy, pitchSub = wSub*bpp>>3;
bool fScale2x = wIn*2 <= wSub;
- if(fScale2x) wIn <<= 1, hIn <<= 1;
+ if(fScale2x) {
+ wIn <<= 1, hIn <<= 1;
+ }
int left = ((wSub - wIn)>>1)&~1;
int mid = wIn;
@@ -136,32 +118,27 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
j += (hSub - hIn) >> 1;
- for(; i < j; i++, pSub += pitchSub)
- {
+ for(; i < j; i++, pSub += pitchSub) {
memsetd(pSub, black, dpLeft+dpMid+dpRight);
}
j += hIn;
- if(hIn > hSub)
+ if(hIn > hSub) {
pIn += pitchIn * ((hIn - hSub) >> (fScale2x?2:1));
+ }
- if(fScale2x)
- {
+ if(fScale2x) {
Scale2x(subtype,
pSub + dpLeft, pitchSub, pIn, pitchIn,
in.cx, (min(j, hSub) - i) >> 1);
- for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
- {
+ for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
memsetd(pSub, black, dpLeft);
memsetd(pSub + dpLeft+dpMid, black, dpRight);
}
- }
- else
- {
- for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
- {
+ } else {
+ for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
memsetd(pSub, black, dpLeft);
memcpy(pSub + dpLeft, pIn, dpMid);
memsetd(pSub + dpLeft+dpMid, black, dpRight);
@@ -170,8 +147,7 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
j = hSub;
- for(; i < j; i++, pSub += pitchSub)
- {
+ for(; i < j; i++, pSub += pitchSub) {
memsetd(pSub, black, dpLeft+dpMid+dpRight);
}
}
@@ -181,8 +157,9 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
{
- if(!m_hdc || !m_hbm)
+ if(!m_hdc || !m_hbm) {
return;
+ }
ColorConvInit();
@@ -193,8 +170,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
CString msg, tmp;
- if(m_fOSD)
- {
+ if(m_fOSD) {
tmp.Format(_T("in: %dx%d %s\nout: %dx%d %s\n"),
m_w, m_h,
Subtype2String(m_pInput->CurrentMediaType().subtype),
@@ -211,16 +187,14 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
int nSubPics = -1;
REFERENCE_TIME rtNow = -1, rtStart = -1, rtStop = -1;
m_pSubPicQueue->GetStats(nSubPics, rtNow, rtStart, rtStop);
tmp.Format(_T("queue stats: %I64d - %I64d [ms]\n"), rtStart/10000, rtStop/10000);
msg += tmp;
- for(ptrdiff_t i = 0; i < nSubPics; i++)
- {
+ for(ptrdiff_t i = 0; i < nSubPics; i++) {
m_pSubPicQueue->GetStats(i, rtStart, rtStop);
tmp.Format(_T("%d: %I64d - %I64d [ms]\n"), i, rtStart/10000, rtStop/10000);
msg += tmp;
@@ -229,7 +203,9 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
}
}
- if(msg.IsEmpty()) return;
+ if(msg.IsEmpty()) {
+ return;
+ }
HANDLE hOldBitmap = SelectObject(m_hdc, m_hbm);
HANDLE hOldFont = SelectObject(m_hdc, m_hfont);
@@ -253,14 +229,14 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
int pitchIn = bm.bmWidthBytes;
int pitchOut = bihOut.biWidth * bihOut.biBitCount >> 3;
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
pitchOut = bihOut.biWidth;
+ }
pitchIn = (pitchIn+3)&~3;
pitchOut = (pitchOut+3)&~3;
- if(bihOut.biHeight > 0 && bihOut.biCompression <= 3) // flip if the dst bitmap is flipped rgb (m_hbm is a top-down bitmap, not like the subpictures)
- {
+ if(bihOut.biHeight > 0 && bihOut.biCompression <= 3) { // flip if the dst bitmap is flipped rgb (m_hbm is a top-down bitmap, not like the subpictures)
pOut += pitchOut * (abs(bihOut.biHeight)-1);
pitchOut = -pitchOut;
}
@@ -268,8 +244,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
pIn += pitchIn * r.top;
pOut += pitchOut * r.top;
- for(ptrdiff_t w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut)
- {
+ for(ptrdiff_t w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut) {
BltLineRGB32((DWORD*)pOut, pIn, w, subtype);
memsetd(pIn, 0xff000000, r.right*4);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSub.cpp b/src/filters/transform/VSFilter/DirectVobSub.cpp
index 59d3a8ec1..8ae4bba69 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSub.cpp
@@ -53,10 +53,12 @@ CDirectVobSub::CDirectVobSub()
m_fMediaFPSEnabled = !!theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), 0);
m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), 0));
pData = NULL;
- if(theApp.GetProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), &pData, &nSize) && pData)
- {
- if(nSize != sizeof(m_MediaFPS)) m_MediaFPS = 25.0;
- else memcpy(&m_MediaFPS, pData, sizeof(m_MediaFPS));
+ if(theApp.GetProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), &pData, &nSize) && pData) {
+ if(nSize != sizeof(m_MediaFPS)) {
+ m_MediaFPS = 25.0;
+ } else {
+ memcpy(&m_MediaFPS, pData, sizeof(m_MediaFPS));
+ }
delete [] pData;
}
m_ZoomRect.left = m_ZoomRect.top = 0;
@@ -74,7 +76,9 @@ STDMETHODIMP CDirectVobSub::get_FileName(WCHAR* fn)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fn) return E_POINTER;
+ if(!fn) {
+ return E_POINTER;
+ }
#ifdef UNICODE
wcscpy(fn, m_FileName);
@@ -89,10 +93,14 @@ STDMETHODIMP CDirectVobSub::put_FileName(WCHAR* fn)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fn) return E_POINTER;
+ if(!fn) {
+ return E_POINTER;
+ }
CString tmp = fn;
- if(!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) return S_FALSE;
+ if(!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) {
+ return S_FALSE;
+ }
#ifdef UNICODE
m_FileName = fn;
@@ -130,13 +138,16 @@ STDMETHODIMP CDirectVobSub::put_SelectedLanguage(int iSelected)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_iSelectedLanguage == iSelected) return S_FALSE;
+ if(m_iSelectedLanguage == iSelected) {
+ return S_FALSE;
+ }
int nCount;
if(FAILED(get_LanguageCount(&nCount))
- || iSelected < 0
- || iSelected >= nCount)
+ || iSelected < 0
+ || iSelected >= nCount) {
return E_FAIL;
+ }
m_iSelectedLanguage = iSelected;
@@ -154,7 +165,9 @@ STDMETHODIMP CDirectVobSub::put_HideSubtitles(bool fHideSubtitles)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fHideSubtitles == fHideSubtitles) return S_FALSE;
+ if(m_fHideSubtitles == fHideSubtitles) {
+ return S_FALSE;
+ }
m_fHideSubtitles = fHideSubtitles;
@@ -172,7 +185,9 @@ STDMETHODIMP CDirectVobSub::put_PreBuffering(bool fDoPreBuffering)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fDoPreBuffering == fDoPreBuffering) return S_FALSE;
+ if(m_fDoPreBuffering == fDoPreBuffering) {
+ return S_FALSE;
+ }
m_fDoPreBuffering = fDoPreBuffering;
@@ -183,9 +198,15 @@ STDMETHODIMP CDirectVobSub::get_Placement(bool* fOverridePlacement, int* xperc,
{
CAutoLock cAutoLock(&m_propsLock);
- if(fOverridePlacement) *fOverridePlacement = m_fOverridePlacement;
- if(xperc) *xperc = m_PlacementXperc;
- if(yperc) *yperc = m_PlacementYperc;
+ if(fOverridePlacement) {
+ *fOverridePlacement = m_fOverridePlacement;
+ }
+ if(xperc) {
+ *xperc = m_PlacementXperc;
+ }
+ if(yperc) {
+ *yperc = m_PlacementYperc;
+ }
return S_OK;
}
@@ -194,7 +215,9 @@ STDMETHODIMP CDirectVobSub::put_Placement(bool fOverridePlacement, int xperc, in
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) return S_FALSE;
+ if(m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) {
+ return S_FALSE;
+ }
m_fOverridePlacement = fOverridePlacement;
m_PlacementXperc = xperc;
@@ -207,9 +230,15 @@ STDMETHODIMP CDirectVobSub::get_VobSubSettings(bool* fBuffer, bool* fOnlyShowFor
{
CAutoLock cAutoLock(&m_propsLock);
- if(fBuffer) *fBuffer = m_fBufferVobSub;
- if(fOnlyShowForcedSubs) *fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
- if(fPolygonize) *fPolygonize = m_fPolygonize;
+ if(fBuffer) {
+ *fBuffer = m_fBufferVobSub;
+ }
+ if(fOnlyShowForcedSubs) {
+ *fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
+ }
+ if(fPolygonize) {
+ *fPolygonize = m_fPolygonize;
+ }
return S_OK;
}
@@ -218,7 +247,9 @@ STDMETHODIMP CDirectVobSub::put_VobSubSettings(bool fBuffer, bool fOnlyShowForce
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) return S_FALSE;
+ if(m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) {
+ return S_FALSE;
+ }
m_fBufferVobSub = fBuffer;
m_fOnlyShowForcedVobSubs = fOnlyShowForcedSubs;
@@ -231,14 +262,14 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo
{
CAutoLock cAutoLock(&m_propsLock);
- if(lf)
- {
- if(lflen == sizeof(LOGFONTA))
+ if(lf) {
+ if(lflen == sizeof(LOGFONTA)) {
strncpy_s(((LOGFONTA*)lf)->lfFaceName, LF_FACESIZE, CStringA(m_defStyle.fontName), _TRUNCATE);
- else if(lflen == sizeof(LOGFONTW))
+ } else if(lflen == sizeof(LOGFONTW)) {
wcsncpy_s(((LOGFONTW*)lf)->lfFaceName, LF_FACESIZE, CStringW(m_defStyle.fontName), _TRUNCATE);
- else
+ } else {
return E_INVALIDARG;
+ }
((LOGFONT*)lf)->lfCharSet = m_defStyle.charSet;
((LOGFONT*)lf)->lfItalic = m_defStyle.fItalic;
@@ -248,10 +279,18 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo
((LOGFONT*)lf)->lfUnderline = m_defStyle.fUnderline;
}
- if(color) *color = m_defStyle.colors[0];
- if(fShadow) *fShadow = (m_defStyle.shadowDepthX!=0) || (m_defStyle.shadowDepthY!=0);
- if(fOutline) *fOutline = (m_defStyle.outlineWidthX+m_defStyle.outlineWidthY)>0;
- if(fAdvancedRenderer) *fAdvancedRenderer = m_fAdvancedRenderer;
+ if(color) {
+ *color = m_defStyle.colors[0];
+ }
+ if(fShadow) {
+ *fShadow = (m_defStyle.shadowDepthX!=0) || (m_defStyle.shadowDepthY!=0);
+ }
+ if(fOutline) {
+ *fOutline = (m_defStyle.outlineWidthX+m_defStyle.outlineWidthY)>0;
+ }
+ if(fAdvancedRenderer) {
+ *fAdvancedRenderer = m_fAdvancedRenderer;
+ }
return S_OK;
}
@@ -260,14 +299,14 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color
{
CAutoLock cAutoLock(&m_propsLock);
- if(lf)
- {
- if(lflen == sizeof(LOGFONTA))
+ if(lf) {
+ if(lflen == sizeof(LOGFONTA)) {
m_defStyle.fontName = ((LOGFONTA*)lf)->lfFaceName;
- else if(lflen == sizeof(LOGFONTW))
+ } else if(lflen == sizeof(LOGFONTW)) {
m_defStyle.fontName = ((LOGFONTW*)lf)->lfFaceName;
- else
+ } else {
return E_INVALIDARG;
+ }
m_defStyle.charSet = ((LOGFONT*)lf)->lfCharSet;
m_defStyle.fItalic = !!((LOGFONT*)lf)->lfItalic;
@@ -276,8 +315,7 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color
m_defStyle.fStrikeOut = !!((LOGFONT*)lf)->lfStrikeOut;
m_defStyle.fUnderline = !!((LOGFONT*)lf)->lfUnderline;
- if(m_defStyle.fontSize < 0)
- {
+ if(m_defStyle.fontSize < 0) {
HDC hdc = ::GetDC(0);
m_defStyle.fontSize = -m_defStyle.fontSize * 72 / GetDeviceCaps(hdc, LOGPIXELSY);
::ReleaseDC(0, hdc);
@@ -297,8 +335,12 @@ STDMETHODIMP CDirectVobSub::get_Flip(bool* fPicture, bool* fSubtitles)
{
CAutoLock cAutoLock(&m_propsLock);
- if(fPicture) *fPicture = m_fFlipPicture;
- if(fSubtitles) *fSubtitles = m_fFlipSubtitles;
+ if(fPicture) {
+ *fPicture = m_fFlipPicture;
+ }
+ if(fSubtitles) {
+ *fSubtitles = m_fFlipSubtitles;
+ }
return S_OK;
}
@@ -307,7 +349,9 @@ STDMETHODIMP CDirectVobSub::put_Flip(bool fPicture, bool fSubtitles)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) return S_FALSE;
+ if(m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) {
+ return S_FALSE;
+ }
m_fFlipPicture = fPicture;
m_fFlipSubtitles = fSubtitles;
@@ -326,7 +370,9 @@ STDMETHODIMP CDirectVobSub::put_OSD(bool fOSD)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fOSD == fOSD) return S_FALSE;
+ if(m_fOSD == fOSD) {
+ return S_FALSE;
+ }
m_fOSD = fOSD;
@@ -344,7 +390,9 @@ STDMETHODIMP CDirectVobSub::put_SaveFullPath(bool fSaveFullPath)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fSaveFullPath == fSaveFullPath) return S_FALSE;
+ if(m_fSaveFullPath == fSaveFullPath) {
+ return S_FALSE;
+ }
m_fSaveFullPath = fSaveFullPath;
@@ -355,9 +403,15 @@ STDMETHODIMP CDirectVobSub::get_SubtitleTiming(int* delay, int* speedmul, int* s
{
CAutoLock cAutoLock(&m_propsLock);
- if(delay) *delay = m_SubtitleDelay;
- if(speedmul) *speedmul = m_SubtitleSpeedMul;
- if(speeddiv) *speeddiv = m_SubtitleSpeedDiv;
+ if(delay) {
+ *delay = m_SubtitleDelay;
+ }
+ if(speedmul) {
+ *speedmul = m_SubtitleSpeedMul;
+ }
+ if(speeddiv) {
+ *speeddiv = m_SubtitleSpeedDiv;
+ }
return S_OK;
}
@@ -366,11 +420,15 @@ STDMETHODIMP CDirectVobSub::put_SubtitleTiming(int delay, int speedmul, int spee
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) return S_FALSE;
+ if(m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) {
+ return S_FALSE;
+ }
m_SubtitleDelay = delay;
m_SubtitleSpeedMul = speedmul;
- if(speeddiv > 0) m_SubtitleSpeedDiv = speeddiv;
+ if(speeddiv > 0) {
+ m_SubtitleSpeedDiv = speeddiv;
+ }
return S_OK;
}
@@ -379,8 +437,12 @@ STDMETHODIMP CDirectVobSub::get_MediaFPS(bool* fEnabled, double* fps)
{
CAutoLock cAutoLock(&m_propsLock);
- if(fEnabled) *fEnabled = m_fMediaFPSEnabled;
- if(fps) *fps = m_MediaFPS;
+ if(fEnabled) {
+ *fEnabled = m_fMediaFPSEnabled;
+ }
+ if(fps) {
+ *fps = m_MediaFPS;
+ }
return S_OK;
}
@@ -389,10 +451,14 @@ STDMETHODIMP CDirectVobSub::put_MediaFPS(bool fEnabled, double fps)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) return S_FALSE;
+ if(m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) {
+ return S_FALSE;
+ }
m_fMediaFPSEnabled = fEnabled;
- if(fps > 0) m_MediaFPS = fps;
+ if(fps > 0) {
+ m_MediaFPS = fps;
+ }
return S_OK;
}
@@ -401,7 +467,9 @@ STDMETHODIMP CDirectVobSub::get_ZoomRect(NORMALIZEDRECT* rect)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!rect) return E_POINTER;
+ if(!rect) {
+ return E_POINTER;
+ }
*rect = m_ZoomRect;
@@ -412,9 +480,13 @@ STDMETHODIMP CDirectVobSub::put_ZoomRect(NORMALIZEDRECT* rect)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!rect) return E_POINTER;
+ if(!rect) {
+ return E_POINTER;
+ }
- if(!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) return S_FALSE;
+ if(!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) {
+ return S_FALSE;
+ }
m_ZoomRect = *rect;
@@ -465,7 +537,9 @@ STDMETHODIMP CDirectVobSub::IsSubtitleReloaderLocked(bool* fLocked)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fLocked) return E_POINTER;
+ if(!fLocked) {
+ return E_POINTER;
+ }
bool fDisabled;
get_SubtitleReloader(&fDisabled);
@@ -479,11 +553,16 @@ STDMETHODIMP CDirectVobSub::LockSubtitleReloader(bool fLock)
{
CAutoLock cAutoLock(&m_propsLock);
- if(fLock) m_nReloaderDisableCount++;
- else m_nReloaderDisableCount--;
+ if(fLock) {
+ m_nReloaderDisableCount++;
+ } else {
+ m_nReloaderDisableCount--;
+ }
ASSERT(m_nReloaderDisableCount >= 0);
- if(m_nReloaderDisableCount < 0) m_nReloaderDisableCount = 0;
+ if(m_nReloaderDisableCount < 0) {
+ m_nReloaderDisableCount = 0;
+ }
return S_OK;
}
@@ -494,7 +573,9 @@ STDMETHODIMP CDirectVobSub::get_SubtitleReloader(bool* fDisabled)
CAutoLock cAutoLock(&m_propsLock);
- if(fDisabled) *fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
+ if(fDisabled) {
+ *fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
+ }
return S_OK;
}
@@ -507,7 +588,9 @@ STDMETHODIMP CDirectVobSub::put_SubtitleReloader(bool fDisable)
bool b;
get_SubtitleReloader(&b);
- if(b == fDisable) return S_FALSE;
+ if(b == fDisable) {
+ return S_FALSE;
+ }
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), fDisable);
@@ -520,11 +603,21 @@ STDMETHODIMP CDirectVobSub::get_ExtendPicture(int* horizontal, int* vertical, in
CAutoLock cAutoLock(&m_propsLock);
- if(horizontal) *horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
- if(vertical) *vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
- if(resx2) *resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
- if(resx2minw) *resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
- if(resx2minh) *resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
+ if(horizontal) {
+ *horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
+ }
+ if(vertical) {
+ *vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
+ }
+ if(resx2) {
+ *resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
+ }
+ if(resx2minw) {
+ *resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
+ }
+ if(resx2minh) {
+ *resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
+ }
return S_OK;
}
@@ -537,7 +630,9 @@ STDMETHODIMP CDirectVobSub::put_ExtendPicture(int horizontal, int vertical, int
int i[5];
get_ExtendPicture(i, i+1, i+2, i+3, i+4);
- if(i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) return S_FALSE;
+ if(i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) {
+ return S_FALSE;
+ }
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), horizontal & 1);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), vertical);
@@ -554,10 +649,18 @@ STDMETHODIMP CDirectVobSub::get_LoadSettings(int* level, bool* fExternalLoad, bo
CAutoLock cAutoLock(&m_propsLock);
- if(level) *level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
- if(fExternalLoad) *fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
- if(fWebLoad) *fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
- if(fEmbeddedLoad) *fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
+ if(level) {
+ *level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
+ }
+ if(fExternalLoad) {
+ *fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
+ }
+ if(fWebLoad) {
+ *fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
+ }
+ if(fEmbeddedLoad) {
+ *fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
+ }
return S_OK;
}
@@ -571,7 +674,9 @@ STDMETHODIMP CDirectVobSub::put_LoadSettings(int level, bool fExternalLoad, bool
int i;
bool b[3];
get_LoadSettings(&i, b, b+1, b+2);
- if(i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) return S_FALSE;
+ if(i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) {
+ return S_FALSE;
+ }
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), level & 3);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), fExternalLoad);
@@ -617,8 +722,9 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(STSStyle* pDefStyle)
CAutoLock cAutoLock(&m_propsLock);
- if(!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle)))
+ if(!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle))) {
return S_FALSE;
+ }
m_defStyle = *pDefStyle;
diff --git a/src/filters/transform/VSFilter/DirectVobSub.h b/src/filters/transform/VSFilter/DirectVobSub.h
index 7f6edcba4..1c3917707 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.h
+++ b/src/filters/transform/VSFilter/DirectVobSub.h
@@ -91,8 +91,12 @@ public:
STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
- STDMETHODIMP get_ColorFormat(int* iPosition) {return E_NOTIMPL;}
- STDMETHODIMP put_ColorFormat(int iPosition) {return E_NOTIMPL;}
+ STDMETHODIMP get_ColorFormat(int* iPosition) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_ColorFormat(int iPosition) {
+ return E_NOTIMPL;
+ }
STDMETHODIMP UpdateRegistry();
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
index 1d0726364..935e29b57 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
@@ -100,7 +100,9 @@ CDirectVobSubFilter::CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUI
CDirectVobSubFilter::~CDirectVobSubFilter()
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue) m_pSubPicQueue->Invalidate();
+ if(m_pSubPicQueue) {
+ m_pSubPicQueue->Invalidate();
+ }
m_pSubPicQueue = NULL;
if(m_hfont) {
@@ -116,8 +118,9 @@ CDirectVobSubFilter::~CDirectVobSubFilter()
m_hdc = 0;
}
- for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++) {
delete m_pTextInput[i];
+ }
m_frd.EndThreadEvent.Set();
CAMThread::Close();
@@ -145,15 +148,17 @@ void CDirectVobSubFilter::GetOutputSize(int& w, int& h, int& arx, int& ary)
w = s.cx;
h = s.cy;
- if(w != os.cx)
- {
- while(arx < 100) arx *= 10, ary *= 10;
+ if(w != os.cx) {
+ while(arx < 100) {
+ arx *= 10, ary *= 10;
+ }
arx = arx * w / os.cx;
}
- if(h != os.cy)
- {
- while(ary < 100) arx *= 10, ary *= 10;
+ if(h != os.cy) {
+ while(ary < 100) {
+ arx *= 10, ary *= 10;
+ }
ary = ary * h / os.cy;
}
}
@@ -164,18 +169,17 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
REFERENCE_TIME rtStart, rtStop;
- if(SUCCEEDED(pIn->GetTime(&rtStart, &rtStop)))
- {
+ if(SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
double dRate = m_pInput->CurrentRate();
m_tPrev = m_pInput->CurrentStartTime() + dRate*rtStart;
REFERENCE_TIME rtAvgTimePerFrame = rtStop - rtStart;
- if(CComQIPtr<ISubClock2> pSC2 = m_pSubClock)
- {
+ if(CComQIPtr<ISubClock2> pSC2 = m_pSubClock) {
REFERENCE_TIME rt;
- if(S_OK == pSC2->GetAvgTimePerFrame(&rt))
+ if(S_OK == pSC2->GetAvgTimePerFrame(&rt)) {
rtAvgTimePerFrame = rt;
+ }
}
m_fps = 10000000.0/rtAvgTimePerFrame / dRate;
@@ -186,8 +190,7 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetTime(CalcCurrentTime());
m_pSubPicQueue->SetFPS(m_fps);
}
@@ -196,8 +199,9 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
//
BYTE* pDataIn = NULL;
- if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn)
+ if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
return S_FALSE;
+ }
const CMediaType& mt = m_pInput->CurrentMediaType();
@@ -211,11 +215,11 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CSize sub(m_w, m_h);
CSize in(bihIn.biWidth, bihIn.biHeight);
- if(FAILED(Copy((BYTE*)m_pTempPicBuff, pDataIn, sub, in, bpp, mt.subtype, black)))
+ if(FAILED(Copy((BYTE*)m_pTempPicBuff, pDataIn, sub, in, bpp, mt.subtype, black))) {
return E_FAIL;
+ }
- if(fYV12)
- {
+ if(fYV12) {
BYTE* pSubV = (BYTE*)m_pTempPicBuff + (sub.cx*bpp>>3)*sub.cy;
BYTE* pInV = pDataIn + (in.cx*bpp>>3)*in.cy;
sub.cx >>= 1;
@@ -224,10 +228,12 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
in.cy >>= 1;
BYTE* pSubU = pSubV + (sub.cx*bpp>>3)*sub.cy;
BYTE* pInU = pInV + (in.cx*bpp>>3)*in.cy;
- if(FAILED(Copy(pSubV, pInV, sub, in, bpp, mt.subtype, 0x80808080)))
+ if(FAILED(Copy(pSubV, pInV, sub, in, bpp, mt.subtype, 0x80808080))) {
return E_FAIL;
- if(FAILED(Copy(pSubU, pInU, sub, in, bpp, mt.subtype, 0x80808080)))
+ }
+ if(FAILED(Copy(pSubU, pInU, sub, in, bpp, mt.subtype, 0x80808080))) {
return E_FAIL;
+ }
}
//
@@ -237,8 +243,9 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
if(FAILED(hr = GetDeliveryBuffer(spd.w, spd.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
pOut->SetTime(&rtStart, &rtStop);
pOut->SetMediaTime(NULL, NULL);
@@ -256,27 +263,32 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
bool fFlip = fInputFlipped != fOutputFlipped;
- if(m_fFlipPicture) fFlip = !fFlip;
- if(m_fMSMpeg4Fix) fFlip = !fFlip;
+ if(m_fFlipPicture) {
+ fFlip = !fFlip;
+ }
+ if(m_fMSMpeg4Fix) {
+ fFlip = !fFlip;
+ }
bool fFlipSub = fOutputFlipped;
- if(m_fFlipSubtitles) fFlipSub = !fFlipSub;
+ if(m_fFlipSubtitles) {
+ fFlipSub = !fFlipSub;
+ }
//
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
CComPtr<ISubPic> pSubPic;
- if(SUCCEEDED(m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic)
- {
+ if(SUCCEEDED(m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic) {
CRect r;
pSubPic->GetDirtyRect(r);
- if(fFlip ^ fFlipSub)
+ if(fFlip ^ fFlipSub) {
spd.h = -spd.h;
+ }
pSubPic->AlphaBlt(r, r, &spd);
}
@@ -294,13 +306,15 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CBasePin* CDirectVobSubFilter::GetPin(int n)
{
- if(n < __super::GetPinCount())
+ if(n < __super::GetPinCount()) {
return __super::GetPin(n);
+ }
n -= __super::GetPinCount();
- if(n >= 0 && n < m_pTextInput.GetCount())
+ if(n >= 0 && n < m_pTextInput.GetCount()) {
return m_pTextInput[n];
+ }
n -= m_pTextInput.GetCount();
@@ -314,21 +328,17 @@ int CDirectVobSubFilter::GetPinCount()
HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if(pGraph)
- {
+ if(pGraph) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0))
- {
+ if(!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0)) {
unsigned __int64 ver = GetFileVersion(_T("divx_c32.ax"));
- if(((ver >> 48)&0xffff) == 4 && ((ver >> 32)&0xffff) == 2)
- {
+ if(((ver >> 48)&0xffff) == 4 && ((ver >> 32)&0xffff) == 2) {
DWORD dwVersion = GetVersion();
DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
- if(dwVersion < 0x80000000 && dwWindowsMajorVersion >= 5)
- {
+ if(dwVersion < 0x80000000 && dwWindowsMajorVersion >= 5) {
AfxMessageBox(IDS_DIVX_WARNING);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 1);
}
@@ -336,20 +346,15 @@ HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName
}
/*removeme*/
- if(!g_RegOK)
- {
+ if(!g_RegOK) {
DllRegisterServer();
g_RegOK = true;
}
- }
- else
- {
- if(m_hSystrayThread)
- {
+ } else {
+ if(m_hSystrayThread) {
SendMessage(m_tbid.hSystrayWnd, WM_CLOSE, 0, 0);
- if(WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0)
- {
+ if(WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0) {
DbgLog((LOG_TRACE, 0, _T("CALL THE AMBULANCE!!!")));
TerminateThread(m_hSystrayThread, (DWORD)-1);
}
@@ -366,13 +371,15 @@ STDMETHODIMP CDirectVobSubFilter::QueryFilterInfo(FILTER_INFO* pInfo)
CheckPointer(pInfo, E_POINTER);
ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- if(!get_Forced())
+ if(!get_Forced()) {
return __super::QueryFilterInfo(pInfo);
+ }
wcscpy(pInfo->achName, L"DirectVobSub (forced auto-loading version)");
pInfo->pGraph = m_pGraph;
- if(m_pGraph)
+ if(m_pGraph) {
m_pGraph->AddRef();
+ }
return S_OK;
}
@@ -382,10 +389,11 @@ STDMETHODIMP CDirectVobSubFilter::QueryFilterInfo(FILTER_INFO* pInfo)
HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
HRESULT hr = __super::SetMediaType(dir, pmt);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CAutoLock cAutoLock(&m_csReceive);
REFERENCE_TIME atpf =
@@ -395,13 +403,12 @@ HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* p
m_fps = atpf ? 10000000.0 / atpf : 25;
- if (pmt->formattype == FORMAT_VideoInfo2)
+ if (pmt->formattype == FORMAT_VideoInfo2) {
m_CurrentVIH2 = *(VIDEOINFOHEADER2*)pmt->Format();
+ }
InitSubPicQueue();
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
}
@@ -410,11 +417,8 @@ HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* p
HRESULT CDirectVobSubFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if(dir == PINDIR_INPUT)
- {
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ if(dir == PINDIR_INPUT) {
+ } else if(dir == PINDIR_OUTPUT) {
}
return __super::CheckConnect(dir, pPin);
@@ -422,24 +426,19 @@ HRESULT CDirectVobSubFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CDirectVobSubFilter::CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePin)
{
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CComPtr<IBaseFilter> pFilter;
// needed when we have a decoder with a version number of 3.x
if(SUCCEEDED(m_pGraph->FindFilterByName(L"DivX MPEG-4 DVD Video Decompressor ", &pFilter))
- && (GetFileVersion(_T("divx_c32.ax")) >> 48) <= 4
- || SUCCEEDED(m_pGraph->FindFilterByName(L"Microcrap MPEG-4 Video Decompressor", &pFilter))
- || SUCCEEDED(m_pGraph->FindFilterByName(L"Microsoft MPEG-4 Video Decompressor", &pFilter))
- && (GetFileVersion(_T("mpg4ds32.ax")) >> 48) <= 3)
- {
+ && (GetFileVersion(_T("divx_c32.ax")) >> 48) <= 4
+ || SUCCEEDED(m_pGraph->FindFilterByName(L"Microcrap MPEG-4 Video Decompressor", &pFilter))
+ || SUCCEEDED(m_pGraph->FindFilterByName(L"Microsoft MPEG-4 Video Decompressor", &pFilter))
+ && (GetFileVersion(_T("mpg4ds32.ax")) >> 48) <= 3) {
m_fMSMpeg4Fix = true;
}
- }
- else if(dir == PINDIR_OUTPUT)
- {
- if(!m_hSystrayThread)
- {
+ } else if(dir == PINDIR_OUTPUT) {
+ if(!m_hSystrayThread) {
m_tbid.graph = m_pGraph;
m_tbid.dvs = static_cast<IDirectVobSub*>(this);
@@ -456,16 +455,12 @@ HRESULT CDirectVobSubFilter::CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePi
HRESULT CDirectVobSubFilter::BreakConnect(PIN_DIRECTION dir)
{
- if(dir == PINDIR_INPUT)
- {
- if(m_pOutput->IsConnected())
- {
+ if(dir == PINDIR_INPUT) {
+ if(m_pOutput->IsConnected()) {
m_pOutput->GetConnected()->Disconnect();
m_pOutput->Disconnect();
}
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
// not really needed, but may free up a little memory
CAutoLock cAutoLock(&m_csQueueLock);
m_pSubPicQueue = NULL;
@@ -526,13 +521,21 @@ void CDirectVobSubFilter::InitSubPicQueue()
ExtractBIH(&m_pInput->CurrentMediaType(), &bihIn);
m_spd.type = -1;
- if(subtype == MEDIASUBTYPE_YV12) m_spd.type = MSP_YV12;
- else if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) m_spd.type = MSP_IYUV;
- else if(subtype == MEDIASUBTYPE_YUY2) m_spd.type = MSP_YUY2;
- else if(subtype == MEDIASUBTYPE_RGB32) m_spd.type = MSP_RGB32;
- else if(subtype == MEDIASUBTYPE_RGB24) m_spd.type = MSP_RGB24;
- else if(subtype == MEDIASUBTYPE_RGB565) m_spd.type = MSP_RGB16;
- else if(subtype == MEDIASUBTYPE_RGB555) m_spd.type = MSP_RGB15;
+ if(subtype == MEDIASUBTYPE_YV12) {
+ m_spd.type = MSP_YV12;
+ } else if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
+ m_spd.type = MSP_IYUV;
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
+ m_spd.type = MSP_YUY2;
+ } else if(subtype == MEDIASUBTYPE_RGB32) {
+ m_spd.type = MSP_RGB32;
+ } else if(subtype == MEDIASUBTYPE_RGB24) {
+ m_spd.type = MSP_RGB24;
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
+ m_spd.type = MSP_RGB16;
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
+ m_spd.type = MSP_RGB15;
+ }
m_spd.w = m_w;
m_spd.h = m_h;
m_spd.bpp = (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) ? 8 : bihIn.biBitCount;
@@ -542,7 +545,9 @@ void CDirectVobSubFilter::InitSubPicQueue()
CComPtr<ISubPicAllocator> pSubPicAllocator = new CMemSubPicAllocator(m_spd.type, CSize(m_w, m_h));
CSize video(bihIn.biWidth, bihIn.biHeight), window = video;
- if(AdjustFrameSize(window)) video += video;
+ if(AdjustFrameSize(window)) {
+ video += video;
+ }
ASSERT(window == CSize(m_w, m_h));
pSubPicAllocator->SetCurSize(window);
@@ -553,7 +558,9 @@ void CDirectVobSubFilter::InitSubPicQueue()
? (ISubPicQueue*)new CSubPicQueue(10, false, pSubPicAllocator, &hr)
: (ISubPicQueue*)new CSubPicQueueNoThread(pSubPicAllocator, &hr);
- if(FAILED(hr)) m_pSubPicQueue = NULL;
+ if(FAILED(hr)) {
+ m_pSubPicQueue = NULL;
+ }
UpdateSubtitle(false);
@@ -585,35 +592,40 @@ bool CDirectVobSubFilter::AdjustFrameSize(CSize& s)
bool fRet = (resx2 == 1) || (resx2 == 2 && s.cx*s.cy <= resx2minw*resx2minh);
- if(fRet)
- {
+ if(fRet) {
s.cx <<= 1;
s.cy <<= 1;
}
int h;
- switch(vertical&0x7f)
- {
- case 1:
- h = s.cx * 9 / 16;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- case 2:
- h = s.cx * 3 / 4;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- case 3:
- h = 480;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- case 4:
- h = 576;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- }
-
- if(horizontal == 1)
- {
+ switch(vertical&0x7f) {
+ case 1:
+ h = s.cx * 9 / 16;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 2:
+ h = s.cx * 3 / 4;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 3:
+ h = 480;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 4:
+ h = 576;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ }
+
+ if(horizontal == 1) {
s.cx = (s.cx + 31) & ~31;
s.cy = (s.cy + 1) & ~1;
}
@@ -623,13 +635,16 @@ bool CDirectVobSubFilter::AdjustFrameSize(CSize& s)
STDMETHODIMP CDirectVobSubFilter::Count(DWORD* pcStreams)
{
- if(!pcStreams) return E_POINTER;
+ if(!pcStreams) {
+ return E_POINTER;
+ }
*pcStreams = 0;
int nLangs = 0;
- if(SUCCEEDED(get_LanguageCount(&nLangs)))
+ if(SUCCEEDED(get_LanguageCount(&nLangs))) {
(*pcStreams) += nLangs;
+ }
(*pcStreams) += 2; // enable ... disable
@@ -647,26 +662,27 @@ int CDirectVobSubFilter::FindPreferedLanguage(bool fHideToo)
int nLangs;
get_LanguageCount(&nLangs);
- if(nLangs <= 0) return(0);
+ if(nLangs <= 0) {
+ return(0);
+ }
- for(ptrdiff_t i = 0; i < MAXPREFLANGS; i++)
- {
+ for(ptrdiff_t i = 0; i < MAXPREFLANGS; i++) {
CString tmp;
tmp.Format(IDS_RL_LANG, i);
CString lang = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
- if(!lang.IsEmpty())
- {
- for(ptrdiff_t ret = 0; ret < nLangs; ret++)
- {
+ if(!lang.IsEmpty()) {
+ for(ptrdiff_t ret = 0; ret < nLangs; ret++) {
CString l;
WCHAR* pName = NULL;
get_LanguageName(ret, &pName);
l = pName;
CoTaskMemFree(pName);
- if(!l.CompareNoCase(lang)) return(ret);
+ if(!l.CompareNoCase(lang)) {
+ return(ret);
+ }
}
}
}
@@ -681,30 +697,28 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
CString langs[MAXPREFLANGS+1];
int i = 0, j = 0, k = -1;
- for(; i < MAXPREFLANGS; i++)
- {
+ for(; i < MAXPREFLANGS; i++) {
CString tmp;
tmp.Format(IDS_RL_LANG, i);
langs[j] = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
- if(!langs[j].IsEmpty())
- {
- if(!langs[j].CompareNoCase(l)) k = j;
+ if(!langs[j].IsEmpty()) {
+ if(!langs[j].CompareNoCase(l)) {
+ k = j;
+ }
j++;
}
}
- if(k == -1)
- {
+ if(k == -1) {
langs[k = j] = l;
j++;
}
// move the selected to the top of the list
- while(k > 0)
- {
+ while(k > 0) {
CString tmp = langs[k];
langs[k] = langs[k-1];
langs[k-1] = tmp;
@@ -716,21 +730,20 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
CString hidesubs;
hidesubs.LoadString(IDS_M_HIDESUBTITLES);
- for(k = 1; k < j; k++)
- {
- if(!langs[k].CompareNoCase(hidesubs)) break;
+ for(k = 1; k < j; k++) {
+ if(!langs[k].CompareNoCase(hidesubs)) {
+ break;
+ }
}
- while(k < j-1)
- {
+ while(k < j-1) {
CString tmp = langs[k];
langs[k] = langs[k+1];
langs[k+1] = tmp;
k++;
}
- for(i = 0; i < j; i++)
- {
+ for(i = 0; i < j; i++) {
CString tmp;
tmp.Format(IDS_RL_LANG, i);
@@ -740,39 +753,35 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
STDMETHODIMP CDirectVobSubFilter::Enable(long lIndex, DWORD dwFlags)
{
- if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE))
+ if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
return E_NOTIMPL;
+ }
int nLangs = 0;
get_LanguageCount(&nLangs);
- if(!(lIndex >= 0 && lIndex < nLangs+2+2))
+ if(!(lIndex >= 0 && lIndex < nLangs+2+2)) {
return E_INVALIDARG;
+ }
int i = lIndex-1;
- if(i == -1 && !m_fLoading) // we need this because when loading something stupid media player pushes the first stream it founds, which is "enable" in our case
- {
+ if(i == -1 && !m_fLoading) { // we need this because when loading something stupid media player pushes the first stream it founds, which is "enable" in our case
put_HideSubtitles(false);
- }
- else if(i >= 0 && i < nLangs)
- {
+ } else if(i >= 0 && i < nLangs) {
put_HideSubtitles(false);
put_SelectedLanguage(i);
WCHAR* pName = NULL;
- if(SUCCEEDED(get_LanguageName(i, &pName)))
- {
+ if(SUCCEEDED(get_LanguageName(i, &pName))) {
UpdatePreferedLanguages(CString(pName));
- if(pName) CoTaskMemFree(pName);
+ if(pName) {
+ CoTaskMemFree(pName);
+ }
}
- }
- else if(i == nLangs && !m_fLoading)
- {
+ } else if(i == nLangs && !m_fLoading) {
put_HideSubtitles(true);
- }
- else if((i == nLangs+1 || i == nLangs+2) && !m_fLoading)
- {
+ } else if((i == nLangs+1 || i == nLangs+2) && !m_fLoading) {
put_Flip(i == nLangs+2, m_fFlipSubtitles);
}
@@ -786,66 +795,83 @@ STDMETHODIMP CDirectVobSubFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD*
int nLangs = 0;
get_LanguageCount(&nLangs);
- if(!(lIndex >= 0 && lIndex < nLangs+2+2))
+ if(!(lIndex >= 0 && lIndex < nLangs+2+2)) {
return E_INVALIDARG;
+ }
int i = lIndex-1;
- if(ppmt) *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
+ if(ppmt) {
+ *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
+ }
- if(pdwFlags)
- {
+ if(pdwFlags) {
*pdwFlags = 0;
if(i == -1 && !m_fHideSubtitles
- || i >= 0 && i < nLangs && i == m_iSelectedLanguage
- || i == nLangs && m_fHideSubtitles
- || i == nLangs+1 && !m_fFlipPicture
- || i == nLangs+2 && m_fFlipPicture)
- {
+ || i >= 0 && i < nLangs && i == m_iSelectedLanguage
+ || i == nLangs && m_fHideSubtitles
+ || i == nLangs+1 && !m_fFlipPicture
+ || i == nLangs+2 && m_fFlipPicture) {
*pdwFlags |= AMSTREAMSELECTINFO_ENABLED;
}
}
- if(plcid) *plcid = 0;
+ if(plcid) {
+ *plcid = 0;
+ }
- if(pdwGroup) *pdwGroup = 0x648E51;
+ if(pdwGroup) {
+ *pdwGroup = 0x648E51;
+ }
- if(ppszName)
- {
+ if(ppszName) {
*ppszName = NULL;
CStringW str;
- if(i == -1) str = ResStr(IDS_M_SHOWSUBTITLES);
- else if(i >= 0 && i < nLangs) get_LanguageName(i, ppszName);
- else if(i == nLangs) str = ResStr(IDS_M_HIDESUBTITLES);
- else if(i == nLangs+1) {
+ if(i == -1) {
+ str = ResStr(IDS_M_SHOWSUBTITLES);
+ } else if(i >= 0 && i < nLangs) {
+ get_LanguageName(i, ppszName);
+ } else if(i == nLangs) {
+ str = ResStr(IDS_M_HIDESUBTITLES);
+ } else if(i == nLangs+1) {
str = ResStr(IDS_M_ORIGINALPICTURE);
- if(pdwGroup) (*pdwGroup)++;
- }
- else if(i == nLangs+2) {
+ if(pdwGroup) {
+ (*pdwGroup)++;
+ }
+ } else if(i == nLangs+2) {
str = ResStr(IDS_M_FLIPPEDPICTURE);
- if(pdwGroup) (*pdwGroup)++;
+ if(pdwGroup) {
+ (*pdwGroup)++;
+ }
}
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
*ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if(*ppszName == NULL) return S_FALSE;
+ if(*ppszName == NULL) {
+ return S_FALSE;
+ }
wcscpy(*ppszName, str);
}
}
- if(ppObject) *ppObject = NULL;
+ if(ppObject) {
+ *ppObject = NULL;
+ }
- if(ppUnk) *ppUnk = NULL;
+ if(ppUnk) {
+ *ppUnk = NULL;
+ }
return S_OK;
}
STDMETHODIMP CDirectVobSubFilter::GetClassID(CLSID* pClsid)
{
- if(pClsid == NULL) return E_POINTER;
+ if(pClsid == NULL) {
+ return E_POINTER;
+ }
*pClsid = m_clsid;
return NOERROR;
}
@@ -857,7 +883,9 @@ STDMETHODIMP CDirectVobSubFilter::GetPages(CAUUID* pPages)
pPages->cElems = 7;
pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID)*pPages->cElems);
- if(pPages->pElems == NULL) return E_OUTOFMEMORY;
+ if(pPages->pElems == NULL) {
+ return E_OUTOFMEMORY;
+ }
int i = 0;
pPages->pElems[i++] = __uuidof(CDVSMainPPage);
@@ -877,8 +905,7 @@ STDMETHODIMP CDirectVobSubFilter::put_FileName(WCHAR* fn)
{
HRESULT hr = CDirectVobSub::put_FileName(fn);
- if(hr == S_OK && !Open())
- {
+ if(hr == S_OK && !Open()) {
m_FileName.Empty();
hr = E_FAIL;
}
@@ -890,13 +917,14 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageCount(int* nLangs)
{
HRESULT hr = CDirectVobSub::get_LanguageCount(nLangs);
- if(hr == NOERROR && nLangs)
- {
+ if(hr == NOERROR && nLangs) {
CAutoLock cAutolock(&m_csQueueLock);
*nLangs = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ while(pos) {
+ (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
}
return hr;
@@ -906,10 +934,11 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName
{
HRESULT hr = CDirectVobSub::get_LanguageName(iLanguage, ppName);
- if(!ppName) return E_POINTER;
+ if(!ppName) {
+ return E_POINTER;
+ }
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
CAutoLock cAutolock(&m_csQueueLock);
hr = E_INVALIDARG;
@@ -917,12 +946,10 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName
int i = iLanguage;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(i >= 0 && pos)
- {
+ while(i >= 0 && pos) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
pSubStream->GetStreamInfo(i, ppName, NULL);
hr = NOERROR;
break;
@@ -939,8 +966,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SelectedLanguage(int iSelected)
{
HRESULT hr = CDirectVobSub::put_SelectedLanguage(iSelected);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -951,8 +977,7 @@ STDMETHODIMP CDirectVobSubFilter::put_HideSubtitles(bool fHideSubtitles)
{
HRESULT hr = CDirectVobSub::put_HideSubtitles(fHideSubtitles);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -963,8 +988,7 @@ STDMETHODIMP CDirectVobSubFilter::put_PreBuffering(bool fDoPreBuffering)
{
HRESULT hr = CDirectVobSub::put_PreBuffering(fDoPreBuffering);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
InitSubPicQueue();
}
@@ -975,8 +999,7 @@ STDMETHODIMP CDirectVobSubFilter::put_Placement(bool fOverridePlacement, int xpe
{
HRESULT hr = CDirectVobSub::put_Placement(fOverridePlacement, xperc, yperc);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -987,9 +1010,8 @@ STDMETHODIMP CDirectVobSubFilter::put_VobSubSettings(bool fBuffer, bool fOnlySho
{
HRESULT hr = CDirectVobSub::put_VobSubSettings(fBuffer, fOnlyShowForcedSubs, fReserved);
- if(hr == NOERROR)
- {
-// UpdateSubtitle(false);
+ if(hr == NOERROR) {
+ // UpdateSubtitle(false);
InvalidateSubtitle();
}
@@ -1000,9 +1022,8 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(void* lf, int lflen, COLORREF
{
HRESULT hr = CDirectVobSub::put_TextSettings(lf, lflen, color, fShadow, fOutline, fAdvancedRenderer);
- if(hr == NOERROR)
- {
-// UpdateSubtitle(true);
+ if(hr == NOERROR) {
+ // UpdateSubtitle(true);
InvalidateSubtitle();
}
@@ -1013,8 +1034,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SubtitleTiming(int delay, int speedmul, in
{
HRESULT hr = CDirectVobSub::put_SubtitleTiming(delay, speedmul, speeddiv);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
InvalidateSubtitle();
}
@@ -1027,10 +1047,11 @@ STDMETHODIMP CDirectVobSubFilter::get_MediaFPS(bool* fEnabled, double* fps)
CComQIPtr<IMediaSeeking> pMS = m_pGraph;
double rate;
- if(pMS && SUCCEEDED(pMS->GetRate(&rate)))
- {
+ if(pMS && SUCCEEDED(pMS->GetRate(&rate))) {
m_MediaFPS = rate * m_fps;
- if(fps) *fps = m_MediaFPS;
+ if(fps) {
+ *fps = m_MediaFPS;
+ }
}
return hr;
@@ -1041,16 +1062,15 @@ STDMETHODIMP CDirectVobSubFilter::put_MediaFPS(bool fEnabled, double fps)
HRESULT hr = CDirectVobSub::put_MediaFPS(fEnabled, fps);
CComQIPtr<IMediaSeeking> pMS = m_pGraph;
- if(pMS)
- {
- if(hr == NOERROR)
- {
+ if(pMS) {
+ if(hr == NOERROR) {
hr = pMS->SetRate(m_fMediaFPSEnabled ? m_MediaFPS / m_fps : 1.0);
}
double dRate;
- if(SUCCEEDED(pMS->GetRate(&dRate)))
+ if(SUCCEEDED(pMS->GetRate(&dRate))) {
m_MediaFPS = dRate * m_fps;
+ }
}
return hr;
@@ -1072,8 +1092,7 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(STSStyle* pDefStyle)
{
HRESULT hr = CDirectVobSub::put_TextSettings(pDefStyle);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1084,8 +1103,7 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E
{
HRESULT hr = CDirectVobSub::put_AspectRatioSettings(ePARCompensationType);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1097,10 +1115,12 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E
STDMETHODIMP CDirectVobSubFilter::HasConfigDialog(int iSelected)
{
int nLangs;
- if(FAILED(get_LanguageCount(&nLangs))) return E_FAIL;
+ if(FAILED(get_LanguageCount(&nLangs))) {
+ return E_FAIL;
+ }
return E_FAIL;
// TODO: temporally disabled since we don't have a new textsub/vobsub editor dlg for dvs yet
-// return(nLangs >= 0 && iSelected < nLangs ? S_OK : E_FAIL);
+ // return(nLangs >= 0 && iSelected < nLangs ? S_OK : E_FAIL);
}
STDMETHODIMP CDirectVobSubFilter::ShowConfigDialog(int iSelected, HWND hWndParent)
@@ -1119,19 +1139,21 @@ CDirectVobSubFilter2::CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const G
HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
CPinInfo pi;
- if(FAILED(pPin->QueryPinInfo(&pi))) return E_FAIL;
+ if(FAILED(pPin->QueryPinInfo(&pi))) {
+ return E_FAIL;
+ }
- if(CComQIPtr<IDirectVobSub>(pi.pFilter)) return E_FAIL;
+ if(CComQIPtr<IDirectVobSub>(pi.pFilter)) {
+ return E_FAIL;
+ }
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CFilterInfo fi;
if(SUCCEEDED(pi.pFilter->QueryFilterInfo(&fi))
- && !wcsnicmp(fi.achName, L"Overlay Mixer", 13))
+ && !wcsnicmp(fi.achName, L"Overlay Mixer", 13)) {
return(E_FAIL);
- }
- else
- {
+ }
+ } else {
}
return __super::CheckConnect(dir, pPin);
@@ -1139,12 +1161,11 @@ HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if(pGraph)
- {
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF))
+ if(pGraph) {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF)) {
return E_FAIL;
+ }
}
EndEnumFilters
@@ -1158,31 +1179,32 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
// This whole workaround is needed because the video stream will always be connected
// to the pre-added filters first, no matter how high merit we have.
- if(!get_Forced())
- {
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(CComQIPtr<IDirectVobSub>(pBF))
+ if(!get_Forced()) {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(CComQIPtr<IDirectVobSub>(pBF)) {
continue;
+ }
CComPtr<IPin> pInPin = GetFirstPin(pBF, PINDIR_INPUT);
CComPtr<IPin> pOutPin = GetFirstPin(pBF, PINDIR_OUTPUT);
- if(!pInPin)
+ if(!pInPin) {
continue;
+ }
CComPtr<IPin> pPin;
if(pInPin && SUCCEEDED(pInPin->ConnectedTo(&pPin))
- || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin)))
+ || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin))) {
continue;
+ }
- if(pOutPin && GetFilterName(pBF) == _T("Overlay Mixer"))
+ if(pOutPin && GetFilterName(pBF) == _T("Overlay Mixer")) {
continue;
+ }
bool fVideoInputPin = false;
- do
- {
+ do {
BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER), 384, 288, 1, 16, '2YUY', 384*288*2, 0, 0, 0, 0};
CMediaType cmt;
@@ -1198,8 +1220,7 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
memcpy(&vih->bmiHeader, &bih, sizeof(bih));
vih->AvgTimePerFrame = 400000;
- if(SUCCEEDED(pInPin->QueryAccept(&cmt)))
- {
+ if(SUCCEEDED(pInPin->QueryAccept(&cmt))) {
fVideoInputPin = true;
break;
}
@@ -1211,19 +1232,15 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
vih2->dwPictAspectRatioX = 384;
vih2->dwPictAspectRatioY = 288;
- if(SUCCEEDED(pInPin->QueryAccept(&cmt)))
- {
+ if(SUCCEEDED(pInPin->QueryAccept(&cmt))) {
fVideoInputPin = true;
break;
}
- }
- while(false);
+ } while(false);
- if(fVideoInputPin)
- {
+ if(fVideoInputPin) {
CComPtr<IBaseFilter> pDVS;
- if(ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2))))
- {
+ if(ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2)))) {
CComQIPtr<IDirectVobSub2>(pDVS)->put_Forced(true);
CComQIPtr<IGraphConfig>(pGraph)->AddFilterToCache(pDVS);
}
@@ -1233,9 +1250,7 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
}
EndEnumFilters
}
- }
- else
- {
+ } else {
}
return __super::JoinFilterGraph(pGraph, pName);
@@ -1245,9 +1260,13 @@ HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* mtIn)
{
HRESULT hr = __super::CheckInputType(mtIn);
- if(FAILED(hr) || m_pInput->IsConnected()) return hr;
+ if(FAILED(hr) || m_pInput->IsConnected()) {
+ return hr;
+ }
- if(!ShouldWeAutoload(m_pGraph)) return VFW_E_TYPE_NOT_ACCEPTED;
+ if(!ShouldWeAutoload(m_pGraph)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
GetRidOfInternalScriptRenderer();
@@ -1256,8 +1275,7 @@ HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* mtIn)
bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
{
- TCHAR blacklistedapps[][32] =
- {
+ TCHAR blacklistedapps[][32] = {
_T("WM8EUTIL."), // wmp8 encoder's dummy renderer releases the outputted media sample after calling Receive on its input pin (yes, even when dvobsub isn't registered at all)
_T("explorer."), // as some users reported thumbnail preview loads dvobsub, I've never experienced this yet...
_T("producer."), // this is real's producer
@@ -1266,54 +1284,54 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
_T("GoogleDesktopCrawl."), // Google Desktop
};
- for(ptrdiff_t i = 0; i < countof(blacklistedapps); i++)
- {
- if(theApp.m_AppName.Find(blacklistedapps[i]) >= 0)
+ for(ptrdiff_t i = 0; i < countof(blacklistedapps); i++) {
+ if(theApp.m_AppName.Find(blacklistedapps[i]) >= 0) {
return(false);
+ }
}
int level;
bool m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad;
get_LoadSettings(&level, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
- if(level < 0 || level >= 2) return(false);
+ if(level < 0 || level >= 2) {
+ return(false);
+ }
bool fRet = false;
- if(level == 1)
+ if(level == 1) {
fRet = m_fExternalLoad = m_fWebLoad = m_fEmbeddedLoad = true;
+ }
// find text stream on known splitters
- if(!fRet && m_fEmbeddedLoad)
- {
+ if(!fRet && m_fEmbeddedLoad) {
CComPtr<IBaseFilter> pBF;
if((pBF = FindFilter(CLSID_OggSplitter, pGraph)) || (pBF = FindFilter(CLSID_AviSplitter, pGraph))
- || (pBF = FindFilter(L"{34293064-02F2-41D5-9D75-CC5967ACA1AB}", pGraph)) // matroska demux
- || (pBF = FindFilter(L"{0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4}", pGraph)) // matroska source
- || (pBF = FindFilter(L"{149D2E01-C32E-4939-80F6-C07B81015A7A}", pGraph)) // matroska splitter
- || (pBF = FindFilter(L"{9AB95E90-1F37-427e-9B3D-257FB0CB25F7}", pGraph)) // Haali's matroska splitter (?)
- || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's matroska splitter
- || (pBF = FindFilter(L"{52B63861-DC93-11CE-A099-00AA00479A58}", pGraph)) // 3ivx splitter
- || (pBF = FindFilter(L"{6D3688CE-3E9D-42F4-92CA-8A11119D25CD}", pGraph)) // our ogg source
- || (pBF = FindFilter(L"{9FF48807-E133-40AA-826F-9B2959E5232D}", pGraph)) // our ogg splitter
- || (pBF = FindFilter(L"{803E8280-F3CE-4201-982C-8CD8FB512004}", pGraph)) // dsm source
- || (pBF = FindFilter(L"{0912B4DD-A30A-4568-B590-7179EBB420EC}", pGraph)) // dsm splitter
- || (pBF = FindFilter(L"{3CCC052E-BDEE-408a-BEA7-90914EF2964B}", pGraph)) // mp4 source
- || (pBF = FindFilter(L"{61F47056-E400-43d3-AF1E-AB7DFFD4C4AD}", pGraph))) // mp4 splitter
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- BeginEnumMediaTypes(pPin, pEM, pmt)
- {
- if(pmt->majortype == MEDIATYPE_Text || pmt->majortype == MEDIATYPE_Subtitle)
- {
+ || (pBF = FindFilter(L"{34293064-02F2-41D5-9D75-CC5967ACA1AB}", pGraph)) // matroska demux
+ || (pBF = FindFilter(L"{0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4}", pGraph)) // matroska source
+ || (pBF = FindFilter(L"{149D2E01-C32E-4939-80F6-C07B81015A7A}", pGraph)) // matroska splitter
+ || (pBF = FindFilter(L"{9AB95E90-1F37-427e-9B3D-257FB0CB25F7}", pGraph)) // Haali's matroska splitter (?)
+ || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's matroska splitter
+ || (pBF = FindFilter(L"{52B63861-DC93-11CE-A099-00AA00479A58}", pGraph)) // 3ivx splitter
+ || (pBF = FindFilter(L"{6D3688CE-3E9D-42F4-92CA-8A11119D25CD}", pGraph)) // our ogg source
+ || (pBF = FindFilter(L"{9FF48807-E133-40AA-826F-9B2959E5232D}", pGraph)) // our ogg splitter
+ || (pBF = FindFilter(L"{803E8280-F3CE-4201-982C-8CD8FB512004}", pGraph)) // dsm source
+ || (pBF = FindFilter(L"{0912B4DD-A30A-4568-B590-7179EBB420EC}", pGraph)) // dsm splitter
+ || (pBF = FindFilter(L"{3CCC052E-BDEE-408a-BEA7-90914EF2964B}", pGraph)) // mp4 source
+ || (pBF = FindFilter(L"{61F47056-E400-43d3-AF1E-AB7DFFD4C4AD}", pGraph))) { // mp4 splitter
+ BeginEnumPins(pBF, pEP, pPin) {
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ if(pmt->majortype == MEDIATYPE_Text || pmt->majortype == MEDIATYPE_Subtitle) {
fRet = true;
break;
}
}
EndEnumMediaTypes(pmt)
- if(fRet) break;
+ if(fRet) {
+ break;
+ }
}
EndEnumFilters
}
@@ -1323,13 +1341,12 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
CStringW fn;
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(CComQIPtr<IFileSourceFilter> pFSF = pBF)
- {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(CComQIPtr<IFileSourceFilter> pFSF = pBF) {
LPOLESTR fnw = NULL;
- if(!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw)
+ if(!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw) {
continue;
+ }
fn = CString(fnw);
CoTaskMemFree(fnw);
break;
@@ -1337,13 +1354,14 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
}
EndEnumFilters
- if((m_fExternalLoad || m_fWebLoad) && (m_fWebLoad || !(wcsstr(fn, L"http://") || wcsstr(fn, L"mms://"))))
- {
+ if((m_fExternalLoad || m_fWebLoad) && (m_fWebLoad || !(wcsstr(fn, L"http://") || wcsstr(fn, L"mms://")))) {
bool fTemp = m_fHideSubtitles;
fRet = !fn.IsEmpty() && SUCCEEDED(put_FileName((LPWSTR)(LPCWSTR)fn))
|| SUCCEEDED(put_FileName(L"c:\\tmp.srt"))
|| fRet;
- if(fTemp) m_fHideSubtitles = true;
+ if(fTemp) {
+ m_fHideSubtitles = true;
+ }
}
return(fRet);
@@ -1351,16 +1369,13 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
{
- while(CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph))
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
+ while(CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph)) {
+ BeginEnumPins(pBF, pEP, pPin) {
PIN_DIRECTION dir;
CComPtr<IPin> pPinTo;
if(SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
- && SUCCEEDED(pPin->ConnectedTo(&pPinTo)))
- {
+ && SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
m_pGraph->Disconnect(pPinTo);
m_pGraph->Disconnect(pPin);
m_pGraph->ConnectDirect(pPinTo, GetPin(2 + m_pTextInput.GetCount()-1), NULL);
@@ -1368,8 +1383,9 @@ void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
}
EndEnumPins
- if(FAILED(m_pGraph->RemoveFilter(pBF)))
+ if(FAILED(m_pGraph->RemoveFilter(pBF))) {
break;
+ }
}
}
@@ -1387,68 +1403,63 @@ bool CDirectVobSubFilter::Open()
CAtlArray<CString> paths;
- for(ptrdiff_t i = 0; i < 10; i++)
- {
+ for(ptrdiff_t i = 0; i < 10; i++) {
CString tmp;
tmp.Format(IDS_RP_PATH, i);
CString path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp);
- if(!path.IsEmpty()) paths.Add(path);
+ if(!path.IsEmpty()) {
+ paths.Add(path);
+ }
}
CAtlArray<SubFile> ret;
GetSubFileNames(m_FileName, paths, ret);
- for(ptrdiff_t i = 0; i < ret.GetCount(); i++)
- {
- if(m_frd.files.Find(ret[i].fn))
+ for(ptrdiff_t i = 0; i < ret.GetCount(); i++) {
+ if(m_frd.files.Find(ret[i].fn)) {
continue;
+ }
CComPtr<ISubStream> pSubStream;
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<CVobSubFile> pVSF(new CVobSubFile(&m_csSubLock));
- if(pVSF && pVSF->Open(ret[i].fn) && pVSF->GetStreamCount() > 0)
- {
+ if(pVSF && pVSF->Open(ret[i].fn) && pVSF->GetStreamCount() > 0) {
pSubStream = pVSF.Detach();
m_frd.files.AddTail(ret[i].fn.Left(ret[i].fn.GetLength()-4) + _T(".sub"));
}
}
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<ssf::CRenderer> pSSF(new ssf::CRenderer(&m_csSubLock));
- if(pSSF && pSSF->Open(ret[i].fn) && pSSF->GetStreamCount() > 0)
- {
+ if(pSSF && pSSF->Open(ret[i].fn) && pSSF->GetStreamCount() > 0) {
pSubStream = pSSF.Detach();
}
}
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<CRenderedTextSubtitle> pRTS(new CRenderedTextSubtitle(&m_csSubLock));
- if(pRTS && pRTS->Open(ret[i].fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0)
- {
+ if(pRTS && pRTS->Open(ret[i].fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0) {
pSubStream = pRTS.Detach();
m_frd.files.AddTail(ret[i].fn + _T(".style"));
}
}
- if(pSubStream)
- {
+ if(pSubStream) {
m_pSubStreams.AddTail(pSubStream);
m_frd.files.AddTail(ret[i].fn);
}
}
- for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
- {
- if(m_pTextInput[i]->IsConnected())
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++) {
+ if(m_pTextInput[i]->IsConnected()) {
m_pSubStreams.AddTail(m_pTextInput[i]->GetSubStream());
+ }
}
- if(S_FALSE == put_SelectedLanguage(FindPreferedLanguage()))
- UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
+ if(S_FALSE == put_SelectedLanguage(FindPreferedLanguage())) {
+ UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
+ }
m_frd.RefreshEvent.Set();
@@ -1459,22 +1470,21 @@ void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle)
{
CAutoLock cAutolock(&m_csQueueLock);
- if(!m_pSubPicQueue) return;
+ if(!m_pSubPicQueue) {
+ return;
+ }
InvalidateSubtitle();
CComPtr<ISubStream> pSubStream;
- if(!m_fHideSubtitles)
- {
+ if(!m_fHideSubtitles) {
int i = m_iSelectedLanguage;
- for(POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL)
- {
+ for(POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL) {
pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
CAutoLock cAutoLock(&m_csSubLock);
pSubStream->SetStream(i);
break;
@@ -1491,43 +1501,33 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
{
CAutoLock cAutolock(&m_csQueueLock);
- if(pSubStream)
- {
+ if(pSubStream) {
CAutoLock cAutolock(&m_csSubLock);
CLSID clsid;
pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile))
- {
+ if(clsid == __uuidof(CVobSubFile)) {
CVobSubSettings* pVSS = (CVobSubFile*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
- }
- else if(clsid == __uuidof(CVobSubStream))
- {
+ } else if(clsid == __uuidof(CVobSubStream)) {
CVobSubSettings* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ } else if(clsid == __uuidof(CRenderedTextSubtitle)) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
- if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle)
- {
+ if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
STSStyle s = m_defStyle;
- if(m_fOverridePlacement)
- {
+ if(m_fOverridePlacement) {
s.scrAlignment = 2;
int w = pRTS->m_dstScreenSize.cx;
int h = pRTS->m_dstScreenSize.cy;
@@ -1541,14 +1541,11 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
}
pRTS->m_ePARCompensationType = m_ePARCompensationType;
- if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0&& m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0)
- {
+ if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0&& m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0) {
pRTS->m_dPARCompensation = ((double)abs(m_CurrentVIH2.bmiHeader.biWidth) / (double)abs(m_CurrentVIH2.bmiHeader.biHeight)) /
((double)abs((long)m_CurrentVIH2.dwPictAspectRatioX) / (double)abs((long)m_CurrentVIH2.dwPictAspectRatioY));
- }
- else
- {
+ } else {
pRTS->m_dPARCompensation = 1.00;
}
@@ -1556,17 +1553,14 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
}
}
- if(!fApplyDefStyle)
- {
+ if(!fApplyDefStyle) {
int i = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
- if(pSubStream == pSubStream2)
- {
+ if(pSubStream == pSubStream2) {
m_iSelectedLanguage = i + pSubStream2->GetStream();
break;
}
@@ -1577,18 +1571,19 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
m_nSubtitleId = (DWORD_PTR)pSubStream;
- if(m_pSubPicQueue)
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
+ }
}
void CDirectVobSubFilter::InvalidateSubtitle(REFERENCE_TIME rtInvalidate, DWORD_PTR nSubtitleId)
{
CAutoLock cAutolock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
- if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId)
+ if(m_pSubPicQueue) {
+ if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId) {
m_pSubPicQueue->Invalidate(rtInvalidate);
+ }
}
}
@@ -1599,14 +1594,17 @@ void CDirectVobSubFilter::AddSubStream(ISubStream* pSubStream)
CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(!pos) m_pSubStreams.AddTail(pSubStream);
+ if(!pos) {
+ m_pSubStreams.AddTail(pSubStream);
+ }
int len = m_pTextInput.GetCount();
for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
- if(m_pTextInput[i]->IsConnected()) len--;
+ if(m_pTextInput[i]->IsConnected()) {
+ len--;
+ }
- if(len == 0)
- {
+ if(len == 0) {
HRESULT hr = S_OK;
m_pTextInput.Add(new CTextInputPin(this, m_pLock, &m_csSubLock, &hr));
}
@@ -1617,21 +1615,28 @@ void CDirectVobSubFilter::RemoveSubStream(ISubStream* pSubStream)
CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(pos) m_pSubStreams.RemoveAt(pos);
+ if(pos) {
+ m_pSubStreams.RemoveAt(pos);
+ }
}
void CDirectVobSubFilter::Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId)
{
- if(nSubtitleId != -1 && nSubtitleId != m_nSubtitleId)
+ if(nSubtitleId != -1 && nSubtitleId != m_nSubtitleId) {
return;
+ }
CComQIPtr<IMediaEventSink> pMES = m_pGraph;
- if(!pMES) return;
+ if(!pMES) {
+ return;
+ }
CComBSTR bstr1("Text"), bstr2(" ");
str.Trim();
- if(!str.IsEmpty()) bstr2 = CStringA(str);
+ if(!str.IsEmpty()) {
+ bstr2 = CStringA(str);
+ }
pMES->Notify(EC_OLE_EVENT, (LONG_PTR)bstr1.Detach(), (LONG_PTR)bstr2.Detach());
}
@@ -1642,8 +1647,7 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl
{
CAutoLock cAutolock(&m_csSubLock);
- for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
- {
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
@@ -1656,30 +1660,32 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl
m_frd.mtime.SetCount(m_frd.files.GetCount());
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
+ for(ptrdiff_t i = 0; pos; i++) {
CString fn = m_frd.files.GetNext(pos);
CFileStatus status;
- if(CFileGetStatus(fn, status))
+ if(CFileGetStatus(fn, status)) {
m_frd.mtime[i] = status.m_mtime;
+ }
fn.Replace('\\', '/');
fn = fn.Left(fn.ReverseFind('/')+1);
bool fFound = false;
- for(ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++)
- {
- if(paths[j] == fn) fFound = true;
+ for(ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++) {
+ if(paths[j] == fn) {
+ fFound = true;
+ }
}
- if(!fFound)
- {
+ if(!fFound) {
paths.Add(fn);
HANDLE h = FindFirstChangeNotification(fn, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if(h != INVALID_HANDLE_VALUE) handles.Add(h);
+ if(h != INVALID_HANDLE_VALUE) {
+ handles.Add(h);
+ }
}
}
}
@@ -1693,47 +1699,39 @@ DWORD CDirectVobSubFilter::ThreadProc()
SetupFRD(paths, handles);
- while(1)
- {
+ while(1) {
DWORD idx = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, INFINITE);
- if(idx == (WAIT_OBJECT_0 + 0)) // m_frd.hEndThreadEvent
- {
+ if(idx == (WAIT_OBJECT_0 + 0)) { // m_frd.hEndThreadEvent
break;
}
- if(idx == (WAIT_OBJECT_0 + 1)) // m_frd.hRefreshEvent
- {
+ if(idx == (WAIT_OBJECT_0 + 1)) { // m_frd.hRefreshEvent
SetupFRD(paths, handles);
- }
- else if(idx >= (WAIT_OBJECT_0 + 2) && idx < (WAIT_OBJECT_0 + handles.GetCount()))
- {
+ } else if(idx >= (WAIT_OBJECT_0 + 2) && idx < (WAIT_OBJECT_0 + handles.GetCount())) {
bool fLocked = true;
IsSubtitleReloaderLocked(&fLocked);
- if(fLocked) continue;
+ if(fLocked) {
+ continue;
+ }
- if(FindNextChangeNotification(handles[idx - WAIT_OBJECT_0]) == FALSE)
+ if(FindNextChangeNotification(handles[idx - WAIT_OBJECT_0]) == FALSE) {
break;
+ }
int j = 0;
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos && j == 0; i++)
- {
+ for(ptrdiff_t i = 0; pos && j == 0; i++) {
CString fn = m_frd.files.GetNext(pos);
CFileStatus status;
- if(CFileGetStatus(fn, status) && m_frd.mtime[i] != status.m_mtime)
- {
- for(j = 0; j < 10; j++)
- {
- if(FILE* f = _tfopen(fn, _T("rb+")))
- {
+ if(CFileGetStatus(fn, status) && m_frd.mtime[i] != status.m_mtime) {
+ for(j = 0; j < 10; j++) {
+ if(FILE* f = _tfopen(fn, _T("rb+"))) {
fclose(f);
j = 0;
break;
- }
- else
- {
+ } else {
Sleep(100);
j++;
}
@@ -1741,36 +1739,28 @@ DWORD CDirectVobSubFilter::ThreadProc()
}
}
- if(j > 0)
- {
+ if(j > 0) {
SetupFRD(paths, handles);
- }
- else
- {
+ } else {
Sleep(500);
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
+ for(ptrdiff_t i = 0; pos; i++) {
CFileStatus status;
if(CFileGetStatus(m_frd.files.GetNext(pos), status)
- && m_frd.mtime[i] != status.m_mtime)
- {
+ && m_frd.mtime[i] != status.m_mtime) {
Open();
SetupFRD(paths, handles);
break;
}
}
}
- }
- else
- {
+ } else {
break;
}
}
- for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
- {
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.h b/src/filters/transform/VSFilter/DirectVobSubFilter.h
index 6552d5f17..82932bd2c 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.h
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.h
@@ -30,8 +30,7 @@
#include "../../../Subtitles/RTS.h"
#include "../../../Subtitles/SSF.h"
-typedef struct
-{
+typedef struct {
HWND hSystrayWnd;
IFilterGraph* graph;
IDirectVobSub* dvs;
diff --git a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
index 4b4713a64..79196273c 100644
--- a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
@@ -48,7 +48,9 @@ BOOL WINAPI MyGetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, SI
pDlgProc,
lParam);
- if(hwnd == NULL) return FALSE;
+ if(hwnd == NULL) {
+ return FALSE;
+ }
RECT rc;
GetWindowRect(hwnd, &rc);
@@ -65,7 +67,9 @@ STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo)
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString str;
- if(!str.LoadString(m_TitleId)) return E_FAIL;
+ if(!str.LoadString(m_TitleId)) {
+ return E_FAIL;
+ }
WCHAR wszTitle[STR_MAX_LENGTH];
#ifdef UNICODE
@@ -104,16 +108,20 @@ STDMETHODIMP CDVSBasePPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CheckPointer(pRect,E_POINTER);
-/*
- // Return failure if SetObject has not been called.
- if (m_bObjectSet == FALSE) {
+ /*
+ // Return failure if SetObject has not been called.
+ if (m_bObjectSet == FALSE) {
+ return E_UNEXPECTED;
+ }
+ */
+ if(m_hwnd) {
return E_UNEXPECTED;
}
-*/
- if(m_hwnd) return E_UNEXPECTED;
m_hwnd = CreateDialogParam(AfxGetResourceHandle(), MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);
- if(m_hwnd == NULL) return E_OUTOFMEMORY;
+ if(m_hwnd == NULL) {
+ return E_OUTOFMEMORY;
+ }
OnActivate();
Move(pRect);
@@ -132,36 +140,34 @@ CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int Ti
INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- if(m_bIsInitialized)
- {
- m_bDirty = TRUE;
- if(m_pPageSite) m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
-
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- case CBN_SELCHANGE:
- case EN_CHANGE:
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if(!m_fDisableInstantUpdate
- && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
- && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1))
- OnApplyChanges();
- }
+ switch(uMsg) {
+ case WM_COMMAND: {
+ if(m_bIsInitialized) {
+ m_bDirty = TRUE;
+ if(m_pPageSite) {
+ m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
+ }
+
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED:
+ case CBN_SELCHANGE:
+ case EN_CHANGE: {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if(!m_fDisableInstantUpdate
+ && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
+ && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1)) {
+ OnApplyChanges();
+ }
+ }
+ }
}
}
- }
- break;
-
- case WM_NCDESTROY:
- DetachControls();
break;
+
+ case WM_NCDESTROY:
+ DetachControls();
+ break;
}
return OnMessage(uMsg, wParam, lParam)
@@ -171,7 +177,9 @@ INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
{
- if(!(m_pDirectVobSub = pUnknown)) return E_NOINTERFACE;
+ if(!(m_pDirectVobSub = pUnknown)) {
+ return E_NOINTERFACE;
+ }
m_pDirectVobSub->LockSubtitleReloader(true); // *
@@ -186,7 +194,9 @@ HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
HRESULT CDVSBasePPage::OnDisconnect()
{
- if(m_pDirectVobSub == NULL) return E_UNEXPECTED;
+ if(m_pDirectVobSub == NULL) {
+ return E_UNEXPECTED;
+ }
m_pDirectVobSub->LockSubtitleReloader(false); // *
@@ -233,8 +243,7 @@ HRESULT CDVSBasePPage::OnApplyChanges()
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_bIsInitialized)
- {
+ if(m_bIsInitialized) {
OnDeactivate();
UpdateObjectData(true);
m_pDirectVobSub->UpdateRegistry(); // *
@@ -251,13 +260,11 @@ void CDVSBasePPage::AttachControls()
AFX_MANAGE_STATE(AfxGetStaticModuleState());
POSITION pos = m_controls.GetStartPosition();
- while(pos)
- {
+ while(pos) {
UINT id;
CWnd* pControl;
m_controls.GetNextAssoc(pos, id, pControl);
- if(pControl)
- {
+ if(pControl) {
BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
ASSERT(fRet);
}
@@ -268,17 +275,20 @@ void CDVSBasePPage::AttachControls()
void CDVSBasePPage::DetachControls()
{
- if(!m_fAttached) return;
+ if(!m_fAttached) {
+ return;
+ }
AFX_MANAGE_STATE(AfxGetStaticModuleState());
POSITION pos = m_controls.GetStartPosition();
- while(pos)
- {
+ while(pos) {
UINT id;
CWnd* pControl;
m_controls.GetNextAssoc(pos, id, pControl);
- if(pControl) pControl->Detach();
+ if(pControl) {
+ pControl->Detach();
+ }
}
m_fAttached = false;
@@ -313,9 +323,10 @@ CDVSMainPPage::~CDVSMainPPage()
void CDVSMainPPage::FreeLangs()
{
- if(m_nLangs > 0 && m_ppLangs)
- {
- for(ptrdiff_t i = 0; i < m_nLangs; i++) CoTaskMemFree(m_ppLangs[i]);
+ if(m_nLangs > 0 && m_ppLangs) {
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ CoTaskMemFree(m_ppLangs[i]);
+ }
CoTaskMemFree(m_ppLangs);
m_nLangs = 0;
m_ppLangs = NULL;
@@ -330,52 +341,45 @@ void CDVSMainPPage::AllocLangs(int nLangs)
bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_OPEN)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CFileDialog fd(TRUE, NULL, NULL,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,
- _T(".idx .smi .sub .srt .psb .ssa .ass .usf .ssf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf;*.ssf|")
- _T("All files (*.*)|*.*||"),
- CDialog::FromHandle(m_Dlg), 0);
-
- if(fd.DoModal() == IDOK)
- {
- m_fnedit.SetWindowText(fd.GetPathName());
- }
-
- return(true);
- }
- else if(LOWORD(wParam) == IDC_FONT)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
-
- if(dlg.DoModal() == IDOK)
- {
- m_defStyle = dlg.m_stss;
- CString str = m_defStyle.fontName;
- if(str.GetLength() > 18) str = str.Left(16).TrimRight() + _T("...");
- m_font.SetWindowText(str);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_OPEN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CFileDialog fd(TRUE, NULL, NULL,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,
+ _T(".idx .smi .sub .srt .psb .ssa .ass .usf .ssf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf;*.ssf|")
+ _T("All files (*.*)|*.*||"),
+ CDialog::FromHandle(m_Dlg), 0);
+
+ if(fd.DoModal() == IDOK) {
+ m_fnedit.SetWindowText(fd.GetPathName());
+ }
+
+ return(true);
+ } else if(LOWORD(wParam) == IDC_FONT) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
+
+ if(dlg.DoModal() == IDOK) {
+ m_defStyle = dlg.m_stss;
+ CString str = m_defStyle.fontName;
+ if(str.GetLength() > 18) {
+ str = str.Left(16).TrimRight() + _T("...");
+ }
+ m_font.SetWindowText(str);
+ }
+
+ return(true);
+ }
}
-
- return(true);
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -383,14 +387,14 @@ bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSMainPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
- if(m_pDirectVobSub->put_FileName(m_fn) == S_OK)
- {
+ if(fSave) {
+ if(m_pDirectVobSub->put_FileName(m_fn) == S_OK) {
int nLangs;
m_pDirectVobSub->get_LanguageCount(&nLangs);
AllocLangs(nLangs);
- for(ptrdiff_t i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ }
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
}
@@ -399,14 +403,14 @@ void CDVSMainPPage::UpdateObjectData(bool fSave)
m_pDirectVobSub->put_VobSubSettings(true, m_fOnlyShowForcedVobSubs, false);
m_pDirectVobSub->put_TextSettings(&m_defStyle);
m_pDirectVobSub->put_AspectRatioSettings(&m_ePARCompensationType);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_FileName(m_fn);
int nLangs;
m_pDirectVobSub->get_LanguageCount(&nLangs);
AllocLangs(nLangs);
- for(ptrdiff_t i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ }
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
m_pDirectVobSub->get_Placement(&m_fOverridePlacement, &m_PlacementXperc, &m_PlacementYperc);
m_pDirectVobSub->get_VobSubSettings(NULL, &m_fOnlyShowForcedVobSubs, NULL);
@@ -417,8 +421,7 @@ void CDVSMainPPage::UpdateObjectData(bool fSave)
void CDVSMainPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
CString fn;
m_fnedit.GetWindowText(fn);
#ifdef UNICODE
@@ -431,13 +434,12 @@ void CDVSMainPPage::UpdateControlData(bool fSave)
m_PlacementXperc = m_subposx.GetPos();
m_PlacementYperc = m_subposy.GetPos();
m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();
- if (m_PARCombo.GetCurSel() != CB_ERR)
+ if (m_PARCombo.GetCurSel() != CB_ERR) {
m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(m_PARCombo.GetItemData(m_PARCombo.GetCurSel()));
- else
+ } else {
m_ePARCompensationType = CSimpleTextSubtitle::EPCTDisabled;
- }
- else
- {
+ }
+ } else {
m_fnedit.SetWindowText(CString(m_fn));
m_oplacement.SetCheck(m_fOverridePlacement);
m_subposx.SetRange(-20, 120);
@@ -450,29 +452,35 @@ void CDVSMainPPage::UpdateControlData(bool fSave)
m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);
m_langs.ResetContent();
m_langs.EnableWindow(m_nLangs > 0);
- for(ptrdiff_t i = 0; i < m_nLangs; i++) m_langs.AddString(CString(m_ppLangs[i]));
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_langs.AddString(CString(m_ppLangs[i]));
+ }
m_langs.SetCurSel(m_iSelectedLanguage);
m_PARCombo.ResetContent();
m_PARCombo.InsertString(0, ResStr(IDS_RT_PAR_DISABLED));
m_PARCombo.SetItemData(0, CSimpleTextSubtitle::EPCTDisabled);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled) {
m_PARCombo.SetCurSel(0);
+ }
m_PARCombo.InsertString(1, ResStr(IDS_RT_PAR_DOWNSCALE));
m_PARCombo.SetItemData(1, CSimpleTextSubtitle::EPCTDownscale);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale) {
m_PARCombo.SetCurSel(1);
+ }
m_PARCombo.InsertString(2, ResStr(IDS_RT_PAR_UPSCALE));
m_PARCombo.SetItemData(2, CSimpleTextSubtitle::EPCTUpscale);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale) {
m_PARCombo.SetCurSel(2);
+ }
m_PARCombo.InsertString(3, ResStr(IDS_RT_PAR_ACCURATE_SIZE));
m_PARCombo.SetItemData(3, CSimpleTextSubtitle::EPCTAccurateSize);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize) {
m_PARCombo.SetCurSel(3);
+ }
}
}
@@ -494,34 +502,27 @@ CDVSGeneralPPage::CDVSGeneralPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case CBN_SELCHANGE:
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if(LOWORD(wParam) == IDC_RESX2COMBO)
- {
- m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
- m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
- return(true);
- }
- else if(LOWORD(wParam) == IDC_LOADCOMBO)
- {
- m_extload.EnableWindow(m_load.GetCurSel() == 1);
- m_webload.EnableWindow(m_load.GetCurSel() == 1);
- m_embload.EnableWindow(m_load.GetCurSel() == 1);
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case CBN_SELCHANGE: {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if(LOWORD(wParam) == IDC_RESX2COMBO) {
+ m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
+ m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
+ return(true);
+ } else if(LOWORD(wParam) == IDC_LOADCOMBO) {
+ m_extload.EnableWindow(m_load.GetCurSel() == 1);
+ m_webload.EnableWindow(m_load.GetCurSel() == 1);
+ m_embload.EnableWindow(m_load.GetCurSel() == 1);
+ return(true);
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -529,13 +530,10 @@ bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSGeneralPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_ExtendPicture(m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh);
m_pDirectVobSub->put_LoadSettings(m_LoadLevel, m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_ExtendPicture(&m_HorExt, &m_VerExt, &m_ResX2, &m_ResX2minw, &m_ResX2minh);
m_pDirectVobSub->get_LoadSettings(&m_LoadLevel, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
}
@@ -543,20 +541,23 @@ void CDVSGeneralPPage::UpdateObjectData(bool fSave)
void CDVSGeneralPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
- if(m_verext.GetCurSel() >= 0) m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
+ if(fSave) {
+ if(m_verext.GetCurSel() >= 0) {
+ m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
+ }
m_HorExt = !!m_mod32fix.GetCheck();
- if(m_resx2.GetCurSel() >= 0) m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
+ if(m_resx2.GetCurSel() >= 0) {
+ m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
+ }
m_ResX2minw = m_resx2w.GetPos();
m_ResX2minh = m_resx2h.GetPos();
- if(m_load.GetCurSel() >= 0) m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
+ if(m_load.GetCurSel() >= 0) {
+ m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
+ }
m_fExternalLoad = !!m_extload.GetCheck();
m_fWebLoad = !!m_webload.GetCheck();
m_fEmbeddedLoad = !!m_embload.GetCheck();
- }
- else
- {
+ } else {
m_verext.ResetContent();
m_verext.AddString(ResStr(IDS_ORGHEIGHT));
m_verext.SetItemData(0, 0);
@@ -622,25 +623,20 @@ CDVSMiscPPage::CDVSMiscPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_INSTANTUPDATE)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_INSTANTUPDATE) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
+ return(true);
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -648,17 +644,14 @@ bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSMiscPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_Flip(m_fFlipPicture, m_fFlipSubtitles);
m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles);
m_pDirectVobSub->put_OSD(m_fOSD);
m_pDirectVobSub->put_PreBuffering(m_fDoPreBuffering);
m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
m_pDirectVobSub->put_SaveFullPath(m_fSaveFullPath);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_Flip(&m_fFlipPicture, &m_fFlipSubtitles);
m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
m_pDirectVobSub->get_OSD(&m_fOSD);
@@ -670,8 +663,7 @@ void CDVSMiscPPage::UpdateObjectData(bool fSave)
void CDVSMiscPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_fFlipPicture = !!m_flippic.GetCheck();
m_fFlipSubtitles = !!m_flipsub.GetCheck();
m_fHideSubtitles = !!m_hidesub.GetCheck();
@@ -679,9 +671,7 @@ void CDVSMiscPPage::UpdateControlData(bool fSave)
m_fDoPreBuffering = !!m_prebuff.GetCheck();
m_fOSD = !!m_showosd.GetCheck();
m_fReloaderDisabled = !m_autoreload.GetCheck();
- }
- else
- {
+ } else {
m_flippic.SetCheck(m_fFlipPicture);
m_flipsub.SetCheck(m_fFlipSubtitles);
m_hidesub.SetCheck(m_fHideSubtitles);
@@ -707,25 +697,20 @@ CDVSTimingPPage::CDVSTimingPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_MODFPS)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- m_fps.EnableWindow(!!m_modfps.GetCheck());
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_MODFPS) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ m_fps.EnableWindow(!!m_modfps.GetCheck());
+ return(true);
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -733,13 +718,10 @@ bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSTimingPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_SubtitleTiming(m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv);
m_pDirectVobSub->put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_SubtitleTiming(&m_SubtitleDelay, &m_SubtitleSpeedMul, &m_SubtitleSpeedDiv);
m_pDirectVobSub->get_MediaFPS(&m_fMediaFPSEnabled, &m_MediaFPS);
}
@@ -747,13 +729,14 @@ void CDVSTimingPPage::UpdateObjectData(bool fSave)
void CDVSTimingPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_fMediaFPSEnabled = !!m_modfps.GetCheck();
CString fpsstr;
m_fps.GetWindowText(fpsstr);
float fps;
- if(_stscanf(fpsstr, _T("%f"), &fps) == 1) m_MediaFPS = fps;
+ if(_stscanf(fpsstr, _T("%f"), &fps) == 1) {
+ m_MediaFPS = fps;
+ }
#if _MFC_VER >= 0x0700
m_SubtitleDelay = m_subdelay.GetPos32();
m_SubtitleSpeedMul = m_subspeedmul.GetPos32();
@@ -763,9 +746,7 @@ void CDVSTimingPPage::UpdateControlData(bool fSave)
m_SubtitleSpeedMul = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN6), UDM_GETPOS32, 0, 0);
m_SubtitleSpeedDiv = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN9), UDM_GETPOS32, 0, 0);
#endif
- }
- else
- {
+ } else {
m_modfps.SetCheck(m_fMediaFPSEnabled);
CString fpsstr;
fpsstr.Format(_T("%.4f"), m_MediaFPS);
@@ -796,40 +777,32 @@ CDVSAboutPPage::CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr) :
bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
+ switch(uMsg) {
+ case WM_INITDIALOG: {
#ifdef _VSMOD
- SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)", MOD\nCopyright 2001-2010 MPC-HC & VSFilterMod Teams" );
+ SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)", MOD\nCopyright 2001-2010 MPC-HC & VSFilterMod Teams" );
#else
- SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)"\nCopyright 2001-2010 MPC-HC Team" );
+ SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)"\nCopyright 2001-2010 MPC-HC Team" );
#endif
- }
- break;
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_HOMEPAGEBTN)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_HOMEPAGE), NULL, NULL, SW_SHOWNORMAL);
- return(true);
- }
- else if(LOWORD(wParam) == IDC_BUGREPORTBTN)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_EMAIL), NULL, NULL, SW_SHOWNORMAL);
- return(true);
- }
}
break;
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_HOMEPAGEBTN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_HOMEPAGE), NULL, NULL, SW_SHOWNORMAL);
+ return(true);
+ } else if(LOWORD(wParam) == IDC_BUGREPORTBTN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_EMAIL), NULL, NULL, SW_SHOWNORMAL);
+ return(true);
+ }
+ }
+ break;
+ }
}
- }
- break;
+ break;
}
return(false);
@@ -848,28 +821,23 @@ CDVSZoomPPage::CDVSZoomPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case EN_CHANGE:
- {
- if(LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
- || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- UpdateControlData(true);
- UpdateObjectData(true);
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case EN_CHANGE: {
+ if(LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
+ || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ UpdateControlData(true);
+ UpdateObjectData(true);
+ return(true);
+ }
+ }
+
+ break;
}
}
-
break;
- }
- }
- break;
}
return(false);
@@ -877,15 +845,12 @@ bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSZoomPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_rect.left = 1.0f * (short)m_posx.GetPos() / 100;
m_rect.top = 1.0f * (short)m_posy.GetPos() / 100;
m_rect.right = m_rect.left + 1.0f * (short)m_scalex.GetPos() / 100;
m_rect.bottom = m_rect.top + 1.0f * (short)m_scaley.GetPos() / 100;
- }
- else
- {
+ } else {
m_posx.SetRange(-100, 100);
m_posx.SetPos((int)(m_rect.left*100));
m_posy.SetRange(-100, 100);
@@ -899,12 +864,9 @@ void CDVSZoomPPage::UpdateControlData(bool fSave)
void CDVSZoomPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_ZoomRect(&m_rect);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_ZoomRect(&m_rect);
}
}
@@ -925,77 +887,68 @@ CDVSColorPPage::CDVSColorPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case LBN_DBLCLK:
- if((HWND)lParam == m_dynchglist.m_hWnd)
- {
- int old = -1;
- m_pDirectVobSub->get_ColorFormat(&old);
- if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel())))
- m_dynchglist.SetCurSel(old);
-
- return(true);
- }
- break;
-
- case BN_CLICKED:
- {
- switch(LOWORD(wParam))
- {
- case IDC_COLORCHANGE:
- {
- int old = -1;
- m_pDirectVobSub->get_ColorFormat(&old);
- if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel())))
- m_dynchglist.SetCurSel(old);
-
- return(true);
- }
- case IDC_COLORUP:
- {
- int sel = m_preflist.GetCurSel();
- if(sel > 0)
- {
- CString str;
- m_preflist.GetText(sel, str);
- int iPos = (int)m_preflist.GetItemData(sel);
- m_preflist.DeleteString(sel);
- sel--;
- m_preflist.InsertString(sel, str);
- m_preflist.SetItemData(sel, iPos);
- m_preflist.SetCurSel(sel);
- }
-
- return(true);
- }
- case IDC_COLORDOWN:
- {
- int sel = m_preflist.GetCurSel();
- if(sel >= 0 && sel < m_preflist.GetCount()-1)
- {
- CString str;
- m_preflist.GetText(sel, str);
- int iPos = (int)m_preflist.GetItemData(sel);
- m_preflist.DeleteString(sel);
- sel++;
- m_preflist.InsertString(sel, str);
- m_preflist.SetItemData(sel, iPos);
- m_preflist.SetCurSel(sel);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case LBN_DBLCLK:
+ if((HWND)lParam == m_dynchglist.m_hWnd) {
+ int old = -1;
+ m_pDirectVobSub->get_ColorFormat(&old);
+ if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ m_dynchglist.SetCurSel(old);
+ }
+
+ return(true);
+ }
+ break;
+
+ case BN_CLICKED: {
+ switch(LOWORD(wParam)) {
+ case IDC_COLORCHANGE: {
+ int old = -1;
+ m_pDirectVobSub->get_ColorFormat(&old);
+ if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ m_dynchglist.SetCurSel(old);
+ }
+
+ return(true);
+ }
+ case IDC_COLORUP: {
+ int sel = m_preflist.GetCurSel();
+ if(sel > 0) {
+ CString str;
+ m_preflist.GetText(sel, str);
+ int iPos = (int)m_preflist.GetItemData(sel);
+ m_preflist.DeleteString(sel);
+ sel--;
+ m_preflist.InsertString(sel, str);
+ m_preflist.SetItemData(sel, iPos);
+ m_preflist.SetCurSel(sel);
+ }
+
+ return(true);
+ }
+ case IDC_COLORDOWN: {
+ int sel = m_preflist.GetCurSel();
+ if(sel >= 0 && sel < m_preflist.GetCount()-1) {
+ CString str;
+ m_preflist.GetText(sel, str);
+ int iPos = (int)m_preflist.GetItemData(sel);
+ m_preflist.DeleteString(sel);
+ sel++;
+ m_preflist.InsertString(sel, str);
+ m_preflist.SetItemData(sel, iPos);
+ m_preflist.SetCurSel(sel);
+ }
+
+ return(true);
+ }
+ }
}
-
- return(true);
- }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -1003,35 +956,30 @@ bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSColorPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
- }
- else
- {
+ if(fSave) {
+ } else {
}
}
void CDVSColorPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
- if((UINT)m_preflist.GetCount() == VIHSIZE)
- {
+ if(fSave) {
+ if((UINT)m_preflist.GetCount() == VIHSIZE) {
BYTE* pData = new BYTE[VIHSIZE];
- for(ptrdiff_t i = 0; i < m_preflist.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_preflist.GetCount(); i++) {
pData[i] = (BYTE)m_preflist.GetItemData(i);
+ }
theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), pData, VIHSIZE);
delete [] pData;
+ } else {
+ ASSERT(0);
}
- else ASSERT(0);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), !!m_forcergb.GetCheck());
- }
- else
- {
+ } else {
m_preflist.ResetContent();
m_dynchglist.ResetContent();
@@ -1039,19 +987,20 @@ void CDVSColorPPage::UpdateControlData(bool fSave)
UINT nSize;
if(!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
- || !pData || nSize != VIHSIZE)
- {
- if(pData) delete [] pData, pData = NULL;
+ || !pData || nSize != VIHSIZE) {
+ if(pData) {
+ delete [] pData, pData = NULL;
+ }
nSize = VIHSIZE;
pData = new BYTE[VIHSIZE];
- for(ptrdiff_t i = 0; i < VIHSIZE; i++) pData[i] = i;
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++) {
+ pData[i] = i;
+ }
}
- if(pData)
- {
- for(ptrdiff_t i = 0; i < (int)nSize; i++)
- {
+ if(pData) {
+ for(ptrdiff_t i = 0; i < (int)nSize; i++) {
m_dynchglist.AddString(VIH2String(pData[i]));
m_dynchglist.SetItemData(i, pData[i]);
m_preflist.AddString(VIH2String(pData[i]));
@@ -1085,98 +1034,85 @@ CDVSPathsPPage::CDVSPathsPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case LBN_SELCHANGE:
- if((HWND)lParam == m_pathlist.m_hWnd)
- {
- int i = m_pathlist.GetCurSel();
- m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
- if(i >= 0)
- {
- CString path;
- m_pathlist.GetText(i, path);
- m_path.SetWindowText(path);
- }
- return(true);
- }
- break;
-
- case LBN_SELCANCEL:
- if((HWND)lParam == m_pathlist.m_hWnd)
- {
- m_remove.EnableWindow(FALSE);
- return(true);
- }
- break;
-
- case BN_CLICKED:
- {
- switch(LOWORD(wParam))
- {
- case IDC_BROWSE:
- {
- TCHAR pathbuff[MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_Dlg;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = pathbuff;
- bi.lpszTitle = _T("");
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
- bi.lpfn = NULL;
- bi.lParam = 0;
- bi.iImage = 0;
-
- LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if(iil)
- {
- SHGetPathFromIDList(iil, pathbuff);
- m_path.SetWindowText(pathbuff);
- }
-
- return(true);
- }
- break;
-
- case IDC_REMOVE:
- {
- int i = m_pathlist.GetCurSel();
- if(i >= 0)
- {
- m_pathlist.DeleteString(i);
- i = min(i, m_pathlist.GetCount()-1);
- if(i >= 0 && m_pathlist.GetCount() > 0)
- {
- m_pathlist.SetCurSel(i);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case LBN_SELCHANGE:
+ if((HWND)lParam == m_pathlist.m_hWnd) {
+ int i = m_pathlist.GetCurSel();
m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
+ if(i >= 0) {
+ CString path;
+ m_pathlist.GetText(i, path);
+ m_path.SetWindowText(path);
+ }
+ return(true);
}
- }
-
- return(true);
- }
- break;
+ break;
- case IDC_ADD:
- {
- CString path;
- m_path.GetWindowText(path);
- if(!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0)
- m_pathlist.AddString(path);
-
- return(true);
- }
- break;
+ case LBN_SELCANCEL:
+ if((HWND)lParam == m_pathlist.m_hWnd) {
+ m_remove.EnableWindow(FALSE);
+ return(true);
+ }
+ break;
+
+ case BN_CLICKED: {
+ switch(LOWORD(wParam)) {
+ case IDC_BROWSE: {
+ TCHAR pathbuff[MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_Dlg;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = pathbuff;
+ bi.lpszTitle = _T("");
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ LPITEMIDLIST iil = SHBrowseForFolder(&bi);
+ if(iil) {
+ SHGetPathFromIDList(iil, pathbuff);
+ m_path.SetWindowText(pathbuff);
+ }
+
+ return(true);
+ }
+ break;
+
+ case IDC_REMOVE: {
+ int i = m_pathlist.GetCurSel();
+ if(i >= 0) {
+ m_pathlist.DeleteString(i);
+ i = min(i, m_pathlist.GetCount()-1);
+ if(i >= 0 && m_pathlist.GetCount() > 0) {
+ m_pathlist.SetCurSel(i);
+ m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
+ }
+ }
+
+ return(true);
+ }
+ break;
+
+ case IDC_ADD: {
+ CString path;
+ m_path.GetWindowText(path);
+ if(!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0) {
+ m_pathlist.AddString(path);
+ }
+
+ return(true);
+ }
+ break;
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -1184,55 +1120,48 @@ bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSPathsPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
CString chk(_T("123456789")), path, tmp;
int i = 0;
- do
- {
+ do {
tmp.Format(ResStr(IDS_RP_PATH), i++);
path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- if(path != chk) theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
- }
- while(path != chk);
+ if(path != chk) {
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
+ }
+ } while(path != chk);
- for(i = 0; i < m_paths.GetSize(); i++)
- {
+ for(i = 0; i < m_paths.GetSize(); i++) {
tmp.Format(ResStr(IDS_RP_PATH), i);
theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, m_paths[i]);
}
- }
- else
- {
+ } else {
CString chk(_T("123456789")), path, tmp;
int i = 0;
- do
- {
- if(!path.IsEmpty()) m_paths.Add(path);
+ do {
+ if(!path.IsEmpty()) {
+ m_paths.Add(path);
+ }
tmp.Format(ResStr(IDS_RP_PATH), i++);
path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- }
- while(path != chk);
+ } while(path != chk);
}
}
void CDVSPathsPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_paths.RemoveAll();
- for(ptrdiff_t i = 0; i < m_pathlist.GetCount(); i++)
- {
+ for(ptrdiff_t i = 0; i < m_pathlist.GetCount(); i++) {
CString path;
m_pathlist.GetText(i, path);
m_paths.Add(path);
}
- }
- else
- {
+ } else {
m_pathlist.ResetContent();
- for(ptrdiff_t i = 0; i < m_paths.GetSize(); i++)
+ for(ptrdiff_t i = 0; i < m_paths.GetSize(); i++) {
m_pathlist.AddString(m_paths[i]);
+ }
m_remove.EnableWindow(FALSE);
m_add.EnableWindow(TRUE);
diff --git a/src/filters/transform/VSFilter/IDirectVobSub.h b/src/filters/transform/VSFilter/IDirectVobSub.h
index b917f87c3..37fefc6d1 100644
--- a/src/filters/transform/VSFilter/IDirectVobSub.h
+++ b/src/filters/transform/VSFilter/IDirectVobSub.h
@@ -253,24 +253,21 @@ IDirectVobSub :
interface __declspec(uuid("FE6EC6A0-21CA-4970-9EF0-B296F7F38AF0"))
ISubClock :
- public IUnknown
- {
+ public IUnknown {
STDMETHOD(SetTime)(REFERENCE_TIME rt) PURE;
STDMETHOD_(REFERENCE_TIME, GetTime)() PURE;
};
interface __declspec(uuid("0665B760-FBC1-46C3-A35F-E471527C96A4"))
ISubClock2 :
- public ISubClock
- {
+ public ISubClock {
STDMETHOD(SetAvgTimePerFrame)(REFERENCE_TIME rt) PURE;
STDMETHOD(GetAvgTimePerFrame)(REFERENCE_TIME* prt) PURE; // return S_OK only if *prt was set and is valid
};
interface __declspec(uuid("AB52FC9C-2415-4dca-BC1C-8DCC2EAE8150"))
IDirectVobSub2 :
- public IDirectVobSub
- {
+ public IDirectVobSub {
STDMETHOD(AdviseSubClock) (THIS_
ISubClock* pSubClock
) PURE;
diff --git a/src/filters/transform/VSFilter/Scale2x.cpp b/src/filters/transform/VSFilter/Scale2x.cpp
index 71cf01f24..f05773520 100644
--- a/src/filters/transform/VSFilter/Scale2x.cpp
+++ b/src/filters/transform/VSFilter/Scale2x.cpp
@@ -37,13 +37,11 @@ void Scale2x_YV( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1); s1 < s3; s1 += 1, d1 += 2)
- {
+ for(BYTE* s3 = s1 + (w-1); s1 < s3; s1 += 1, d1 += 2) {
d1[0] = s1[0];
d1[1] = (s1[0]+s1[1])>>1;
}
@@ -70,8 +68,7 @@ void Scale2x_YUY2_SSE2( BYTE* s1, BYTE* d1, int w )
__m128i mm4 = _mm_cvtsi64_si128(__0x00ff00ff00ff00ff);
__m128i mm5 = _mm_cvtsi64_si128(__0x00000000ffffffff);
__m128i mm6 = _mm_cvtsi64_si128(__0xffffffff00000000);
- for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8)
- {
+ for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8) {
__m128i mm0 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm0, [esi]
__m128i mm2 = _mm_move_epi64(mm0); //movq mm2, mm0
mm0 = _mm_and_si128(mm0, mm4); //pand mm0, mm4 // mm0 = 00y400y300y200y1
@@ -112,8 +109,7 @@ void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w )
unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
- __asm
- {
+ __asm {
mov esi, s1
mov edi, d1
@@ -124,7 +120,7 @@ void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w )
movq mm4, __0x00ff00ff00ff00ff
movq mm5, __0x00000000ffffffff
movq mm6, __0xffffffff00000000
-row_loop1:
+ row_loop1:
movq mm0, [esi]
movq mm2, mm0
@@ -185,8 +181,7 @@ row_loop1:
void Scale2x_YUY2_c( BYTE* s1, BYTE* d1, int w )
{
- for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8)
- {
+ for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8) {
d1[0] = s1[0];
d1[1] = s1[1];
d1[2] = (s1[0]+s1[2])>>1;
@@ -229,8 +224,7 @@ void Scale2x_YUY2( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch)
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) {
// row0, 4 pixels: y1|u1|y2|v1|y3|u2|y4|v2
// ->
// row0, 8 pixels: y1|u1|(y1+y2)/2|v1|y2|(u1+u2)/2|(y2+y3)/2|(v1+v2)/2
@@ -254,13 +248,11 @@ void Scale2x_RGB555( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4)
- {
+ for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4) {
*((WORD*)d1) = *((WORD*)s1);
*((WORD*)d1+1) =
((((*((WORD*)s1)&0x7c00) + (*((WORD*)s1+1)&0x7c00)) >> 1)&0x7c00)|
@@ -287,13 +279,11 @@ void Scale2x_RGB565( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4)
- {
+ for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4) {
*((WORD*)d1) = *((WORD*)s1);
*((WORD*)d1+1) =
((((*((WORD*)s1)&0xf800) + (*((WORD*)s1+1)&0xf800)) >> 1)&0xf800)|
@@ -320,13 +310,11 @@ void Scale2x_RGB24( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1)*3; s1 < s3; s1 += 3, d1 += 6)
- {
+ for(BYTE* s3 = s1 + (w-1)*3; s1 < s3; s1 += 3, d1 += 6) {
d1[0] = s1[0];
d1[1] = s1[1];
d1[2] = s1[2];
@@ -353,8 +341,7 @@ void Scale2x_RGB24( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
void Scale2x_XRGB32_SSE2( BYTE* s1, BYTE* d1, int w )
{
__m128i mm_zero = _mm_setzero_si128();//pxor mm0, mm0
- for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 4, d1 += 8)
- {
+ for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 4, d1 += 8) {
__m128i mm1 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm1, [esi]
__m128i mm2 = _mm_move_epi64(mm1); //movq mm2, mm1
@@ -379,8 +366,7 @@ void Scale2x_XRGB32_SSE2( BYTE* s1, BYTE* d1, int w )
#else
void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w )
{
- __asm
- {
+ __asm {
mov esi, s1
mov edi, d1
@@ -388,7 +374,7 @@ void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w )
dec ecx
pxor mm0, mm0
-row_loop3:
+ row_loop3:
movq mm1, [esi]
movq mm2, mm1
@@ -422,8 +408,7 @@ row_loop3:
void Scale2x_XRGB32_c( BYTE* s1, BYTE* d1, int w )
{
- for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 3, d1 += 6)
- {
+ for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 3, d1 += 6) {
d1[0] = s1[0];
d1[1] = s1[1];
d1[2] = s1[2];
@@ -456,8 +441,7 @@ void Scale2x_XRGB32( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch)
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) {
scale_func(s1, d1, w);
s1 += spitch;
@@ -474,16 +458,17 @@ void Scale2x_XRGB32( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
/* ResX2 */
void Scale2x(const GUID& subtype, BYTE* d, int dpitch, BYTE* s, int spitch, int w, int h)
{
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
Scale2x_YV(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_YUY2)
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
Scale2x_YUY2(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB555)
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
Scale2x_RGB555(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB565)
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
Scale2x_RGB565(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB24)
+ } else if(subtype == MEDIASUBTYPE_RGB24) {
Scale2x_RGB24(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32)
+ } else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
Scale2x_XRGB32(w, h, d, dpitch, s, spitch);
+ }
}
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.cpp b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
index b31fa4b9c..0cd270f06 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.cpp
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
@@ -106,11 +106,12 @@ void CStyleEditorDialog::DoDataExchange(CDataExchange* pDX)
void CStyleEditorDialog::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
UpdateData();
- if(m_iCharset >= 0) m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ if(m_iCharset >= 0) {
+ m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ }
m_stss.fontSpacing = m_spacing;
m_stss.fontAngleZ = m_angle;
m_stss.fontScaleX = m_scalex;
@@ -123,24 +124,27 @@ void CStyleEditorDialog::UpdateControlData(bool fSave)
m_stss.scrAlignment = m_screenalignment+1;
m_stss.marginRect = m_margin;
- for(ptrdiff_t i = 0; i < 4; i++) m_stss.alpha[i] = 255-m_alpha[i];
- }
- else
- {
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ m_stss.alpha[i] = 255-m_alpha[i];
+ }
+ } else {
m_font.SetWindowText(m_stss.fontName);
m_iCharset = -1;
- for(ptrdiff_t i = 0; i < CharSetLen; i++)
- {
+ for(ptrdiff_t i = 0; i < CharSetLen; i++) {
CString str;
str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
m_charset.AddString(str);
m_charset.SetItemData(i, CharSetList[i]);
- if(m_stss.charSet == CharSetList[i]) m_iCharset = i;
+ if(m_stss.charSet == CharSetList[i]) {
+ m_iCharset = i;
+ }
}
// TODO: allow floats in these edit boxes
m_spacing = m_stss.fontSpacing;
m_spacingspin.SetRange32(-10000, 10000);
- while(m_stss.fontAngleZ < 0) m_stss.fontAngleZ += 360;
+ while(m_stss.fontAngleZ < 0) {
+ m_stss.fontAngleZ += 360;
+ }
m_angle = fmod(m_stss.fontAngleZ, 360);
m_anglespin.SetRange32(0, 359);
m_scalex = m_stss.fontScaleX;
@@ -161,8 +165,7 @@ void CStyleEditorDialog::UpdateControlData(bool fSave)
m_margintopspin.SetRange32(-10000, 10000);
m_marginbottomspin.SetRange32(-10000, 10000);
- for(ptrdiff_t i = 0; i < 4; i++)
- {
+ for(ptrdiff_t i = 0; i < 4; i++) {
m_color[i].SetColorPtr(&m_stss.colors[i]);
m_alpha[i] = 255-m_stss.alpha[i];
m_alphasliders[i].SetRange(0, 255);
@@ -178,8 +181,7 @@ void CStyleEditorDialog::AskColor(int i)
{
CColorDialog dlg(m_stss.colors[i]);
dlg.m_cc.Flags |= CC_FULLOPEN;
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
m_stss.colors[i] = dlg.m_cc.rgbResult;
m_color[i].Invalidate();
}
@@ -223,16 +225,15 @@ void CStyleEditorDialog::OnBnClickedButton1()
lf <<= m_stss;
CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCALABLEONLY|CF_EFFECTS);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
CString str(lf.lfFaceName);
- if(str.GetLength() > 16) str = str.Left(14) + _T("...");
+ if(str.GetLength() > 16) {
+ str = str.Left(14) + _T("...");
+ }
m_font.SetWindowText(str);
- for(ptrdiff_t i = 0, j = m_charset.GetCount(); i < j; i++)
- {
- if(m_charset.GetItemData(i) == lf.lfCharSet)
- {
+ for(ptrdiff_t i = 0, j = m_charset.GetCount(); i < j; i++) {
+ if(m_charset.GetItemData(i) == lf.lfCharSet) {
m_charset.SetCurSel(i);
break;
}
@@ -267,17 +268,22 @@ void CStyleEditorDialog::OnBnClickedCheck1()
UpdateData();
int avg = 0;
- for(ptrdiff_t i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ avg += m_alphasliders[i].GetPos();
+ }
avg /= 4;
- for(ptrdiff_t i = 0; i < 4; i++) m_alphasliders[i].SetPos(avg);
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(avg);
+ }
}
void CStyleEditorDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(m_linkalphasliders && pScrollBar)
- {
+ if(m_linkalphasliders && pScrollBar) {
int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for(ptrdiff_t i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(pos);
+ }
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.h b/src/filters/transform/VSFilter/StyleEditorDialog.h
index b0760539d..ce6585d4b 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.h
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.h
@@ -46,8 +46,7 @@ public:
DECLARE_MESSAGE_MAP()
protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
+ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CRect r;
GetClientRect(r);
CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
@@ -70,7 +69,7 @@ public:
CStyleEditorDialog(CString title, STSStyle* pstss, CWnd* pParent = NULL); // standard constructor
virtual ~CStyleEditorDialog();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_STYLEDIALOG };
STSStyle m_stss;
diff --git a/src/filters/transform/VSFilter/Systray.cpp b/src/filters/transform/VSFilter/Systray.cpp
index 63a4aa0fa..8fcb10948 100644
--- a/src/filters/transform/VSFilter/Systray.cpp
+++ b/src/filters/transform/VSFilter/Systray.cpp
@@ -43,27 +43,25 @@ LRESULT CALLBACK HookProc(UINT code, WPARAM wParam, LPARAM lParam)
{
MSG* msg = (MSG*)lParam;
- if(msg->message == WM_KEYDOWN)
- {
- switch(msg->wParam)
- {
- case VK_F13:
- PostMessage(HWND_BROADCAST, WM_DVSPREVSUB, 0, 0);
- break;
- case VK_F14:
- PostMessage(HWND_BROADCAST, WM_DVSNEXTSUB, 0, 0);
- break;
- case VK_F15:
- PostMessage(HWND_BROADCAST, WM_DVSHIDESUB, 0, 0);
- break;
- case VK_F16:
- PostMessage(HWND_BROADCAST, WM_DVSSHOWSUB, 0, 0);
- break;
- case VK_F17:
- PostMessage(HWND_BROADCAST, WM_DVSSHOWHIDESUB, 0, 0);
- break;
- default:
- break;
+ if(msg->message == WM_KEYDOWN) {
+ switch(msg->wParam) {
+ case VK_F13:
+ PostMessage(HWND_BROADCAST, WM_DVSPREVSUB, 0, 0);
+ break;
+ case VK_F14:
+ PostMessage(HWND_BROADCAST, WM_DVSNEXTSUB, 0, 0);
+ break;
+ case VK_F15:
+ PostMessage(HWND_BROADCAST, WM_DVSHIDESUB, 0, 0);
+ break;
+ case VK_F16:
+ PostMessage(HWND_BROADCAST, WM_DVSSHOWSUB, 0, 0);
+ break;
+ case VK_F17:
+ PostMessage(HWND_BROADCAST, WM_DVSSHOWHIDESUB, 0, 0);
+ break;
+ default:
+ break;
}
}
@@ -75,23 +73,28 @@ class CSystrayWindow : public CWnd
{
SystrayIconData* m_tbid;
- void StepSub(int dir)
- {
+ void StepSub(int dir) {
int iSelected, nLangs;
- if(FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) return;
- if(FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) return;
- if(nLangs > 0) m_tbid->dvs->put_SelectedLanguage((iSelected+dir+nLangs)%nLangs);
+ if(FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) {
+ return;
+ }
+ if(FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) {
+ return;
+ }
+ if(nLangs > 0) {
+ m_tbid->dvs->put_SelectedLanguage((iSelected+dir+nLangs)%nLangs);
+ }
}
- void ShowSub(bool fShow)
- {
+ void ShowSub(bool fShow) {
m_tbid->dvs->put_HideSubtitles(!fShow);
}
- void ToggleSub()
- {
+ void ToggleSub() {
bool fShow;
- if(FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) return;
+ if(FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) {
+ return;
+ }
m_tbid->dvs->put_HideSubtitles(!fShow);
}
@@ -131,13 +134,13 @@ END_MESSAGE_MAP()
int CSystrayWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CWnd::OnCreate(lpCreateStruct) == -1)
+ if(CWnd::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
- if(g_hHook == INVALID_HANDLE_VALUE)
- {
+ if(g_hHook == INVALID_HANDLE_VALUE) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
-// g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
+ // g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
}
SetTimer(1, 5000, NULL);
@@ -160,8 +163,7 @@ void CSystrayWindow::OnDestroy()
tnid.uID = IDI_ICON1;
Shell_NotifyIcon(NIM_DELETE, &tnid);
- if(g_hHook != INVALID_HANDLE_VALUE)
- {
+ if(g_hHook != INVALID_HANDLE_VALUE) {
UnhookWindowsHookEx(g_hHook);
g_hHook = (HHOOK)INVALID_HANDLE_VALUE;
}
@@ -171,11 +173,9 @@ void CSystrayWindow::OnDestroy()
void CSystrayWindow::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
+ if(nIDEvent == 1) {
UINT fScreenSaver = 0;
- if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fScreenSaver, 0))
- {
+ if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fScreenSaver, 0)) {
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fScreenSaver, 0, SPIF_SENDWININICHANGE);
}
@@ -214,21 +214,22 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_tbid->fShowIcon)
- {
+ if(m_tbid->fShowIcon) {
NOTIFYICONDATA tnid;
tnid.cbSize = sizeof(NOTIFYICONDATA);
tnid.hWnd = m_hWnd;
tnid.uID = IDI_ICON1;
tnid.hIcon = (HICON)LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
-// tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT);
+ // tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT);
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
tnid.uCallbackMessage = WM_NOTIFYICON;
lstrcpyn(tnid.szTip, TEXT("DirectVobSub"), sizeof(tnid.szTip));
BOOL res = Shell_NotifyIcon(NIM_ADD, &tnid);
- if(tnid.hIcon) DestroyIcon(tnid.hIcon);
+ if(tnid.hIcon) {
+ DestroyIcon(tnid.hIcon);
+ }
return res?0:-1;
}
@@ -238,145 +239,138 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM)
LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
- if((UINT)wParam != IDI_ICON1)
+ if((UINT)wParam != IDI_ICON1) {
return -1;
+ }
HWND hWnd = m_hWnd;
- switch((UINT)lParam)
- {
- case WM_LBUTTONDBLCLK:
- {
- // IMPORTANT: we must not hold the graph at the same time as showing the property page
- // or else when closing the app the graph doesn't get released and dvobsub's JoinFilterGraph
- // is never called to close us down.
-
- CComPtr<IBaseFilter> pBF2;
-
- BeginEnumFilters(m_tbid->graph, pEF, pBF)
- {
- if(!CComQIPtr<IDirectVobSub>(pBF))
- continue;
-
- if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph)
- {
- HWND hwnd;
- if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
- || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd)))
- hWnd = hwnd;
- }
+ switch((UINT)lParam) {
+ case WM_LBUTTONDBLCLK: {
+ // IMPORTANT: we must not hold the graph at the same time as showing the property page
+ // or else when closing the app the graph doesn't get released and dvobsub's JoinFilterGraph
+ // is never called to close us down.
- pBF2 = pBF;
+ CComPtr<IBaseFilter> pBF2;
- break;
- }
- EndEnumFilters
-
- if(pBF2)
- ShowPPage(pBF2, hWnd);
- }
- break;
+ BeginEnumFilters(m_tbid->graph, pEF, pBF) {
+ if(!CComQIPtr<IDirectVobSub>(pBF)) {
+ continue;
+ }
- case WM_RBUTTONDOWN:
- {
- POINT p;
- GetCursorPos(&p);
+ if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ HWND hwnd;
+ if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
+ hWnd = hwnd;
+ }
+ }
- CInterfaceArray<IAMStreamSelect> pStreams;
- CStringArray names;
+ pBF2 = pBF;
- BeginEnumFilters(m_tbid->graph, pEF, pBF)
- {
- CString name = GetFilterName(pBF);
- if(name.IsEmpty()) continue;
+ break;
+ }
+ EndEnumFilters
- if(CComQIPtr<IAMStreamSelect> pSS = pBF)
- {
- pStreams.Add(pSS);
- names.Add(name);
+ if(pBF2) {
+ ShowPPage(pBF2, hWnd);
}
}
- EndEnumFilters
+ break;
- CMenu popup;
- popup.CreatePopupMenu();
+ case WM_RBUTTONDOWN: {
+ POINT p;
+ GetCursorPos(&p);
- for(ptrdiff_t j = 0; j < pStreams.GetCount(); j++)
- {
- bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
+ CInterfaceArray<IAMStreamSelect> pStreams;
+ CStringArray names;
+
+ BeginEnumFilters(m_tbid->graph, pEF, pBF) {
+ CString name = GetFilterName(pBF);
+ if(name.IsEmpty()) {
+ continue;
+ }
+
+ if(CComQIPtr<IAMStreamSelect> pSS = pBF) {
+ pStreams.Add(pSS);
+ names.Add(name);
+ }
+ }
+ EndEnumFilters
- DWORD cStreams = 0;
- pStreams[j]->Count(&cStreams);
+ CMenu popup;
+ popup.CreatePopupMenu();
- DWORD flags, group, prevgroup = (DWORD)-1;
+ for(ptrdiff_t j = 0; j < pStreams.GetCount(); j++) {
+ bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
- for(UINT i = 0; i < cStreams; i++)
- {
- WCHAR* pName = NULL;
+ DWORD cStreams = 0;
+ pStreams[j]->Count(&cStreams);
- if(S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0))
- {
- if(prevgroup != group && i > 1)
- {
- if(fMMSwitcher) {
- cStreams = i;
- break;
+ DWORD flags, group, prevgroup = (DWORD)-1;
+
+ for(UINT i = 0; i < cStreams; i++) {
+ WCHAR* pName = NULL;
+
+ if(S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0)) {
+ if(prevgroup != group && i > 1) {
+ if(fMMSwitcher) {
+ cStreams = i;
+ break;
+ }
+ popup.AppendMenu(MF_SEPARATOR);
}
- popup.AppendMenu(MF_SEPARATOR);
- }
- prevgroup = group;
+ prevgroup = group;
- if(pName)
- {
- popup.AppendMenu(MF_ENABLED|MF_STRING|(flags?MF_CHECKED:MF_UNCHECKED), (1<<15)|(j<<8)|(i), CString(pName));
- CoTaskMemFree(pName);
+ if(pName) {
+ popup.AppendMenu(MF_ENABLED|MF_STRING|(flags?MF_CHECKED:MF_UNCHECKED), (1<<15)|(j<<8)|(i), CString(pName));
+ CoTaskMemFree(pName);
+ }
}
}
- }
-
- if(cStreams > 0) popup.AppendMenu(MF_SEPARATOR);
- }
- int i = 0;
-
- TCHAR* str;
- str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
- while(str)
- {
- if(_tcsncmp(str, _T("DivX MPEG"), 9) || m_tbid->fRunOnce) // divx3's ppage will crash if the graph hasn't been run at least once yet
- popup.AppendMenu(MF_ENABLED|MF_STRING|MF_UNCHECKED, (1<<14)|(i), str);
+ if(cStreams > 0) {
+ popup.AppendMenu(MF_SEPARATOR);
+ }
+ }
- delete [] str;
+ int i = 0;
- i++;
+ TCHAR* str;
str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
- }
+ while(str) {
+ if(_tcsncmp(str, _T("DivX MPEG"), 9) || m_tbid->fRunOnce) { // divx3's ppage will crash if the graph hasn't been run at least once yet
+ popup.AppendMenu(MF_ENABLED|MF_STRING|MF_UNCHECKED, (1<<14)|(i), str);
+ }
- SetForegroundWindow();
- UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
- PostMessage(WM_NULL);
+ delete [] str;
- if(id & (1<<15))
- {
- pStreams[(id>>8)&0x3f]->Enable(id&0xff, AMSTREAMSELECTENABLE_ENABLE);
- }
- else if(id & (1<<14))
- {
- if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph)
- {
- HWND hwnd;
- if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
- || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd)))
- hWnd = hwnd;
+ i++;
+ str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
}
- CallPPage(m_tbid->graph, id&0xff, hWnd);
- }
- }
- break;
+ SetForegroundWindow();
+ UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
+ PostMessage(WM_NULL);
+
+ if(id & (1<<15)) {
+ pStreams[(id>>8)&0x3f]->Enable(id&0xff, AMSTREAMSELECTENABLE_ENABLE);
+ } else if(id & (1<<14)) {
+ if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ HWND hwnd;
+ if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
+ hWnd = hwnd;
+ }
+ }
- default:
+ CallPPage(m_tbid->graph, id&0xff, hWnd);
+ }
+ }
break;
+
+ default:
+ break;
}
return 0;
@@ -389,14 +383,14 @@ DWORD CALLBACK SystrayThreadProc(void* pParam)
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CSystrayWindow wnd((SystrayIconData*)pParam);
- if(!wnd.CreateEx(0, AfxRegisterWndClass(0), _T("DVSWND"), WS_OVERLAPPED, CRect(0, 0, 0, 0), NULL, 0, NULL))
+ if(!wnd.CreateEx(0, AfxRegisterWndClass(0), _T("DVSWND"), WS_OVERLAPPED, CRect(0, 0, 0, 0), NULL, 0, NULL)) {
return (DWORD)-1;
+ }
((SystrayIconData*)pParam)->hSystrayWnd = wnd.m_hWnd;
MSG msg;
- while(GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0))
- {
+ while(GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -417,13 +411,13 @@ static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd)
CAUUID caGUID;
caGUID.pElems = NULL;
- BeginEnumFilters(pGraph, pEF, pBF)
- {
+ BeginEnumFilters(pGraph, pEF, pBF) {
CComQIPtr<ISpecifyPropertyPages> pSPS = pBF;
- if(!pSPS) continue;
+ if(!pSPS) {
+ continue;
+ }
- if(i == idx)
- {
+ if(i == idx) {
pFilter = pBF;
pSPS->GetPages(&caGUID);
wstr = _wcsdup(CStringW(GetFilterName(pBF))); // double char-wchar conversion happens in the non-unicode build, but anyway... :)
@@ -436,22 +430,23 @@ static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd)
TCHAR* ret = NULL;
- if(pFilter)
- {
- if(hWnd != INVALID_HANDLE_VALUE)
- {
+ if(pFilter) {
+ if(hWnd != INVALID_HANDLE_VALUE) {
ShowPPage(pFilter, hWnd);
- }
- else
- {
+ } else {
ret = new TCHAR[wcslen(wstr)+1];
- if(ret)
+ if(ret) {
_tcscpy(ret, CString(wstr));
+ }
}
}
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- if(wstr) free(wstr);
+ if(caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ if(wstr) {
+ free(wstr);
+ }
return(ret);
}
diff --git a/src/filters/transform/VSFilter/VSFilter.cpp b/src/filters/transform/VSFilter/VSFilter.cpp
index 12ae93e67..2bb1d23fb 100644
--- a/src/filters/transform/VSFilter/VSFilter.cpp
+++ b/src/filters/transform/VSFilter/VSFilter.cpp
@@ -44,8 +44,9 @@ extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL CVSFilterApp::InitInstance()
{
- if(!CWinApp::InitInstance())
+ if(!CWinApp::InitInstance()) {
return FALSE;
+ }
SetRegistryKey(_T("Gabest"));
@@ -82,8 +83,7 @@ CVSFilterApp theApp;
//////////////////////////////////////////////////////////////////////////
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
{&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2},
{&MEDIATYPE_Video, &MEDIASUBTYPE_YV12},
@@ -95,31 +95,27 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
{&MEDIATYPE_Video, &MEDIASUBTYPE_RGB24},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
{&MEDIATYPE_Text, &MEDIASUBTYPE_None},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_None},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
{L"Input2", TRUE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2}
};
-/*const*/ AMOVIESETUP_FILTER sudFilter[] =
-{
+/*const*/
+AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CDirectVobSubFilter), L"DirectVobSub", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CDirectVobSubFilter2), L"DirectVobSub (auto-loading version)", MERIT_PREFERRED+2, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDirectVobSubFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDirectVobSubFilter2>, NULL, &sudFilter[1]},
{L"DVSMainPPage", &__uuidof(CDVSMainPPage), CreateInstance<CDVSMainPPage>},
@@ -140,34 +136,38 @@ STDAPI DllRegisterServer()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1)
+ if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1) {
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0);
+ }
- if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1)
+ if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1) {
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), 0);
+ }
- if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1)
+ if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1) {
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0);
+ }
return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
-// DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
+ // DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
return AMovieDllRegisterServer2(FALSE);
}
void CALLBACK DirectVobSub(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
- if(FAILED(::CoInitialize(0))) return;
+ if(FAILED(::CoInitialize(0))) {
+ return;
+ }
CComPtr<IBaseFilter> pFilter;
CComQIPtr<ISpecifyPropertyPages> pSpecify;
- if(SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter))
- {
+ if(SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter)) {
ShowPPage(pFilter, hwnd);
}
diff --git a/src/filters/transform/VSFilter/csri.h b/src/filters/transform/VSFilter/csri.h
index 83ee828fa..7d67bae96 100644
--- a/src/filters/transform/VSFilter/csri.h
+++ b/src/filters/transform/VSFilter/csri.h
@@ -43,39 +43,39 @@ extern "C" {
#endif
#ifndef CSRIAPI
-/** CSRI API attributes.
- * defaults to \c extern.
-*/
+ /** CSRI API attributes.
+ * defaults to \c extern.
+ */
#define CSRIAPI extern
#endif
-/** \defgroup base CSRI base API. */
-/*@{*/
+ /** \defgroup base CSRI base API. */
+ /*@{*/
-/** pixel format specification for frames */
-enum csri_pixfmt {
- CSRI_F_RGBA = 0,
- CSRI_F_ARGB,
- CSRI_F_BGRA,
- CSRI_F_ABGR,
+ /** pixel format specification for frames */
+ enum csri_pixfmt {
+ CSRI_F_RGBA = 0,
+ CSRI_F_ARGB,
+ CSRI_F_BGRA,
+ CSRI_F_ABGR,
- CSRI_F_RGB_ = 0x100,
- CSRI_F__RGB,
- CSRI_F_BGR_, /**< Windows "RGB32" */
- CSRI_F__BGR,
+ CSRI_F_RGB_ = 0x100,
+ CSRI_F__RGB,
+ CSRI_F_BGR_, /**< Windows "RGB32" */
+ CSRI_F__BGR,
- CSRI_F_RGB = 0x200,
- CSRI_F_BGR, /**< Windows "RGB24" */
+ CSRI_F_RGB = 0x200,
+ CSRI_F_BGR, /**< Windows "RGB24" */
- CSRI_F_AYUV = 0x1000,
- CSRI_F_YUVA,
- CSRI_F_YVUA,
+ CSRI_F_AYUV = 0x1000,
+ CSRI_F_YUVA,
+ CSRI_F_YVUA,
- CSRI_F_YUY2 = 0x1100,
+ CSRI_F_YUY2 = 0x1100,
- CSRI_F_YV12A = 0x2011, /**< planar YUV 2x2 + alpha plane */
- CSRI_F_YV12 = 0x2111 /**< planar YUV 2x2 */
- };
+ CSRI_F_YV12A = 0x2011, /**< planar YUV 2x2 + alpha plane */
+ CSRI_F_YV12 = 0x2111 /**< planar YUV 2x2 */
+ };
#define csri_is_rgb(x) ((x) < 0x1000)
#define csri_is_yuv(x) ((x) >= 0x1000)
@@ -85,261 +85,261 @@ enum csri_pixfmt {
#define csri_is_yuv_packed(x) ((x) >= 0x1000 && (x) < 0x2000)
#define csri_has_alpha(x) (((x) & 0xfff) < 0x100)
-/** frame/image format specification pre-fed to the renderer */
-struct csri_fmt {
- /** format to be used */
- enum csri_pixfmt pixfmt;
- /** image width, full frame.
- *
- * This should specify the full size of the frame.
- * Specifying the video sub-size (in case of added black
- * borders) is left to an extension.
- */
- unsigned width;
- /** image height */
- unsigned height;
-};
-
-/** single frame to be fed to the renderer. */
-struct csri_frame {
- /** frame format.
- * It is an application bug if this differs from the one
- * passed in struct #csri_fmt to csri_query_fmt()
- */
- enum csri_pixfmt pixfmt;
- /** the frame's data.
- * Packed formats only use planes[0]; planar formats
- * have the data ordered as Y, U, V[, A].
- *
- * Also note that the topmost line always comes first.
- * The Windows biHeight strange-ity is \a NOT duplicated.
- */
- unsigned char *planes[4];
- /** strides for the individual planes.
- * Stride means full byte offset, i.e. do \a not add
- * frame width
- */
- ptrdiff_t strides[4];
-};
+ /** frame/image format specification pre-fed to the renderer */
+ struct csri_fmt {
+ /** format to be used */
+ enum csri_pixfmt pixfmt;
+ /** image width, full frame.
+ *
+ * This should specify the full size of the frame.
+ * Specifying the video sub-size (in case of added black
+ * borders) is left to an extension.
+ */
+ unsigned width;
+ /** image height */
+ unsigned height;
+ };
+
+ /** single frame to be fed to the renderer. */
+ struct csri_frame {
+ /** frame format.
+ * It is an application bug if this differs from the one
+ * passed in struct #csri_fmt to csri_query_fmt()
+ */
+ enum csri_pixfmt pixfmt;
+ /** the frame's data.
+ * Packed formats only use planes[0]; planar formats
+ * have the data ordered as Y, U, V[, A].
+ *
+ * Also note that the topmost line always comes first.
+ * The Windows biHeight strange-ity is \a NOT duplicated.
+ */
+ unsigned char *planes[4];
+ /** strides for the individual planes.
+ * Stride means full byte offset, i.e. do \a not add
+ * frame width
+ */
+ ptrdiff_t strides[4];
+ };
#ifndef CSRI_OWN_HANDLES
-/** opaque renderer data */
-typedef void csri_rend;
-/** opaque instance data */
-typedef void csri_inst;
+ /** opaque renderer data */
+ typedef void csri_rend;
+ /** opaque instance data */
+ typedef void csri_inst;
#endif
#ifdef DOXYGEN
-/** disable the emission of the csri_rend and csri_inst typedefs.
- * define this if you are in a renderer and are typedef'ing
- * csri_rend and csri_inst to your own structs.
-*/
+ /** disable the emission of the csri_rend and csri_inst typedefs.
+ * define this if you are in a renderer and are typedef'ing
+ * csri_rend and csri_inst to your own structs.
+ */
#define CSRI_OWN_HANDLES
#endif
-/** renderer description.
- * \ingroup loader
- */
-struct csri_info {
- /** an identifier for the renderer.
- * - MUST match the regular expression
- * \code ^[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])? \endcode
- * i.e. consists only of letters, numbers and underscores;
- * must start with a letter and doesnt have an underscore
- * as the last character.
+ /** renderer description.
+ * \ingroup loader
+ */
+ struct csri_info {
+ /** an identifier for the renderer.
+ * - MUST match the regular expression
+ * \code ^[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])? \endcode
+ * i.e. consists only of letters, numbers and underscores;
+ * must start with a letter and doesnt have an underscore
+ * as the last character.
+ */
+ const char *name;
+ /** an identifier to the exact version of the renderer.
+ * most likely a version number or revision identifier.
+ *
+ * The helper library does a strcmp over this field in order
+ * to order multiple instances of the same renderer. Use
+ * higher-byte-value strings for newer renderers.
+ */
+ const char *specific;
+
+ /** a nice name to be presented to the user */
+ const char *longname;
+ /** the renderer's author */
+ const char *author;
+ /** a copyright string. Copyright (c) 2042 by Mr. Nice Guy */
+ const char *copyright;
+ };
+
+ /** data of extension-dependent type.
+ * The field to be used MUST be specified in the extension where it is used.
*/
- const char *name;
- /** an identifier to the exact version of the renderer.
- * most likely a version number or revision identifier.
+ union csri_vardata {
+ long lval;
+ double dval;
+ const char *utf8val;
+ void *otherval;
+ };
+
+ /** extension identifier.
+ * This follows reverse DNS syntax, i.e.:
+ * \code root.branch.leaf \endcode
+ * you can either reverse a registered domain name, e.g.
+ * \code com.microsoft.csri.usegdiplus \endcode
+ * or ask the CSRI maintainers to assign a namespace to you.
*
- * The helper library does a strcmp over this field in order
- * to order multiple instances of the same renderer. Use
- * higher-byte-value strings for newer renderers.
+ * currently registered namespaces are:
+ *
+ * \code
+ * csri.* - official extensions
+ * asa.* - custom extensions of the asa renderer
+ * \endcode
*/
- const char *specific;
-
- /** a nice name to be presented to the user */
- const char *longname;
- /** the renderer's author */
- const char *author;
- /** a copyright string. Copyright (c) 2042 by Mr. Nice Guy */
- const char *copyright;
-};
-
-/** data of extension-dependent type.
- * The field to be used MUST be specified in the extension where it is used.
- */
-union csri_vardata {
- long lval;
- double dval;
- const char *utf8val;
- void *otherval;
-};
-
-/** extension identifier.
- * This follows reverse DNS syntax, i.e.:
- * \code root.branch.leaf \endcode
- * you can either reverse a registered domain name, e.g.
- * \code com.microsoft.csri.usegdiplus \endcode
- * or ask the CSRI maintainers to assign a namespace to you.
- *
- * currently registered namespaces are:
- *
- * \code
- * csri.* - official extensions
- * asa.* - custom extensions of the asa renderer
- * \endcode
- */
-typedef const char *csri_ext_id;
-
-/** script loading parameters.
- * each flag MUST have an associated extension, which can be queried
- * with csri_query_ext(). If the open flag constitutes an extension on its
- * sole own, csri_query_ext() can return a meaningless non-NULL value for
- * it.
- *
- * The data field used must be specified.
- *
- * An extension can have multiple flags. In that case, the flags should have
- * the extension name as common prefix, separated with a dot.
- *
- * A renderer MUST ignore unknown open flags. It MUST NOT return an error
- * just because it does not support a particular flag.
- */
-struct csri_openflag {
- /** flag name */
- csri_ext_id name;
- /** flag data argument */
- union csri_vardata data;
- /** link to next flag */
- struct csri_openflag *next;
-};
-
-/** load a script from a file.
- * \param renderer the handle to the renderer
- * \param filename the path to the file to be loaded. \n
- * The filename should be encoded as UTF-8. Windows renderers are
- * expected to convert it to UTF-16 and use the Unicode Windows API
- * functions.
- * \param flags a linked list of open flags. \n
- * The caller manages memory allocation, i.e. static allocation is OK.
- * \return the renderer instance handle, or NULL on error.
- */
-CSRIAPI csri_inst *csri_open_file(csri_rend *renderer,
- const char *filename, struct csri_openflag *flags);
-
-/** load a script from memory.
- * \param renderer the handle to the renderer
- * \param data pointer to the first data byte. \n
- * The caller manages memory allocation and should free the data after
- * calling csri_open_mem(). If the renderer needs to keep the data, it
- * must copy it. \n
- * The renderer is not allowed to write to the data.
- * \param length length, in bytes, of the data
- * \param flags see csri_open_file()
- * \return the render instance handle, or NULL on error.
- */
-
-CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer,
- const void *data, size_t length, struct csri_openflag *flags);
-
-/** close a renderer instance.
- * \param inst the instance handle.
- */
-CSRIAPI void csri_close(csri_inst *inst);
-
-
-/** query / set the image format and size.
- * \param inst the renderer instance handle
- * \param fmt the format and image size to be used
- * \return 0 if the format was successfully set,
- * any other value in case of error.
- */
-CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt);
-
-/** render a single frame
- * \param inst the renderer instance handle
- * \param frame frame data to render to
- * \param time associated timestamp of the frame
- */
-CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame,
- double time);
-
-
-/** query for an extension.
- * \param rend the renderer handle
- * \param extname the extension's identifier
- * \return NULL if the extension is not supported,
- * a pointer to extension-specific data otherwise
- *
- * The data pointed to by the return value does not neccessarily need to
- * have any meaning; An extension that does not need to return data
- * can return a pointer to whatever it wants, as long as that pointer is
- * not NULL.
- *
- * In the usual case, the pointer is supposed to point to a struct with
- * function pointers and other information as needed.
- */
-CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname);
+ typedef const char *csri_ext_id;
-/*@}*/
+ /** script loading parameters.
+ * each flag MUST have an associated extension, which can be queried
+ * with csri_query_ext(). If the open flag constitutes an extension on its
+ * sole own, csri_query_ext() can return a meaningless non-NULL value for
+ * it.
+ *
+ * The data field used must be specified.
+ *
+ * An extension can have multiple flags. In that case, the flags should have
+ * the extension name as common prefix, separated with a dot.
+ *
+ * A renderer MUST ignore unknown open flags. It MUST NOT return an error
+ * just because it does not support a particular flag.
+ */
+ struct csri_openflag {
+ /** flag name */
+ csri_ext_id name;
+ /** flag data argument */
+ union csri_vardata data;
+ /** link to next flag */
+ struct csri_openflag *next;
+ };
+
+ /** load a script from a file.
+ * \param renderer the handle to the renderer
+ * \param filename the path to the file to be loaded. \n
+ * The filename should be encoded as UTF-8. Windows renderers are
+ * expected to convert it to UTF-16 and use the Unicode Windows API
+ * functions.
+ * \param flags a linked list of open flags. \n
+ * The caller manages memory allocation, i.e. static allocation is OK.
+ * \return the renderer instance handle, or NULL on error.
+ */
+ CSRIAPI csri_inst *csri_open_file(csri_rend *renderer,
+ const char *filename, struct csri_openflag *flags);
+
+ /** load a script from memory.
+ * \param renderer the handle to the renderer
+ * \param data pointer to the first data byte. \n
+ * The caller manages memory allocation and should free the data after
+ * calling csri_open_mem(). If the renderer needs to keep the data, it
+ * must copy it. \n
+ * The renderer is not allowed to write to the data.
+ * \param length length, in bytes, of the data
+ * \param flags see csri_open_file()
+ * \return the render instance handle, or NULL on error.
+ */
-/** \defgroup loader CSRI loader API.
- *
- * These functions locate renderers based on given parameters.
- *
- * <b>Renderers must implement these functions as well.</b>
- *
- * They are used by the library to grab renderer information
- * from a shared object; and also this way a single renderer
- * can be linked directly into an appliaction.
- */
-/*@{*/
-
-/** get renderer information
- * \param rend the renderer handle
- * \return information about the renderer, or NULL in case the renderer
- * encountered an internal error.
- */
-CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend);
-
-/** try to load a given renderer
- * \param name the name of the renderer, as in csri_info.name
- * \param specific the specific version of the renderer,
- * as in csri_info.specific;\n
- * alternatively NULL if any version of the renderer is ok.
- * \return a handle to the renderer if it was successfully loaded,
- * NULL otherwise.
- */
-CSRIAPI csri_rend *csri_renderer_byname(const char *name,
- const char *specific);
-
-/** try to find an implementation of the given extensions.
- * \param next number of extensions pointed to by ext
- * \param ext array of extensions to search for
- * \return a handle to a renderer supporting ALL of the
- * extensions, NULL if none was found.
- */
-CSRIAPI csri_rend *csri_renderer_byext(unsigned n_ext, csri_ext_id *ext);
-
-/** get the default (highest priority) renderer
- * \return a handle to the default renderer, or NULL if
- * no renderer is installed.
- *
- * Together with csri_renderer_next(), this can be used
- * to enumerate all installed renderers.
- */
-CSRIAPI csri_rend *csri_renderer_default();
-
-/** get the next lower priority renderer
- * \param prev the current renderer
- * \return the renderer with the next lower priority than
- * the one named in prev, or NULL if prev is the last
- * renderer installed.
- */
-CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev);
-
-/*@}*/
+ CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer,
+ const void *data, size_t length, struct csri_openflag *flags);
+
+ /** close a renderer instance.
+ * \param inst the instance handle.
+ */
+ CSRIAPI void csri_close(csri_inst *inst);
+
+
+ /** query / set the image format and size.
+ * \param inst the renderer instance handle
+ * \param fmt the format and image size to be used
+ * \return 0 if the format was successfully set,
+ * any other value in case of error.
+ */
+ CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt);
+
+ /** render a single frame
+ * \param inst the renderer instance handle
+ * \param frame frame data to render to
+ * \param time associated timestamp of the frame
+ */
+ CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame,
+ double time);
+
+
+ /** query for an extension.
+ * \param rend the renderer handle
+ * \param extname the extension's identifier
+ * \return NULL if the extension is not supported,
+ * a pointer to extension-specific data otherwise
+ *
+ * The data pointed to by the return value does not neccessarily need to
+ * have any meaning; An extension that does not need to return data
+ * can return a pointer to whatever it wants, as long as that pointer is
+ * not NULL.
+ *
+ * In the usual case, the pointer is supposed to point to a struct with
+ * function pointers and other information as needed.
+ */
+ CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname);
+
+ /*@}*/
+
+ /** \defgroup loader CSRI loader API.
+ *
+ * These functions locate renderers based on given parameters.
+ *
+ * <b>Renderers must implement these functions as well.</b>
+ *
+ * They are used by the library to grab renderer information
+ * from a shared object; and also this way a single renderer
+ * can be linked directly into an appliaction.
+ */
+ /*@{*/
+
+ /** get renderer information
+ * \param rend the renderer handle
+ * \return information about the renderer, or NULL in case the renderer
+ * encountered an internal error.
+ */
+ CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend);
+
+ /** try to load a given renderer
+ * \param name the name of the renderer, as in csri_info.name
+ * \param specific the specific version of the renderer,
+ * as in csri_info.specific;\n
+ * alternatively NULL if any version of the renderer is ok.
+ * \return a handle to the renderer if it was successfully loaded,
+ * NULL otherwise.
+ */
+ CSRIAPI csri_rend *csri_renderer_byname(const char *name,
+ const char *specific);
+
+ /** try to find an implementation of the given extensions.
+ * \param next number of extensions pointed to by ext
+ * \param ext array of extensions to search for
+ * \return a handle to a renderer supporting ALL of the
+ * extensions, NULL if none was found.
+ */
+ CSRIAPI csri_rend *csri_renderer_byext(unsigned n_ext, csri_ext_id *ext);
+
+ /** get the default (highest priority) renderer
+ * \return a handle to the default renderer, or NULL if
+ * no renderer is installed.
+ *
+ * Together with csri_renderer_next(), this can be used
+ * to enumerate all installed renderers.
+ */
+ CSRIAPI csri_rend *csri_renderer_default();
+
+ /** get the next lower priority renderer
+ * \param prev the current renderer
+ * \return the renderer with the next lower priority than
+ * the one named in prev, or NULL if prev is the last
+ * renderer installed.
+ */
+ CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev);
+
+ /*@}*/
#ifdef __cplusplus
}
diff --git a/src/filters/transform/VSFilter/csriapi.cpp b/src/filters/transform/VSFilter/csriapi.cpp
index 059c02c84..498c1d592 100644
--- a/src/filters/transform/VSFilter/csriapi.cpp
+++ b/src/filters/transform/VSFilter/csriapi.cpp
@@ -54,8 +54,9 @@ CSRIAPI csri_inst *csri_open_file(csri_rend *renderer, const char *filename, str
wchar_t *namebuf;
namesize = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
- if (!namesize)
+ if (!namesize) {
return 0;
+ }
namesize++;
namebuf = new wchar_t[namesize];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, namebuf, namesize);
@@ -98,7 +99,9 @@ CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer, const void *data, size_t l
CSRIAPI void csri_close(csri_inst *inst)
{
- if (!inst) return;
+ if (!inst) {
+ return;
+ }
delete inst->rts;
delete inst->cs;
@@ -108,10 +111,13 @@ CSRIAPI void csri_close(csri_inst *inst)
CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt)
{
- if (!inst) return -1;
+ if (!inst) {
+ return -1;
+ }
- if (!fmt->width || !fmt->height)
+ if (!fmt->width || !fmt->height) {
return -1;
+ }
// Check if pixel format is supported
switch (fmt->pixfmt) {
@@ -188,18 +194,18 @@ CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname)
// Get info for renderer
static struct csri_info csri_vsfilter_info = {
#ifdef _DEBUG
- #ifdef _VSMOD
- "vsfiltermod_textsub_debug", // name
- #else
- "vsfilter_textsub_debug", // name
- #endif
+#ifdef _VSMOD
+ "vsfiltermod_textsub_debug", // name
+#else
+ "vsfilter_textsub_debug", // name
+#endif
"2.40", // version (assumed version number, svn revision, patchlevel)
#else
- #ifdef _VSMOD
- "vsfiltermod_textsub", // name
- #else
- "vsfilter_textsub", // name
- #endif
+#ifdef _VSMOD
+ "vsfiltermod_textsub", // name
+#else
+ "vsfilter_textsub", // name
+#endif
"2.40", // version (assumed version number, svn revision, patchlevel)
#endif
// 2.38-0611 is base svn 611
@@ -216,17 +222,18 @@ static struct csri_info csri_vsfilter_info = {
"Gabest", // author
"Copyright (c) 2003-2010 by Gabest and others" // copyright
};
-CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend)
-{
+CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend) {
return &csri_vsfilter_info;
}
// Only one supported, obviously
CSRIAPI csri_rend *csri_renderer_byname(const char *name, const char *specific)
{
- if (strcmp(name, csri_vsfilter_info.name))
+ if (strcmp(name, csri_vsfilter_info.name)) {
return 0;
- if (specific && strcmp(specific, csri_vsfilter_info.specific))
+ }
+ if (specific && strcmp(specific, csri_vsfilter_info.specific)) {
return 0;
+ }
return &csri_vsfilter;
}
// Still just one
diff --git a/src/filters/transform/VSFilter/plugins.cpp b/src/filters/transform/VSFilter/plugins.cpp
index 9f7146b1f..6e4732c0c 100644
--- a/src/filters/transform/VSFilter/plugins.cpp
+++ b/src/filters/transform/VSFilter/plugins.cpp
@@ -39,1104 +39,1102 @@
namespace Plugin
{
-class CFilter : public CAMThread, public CCritSec
-{
-private:
- CString m_fn;
-
-protected:
- float m_fps;
- CCritSec m_csSubLock;
- CComPtr<ISubPicQueue> m_pSubPicQueue;
- CComPtr<ISubPicProvider> m_pSubPicProvider;
- DWORD_PTR m_SubPicProviderId;
-
-public:
- CFilter() : m_fps(-1), m_SubPicProviderId(0) {
- CAMThread::Create();
- }
- virtual ~CFilter() {
- CAMThread::CallWorker(0);
- }
+ class CFilter : public CAMThread, public CCritSec
+ {
+ private:
+ CString m_fn;
+
+ protected:
+ float m_fps;
+ CCritSec m_csSubLock;
+ CComPtr<ISubPicQueue> m_pSubPicQueue;
+ CComPtr<ISubPicProvider> m_pSubPicProvider;
+ DWORD_PTR m_SubPicProviderId;
+
+ public:
+ CFilter() : m_fps(-1), m_SubPicProviderId(0) {
+ CAMThread::Create();
+ }
+ virtual ~CFilter() {
+ CAMThread::CallWorker(0);
+ }
- CString GetFileName() {
- CAutoLock cAutoLock(this);
- return m_fn;
- }
- void SetFileName(CString fn) {
- CAutoLock cAutoLock(this);
- m_fn = fn;
- }
+ CString GetFileName() {
+ CAutoLock cAutoLock(this);
+ return m_fn;
+ }
+ void SetFileName(CString fn) {
+ CAutoLock cAutoLock(this);
+ m_fn = fn;
+ }
- bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps)
- {
- if(!m_pSubPicProvider)
- return(false);
+ bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps) {
+ if(!m_pSubPicProvider) {
+ return(false);
+ }
- CSize size(dst.w, dst.h);
+ CSize size(dst.w, dst.h);
- if(!m_pSubPicQueue)
- {
- CComPtr<ISubPicAllocator> pAllocator = new CMemSubPicAllocator(dst.type, size);
+ if(!m_pSubPicQueue) {
+ CComPtr<ISubPicAllocator> pAllocator = new CMemSubPicAllocator(dst.type, size);
+
+ HRESULT hr;
+ if(!(m_pSubPicQueue = new CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr)) {
+ m_pSubPicQueue = NULL;
+ return(false);
+ }
+ }
+
+ if(m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
+ m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
+ }
- HRESULT hr;
- if(!(m_pSubPicQueue = new CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr))
- {
- m_pSubPicQueue = NULL;
+ CComPtr<ISubPic> pSubPic;
+ if(!m_pSubPicQueue->LookupSubPic(rt, pSubPic)) {
return(false);
}
- }
- if(m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider)
- {
- m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
- m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
- }
+ CRect r;
+ pSubPic->GetDirtyRect(r);
- CComPtr<ISubPic> pSubPic;
- if(!m_pSubPicQueue->LookupSubPic(rt, pSubPic))
- return(false);
+ if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15) {
+ dst.h = -dst.h;
+ }
- CRect r;
- pSubPic->GetDirtyRect(r);
+ pSubPic->AlphaBlt(r, r, &dst);
- if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15)
- dst.h = -dst.h;
+ return(true);
+ }
- pSubPic->AlphaBlt(r, r, &dst);
+ DWORD ThreadProc() {
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
- return(true);
- }
+ CAtlArray<HANDLE> handles;
+ handles.Add(GetRequestHandle());
- DWORD ThreadProc()
- {
- SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
+ CString fn = GetFileName();
+ CFileStatus fs;
+ fs.m_mtime = 0;
+ CFileGetStatus(fn, fs);
- CAtlArray<HANDLE> handles;
- handles.Add(GetRequestHandle());
+ while(1) {
+ DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
- CString fn = GetFileName();
- CFileStatus fs;
- fs.m_mtime = 0;
- CFileGetStatus(fn, fs);
+ if(WAIT_OBJECT_0 == i) {
+ Reply(S_OK);
+ break;
+ } else if(WAIT_OBJECT_0 + 1 >= i && i <= WAIT_OBJECT_0 + handles.GetCount()) {
+ if(FindNextChangeNotification(handles[i - WAIT_OBJECT_0])) {
+ CFileStatus fs2;
+ fs2.m_mtime = 0;
+ CFileGetStatus(fn, fs2);
- while(1)
- {
- DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
+ if(fs.m_mtime < fs2.m_mtime) {
+ fs.m_mtime = fs2.m_mtime;
- if(WAIT_OBJECT_0 == i)
- {
- Reply(S_OK);
- break;
- }
- else if(WAIT_OBJECT_0 + 1 >= i && i <= WAIT_OBJECT_0 + handles.GetCount())
- {
- if(FindNextChangeNotification(handles[i - WAIT_OBJECT_0]))
- {
- CFileStatus fs2;
- fs2.m_mtime = 0;
- CFileGetStatus(fn, fs2);
-
- if(fs.m_mtime < fs2.m_mtime)
- {
- fs.m_mtime = fs2.m_mtime;
-
- if(CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider)
- {
- CAutoLock cAutoLock(&m_csSubLock);
- pSubStream->Reload();
+ if(CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider) {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pSubStream->Reload();
+ }
}
}
- }
- }
- else if(WAIT_TIMEOUT == i)
- {
- CString fn2 = GetFileName();
-
- if(fn != fn2)
- {
- CPath p(fn2);
- p.RemoveFileSpec();
- HANDLE h = FindFirstChangeNotification(p, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if(h != INVALID_HANDLE_VALUE)
- {
- fn = fn2;
- handles.SetCount(1);
- handles.Add(h);
+ } else if(WAIT_TIMEOUT == i) {
+ CString fn2 = GetFileName();
+
+ if(fn != fn2) {
+ CPath p(fn2);
+ p.RemoveFileSpec();
+ HANDLE h = FindFirstChangeNotification(p, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
+ if(h != INVALID_HANDLE_VALUE) {
+ fn = fn2;
+ handles.SetCount(1);
+ handles.Add(h);
+ }
}
+ } else { // if(WAIT_ABANDONED_0 == i || WAIT_FAILED == i)
+ break;
}
}
- else // if(WAIT_ABANDONED_0 == i || WAIT_FAILED == i)
- {
- break;
- }
- }
- m_hThread = 0;
+ m_hThread = 0;
- for(ptrdiff_t i = 1; i < handles.GetCount(); i++)
- FindCloseChangeNotification(handles[i]);
-
- return 0;
- }
-};
+ for(ptrdiff_t i = 1; i < handles.GetCount(); i++) {
+ FindCloseChangeNotification(handles[i]);
+ }
-class CVobSubFilter : virtual public CFilter
-{
-public:
- CVobSubFilter(CString fn = _T(""))
- {
- if(!fn.IsEmpty()) Open(fn);
- }
+ return 0;
+ }
+ };
- bool Open(CString fn)
+ class CVobSubFilter : virtual public CFilter
{
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if(CVobSubFile* vsf = new CVobSubFile(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)vsf;
- if(vsf->Open(CString(fn))) SetFileName(fn);
- else m_pSubPicProvider = NULL;
+ public:
+ CVobSubFilter(CString fn = _T("")) {
+ if(!fn.IsEmpty()) {
+ Open(fn);
+ }
}
- return !!m_pSubPicProvider;
- }
-};
-
-class CTextSubFilter : virtual public CFilter
-{
- int m_CharSet;
+ bool Open(CString fn) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
-public:
- CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
- : m_CharSet(CharSet)
- {
- m_fps = fps;
- if(!fn.IsEmpty()) Open(fn, CharSet);
- }
+ if(CVobSubFile* vsf = new CVobSubFile(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)vsf;
+ if(vsf->Open(CString(fn))) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
- int GetCharSet() {
- return(m_CharSet);
- }
+ return !!m_pSubPicProvider;
+ }
+ };
- bool Open(CString fn, int CharSet = DEFAULT_CHARSET)
+ class CTextSubFilter : virtual public CFilter
{
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if(!m_pSubPicProvider)
- {
- if(ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)ssf;
- if(ssf->Open(CString(fn))) SetFileName(fn);
- else m_pSubPicProvider = NULL;
+ int m_CharSet;
+
+ public:
+ CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
+ : m_CharSet(CharSet) {
+ m_fps = fps;
+ if(!fn.IsEmpty()) {
+ Open(fn, CharSet);
}
}
- if(!m_pSubPicProvider)
- {
- if(CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)rts;
- if(rts->Open(CString(fn), CharSet)) SetFileName(fn);
- else m_pSubPicProvider = NULL;
- }
+ int GetCharSet() {
+ return(m_CharSet);
}
- return !!m_pSubPicProvider;
- }
-};
-
-#ifndef WIN64
-//
-// old VirtualDub interface
-//
-
-namespace VirtualDub
-{
-//#include <VirtualDub\VirtualDub.h>
-//#include <vd2/OldFilterSDK/VirtualDub.h>
-#include <vd2/extras/FilterSDK/VirtualDub.h>
-
-class CVirtualDubFilter : virtual public CFilter
-{
-public:
- CVirtualDubFilter() {}
- virtual ~CVirtualDubFilter() {}
-
- virtual int RunProc(const FilterActivation* fa, const FilterFunctions* ff)
- {
- SubPicDesc dst;
- dst.type = MSP_RGB32;
- dst.w = fa->src.w;
- dst.h = fa->src.h;
- dst.bpp = 32;
- dst.pitch = fa->src.pitch;
- dst.bits = (LPVOID)fa->src.data;
-
- Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
-
- return 0;
- }
-
- virtual long ParamProc(FilterActivation* fa, const FilterFunctions* ff)
- {
- fa->dst.offset = fa->src.offset;
- fa->dst.modulo = fa->src.modulo;
- fa->dst.pitch = fa->src.pitch;
+ bool Open(CString fn, int CharSet = DEFAULT_CHARSET) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
+
+ if(!m_pSubPicProvider) {
+ if(ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)ssf;
+ if(ssf->Open(CString(fn))) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+ }
- return 0;
- }
+ if(!m_pSubPicProvider) {
+ if(CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)rts;
+ if(rts->Open(CString(fn), CharSet)) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+ }
- virtual int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) = 0;
- virtual void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) = 0;
- virtual bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) = 0;
-};
+ return !!m_pSubPicProvider;
+ }
+ };
-class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
-{
-public:
- CVobSubVirtualDubFilter(CString fn = _T(""))
- : CVobSubFilter(fn) {}
+#ifndef WIN64
+ //
+ // old VirtualDub interface
+ //
- int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
+ namespace VirtualDub
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ //#include <VirtualDub\VirtualDub.h>
+ //#include <vd2/OldFilterSDK/VirtualDub.h>
+#include <vd2/extras/FilterSDK/VirtualDub.h>
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
- _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
+ class CVirtualDubFilter : virtual public CFilter
+ {
+ public:
+ CVirtualDubFilter() {}
+ virtual ~CVirtualDubFilter() {}
+
+ virtual int RunProc(const FilterActivation* fa, const FilterFunctions* ff) {
+ SubPicDesc dst;
+ dst.type = MSP_RGB32;
+ dst.w = fa->src.w;
+ dst.h = fa->src.h;
+ dst.bpp = 32;
+ dst.pitch = fa->src.pitch;
+ dst.bits = (LPVOID)fa->src.data;
+
+ Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
+
+ return 0;
+ }
- if(fd.DoModal() != IDOK) return 1;
+ virtual long ParamProc(FilterActivation* fa, const FilterFunctions* ff) {
+ fa->dst.offset = fa->src.offset;
+ fa->dst.modulo = fa->src.modulo;
+ fa->dst.pitch = fa->src.pitch;
- return Open(fd.GetPathName()) ? 0 : 1;
- }
+ return 0;
+ }
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
- {
- sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
- }
+ virtual int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) = 0;
+ virtual void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) = 0;
+ virtual bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) = 0;
+ };
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\")", fn);
- return(true);
- }
-};
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
-class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
-{
-public:
- CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
- : CTextSubFilter(fn, CharSet) {}
+ int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
- const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
- formats, CWnd::FromHandle(hwnd), sizeof(OPENFILENAME));
- //OPENFILENAME_SIZE_VERSION_400 /*0* /);
- UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- fd.m_pOFN->hInstance = AfxGetResourceHandle();
- fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
- fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
- fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
- if(fd.DoModal() != IDOK) return 1;
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
- return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
- }
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\")", fn);
+ return(true);
+ }
+ };
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
- {
- if(!GetFileName().IsEmpty()) sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
- else sprintf(str, " (empty)");
- }
+ class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
+ : CTextSubFilter(fn, CharSet) {}
+
+ int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
+ formats, CWnd::FromHandle(hwnd), sizeof(OPENFILENAME));
+ //OPENFILENAME_SIZE_VERSION_400 /*0* /);
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+ fd.m_pOFN->hInstance = AfxGetResourceHandle();
+ fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
+ fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return(true);
- }
-};
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
-int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- *(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
-}
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ if(!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
-int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- *(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
-}
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return(true);
+ }
+ };
-void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f, f = NULL;
-}
+ int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
-int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
-}
+ int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
-long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
-}
+ void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f, f = NULL;
+ }
+ }
-int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
-}
+ int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
-void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) f->StringProc(fa, ff, str);
-}
+ long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
-bool baseFssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->FssProc(fa, ff, buf, buflen) : false;
-}
+ int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
-void vobsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
-{
- FilterActivation* fa = (FilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
-void textsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
-{
- FilterActivation* fa = (FilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ bool baseFssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->FssProc(fa, ff, buf, buflen) : false;
+ }
-ScriptFunctionDef vobsub_func_defs[]= {
- { (ScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
-};
+ void vobsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
+ {
+ FilterActivation* fa = (FilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-CScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
-};
+ void textsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
+ {
+ FilterActivation* fa = (FilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-struct FilterDefinition filterDef_vobsub =
-{
- NULL, NULL, NULL, // next, prev, module
- "VobSub", // name
- "Adds subtitles from a vob sequence.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- vobsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &vobsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-ScriptFunctionDef textsub_func_defs[]= {
- { (ScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
- { NULL },
-};
-
-CScriptObject textsub_obj= {
- NULL, textsub_func_defs
-};
-
-struct FilterDefinition filterDef_textsub =
-{
- NULL, NULL, NULL, // next, prev, module
+ ScriptFunctionDef vobsub_func_defs[]= {
+ { (ScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
+ { NULL },
+ };
+
+ CScriptObject vobsub_obj= {
+ NULL, vobsub_func_defs
+ };
+
+ struct FilterDefinition filterDef_vobsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "VobSub", // name
+ "Adds subtitles from a vob sequence.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ vobsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &vobsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ ScriptFunctionDef textsub_func_defs[]= {
+ { (ScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
+ { NULL },
+ };
+
+ CScriptObject textsub_obj= {
+ NULL, textsub_func_defs
+ };
+
+ struct FilterDefinition filterDef_textsub = {
+ NULL, NULL, NULL, // next, prev, module
#ifdef _VSMOD
- "TextSubMod", // name
+ "TextSubMod", // name
#else
- "TextSub", // name
+ "TextSub", // name
#endif
- "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- textsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &textsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-static FilterDefinition* fd_vobsub;
-static FilterDefinition* fd_textsub;
-
-extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(FilterModule *fm, const FilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
-{
- fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(FilterDefinition));
- if(!fd_vobsub)
- return 1;
- fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(FilterDefinition));
- if(!fd_textsub)
- return 1;
+ "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ textsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &textsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ static FilterDefinition* fd_vobsub;
+ static FilterDefinition* fd_textsub;
+
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(FilterModule *fm, const FilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
+ {
+ fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(FilterDefinition));
+ if(!fd_vobsub) {
+ return 1;
+ }
+ fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(FilterDefinition));
+ if(!fd_textsub) {
+ return 1;
+ }
- vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
- vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
- return 0;
-}
+ return 0;
+ }
-extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(FilterModule *fm, const FilterFunctions *ff)
-{
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
-}
-}/**/
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(FilterModule *fm, const FilterFunctions *ff)
+ {
+ ff->removeFilter(fd_textsub);
+ ff->removeFilter(fd_vobsub);
+ }
+ }/**/
#else
-//
-// VirtualDub new plugin interface sdk 1.1
-//
-namespace VirtualDubNew
-{
+ //
+ // VirtualDub new plugin interface sdk 1.1
+ //
+ namespace VirtualDubNew
+ {
#include <vd2/plugin/vdplugin.h>
#include <vd2/plugin/vdvideofilt.h>
-class CVirtualDubFilter : virtual public CFilter
-{
-public:
- CVirtualDubFilter() {}
- virtual ~CVirtualDubFilter() {}
-
- virtual int RunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- SubPicDesc dst;
- dst.type = MSP_RGB32;
- dst.w = fa->src.w;
- dst.h = fa->src.h;
- dst.bpp = 32;
- dst.pitch = fa->src.pitch;
- dst.bits = (LPVOID)fa->src.data;
-
- Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
-
- return 0;
- }
+ class CVirtualDubFilter : virtual public CFilter
+ {
+ public:
+ CVirtualDubFilter() {}
+ virtual ~CVirtualDubFilter() {}
+
+ virtual int RunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
+ SubPicDesc dst;
+ dst.type = MSP_RGB32;
+ dst.w = fa->src.w;
+ dst.h = fa->src.h;
+ dst.bpp = 32;
+ dst.pitch = fa->src.pitch;
+ dst.bits = (LPVOID)fa->src.data;
+
+ Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
+
+ return 0;
+ }
- virtual long ParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- fa->dst.offset = fa->src.offset;
- fa->dst.modulo = fa->src.modulo;
- fa->dst.pitch = fa->src.pitch;
+ virtual long ParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
+ fa->dst.offset = fa->src.offset;
+ fa->dst.modulo = fa->src.modulo;
+ fa->dst.pitch = fa->src.pitch;
- return 0;
- }
+ return 0;
+ }
- virtual int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) = 0;
- virtual void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) = 0;
- virtual bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) = 0;
-};
+ virtual int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) = 0;
+ virtual void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) = 0;
+ virtual bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) = 0;
+ };
-class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
-{
-public:
- CVobSubVirtualDubFilter(CString fn = _T(""))
- : CVobSubFilter(fn) {}
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
- int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
- _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle((HWND)hwnd), 0);
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle((HWND)hwnd), 0);
- if(fd.DoModal() != IDOK) return 1;
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- return Open(fd.GetPathName()) ? 0 : 1;
- }
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
- void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
- {
- sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
- }
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
- bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\")", fn);
- return(true);
- }
-};
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\")", fn);
+ return(true);
+ }
+ };
-class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
-{
-public:
- CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
- : CTextSubFilter(fn, CharSet) {}
+ class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
+ : CTextSubFilter(fn, CharSet) {}
- int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- /* off encoding changing */
+ /* off encoding changing */
#ifndef _DEBUG
- const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
- formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
- //OPENFILENAME_SIZE_VERSION_400 /*0*/);
- UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
-
- fd.m_pOFN->hInstance = AfxGetResourceHandle();
- fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
- fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
- fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+ //OPENFILENAME_SIZE_VERSION_400 /*0*/);
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+ fd.m_pOFN->hInstance = AfxGetResourceHandle();
+ fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
+ fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
#else
-const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
-CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING|OFN_HIDEREADONLY,
- formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
#endif
- if(fd.DoModal() != IDOK) return 1;
-
- return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
- }
-
- void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
- {
- if(!GetFileName().IsEmpty()) sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
- else sprintf(str, " (empty)");
- }
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return(true);
- }
-};
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
-int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- return !(*(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter());
-}
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
+ if(!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
-int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- return !(*(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter());
-}
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return(true);
+ }
+ };
-void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f, f = NULL;
-}
+ int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter());
+ }
-int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
-}
+ int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter());
+ }
-long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
-}
+ void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f, f = NULL;
+ }
+ }
-int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
-}
+ int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
-void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) f->StringProc(fa, ff, str);
-}
+ long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
-bool baseFssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->FssProc(fa, ff, buf, buflen) : false;
-}
+ int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
-void vobsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
-{
- VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
-void textsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
-{
- VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ bool baseFssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->FssProc(fa, ff, buf, buflen) : false;
+ }
-VDXScriptFunctionDef vobsub_func_defs[]= {
- { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
-};
+ void vobsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-VDXScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
-};
+ void textsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-struct VDXFilterDefinition filterDef_vobsub =
-{
- NULL, NULL, NULL, // next, prev, module
- "VobSub", // name
- "Adds subtitles from a vob sequence.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- vobsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &vobsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-VDXScriptFunctionDef textsub_func_defs[]= {
- { (VDXScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
- { NULL },
-};
-
-VDXScriptObject textsub_obj= {
- NULL, textsub_func_defs
-};
-
-struct VDXFilterDefinition filterDef_textsub =
-{
- NULL, NULL, NULL, // next, prev, module
+ VDXScriptFunctionDef vobsub_func_defs[]= {
+ { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
+ { NULL },
+ };
+
+ VDXScriptObject vobsub_obj= {
+ NULL, vobsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_vobsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "VobSub", // name
+ "Adds subtitles from a vob sequence.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ vobsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &vobsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ VDXScriptFunctionDef textsub_func_defs[]= {
+ { (VDXScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
+ { NULL },
+ };
+
+ VDXScriptObject textsub_obj= {
+ NULL, textsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_textsub = {
+ NULL, NULL, NULL, // next, prev, module
#ifdef _VSMOD
- "TextSubMod", // name
+ "TextSubMod", // name
#else
-"TextSub", // name
+ "TextSub", // name
#endif
- "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- textsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &textsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-static VDXFilterDefinition* fd_vobsub;
-static VDXFilterDefinition* fd_textsub;
-
-extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
-{
- if(!(fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition)))
- || !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition))))
- return 1;
+ "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ textsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &textsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ static VDXFilterDefinition* fd_vobsub;
+ static VDXFilterDefinition* fd_textsub;
+
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
+ {
+ if(!(fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition)))
+ || !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition)))) {
+ return 1;
+ }
- vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
- vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
- return 0;
-}
+ return 0;
+ }
-extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule *fm, const VDXFilterFunctions *ff)
-{
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
-}
-}
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule *fm, const VDXFilterFunctions *ff)
+ {
+ ff->removeFilter(fd_textsub);
+ ff->removeFilter(fd_vobsub);
+ }
+ }
#endif
-//
-// Avisynth interface
-//
+ //
+ // Avisynth interface
+ //
-namespace AviSynth1
-{
+ namespace AviSynth1
+ {
#include <avisynth\avisynth1.h>
-class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
-{
-public:
- CAvisynthFilter(PClip c, IScriptEnvironment* env) : GenericVideoFilter(c) {}
+ class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
+ {
+ public:
+ CAvisynthFilter(PClip c, IScriptEnvironment* env) : GenericVideoFilter(c) {}
- PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env)
- {
- PVideoFrame frame = child->GetFrame(n, env);
+ PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
+ PVideoFrame frame = child->GetFrame(n, env);
- env->MakeWritable(&frame);
+ env->MakeWritable(&frame);
- SubPicDesc dst;
- dst.w = vi.width;
- dst.h = vi.height;
- dst.pitch = frame->GetPitch();
- dst.bits = (void**)frame->GetWritePtr();
- dst.bpp = vi.BitsPerPixel();
- dst.type =
- vi.IsRGB32() ? ( env->GetVar("RGBA").AsBool() ? MSP_RGBA :MSP_RGB32) :
- vi.IsRGB24() ? MSP_RGB24 :
- vi.IsYUY2() ? MSP_YUY2 :
- -1;
+ SubPicDesc dst;
+ dst.w = vi.width;
+ dst.h = vi.height;
+ dst.pitch = frame->GetPitch();
+ dst.bits = (void**)frame->GetWritePtr();
+ dst.bpp = vi.BitsPerPixel();
+ dst.type =
+ vi.IsRGB32() ? ( env->GetVar("RGBA").AsBool() ? MSP_RGBA :MSP_RGB32) :
+ vi.IsRGB24() ? MSP_RGB24 :
+ vi.IsYUY2() ? MSP_YUY2 :
+ -1;
- float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
+ float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
- Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
+ Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
- return(frame);
- }
-};
+ return(frame);
+ }
+ };
-class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
-{
-public:
- CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
- : CVobSubFilter(CString(fn))
- , CAvisynthFilter(c, env)
- {
- if(!m_pSubPicProvider)
- env->ThrowError("VobSub: Can't open \"%s\"", fn);
- }
-};
+ class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
+ {
+ public:
+ CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
+ : CVobSubFilter(CString(fn))
+ , CAvisynthFilter(c, env) {
+ if(!m_pSubPicProvider) {
+ env->ThrowError("VobSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
-AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
-}
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
+ }
-class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
-{
-public:
- CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1)
- : CTextSubFilter(CString(fn), CharSet, fps)
- , CAvisynthFilter(c, env)
- {
- if(!m_pSubPicProvider)
+ class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
+ {
+ public:
+ CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1)
+ : CTextSubFilter(CString(fn), CharSet, fps)
+ , CAvisynthFilter(c, env) {
+ if(!m_pSubPicProvider)
#ifdef _VSMOD
- env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
#endif
- }
-};
+ }
+ };
-AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
-}
+ AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
+ }
-AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
-}
+ AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
+ }
-AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), args[3].AsFloat()));
-}
+ AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), args[3].AsFloat()));
+ }
-AVSValue __cdecl MaskSubCreateSIIFI(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- AVSValue rgb32("RGB32");
- AVSValue tab[5] = {
- args[1],
- args[2],
- args[3],
- args[4],
- rgb32
- };
- AVSValue value(tab,5);
- const char * nom[5]= {
- "width",
- "height",
- "fps",
- "length",
- "pixel_type"
- };
- AVSValue clip(env->Invoke("Blackness",value,nom));
- env->SetVar(env->SaveString("RGBA"),true);
- return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
-}
+ AVSValue __cdecl MaskSubCreateSIIFI(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ AVSValue rgb32("RGB32");
+ AVSValue tab[5] = {
+ args[1],
+ args[2],
+ args[3],
+ args[4],
+ rgb32
+ };
+ AVSValue value(tab,5);
+ const char * nom[5]= {
+ "width",
+ "height",
+ "fps",
+ "length",
+ "pixel_type"
+ };
+ AVSValue clip(env->Invoke("Blackness",value,nom));
+ env->SetVar(env->SaveString("RGBA"),true);
+ return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ }
-extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
-{
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
#ifdef _VSMOD
- env->AddFunction("TextSubMod", "cs", TextSubCreateS, 0);
- env->AddFunction("TextSubMod", "csi", TextSubCreateSI, 0);
- env->AddFunction("TextSubMod", "csif", TextSubCreateSIF, 0);
- env->AddFunction("MaskSubMod", "siifi", MaskSubCreateSIIFI, 0);
+ env->AddFunction("TextSubMod", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSubMod", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSubMod", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSubMod", "siifi", MaskSubCreateSIIFI, 0);
#else
- env->AddFunction("TextSub", "cs", TextSubCreateS, 0);
- env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
- env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
- env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
+ env->AddFunction("TextSub", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
#endif
- env->SetVar(env->SaveString("RGBA"),false);
- return(NULL);
-}
-}
+ env->SetVar(env->SaveString("RGBA"),false);
+ return(NULL);
+ }
+ }
-namespace AviSynth25
-{
+ namespace AviSynth25
+ {
#include <avisynth\avisynth25.h>
-static bool s_fSwapUV = false;
+ static bool s_fSwapUV = false;
-class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
-{
-public:
- VFRTranslator *vfr;
+ class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
+ {
+ public:
+ VFRTranslator *vfr;
+
+ CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
+
+ PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
+ PVideoFrame frame = child->GetFrame(n, env);
+
+ env->MakeWritable(&frame);
+
+ SubPicDesc dst;
+ dst.w = vi.width;
+ dst.h = vi.height;
+ dst.pitch = frame->GetPitch();
+ dst.pitchUV = frame->GetPitch(PLANAR_U);
+ dst.bits = (void**)frame->GetWritePtr();
+ dst.bitsU = frame->GetWritePtr(PLANAR_U);
+ dst.bitsV = frame->GetWritePtr(PLANAR_V);
+ dst.bpp = dst.pitch/dst.w*8; //vi.BitsPerPixel();
+ dst.type =
+ vi.IsRGB32() ?( env->GetVar("RGBA").AsBool() ? MSP_RGBA : MSP_RGB32) :
+ vi.IsRGB24() ? MSP_RGB24 :
+ vi.IsYUY2() ? MSP_YUY2 :
+ /*vi.IsYV12()*/ vi.pixel_type == VideoInfo::CS_YV12 ? (s_fSwapUV?MSP_IYUV:MSP_YV12) :
+ /*vi.IsIYUV()*/ vi.pixel_type == VideoInfo::CS_IYUV ? (s_fSwapUV?MSP_YV12:MSP_IYUV) :
+ -1;
+
+ float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
+
+ REFERENCE_TIME timestamp;
+
+ if (!vfr) {
+ timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
+ } else {
+ timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
+ }
- CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
+ Render(dst, timestamp, fps);
- PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env)
- {
- PVideoFrame frame = child->GetFrame(n, env);
-
- env->MakeWritable(&frame);
-
- SubPicDesc dst;
- dst.w = vi.width;
- dst.h = vi.height;
- dst.pitch = frame->GetPitch();
- dst.pitchUV = frame->GetPitch(PLANAR_U);
- dst.bits = (void**)frame->GetWritePtr();
- dst.bitsU = frame->GetWritePtr(PLANAR_U);
- dst.bitsV = frame->GetWritePtr(PLANAR_V);
- dst.bpp = dst.pitch/dst.w*8; //vi.BitsPerPixel();
- dst.type =
- vi.IsRGB32() ?( env->GetVar("RGBA").AsBool() ? MSP_RGBA : MSP_RGB32) :
- vi.IsRGB24() ? MSP_RGB24 :
- vi.IsYUY2() ? MSP_YUY2 :
- /*vi.IsYV12()*/ vi.pixel_type == VideoInfo::CS_YV12 ? (s_fSwapUV?MSP_IYUV:MSP_YV12) :
- /*vi.IsIYUV()*/ vi.pixel_type == VideoInfo::CS_IYUV ? (s_fSwapUV?MSP_YV12:MSP_IYUV) :
- -1;
-
- float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
-
- REFERENCE_TIME timestamp;
-
- if (!vfr)
- timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
- else
- timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
-
- Render(dst, timestamp, fps);
-
- return(frame);
- }
-};
+ return(frame);
+ }
+ };
-class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
-{
-public:
- CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
- : CVobSubFilter(CString(fn))
- , CAvisynthFilter(c, env)
- {
- if(!m_pSubPicProvider)
- env->ThrowError("VobSub: Can't open \"%s\"", fn);
- }
-};
+ class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
+ {
+ public:
+ CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
+ : CVobSubFilter(CString(fn))
+ , CAvisynthFilter(c, env) {
+ if(!m_pSubPicProvider) {
+ env->ThrowError("VobSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
-AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
-}
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
+ }
-class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
-{
-public:
- CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator *vfr = 0) //vfr patch
- : CTextSubFilter(CString(fn), CharSet, fps)
- , CAvisynthFilter(c, env, vfr)
- {
- if(!m_pSubPicProvider)
+ class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
+ {
+ public:
+ CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator *vfr = 0) //vfr patch
+ : CTextSubFilter(CString(fn), CharSet, fps)
+ , CAvisynthFilter(c, env, vfr) {
+ if(!m_pSubPicProvider)
#ifdef _VSMOD
- env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
#endif
- }
-};
+ }
+ };
-AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- if (!args[1].Defined())
+ AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ if (!args[1].Defined())
#ifdef _VSMOD
- env->ThrowError("TextSubMod: You must specify a subtitle file to use");
+ env->ThrowError("TextSubMod: You must specify a subtitle file to use");
#else
- env->ThrowError("TextSub: You must specify a subtitle file to use");
+ env->ThrowError("TextSub: You must specify a subtitle file to use");
#endif
- VFRTranslator *vfr = 0;
- if (args[4].Defined())
- vfr = GetVFRTranslator(args[4].AsString());
-
- return(new CTextSubAvisynthFilter(
- args[0].AsClip(),
- env,
- args[1].AsString(),
- args[2].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
-}
+ VFRTranslator *vfr = 0;
+ if (args[4].Defined()) {
+ vfr = GetVFRTranslator(args[4].AsString());
+ }
-AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- s_fSwapUV = args[0].AsBool(false);
- return(AVSValue());
-}
+ return(new CTextSubAvisynthFilter(
+ args[0].AsClip(),
+ env,
+ args[1].AsString(),
+ args[2].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
+ }
-AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
-{
- if (!args[0].Defined())
+ AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ s_fSwapUV = args[0].AsBool(false);
+ return(AVSValue());
+ }
+
+ AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
+ {
+ if (!args[0].Defined())
#ifdef _VSMOD
- env->ThrowError("MaskSubMod: You must specify a subtitle file to use");
+ env->ThrowError("MaskSubMod: You must specify a subtitle file to use");
#else
- env->ThrowError("MaskSub: You must specify a subtitle file to use");
+ env->ThrowError("MaskSub: You must specify a subtitle file to use");
#endif
- if (!args[3].Defined() && !args[6].Defined())
+ if (!args[3].Defined() && !args[6].Defined())
#ifdef _VSMOD
- env->ThrowError("MaskSubMod: You must specify either FPS or a VFR timecodes file");
+ env->ThrowError("MaskSubMod: You must specify either FPS or a VFR timecodes file");
#else
- env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
+ env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
#endif
- VFRTranslator *vfr = 0;
- if (args[6].Defined())
- vfr = GetVFRTranslator(args[6].AsString());
-
- AVSValue rgb32("RGB32");
- AVSValue fps(args[3].AsFloat(25));
- AVSValue tab[6] = {
- args[1],
- args[2],
- args[3],
- args[4],
- rgb32
- };
- AVSValue value(tab,5);
- const char * nom[5]= {
- "width",
- "height",
- "fps",
- "length",
- "pixel_type"
- };
- AVSValue clip(env->Invoke("Blackness",value,nom));
- env->SetVar(env->SaveString("RGBA"),true);
- //return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
- return(new CTextSubAvisynthFilter(
- clip.AsClip(),
- env,
- args[0].AsString(),
- args[5].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
-}
+ VFRTranslator *vfr = 0;
+ if (args[6].Defined()) {
+ vfr = GetVFRTranslator(args[6].AsString());
+ }
-extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
-{
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ AVSValue rgb32("RGB32");
+ AVSValue fps(args[3].AsFloat(25));
+ AVSValue tab[6] = {
+ args[1],
+ args[2],
+ args[3],
+ args[4],
+ rgb32
+ };
+ AVSValue value(tab,5);
+ const char * nom[5]= {
+ "width",
+ "height",
+ "fps",
+ "length",
+ "pixel_type"
+ };
+ AVSValue clip(env->Invoke("Blackness",value,nom));
+ env->SetVar(env->SaveString("RGBA"),true);
+ //return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ return(new CTextSubAvisynthFilter(
+ clip.AsClip(),
+ env,
+ args[0].AsString(),
+ args[5].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
+ }
+
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
#ifdef _VSMOD
- env->AddFunction("TextSubMod", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
- env->AddFunction("TextSubModSwapUV", "b", TextSubSwapUV, 0);
- env->AddFunction("MaskSubMod", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+ env->AddFunction("TextSubMod", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+ env->AddFunction("TextSubModSwapUV", "b", TextSubSwapUV, 0);
+ env->AddFunction("MaskSubMod", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
#else
- env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
- env->AddFunction("TextSubSwapUV", "b", TextSubSwapUV, 0);
- env->AddFunction("MaskSub", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+ env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+ env->AddFunction("TextSubSwapUV", "b", TextSubSwapUV, 0);
+ env->AddFunction("MaskSub", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
#endif
- env->SetVar(env->SaveString("RGBA"),false);
- return(NULL);
-}
-}
+ env->SetVar(env->SaveString("RGBA"),false);
+ return(NULL);
+ }
+ }
}
UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uiMsg)
- {
- case WM_NOTIFY:
- {
- OPENFILENAME* ofn = ((OFNOTIFY *)lParam)->lpOFN;
+ switch(uiMsg) {
+ case WM_NOTIFY: {
+ OPENFILENAME* ofn = ((OFNOTIFY *)lParam)->lpOFN;
- if(((NMHDR *)lParam)->code == CDN_FILEOK)
- {
- ofn->lCustData = (LPARAM)CharSetList[SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_GETCURSEL, 0, 0)];
- }
+ if(((NMHDR *)lParam)->code == CDN_FILEOK) {
+ ofn->lCustData = (LPARAM)CharSetList[SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_GETCURSEL, 0, 0)];
+ }
- break;
- }
+ break;
+ }
- case WM_INITDIALOG:
- {
+ case WM_INITDIALOG: {
#ifdef WIN64
- SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
#else
- SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
+ SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
#endif
- for(ptrdiff_t i = 0; i < CharSetLen; i++)
- {
- CString s;
- s.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
- SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_ADDSTRING, 0, (LONG)(LPCTSTR)s);
- if(CharSetList[i] == (int)((OPENFILENAME*)lParam)->lCustData)
- SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_SETCURSEL, i, 0);
- }
+ for(ptrdiff_t i = 0; i < CharSetLen; i++) {
+ CString s;
+ s.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
+ SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_ADDSTRING, 0, (LONG)(LPCTSTR)s);
+ if(CharSetList[i] == (int)((OPENFILENAME*)lParam)->lCustData) {
+ SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_SETCURSEL, i, 0);
+ }
+ }
- break;
- }
+ break;
+ }
- default:
- break;
+ default:
+ break;
}
return FALSE;
diff --git a/src/filters/transform/VSFilter/vfr.cpp b/src/filters/transform/VSFilter/vfr.cpp
index bb56a6126..0c0eb36a5 100644
--- a/src/filters/transform/VSFilter/vfr.cpp
+++ b/src/filters/transform/VSFilter/vfr.cpp
@@ -32,7 +32,8 @@
// Work with seconds per frame (spf) here instead of fps since that's more natural for the translation we're doing
-class TimecodesV1 : public VFRTranslator {
+class TimecodesV1 : public VFRTranslator
+{
private:
// Used when sections run out
double default_spf;
@@ -50,8 +51,7 @@ private:
std::vector<FrameRateSection> sections;
public:
- virtual double TimeStampFromFrameNumber(int n)
- {
+ virtual double TimeStampFromFrameNumber(int n) {
// Find correct section
for (size_t i = 0; i < sections.size(); i++) {
FrameRateSection &sect = sections[i];
@@ -60,12 +60,13 @@ public:
}
}
// Not in a section
- if (n < 0) return 0.0;
+ if (n < 0) {
+ return 0.0;
+ }
return first_non_section_timestamp + (n - first_non_section_frame) * default_spf;
}
- TimecodesV1(FILE *vfrfile)
- {
+ TimecodesV1(FILE *vfrfile) {
char buf[100];
default_spf = -1;
@@ -79,15 +80,18 @@ public:
while (fgets(buf, 100, vfrfile)) {
// Comment?
- if (buf[0] == '#') continue;
+ if (buf[0] == '#') {
+ continue;
+ }
if (_strnicmp(buf, "Assume ", 7) == 0 && default_spf < 0) {
char *num = buf+7;
default_spf = atof(num);
- if (default_spf > 0)
+ if (default_spf > 0) {
default_spf = 1 / default_spf;
- else
+ } else {
default_spf = -1;
+ }
temp_section.spf = default_spf;
continue;
}
@@ -123,7 +127,8 @@ public:
};
-class TimecodesV2 : public VFRTranslator {
+class TimecodesV2 : public VFRTranslator
+{
private:
// Main data
std::vector<double> timestamps;
@@ -133,24 +138,26 @@ private:
double assumed_spf;
public:
- virtual double TimeStampFromFrameNumber(int n)
- {
+ virtual double TimeStampFromFrameNumber(int n) {
if (n < (int)timestamps.size() && n >= 0) {
return timestamps[n];
}
- if (n < 0) return 0.0;
+ if (n < 0) {
+ return 0.0;
+ }
return last_known_timestamp + (n - last_known_frame) * assumed_spf;
}
- TimecodesV2(FILE *vfrfile)
- {
+ TimecodesV2(FILE *vfrfile) {
char buf[50];
timestamps.reserve(8192); // should be enough for most cases
while (fgets(buf, 50, vfrfile)) {
// Comment?
- if (buf[0] == '#') continue;
+ if (buf[0] == '#') {
+ continue;
+ }
// Otherwise assume it's a good timestamp
timestamps.push_back(atof(buf)/1000);
}
diff --git a/src/filters/transform/VSFilter/vfr.h b/src/filters/transform/VSFilter/vfr.h
index a4aafffd4..837577b6e 100644
--- a/src/filters/transform/VSFilter/vfr.h
+++ b/src/filters/transform/VSFilter/vfr.h
@@ -26,7 +26,8 @@
#ifndef VFR_H
#define VFR_H
-class VFRTranslator {
+class VFRTranslator
+{
public:
virtual double TimeStampFromFrameNumber(int n) = 0;
};