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>2011-01-10 03:05:13 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2011-01-10 03:05:13 +0300
commit0eb98dcebf3ff5c8fbdc1235474c0d5640f9a04c (patch)
tree65e403462fdb55541e4a98358c824aa8a15b8027 /src/SubPic
parent93411f0c1eef8de213410b0544b246dd7086be74 (diff)
legacy branch: merge r2785-r2825,r2827 from trunk
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/branches/legacy@2830 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/SubPic')
-rw-r--r--src/SubPic/CoordGeom.cpp53
-rw-r--r--src/SubPic/CoordGeom.h2
-rw-r--r--src/SubPic/DX7SubPic.cpp84
-rw-r--r--src/SubPic/DX9SubPic.cpp165
-rw-r--r--src/SubPic/DX9SubPic.h9
-rw-r--r--src/SubPic/ISubPic.h24
-rw-r--r--src/SubPic/ISubRender.h9
-rw-r--r--src/SubPic/MemSubPic.cpp392
-rw-r--r--src/SubPic/SubPicAllocatorPresenterImpl.cpp89
-rw-r--r--src/SubPic/SubPicAllocatorPresenterImpl.h6
-rw-r--r--src/SubPic/SubPicImpl.cpp40
-rw-r--r--src/SubPic/SubPicImpl.h56
-rw-r--r--src/SubPic/SubPicQueueImpl.cpp289
-rw-r--r--src/SubPic/SubPicQueueImpl.h12
14 files changed, 583 insertions, 647 deletions
diff --git a/src/SubPic/CoordGeom.cpp b/src/SubPic/CoordGeom.cpp
index 018fb495a..dde63e033 100644
--- a/src/SubPic/CoordGeom.cpp
+++ b/src/SubPic/CoordGeom.cpp
@@ -75,7 +75,9 @@ Vector Vector::Pow(float exp)
Vector Vector::Unit()
{
float l = Length();
- if(!l || l == 1) return(*this);
+ if(!l || l == 1) {
+ return(*this);
+ }
return(*this * (1 / l));
}
@@ -106,9 +108,13 @@ void Vector::Angle(float& u, float& v)
u = asin(n.y);
- if(IsZero(n.z)) v = PI/2 * Sgn(n.x);
- else if(n.z > 0) v = atan(n.x / n.z);
- else if(n.z < 0) v = IsZero(n.x) ? PI : (PI * Sgn(n.x) + atan(n.x / n.z));
+ if(IsZero(n.z)) {
+ v = PI/2 * Sgn(n.x);
+ } else if(n.z > 0) {
+ v = atan(n.x / n.z);
+ } else if(n.z < 0) {
+ v = IsZero(n.x) ? PI : (PI * Sgn(n.x) + atan(n.x / n.z));
+ }
}
Vector Vector::Angle()
@@ -157,8 +163,7 @@ Vector Vector::Refract(Vector& N, float nFront, float nBack, float* nOut)
float len_sin_T = sin_T | sin_T;
- if(len_sin_T > 1)
- {
+ if(len_sin_T > 1) {
if(nOut) {
*nOut = N_dot_D >= 0 ? nFront : nBack;
}
@@ -166,7 +171,9 @@ Vector Vector::Refract(Vector& N, float nFront, float nBack, float* nOut)
}
float N_dot_T = sqrt(1.0 - len_sin_T);
- if(N_dot_D < 0) N_dot_T = -N_dot_T;
+ if(N_dot_D < 0) {
+ N_dot_T = -N_dot_T;
+ }
if(nOut) {
*nOut = N_dot_D >= 0 ? nBack : nFront;
@@ -187,8 +194,7 @@ Vector Vector::Refract2(Vector& N, float nFrom, float nTo, float* nOut)
float len_sin_T = sin_T | sin_T;
- if(len_sin_T > 1)
- {
+ if(len_sin_T > 1) {
if(nOut) {
*nOut = nFrom;
}
@@ -196,7 +202,9 @@ Vector Vector::Refract2(Vector& N, float nFrom, float nTo, float* nOut)
}
float N_dot_T = sqrt(1.0 - len_sin_T);
- if(N_dot_D < 0) N_dot_T = -N_dot_T;
+ if(N_dot_D < 0) {
+ N_dot_T = -N_dot_T;
+ }
if(nOut) {
*nOut = nTo;
@@ -227,7 +235,9 @@ Vector Vector::operator - ()
bool Vector::operator == (const Vector& v) const
{
- if(IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) return(true);
+ if(IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) {
+ return(true);
+ }
return(false);
}
@@ -359,7 +369,9 @@ void Ray::Set(Vector& p, Vector& d)
float Ray::GetDistanceFrom(Ray& r)
{
float t = (d | r.d);
- if(IsZero(t)) return(-BIGNUMBER); // plane is paralell to the ray, return -infinite
+ if(IsZero(t)) {
+ return(-BIGNUMBER); // plane is paralell to the ray, return -infinite
+ }
return(((r.p - p) | r.d) / t);
}
@@ -393,15 +405,12 @@ void XForm::Initalize(Ray& r, Vector& s, bool isWorldToLocal)
Initalize();
m_isWorldToLocal = isWorldToLocal;
- if(isWorldToLocal)
- {
+ if(isWorldToLocal) {
*this -= r.p;
*this >>= r.d;
*this /= s;
- }
- else
- {
+ } else {
*this *= s;
*this <<= r.d;
*this += r.p;
@@ -543,16 +552,16 @@ XForm::Matrix XForm::Matrix::operator * (Matrix& m)
{
Matrix ret;
- for(ptrdiff_t i = 0; i < 4; i++)
- {
- for(ptrdiff_t j = 0; j < 4; j++)
- {
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ for(ptrdiff_t j = 0; j < 4; j++) {
ret.mat[i][j] = mat[i][0] * m.mat[0][j] +
mat[i][1] * m.mat[1][j] +
mat[i][2] * m.mat[2][j] +
mat[i][3] * m.mat[3][j];
- if(IsZero(ret.mat[i][j])) ret.mat[i][j] = 0;
+ if(IsZero(ret.mat[i][j])) {
+ ret.mat[i][j] = 0;
+ }
}
}
diff --git a/src/SubPic/CoordGeom.h b/src/SubPic/CoordGeom.h
index 4b2bf9e48..7edd7aa1f 100644
--- a/src/SubPic/CoordGeom.h
+++ b/src/SubPic/CoordGeom.h
@@ -138,7 +138,7 @@ public:
void operator -= (Vector& t); // translate
void operator >>= (Vector& r); // rotate
-// transformations
+ // transformations
Vector operator < (Vector& n); // normal
Vector operator << (Vector& v); // vector
Ray operator << (Ray& r); // ray
diff --git a/src/SubPic/DX7SubPic.cpp b/src/SubPic/DX7SubPic.cpp
index 976510f37..3296c53d3 100644
--- a/src/SubPic/DX7SubPic.cpp
+++ b/src/SubPic/DX7SubPic.cpp
@@ -36,8 +36,7 @@ CDX7SubPic::CDX7SubPic(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pSurface)
{
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd)))
- {
+ if(SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd))) {
m_maxsize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
m_rcDirty.SetRect(0, 0, ddsd.dwWidth, ddsd.dwHeight);
}
@@ -54,8 +53,9 @@ STDMETHODIMP CDX7SubPic::GetDesc(SubPicDesc& spd)
{
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pSurface->GetSurfaceDesc(&ddsd)))
+ if(FAILED(m_pSurface->GetSurfaceDesc(&ddsd))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -71,8 +71,9 @@ STDMETHODIMP CDX7SubPic::GetDesc(SubPicDesc& spd)
STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic)))
+ if(FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
+ }
CPoint p = m_rcDirty.TopLeft();
hr = m_pD3DDev->Load((IDirectDrawSurface7*)pSubPic->GetObject(), &p, (IDirectDrawSurface7*)GetObject(), m_rcDirty, 0);
@@ -82,8 +83,9 @@ STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic)
STDMETHODIMP CDX7SubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_FALSE;
+ }
DDBLTFX fx;
INITDDSTRUCT(fx);
@@ -99,8 +101,9 @@ STDMETHODIMP CDX7SubPic::Lock(SubPicDesc& spd)
{
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL)))
+ if(FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -117,14 +120,11 @@ STDMETHODIMP CDX7SubPic::Unlock(RECT* pDirtyRect)
{
m_pSurface->Unlock(NULL);
- if(pDirtyRect)
- {
+ if(pDirtyRect) {
m_rcDirty = *pDirtyRect;
m_rcDirty.InflateRect(1, 1);
m_rcDirty &= CRect(CPoint(0, 0), m_size);
- }
- else
- {
+ } else {
m_rcDirty = CRect(CPoint(0, 0), m_size);
}
@@ -135,42 +135,41 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
ASSERT(pTarget == NULL);
- if(!m_pD3DDev || !m_pSurface || !pSrc || !pDst)
+ if(!m_pD3DDev || !m_pSurface || !pSrc || !pDst) {
return E_POINTER;
+ }
CRect src(*pSrc), dst(*pDst);
HRESULT hr;
- do
- {
+ do {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd)))
+ if(FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd))) {
break;
+ }
float w = (float)ddsd.dwWidth;
float h = (float)ddsd.dwHeight;
- struct
- {
+ struct {
float x, y, z, rhw;
float tu, tv;
}
- pVertices[] =
- {
+ pVertices[] = {
{(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
{(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
{(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
{(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
};
-/*
- for(ptrdiff_t i = 0; i < countof(pVertices); i++)
- {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
-*/
+ /*
+ for(ptrdiff_t i = 0; i < countof(pVertices); i++)
+ {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+ */
hr = m_pD3DDev->SetTexture(0, m_pSurface);
m_pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
@@ -202,8 +201,9 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
*///
- if(FAILED(hr = m_pD3DDev->BeginScene()))
+ if(FAILED(hr = m_pD3DDev->BeginScene())) {
break;
+ }
hr = m_pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
D3DFVF_XYZRHW | D3DFVF_TEX1,
@@ -215,8 +215,7 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
m_pD3DDev->SetTexture(0, NULL);
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -237,7 +236,9 @@ CDX7SubPicAllocator::CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize
STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
CComQIPtr<IDirect3DDevice7, &IID_IDirect3DDevice7> pD3DDev = pDev;
- if(!pD3DDev) return E_NOINTERFACE;
+ if(!pD3DDev) {
+ return E_NOINTERFACE;
+ }
CAutoLock cAutoLock(this);
m_pD3DDev = pD3DDev;
@@ -249,8 +250,9 @@ STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev)
bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return(false);
+ }
CAutoLock cAutoLock(this);
@@ -269,26 +271,32 @@ bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
- if(m_fPow2Textures)
- {
+ if(m_fPow2Textures) {
ddsd.dwWidth = ddsd.dwHeight = 1;
- while(ddsd.dwWidth < (DWORD)m_maxsize.cx) ddsd.dwWidth <<= 1;
- while(ddsd.dwHeight < (DWORD)m_maxsize.cy) ddsd.dwHeight <<= 1;
+ while(ddsd.dwWidth < (DWORD)m_maxsize.cx) {
+ ddsd.dwWidth <<= 1;
+ }
+ while(ddsd.dwHeight < (DWORD)m_maxsize.cy) {
+ ddsd.dwHeight <<= 1;
+ }
}
CComPtr<IDirect3D7> pD3D;
CComQIPtr<IDirectDraw7, &IID_IDirectDraw7> pDD;
- if(FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D))
+ if(FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
return(false);
+ }
CComPtr<IDirectDrawSurface7> pSurface;
- if(FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL)))
+ if(FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL))) {
return(false);
+ }
*ppSubPic = DNew CDX7SubPic(m_pD3DDev, pSurface);
- if(!(*ppSubPic))
+ if(!(*ppSubPic)) {
return(false);
+ }
(*ppSubPic)->AddRef();
diff --git a/src/SubPic/DX9SubPic.cpp b/src/SubPic/DX9SubPic.cpp
index 54743ad1d..fa769b33d 100644
--- a/src/SubPic/DX9SubPic.cpp
+++ b/src/SubPic/DX9SubPic.cpp
@@ -35,8 +35,7 @@ CDX9SubPic::CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator *pAlloca
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(SUCCEEDED(m_pSurface->GetDesc(&d3dsd)))
- {
+ if(SUCCEEDED(m_pSurface->GetDesc(&d3dsd))) {
m_maxsize.SetSize(d3dsd.Width, d3dsd.Height);
m_rcDirty.SetRect(0, 0, d3dsd.Width, d3dsd.Height);
}
@@ -47,14 +46,11 @@ CDX9SubPic::~CDX9SubPic()
{
CAutoLock Lock(&CDX9SubPicAllocator::ms_SurfaceQueueLock);
// Add surface to cache
- if (m_pAllocator)
- {
- for (POSITION pos = m_pAllocator->m_AllocatedSurfaces.GetHeadPosition(); pos; )
- {
+ if (m_pAllocator) {
+ for (POSITION pos = m_pAllocator->m_AllocatedSurfaces.GetHeadPosition(); pos; ) {
POSITION ThisPos = pos;
CDX9SubPic *pSubPic = m_pAllocator->m_AllocatedSurfaces.GetNext(pos);
- if (pSubPic == this)
- {
+ if (pSubPic == this) {
m_pAllocator->m_AllocatedSurfaces.RemoveAt(ThisPos);
break;
}
@@ -70,8 +66,9 @@ CDX9SubPic::~CDX9SubPic()
STDMETHODIMP_(void*) CDX9SubPic::GetObject()
{
CComPtr<IDirect3DTexture9> pTexture;
- if(SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture)))
+ if(SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture))) {
return (void*)(IDirect3DTexture9*)pTexture;
+ }
return NULL;
}
@@ -80,8 +77,9 @@ STDMETHODIMP CDX9SubPic::GetDesc(SubPicDesc& spd)
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pSurface->GetDesc(&d3dsd)))
+ if(FAILED(m_pSurface->GetDesc(&d3dsd))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -99,15 +97,18 @@ STDMETHODIMP CDX9SubPic::GetDesc(SubPicDesc& spd)
STDMETHODIMP CDX9SubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic)))
+ if(FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
+ }
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_FALSE;
+ }
CComPtr<IDirect3DDevice9> pD3DDev;
- if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev)
+ if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_FAIL;
+ }
IDirect3DTexture9* pSrcTex = (IDirect3DTexture9*)GetObject();
CComPtr<IDirect3DSurface9> pSrcSurf;
@@ -125,52 +126,48 @@ STDMETHODIMP CDX9SubPic::CopyTo(ISubPic* pSubPic)
SetRect(&r, 0, 0, min(srcDesc.Width, dstDesc.Width), min(srcDesc.Height, dstDesc.Height));
POINT p = { 0, 0 };
hr = pD3DDev->UpdateSurface(pSrcSurf, &r, pDstSurf, &p);
-// ASSERT (SUCCEEDED (hr));
+ // ASSERT (SUCCEEDED (hr));
return SUCCEEDED(hr) ? S_OK : E_FAIL;
}
STDMETHODIMP CDX9SubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_FALSE;
+ }
CComPtr<IDirect3DDevice9> pD3DDev;
- if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev)
+ if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_FAIL;
+ }
SubPicDesc spd;
- if(SUCCEEDED(Lock(spd)))
- {
+ if(SUCCEEDED(Lock(spd))) {
int h = m_rcDirty.Height();
BYTE* ptr = (BYTE*)spd.bits + spd.pitch*m_rcDirty.top + (m_rcDirty.left*spd.bpp>>3);
- if(spd.bpp == 16)
- {
- while(h-- > 0)
- {
+ if(spd.bpp == 16) {
+ while(h-- > 0) {
memsetw(ptr, color, 2 * m_rcDirty.Width());
ptr += spd.pitch;
}
- }
- else if(spd.bpp == 32)
- {
- while(h-- > 0)
- {
+ } else if(spd.bpp == 32) {
+ while(h-- > 0) {
memsetd(ptr, color, 4 * m_rcDirty.Width());
ptr += spd.pitch;
}
}
-/*
- DWORD* ptr = (DWORD*)bm.bits;
- DWORD* end = ptr + bm.h*bm.wBytes/4;
- while(ptr < end) *ptr++ = color;
-*/
+ /*
+ DWORD* ptr = (DWORD*)bm.bits;
+ DWORD* end = ptr + bm.h*bm.wBytes/4;
+ while(ptr < end) *ptr++ = color;
+ */
Unlock(NULL);
}
-// HRESULT hr = pD3DDev->ColorFill(m_pSurface, m_rcDirty, color);
+ // HRESULT hr = pD3DDev->ColorFill(m_pSurface, m_rcDirty, color);
m_rcDirty.SetRectEmpty();
@@ -181,13 +178,15 @@ STDMETHODIMP CDX9SubPic::Lock(SubPicDesc& spd)
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pSurface->GetDesc(&d3dsd)))
+ if(FAILED(m_pSurface->GetDesc(&d3dsd))) {
return E_FAIL;
+ }
D3DLOCKED_RECT LockedRect;
ZeroMemory(&LockedRect, sizeof(LockedRect));
- if(FAILED(m_pSurface->LockRect(&LockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK)))
+ if(FAILED(m_pSurface->LockRect(&LockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -206,11 +205,9 @@ STDMETHODIMP CDX9SubPic::Unlock(RECT* pDirtyRect)
{
HRESULT hr = m_pSurface->UnlockRect();
- if(pDirtyRect)
- {
+ if(pDirtyRect) {
m_rcDirty = *pDirtyRect;
- if (!((CRect*)pDirtyRect)->IsRectEmpty())
- {
+ if (!((CRect*)pDirtyRect)->IsRectEmpty()) {
m_rcDirty.InflateRect(1, 1);
m_rcDirty.left &= ~127;
m_rcDirty.top &= ~63;
@@ -218,15 +215,14 @@ STDMETHODIMP CDX9SubPic::Unlock(RECT* pDirtyRect)
m_rcDirty.bottom = (m_rcDirty.bottom + 63) & ~63;
m_rcDirty &= CRect(CPoint(0, 0), m_size);
}
- }
- else
- {
+ } else {
m_rcDirty = CRect(CPoint(0, 0), m_size);
}
CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
- if (pTexture && !((CRect*)pDirtyRect)->IsRectEmpty())
+ if (pTexture && !((CRect*)pDirtyRect)->IsRectEmpty()) {
hr = pTexture->AddDirtyRect(&m_rcDirty);
+ }
return S_OK;
}
@@ -235,47 +231,47 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
ASSERT(pTarget == NULL);
- if(!pSrc || !pDst)
+ if(!pSrc || !pDst) {
return E_POINTER;
+ }
CRect src(*pSrc), dst(*pDst);
CComPtr<IDirect3DDevice9> pD3DDev;
CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
- if(!pTexture || FAILED(pTexture->GetDevice(&pD3DDev)) || !pD3DDev)
+ if(!pTexture || FAILED(pTexture->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_NOINTERFACE;
+ }
HRESULT hr;
- do
- {
+ do {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
+ if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
break;
+ }
float w = (float)d3dsd.Width;
float h = (float)d3dsd.Height;
- struct
- {
+ struct {
float x, y, z, rhw;
float tu, tv;
}
- pVertices[] =
- {
+ pVertices[] = {
{(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
{(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
{(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
{(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
};
-/*
- for(ptrdiff_t i = 0; i < countof(pVertices); i++)
- {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
-*/
+ /*
+ for(ptrdiff_t i = 0; i < countof(pVertices); i++)
+ {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+ */
hr = pD3DDev->SetTexture(0, pTexture);
@@ -318,13 +314,13 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
hr = pD3DDev->SetPixelShader(NULL);
-// if(FAILED(hr = pD3DDev->BeginScene()))
-// break;
+ // if(FAILED(hr = pD3DDev->BeginScene()))
+ // break;
hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
-// hr = pD3DDev->EndScene();
+ // hr = pD3DDev->EndScene();
//
@@ -335,8 +331,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -373,8 +368,7 @@ void CDX9SubPicAllocator::ClearCache()
{
// Clear the allocator of any remaining subpics
CAutoLock Lock(&ms_SurfaceQueueLock);
- for (POSITION pos = m_AllocatedSurfaces.GetHeadPosition(); pos; )
- {
+ for (POSITION pos = m_AllocatedSurfaces.GetHeadPosition(); pos; ) {
CDX9SubPic *pSubPic = m_AllocatedSurfaces.GetNext(pos);
pSubPic->m_pAllocator = NULL;
}
@@ -389,7 +383,9 @@ STDMETHODIMP CDX9SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
ClearCache();
CComQIPtr<IDirect3DDevice9> pD3DDev = pDev;
- if(!pD3DDev) return E_NOINTERFACE;
+ if(!pD3DDev) {
+ return E_NOINTERFACE;
+ }
CAutoLock cAutoLock(this);
m_pD3DDev = pD3DDev;
@@ -409,8 +405,9 @@ STDMETHODIMP CDX9SubPicAllocator::SetMaxTextureSize(SIZE MaxTextureSize)
bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return(false);
+ }
CAutoLock cAutoLock(this);
@@ -421,41 +418,43 @@ bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
int Width = m_maxsize.cx;
int Height = m_maxsize.cy;
- if(m_fPow2Textures)
- {
+ if(m_fPow2Textures) {
Width = Height = 1;
- while(Width < m_maxsize.cx) Width <<= 1;
- while(Height < m_maxsize.cy) Height <<= 1;
+ while(Width < m_maxsize.cx) {
+ Width <<= 1;
+ }
+ while(Height < m_maxsize.cy) {
+ Height <<= 1;
+ }
}
- if (!fStatic)
- {
+ if (!fStatic) {
CAutoLock cAutoLock(&ms_SurfaceQueueLock);
POSITION FreeSurf = m_FreeSurfaces.GetHeadPosition();
- if (FreeSurf)
- {
+ if (FreeSurf) {
pSurface = m_FreeSurfaces.GetHead();
m_FreeSurfaces.RemoveHead();
}
}
- if (!pSurface)
- {
+ if (!pSurface) {
CComPtr<IDirect3DTexture9> pTexture;
- if(FAILED(m_pD3DDev->CreateTexture(Width, Height, 1, 0, D3DFMT_A8R8G8B8, fStatic?D3DPOOL_SYSTEMMEM:D3DPOOL_DEFAULT, &pTexture, NULL)))
+ if(FAILED(m_pD3DDev->CreateTexture(Width, Height, 1, 0, D3DFMT_A8R8G8B8, fStatic?D3DPOOL_SYSTEMMEM:D3DPOOL_DEFAULT, &pTexture, NULL))) {
return(false);
+ }
- if(FAILED(pTexture->GetSurfaceLevel(0, &pSurface)))
+ if(FAILED(pTexture->GetSurfaceLevel(0, &pSurface))) {
return(false);
+ }
}
*ppSubPic = DNew CDX9SubPic(pSurface, fStatic ? 0 : this);
- if(!(*ppSubPic))
+ if(!(*ppSubPic)) {
return(false);
+ }
(*ppSubPic)->AddRef();
- if (!fStatic)
- {
+ if (!fStatic) {
CAutoLock cAutoLock(&ms_SurfaceQueueLock);
m_AllocatedSurfaces.AddHead((CDX9SubPic *)*ppSubPic);
}
diff --git a/src/SubPic/DX9SubPic.h b/src/SubPic/DX9SubPic.h
index a1abf02a8..e6fac0c32 100644
--- a/src/SubPic/DX9SubPic.h
+++ b/src/SubPic/DX9SubPic.h
@@ -48,22 +48,19 @@ public:
class TCLocker
{
public:
- static void fs_Locker(void *_pLock)
- {
+ static void fs_Locker(void *_pLock) {
((t_Lock *)_pLock)->Unlock();
}
};
template <typename t_Lock>
- CScopeLock(t_Lock &_Lock)
- {
+ CScopeLock(t_Lock &_Lock) {
_Lock.Lock();
m_pLock = &_Lock;
m_pUnlockFunc = TCLocker<t_Lock>::fs_Locker;
}
- ~CScopeLock()
- {
+ ~CScopeLock() {
m_pUnlockFunc(m_pLock);
}
};
diff --git a/src/SubPic/ISubPic.h b/src/SubPic/ISubPic.h
index 87fde2191..826e8ba77 100644
--- a/src/SubPic/ISubPic.h
+++ b/src/SubPic/ISubPic.h
@@ -28,8 +28,7 @@
#include "CoordGeom.h"
#pragma pack(push, 1)
-struct SubPicDesc
-{
+struct SubPicDesc {
int type;
int w, h, bpp, pitch, pitchUV;
void* bits;
@@ -52,8 +51,7 @@ struct SubPicDesc
interface __declspec(uuid("449E11F3-52D1-4a27-AA61-E2733AC92CC0"))
ISubPic :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(void*, GetObject) () PURE;
STDMETHOD_(REFERENCE_TIME, GetStart) () PURE;
@@ -91,8 +89,7 @@ public IUnknown
interface __declspec(uuid("CF7C3C23-6392-4a42-9E72-0736CFF793CB"))
ISubPicAllocator :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (SetCurSize) (SIZE size /*[in]*/) PURE;
STDMETHOD (SetCurVidRect) (RECT curvidrect) PURE;
@@ -112,8 +109,7 @@ public IUnknown
interface __declspec(uuid("D62B9A1A-879A-42db-AB04-88AA8F243CFD"))
ISubPicProvider :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (Lock) () PURE;
STDMETHOD (Unlock) () PURE;
@@ -136,8 +132,7 @@ public IUnknown
interface __declspec(uuid("C8334466-CD1E-4ad1-9D2D-8EE8519BD180"))
ISubPicQueue :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (SetSubPicProvider) (ISubPicProvider* pSubPicProvider /*[in]*/) PURE;
STDMETHOD (GetSubPicProvider) (ISubPicProvider** pSubPicProvider /*[out]*/) PURE;
@@ -158,8 +153,7 @@ public IUnknown
interface __declspec(uuid("CF75B1F0-535C-4074-8869-B15F177F944E"))
ISubPicAllocatorPresenter :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (CreateRenderer) (IUnknown** ppRenderer) PURE;
STDMETHOD_(SIZE, GetVideoSize) (bool fCorrectAR = true) PURE;
@@ -184,8 +178,7 @@ public IUnknown
interface __declspec(uuid("767AEBA8-A084-488a-89C8-F6B74E53A90F"))
ISubPicAllocatorPresenter2 :
-public ISubPicAllocatorPresenter
-{
+public ISubPicAllocatorPresenter {
STDMETHOD (SetPixelShader2) (LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) PURE;
STDMETHOD_(SIZE, GetVisibleVideoSize) () PURE;
};
@@ -197,8 +190,7 @@ public ISubPicAllocatorPresenter
interface __declspec(uuid("DE11E2FB-02D3-45e4-A174-6B7CE2783BDB"))
ISubStream :
-public IPersist
-{
+public IPersist {
STDMETHOD_(int, GetStreamCount) () PURE;
STDMETHOD (GetStreamInfo) (int i, WCHAR** ppName, LCID* pLCID) PURE;
STDMETHOD_(int, GetStream) () PURE;
diff --git a/src/SubPic/ISubRender.h b/src/SubPic/ISubRender.h
index 4894c996b..8252604f4 100644
--- a/src/SubPic/ISubRender.h
+++ b/src/SubPic/ISubRender.h
@@ -27,8 +27,7 @@
interface __declspec(uuid("CD6D2AA5-20D3-4ebe-A8A9-34D3B00CC253"))
ISubRenderCallback :
-public IUnknown
-{
+public IUnknown {
// NULL means release current device, textures and other resources
STDMETHOD(SetDevice)(IDirect3DDevice9 *dev) = 0;
@@ -41,8 +40,7 @@ public IUnknown
interface __declspec(uuid("E602585E-C05A-4828-AC69-AF92997F2E0C"))
ISubRenderCallback2 :
-public ISubRenderCallback
-{
+public ISubRenderCallback {
STDMETHOD(RenderEx)(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,
REFERENCE_TIME AvgTimePerFrame,
int left, int top, int right, int bottom,
@@ -51,7 +49,6 @@ public ISubRenderCallback
interface __declspec(uuid("9CC7F9F7-3ED1-493c-AF65-527EA1D9947F"))
ISubRender :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(SetCallback)(ISubRenderCallback *cb) = 0;
};
diff --git a/src/SubPic/MemSubPic.cpp b/src/SubPic/MemSubPic.cpp
index 77ad6b083..ba814def8 100644
--- a/src/SubPic/MemSubPic.cpp
+++ b/src/SubPic/MemSubPic.cpp
@@ -59,19 +59,19 @@ bool fColorConvInitOK = false;
void ColorConvInit()
{
- if(fColorConvInitOK) return;
+ if(fColorConvInitOK) {
+ return;
+ }
int i;
- for(i = 0; i < 256; i++)
- {
+ for(i = 0; i < 256; i++) {
Clip_base[i] = 0;
Clip_base[i+256] = i;
Clip_base[i+512] = 255;
}
- for(i = 0; i < 256; i++)
- {
+ for(i = 0; i < 256; i++) {
c2y_yb[i] = c2y_cyb*i;
c2y_yg[i] = c2y_cyg*i;
c2y_yr[i] = c2y_cyr*i;
@@ -135,38 +135,40 @@ STDMETHODIMP CMemSubPic::GetDesc(SubPicDesc& spd)
STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic)))
+ if(FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
+ }
SubPicDesc src, dst;
- if(FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst)))
+ if(FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst))) {
return E_FAIL;
+ }
int w = m_rcDirty.Width(), h = m_rcDirty.Height();
BYTE* s = (BYTE*)src.bits + src.pitch*m_rcDirty.top + m_rcDirty.left*4;
BYTE* d = (BYTE*)dst.bits + dst.pitch*m_rcDirty.top + m_rcDirty.left*4;
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
memcpy(d, s, w*4);
+ }
return S_OK;
}
STDMETHODIMP CMemSubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_FALSE;
+ }
BYTE* p = (BYTE*)m_spd.bits + m_spd.pitch*m_rcDirty.top + m_rcDirty.left*(m_spd.bpp>>3);
- for(ptrdiff_t j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch)
- {
+ for(ptrdiff_t j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch) {
int w = m_rcDirty.Width();
#ifdef _WIN64
memsetd(p, color, w*4); // nya
#else
- __asm
- {
+ __asm {
mov eax, color
mov ecx, w
mov edi, p
@@ -190,20 +192,18 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
{
m_rcDirty = pDirtyRect ? *pDirtyRect : CRect(0,0,m_spd.w,m_spd.h);
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_OK;
+ }
- if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV || m_spd.type == MSP_AYUV)
- {
+ if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV || m_spd.type == MSP_AYUV) {
ColorConvInit();
- if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV)
- {
+ if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
m_rcDirty.left &= ~1;
m_rcDirty.right = (m_rcDirty.right+1)&~1;
- if(m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV)
- {
+ if(m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
m_rcDirty.top &= ~1;
m_rcDirty.bottom = (m_rcDirty.bottom+1)&~1;
}
@@ -215,42 +215,30 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
BYTE* top = (BYTE*)m_spd.bits + m_spd.pitch*m_rcDirty.top + m_rcDirty.left*4;
BYTE* bottom = top + m_spd.pitch*h;
- if(m_spd.type == MSP_RGB16)
- {
- for(; top < bottom ; top += m_spd.pitch)
- {
+ if(m_spd.type == MSP_RGB16) {
+ for(; top < bottom ; top += m_spd.pitch) {
DWORD* s = (DWORD*)top;
DWORD* e = s + w;
- for(; s < e; s++)
- {
+ for(; s < e; s++) {
*s = ((*s>>3)&0x1f000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
-// *s = (*s&0xff000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
+ // *s = (*s&0xff000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
}
}
- }
- else if(m_spd.type == MSP_RGB15)
- {
- for(; top < bottom; top += m_spd.pitch)
- {
+ } else if(m_spd.type == MSP_RGB15) {
+ for(; top < bottom; top += m_spd.pitch) {
DWORD* s = (DWORD*)top;
DWORD* e = s + w;
- for(; s < e; s++)
- {
+ for(; s < e; s++) {
*s = ((*s>>3)&0x1f000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
-// *s = (*s&0xff000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
+ // *s = (*s&0xff000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
}
}
- }
- else if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV)
- {
- for(; top < bottom ; top += m_spd.pitch)
- {
+ } else if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
+ for(; top < bottom ; top += m_spd.pitch) {
BYTE* s = top;
BYTE* e = s + w*4;
- for(; s < e; s+=8) // ARGB ARGB -> AxYU AxYV
- {
- if((s[3]+s[7]) < 0x1fe)
- {
+ for(; s < e; s+=8) { // ARGB ARGB -> AxYU AxYV
+ if((s[3]+s[7]) < 0x1fe) {
s[1] = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
s[5] = (c2y_yb[s[4]] + c2y_yg[s[5]] + c2y_yr[s[6]] + 0x108000) >> 16;
@@ -258,33 +246,24 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
s[0] = Clip[(((((s[0]+s[4])<<15) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
s[4] = Clip[(((((s[2]+s[6])<<15) - scaled_y) >> 10) * c2y_cv + 0x800000 + 0x8000) >> 16];
- }
- else
- {
+ } else {
s[1] = s[5] = 0x10;
s[0] = s[4] = 0x80;
}
}
}
- }
- else if(m_spd.type == MSP_AYUV)
- {
- for(; top < bottom ; top += m_spd.pitch)
- {
+ } else if(m_spd.type == MSP_AYUV) {
+ for(; top < bottom ; top += m_spd.pitch) {
BYTE* s = top;
BYTE* e = s + w*4;
- for(; s < e; s+=4) // ARGB -> AYUV
- {
- if(s[3] < 0xff)
- {
+ for(; s < e; s+=4) { // ARGB -> AYUV
+ if(s[3] < 0xff) {
int y = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
int scaled_y = (y-32) * cy_cy;
s[1] = Clip[((((s[0]<<16) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
s[0] = Clip[((((s[2]<<16) - scaled_y) >> 10) * c2y_cv + 0x800000 + 0x8000) >> 16];
s[2] = y;
- }
- else
- {
+ } else {
s[0] = s[1] = 0x80;
s[2] = 0x10;
}
@@ -305,13 +284,10 @@ void AlphaBlt_YUY2_SSE2(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpit
BYTE* s2end = s2 + w*4;
static const __int64 _8181 = 0x0080001000800010i64;
- for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch)
- {
- for(; s2 < s2end; s2 += 8, d2++)
- {
+ for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for(; s2 < s2end; s2 += 8, d2++) {
ia = (s2[3]+s2[7])>>1;
- if(ia < 0xff)
- {
+ if(ia < 0xff) {
c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
@@ -348,17 +324,13 @@ void AlphaBlt_YUY2_MMX(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitc
static const __int64 _8181 = 0x0080001000800010i64;
- for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch)
- {
- for(; s2 < s2end; s2 += 8, d2++)
- {
+ for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for(; s2 < s2end; s2 += 8, d2++) {
ia = (s2[3]+s2[7])>>1;
- if(ia < 0xff)
- {
+ if(ia < 0xff) {
c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
- __asm
- {
+ __asm {
mov esi, s2
mov edi, d2
pxor mm0, mm0
@@ -392,13 +364,10 @@ void AlphaBlt_YUY2_C(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch)
BYTE* s2end = s2 + w*4;
static const __int64 _8181 = 0x0080001000800010i64;
- for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch)
- {
- for(; s2 < s2end; s2 += 8, d2++)
- {
+ for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for(; s2 < s2end; s2 += 8, d2++) {
ia = (s2[3]+s2[7])>>1;
- if(ia < 0xff)
- {
+ if(ia < 0xff) {
c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
// YUY2 colorspace fix. rewrited from sse2 asm
@@ -416,192 +385,165 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
ASSERT(pTarget);
- if(!pSrc || !pDst || !pTarget)
+ if(!pSrc || !pDst || !pTarget) {
return E_POINTER;
+ }
const SubPicDesc& src = m_spd;
SubPicDesc dst = *pTarget; // copy, because we might modify it
- if(src.type != dst.type)
+ if(src.type != dst.type) {
return E_INVALIDARG;
+ }
CRect rs(*pSrc), rd(*pDst);
- if(dst.h < 0)
- {
+ if(dst.h < 0) {
dst.h = -dst.h;
rd.bottom = dst.h - rd.bottom;
rd.top = dst.h - rd.top;
}
- if(rs.Width() != rd.Width() || rs.Height() != abs(rd.Height()))
+ if(rs.Width() != rd.Width() || rs.Height() != abs(rd.Height())) {
return E_INVALIDARG;
+ }
int w = rs.Width(), h = rs.Height();
BYTE* s = (BYTE*)src.bits + src.pitch*rs.top + rs.left*4;
BYTE* d = (BYTE*)dst.bits + dst.pitch*rd.top + ((rd.left*dst.bpp)>>3);
- if(rd.top > rd.bottom)
- {
+ if(rd.top > rd.bottom) {
if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24
- || dst.type == MSP_RGB16 || dst.type == MSP_RGB15
- || dst.type == MSP_YUY2 || dst.type == MSP_AYUV)
- {
+ || dst.type == MSP_RGB16 || dst.type == MSP_RGB15
+ || dst.type == MSP_YUY2 || dst.type == MSP_AYUV) {
d = (BYTE*)dst.bits + dst.pitch*(rd.top-1) + (rd.left*dst.bpp>>3);
- }
- else if(dst.type == MSP_YV12 || dst.type == MSP_IYUV)
- {
+ } else if(dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
d = (BYTE*)dst.bits + dst.pitch*(rd.top-1) + (rd.left*8>>3);
- }
- else
- {
+ } else {
return E_NOTIMPL;
}
dst.pitch = -dst.pitch;
}
- switch(dst.type)
- {
- case MSP_RGBA:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
- {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- DWORD* d2 = (DWORD*)d;
- for(; s2 < s2end; s2 += 4, d2++)
- {
- if(s2[3] < 0xff)
- {
- DWORD bd =0x00000100 -( (DWORD) s2[3]);
- DWORD B = ((*((DWORD*)s2)&0x000000ff)<<8)/bd;
- DWORD V = ((*((DWORD*)s2)&0x0000ff00)/bd)<<8;
- DWORD R = (((*((DWORD*)s2)&0x00ff0000)>>8)/bd)<<16;
- *d2 = B | V | R
- | (0xff000000-(*((DWORD*)s2)&0xff000000))&0xff000000;
- }
- }
- }
- break;
- case MSP_RGB32:
- case MSP_AYUV:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
- {
+ switch(dst.type) {
+ case MSP_RGBA:
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
-
DWORD* d2 = (DWORD*)d;
- for(; s2 < s2end; s2 += 4, d2++)
- {
-#ifdef _WIN64
- DWORD ia = 256-s2[3];
- if(s2[3] < 0xff)
- {
- *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (((*((DWORD*)s2)&0x00ff00ff)*ia)>>8)&0x00ff00ff)
- | ((((*d2&0x0000ff00)*s2[3])>>8) + (((*((DWORD*)s2)&0x0000ff00)*ia)>>8)&0x0000ff00);
+ for(; s2 < s2end; s2 += 4, d2++) {
+ if(s2[3] < 0xff) {
+ DWORD bd =0x00000100 -( (DWORD) s2[3]);
+ DWORD B = ((*((DWORD*)s2)&0x000000ff)<<8)/bd;
+ DWORD V = ((*((DWORD*)s2)&0x0000ff00)/bd)<<8;
+ DWORD R = (((*((DWORD*)s2)&0x00ff0000)>>8)/bd)<<16;
+ *d2 = B | V | R
+ | (0xff000000-(*((DWORD*)s2)&0xff000000))&0xff000000;
}
+ }
+ }
+ break;
+ case MSP_RGB32:
+ case MSP_AYUV:
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w*4;
+
+ DWORD* d2 = (DWORD*)d;
+ for(; s2 < s2end; s2 += 4, d2++) {
+#ifdef _WIN64
+ DWORD ia = 256-s2[3];
+ if(s2[3] < 0xff) {
+ *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (((*((DWORD*)s2)&0x00ff00ff)*ia)>>8)&0x00ff00ff)
+ | ((((*d2&0x0000ff00)*s2[3])>>8) + (((*((DWORD*)s2)&0x0000ff00)*ia)>>8)&0x0000ff00);
+ }
#else
- if(s2[3] < 0xff)
- {
- *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (*((DWORD*)s2)&0x00ff00ff)&0x00ff00ff)
- | ((((*d2&0x0000ff00)*s2[3])>>8) + (*((DWORD*)s2)&0x0000ff00)&0x0000ff00);
- }
+ if(s2[3] < 0xff) {
+ *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (*((DWORD*)s2)&0x00ff00ff)&0x00ff00ff)
+ | ((((*d2&0x0000ff00)*s2[3])>>8) + (*((DWORD*)s2)&0x0000ff00)&0x0000ff00);
+ }
#endif
+ }
}
- }
- break;
- case MSP_RGB24:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
- {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- BYTE* d2 = d;
- for(; s2 < s2end; s2 += 4, d2 += 3)
- {
- if(s2[3] < 0xff)
- {
- d2[0] = ((d2[0]*s2[3])>>8) + s2[0];
- d2[1] = ((d2[1]*s2[3])>>8) + s2[1];
- d2[2] = ((d2[2]*s2[3])>>8) + s2[2];
+ break;
+ case MSP_RGB24:
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w*4;
+ BYTE* d2 = d;
+ for(; s2 < s2end; s2 += 4, d2 += 3) {
+ if(s2[3] < 0xff) {
+ d2[0] = ((d2[0]*s2[3])>>8) + s2[0];
+ d2[1] = ((d2[1]*s2[3])>>8) + s2[1];
+ d2[2] = ((d2[2]*s2[3])>>8) + s2[2];
+ }
}
}
- }
- break;
- case MSP_RGB16:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
- {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- WORD* d2 = (WORD*)d;
- for(; s2 < s2end; s2 += 4, d2++)
- {
- if(s2[3] < 0x1f)
- {
-
- *d2 = (WORD)((((((*d2&0xf81f)*s2[3])>>5) + (*(DWORD*)s2&0xf81f))&0xf81f)
- | (((((*d2&0x07e0)*s2[3])>>5) + (*(DWORD*)s2&0x07e0))&0x07e0));
+ break;
+ case MSP_RGB16:
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w*4;
+ WORD* d2 = (WORD*)d;
+ for(; s2 < s2end; s2 += 4, d2++) {
+ if(s2[3] < 0x1f) {
+
+ *d2 = (WORD)((((((*d2&0xf81f)*s2[3])>>5) + (*(DWORD*)s2&0xf81f))&0xf81f)
+ | (((((*d2&0x07e0)*s2[3])>>5) + (*(DWORD*)s2&0x07e0))&0x07e0));
+ }
}
}
- }
- break;
- case MSP_RGB15:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
- {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- WORD* d2 = (WORD*)d;
- for(; s2 < s2end; s2 += 4, d2++)
- {
- if(s2[3] < 0x1f)
- {
- *d2 = (WORD)((((((*d2&0x7c1f)*s2[3])>>5) + (*(DWORD*)s2&0x7c1f))&0x7c1f)
- | (((((*d2&0x03e0)*s2[3])>>5) + (*(DWORD*)s2&0x03e0))&0x03e0));
+ break;
+ case MSP_RGB15:
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w*4;
+ WORD* d2 = (WORD*)d;
+ for(; s2 < s2end; s2 += 4, d2++) {
+ if(s2[3] < 0x1f) {
+ *d2 = (WORD)((((((*d2&0x7c1f)*s2[3])>>5) + (*(DWORD*)s2&0x7c1f))&0x7c1f)
+ | (((((*d2&0x03e0)*s2[3])>>5) + (*(DWORD*)s2&0x03e0))&0x03e0));
+ }
}
}
- }
- break;
- case MSP_YUY2:
- {
- void (*alphablt_func)(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch);
+ break;
+ case MSP_YUY2: {
+ void (*alphablt_func)(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch);
#ifdef _WIN64
- alphablt_func = AlphaBlt_YUY2_SSE2;
+ alphablt_func = AlphaBlt_YUY2_SSE2;
#else
- alphablt_func = AlphaBlt_YUY2_MMX;
+ alphablt_func = AlphaBlt_YUY2_MMX;
#endif
- //alphablt_func = AlphaBlt_YUY2_C;
+ //alphablt_func = AlphaBlt_YUY2_C;
- alphablt_func(w, h, d, dst.pitch, s, src.pitch);
- }
- break;
- case MSP_YV12:
- case MSP_IYUV:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
- {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- BYTE* d2 = d;
- for(; s2 < s2end; s2 += 4, d2++)
- {
- if(s2[3] < 0xff)
- {
- d2[0] = (((d2[0]-0x10)*s2[3])>>8) + s2[1];
+ alphablt_func(w, h, d, dst.pitch, s, src.pitch);
+ }
+ break;
+ case MSP_YV12:
+ case MSP_IYUV:
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w*4;
+ BYTE* d2 = d;
+ for(; s2 < s2end; s2 += 4, d2++) {
+ if(s2[3] < 0xff) {
+ d2[0] = (((d2[0]-0x10)*s2[3])>>8) + s2[1];
+ }
}
}
- }
- break;
- default:
- return E_NOTIMPL;
+ break;
+ default:
+ return E_NOTIMPL;
}
dst.pitch = abs(dst.pitch);
- if(dst.type == MSP_YV12 || dst.type == MSP_IYUV)
- {
+ if(dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
int h2 = h/2;
- if(!dst.pitchUV)
- {
+ if(!dst.pitchUV) {
dst.pitchUV = dst.pitch/2;
}
@@ -609,13 +551,11 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
ss[0] = (BYTE*)src.bits + src.pitch*rs.top + rs.left*4;
ss[1] = ss[0] + 4;
- if(!dst.bitsU || !dst.bitsV)
- {
+ if(!dst.bitsU || !dst.bitsV) {
dst.bitsU = (BYTE*)dst.bits + dst.pitch*dst.h;
dst.bitsV = dst.bitsU + dst.pitchUV*dst.h/2;
- if(dst.type == MSP_YV12)
- {
+ if(dst.type == MSP_YV12) {
BYTE* p = dst.bitsU;
dst.bitsU = dst.bitsV;
dst.bitsV = p;
@@ -626,29 +566,24 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
dd[0] = dst.bitsU + dst.pitchUV*rd.top/2 + rd.left/2;
dd[1] = dst.bitsV + dst.pitchUV*rd.top/2 + rd.left/2;
- if(rd.top > rd.bottom)
- {
+ if(rd.top > rd.bottom) {
dd[0] = dst.bitsU + dst.pitchUV*(rd.top/2-1) + rd.left/2;
dd[1] = dst.bitsV + dst.pitchUV*(rd.top/2-1) + rd.left/2;
dst.pitchUV = -dst.pitchUV;
}
- for(ptrdiff_t i = 0; i < 2; i++)
- {
+ for(ptrdiff_t i = 0; i < 2; i++) {
s = ss[i];
d = dd[i];
BYTE* is = ss[1-i];
- for(ptrdiff_t j = 0; j < h2; j++, s += src.pitch*2, d += dst.pitchUV, is += src.pitch*2)
- {
+ for(ptrdiff_t j = 0; j < h2; j++, s += src.pitch*2, d += dst.pitchUV, is += src.pitch*2) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
BYTE* d2 = d;
BYTE* is2 = is;
- for(; s2 < s2end; s2 += 8, d2++, is2 += 8)
- {
+ for(; s2 < s2end; s2 += 8, d2++, is2 += 8) {
unsigned int ia = (s2[3]+s2[3+src.pitch]+is2[3]+is2[3+src.pitch])>>2;
- if(ia < 0xff)
- {
+ if(ia < 0xff) {
*d2 = (((*d2-0x80)*ia)>>8) + ((s2[0]+s2[src.pitch])>>1);
}
}
@@ -679,8 +614,9 @@ CMemSubPicAllocator::CMemSubPicAllocator(int type, SIZE maxsize)
bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return(false);
+ }
SubPicDesc spd;
spd.w = m_maxsize.cx;
@@ -689,12 +625,14 @@ bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
spd.pitch = (spd.w*spd.bpp)>>3;
spd.type = m_type;
spd.bits = DNew BYTE[spd.pitch*spd.h];
- if(!spd.bits)
+ if(!spd.bits) {
return(false);
+ }
*ppSubPic = DNew CMemSubPic(spd);
- if(!(*ppSubPic))
+ if(!(*ppSubPic)) {
return(false);
+ }
(*ppSubPic)->AddRef();
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.cpp b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
index 936940d14..2d90c85fd 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.cpp
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
@@ -35,11 +35,11 @@ CSubPicAllocatorPresenterImpl::CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT&
, m_bDeviceResetRequested(false)
, m_bPendingResetDevice(false)
{
- if(!IsWindow(m_hWnd))
- {
+ if(!IsWindow(m_hWnd)) {
hr = E_INVALIDARG;
- if (_pError)
+ if (_pError) {
*_pError += "Invalid window handle in ISubPicAllocatorPresenterImpl\n";
+ }
return;
}
GetWindowRect(m_hWnd, &m_WindowRect);
@@ -63,31 +63,31 @@ STDMETHODIMP CSubPicAllocatorPresenterImpl::NonDelegatingQueryInterface(REFIID r
void CSubPicAllocatorPresenterImpl::AlphaBltSubPic(CSize size, SubPicDesc* pTarget)
{
CComPtr<ISubPic> pSubPic;
- if(m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic))
- {
+ if(m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic)) {
CRect rcSource, rcDest;
- if (SUCCEEDED (pSubPic->GetSourceAndDest(&size, rcSource, rcDest)))
+ if (SUCCEEDED (pSubPic->GetSourceAndDest(&size, rcSource, rcDest))) {
pSubPic->AlphaBlt(rcSource, rcDest, pTarget);
-/* SubPicDesc spd;
- pSubPic->GetDesc(spd);
-
- if(spd.w > 0 && spd.h > 0)
- {
- CRect r;
- pSubPic->GetDirtyRect(r);
-
- // FIXME
- r.DeflateRect(1, 1);
-
- CRect rDstText(
- r.left * size.cx / spd.w,
- r.top * size.cy / spd.h,
- r.right * size.cx / spd.w,
- r.bottom * size.cy / spd.h);
-
- pSubPic->AlphaBlt(r, rDstText, pTarget);
}
-*/
+ /* SubPicDesc spd;
+ pSubPic->GetDesc(spd);
+
+ if(spd.w > 0 && spd.h > 0)
+ {
+ CRect r;
+ pSubPic->GetDirtyRect(r);
+
+ // FIXME
+ r.DeflateRect(1, 1);
+
+ CRect rDstText(
+ r.left * size.cx / spd.w,
+ r.top * size.cy / spd.h,
+ r.right * size.cx / spd.w,
+ r.bottom * size.cy / spd.h);
+
+ pSubPic->AlphaBlt(r, rDstText, pTarget);
+ }
+ */
}
}
@@ -97,8 +97,9 @@ STDMETHODIMP_(SIZE) CSubPicAllocatorPresenterImpl::GetVideoSize(bool fCorrectAR)
{
CSize VideoSize(GetVisibleVideoSize());
- if(fCorrectAR && m_AspectRatio.cx > 0 && m_AspectRatio.cy > 0)
+ if(fCorrectAR && m_AspectRatio.cx > 0 && m_AspectRatio.cy > 0) {
VideoSize.cx = (LONGLONG(VideoSize.cy)*LONGLONG(m_AspectRatio.cx))/LONGLONG(m_AspectRatio.cy);
+ }
return(VideoSize);
}
@@ -114,34 +115,31 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetPosition(RECT w, RECT v)
m_VideoRect = v;
- if(fWindowSizeChanged || fVideoRectChanged)
- {
- if(m_pAllocator)
- {
+ if(fWindowSizeChanged || fVideoRectChanged) {
+ if(m_pAllocator) {
m_pAllocator->SetCurSize(m_WindowRect.Size());
m_pAllocator->SetCurVidRect(m_VideoRect);
}
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->Invalidate();
}
}
- if(fWindowPosChanged || fVideoRectChanged)
+ if(fWindowPosChanged || fVideoRectChanged) {
Paint(fWindowSizeChanged || fVideoRectChanged);
+ }
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetTime(REFERENCE_TIME rtNow)
{
-/*
- if(m_rtNow <= rtNow && rtNow <= m_rtNow + 1000000)
- return;
-*/
+ /*
+ if(m_rtNow <= rtNow && rtNow <= m_rtNow + 1000000)
+ return;
+ */
m_rtNow = rtNow - m_rtSubtitleDelay;
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetTime(m_rtNow);
}
}
@@ -165,14 +163,16 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetSubPicProvider(ISubPicProv
{
m_SubPicProvider = pSubPicProvider;
- if(m_pSubPicQueue)
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::Invalidate(REFERENCE_TIME rtInvalidate)
{
- if(m_pSubPicQueue)
+ if(m_pSubPicQueue) {
m_pSubPicQueue->Invalidate(rtInvalidate);
+ }
}
#include <math.h>
@@ -187,8 +187,7 @@ void CSubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4])
Vector center(r.CenterPoint().x, r.CenterPoint().y, 0);
int l = (int)(Vector(r.Size().cx, r.Size().cy, 0).Length()*1.5f)+1;
- for(ptrdiff_t i = 0; i < 4; i++)
- {
+ for(ptrdiff_t i = 0; i < 4; i++) {
v[i] = m_xform << (v[i] - center);
v[i].z = v[i].z / l + 0.5f;
v[i].x /= v[i].z*2;
@@ -200,6 +199,8 @@ void CSubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4])
STDMETHODIMP CSubPicAllocatorPresenterImpl::SetVideoAngle(Vector v, bool fRepaint)
{
m_xform = XForm(Ray(Vector(0, 0, 0), v), Vector(1, 1, 1), false);
- if(fRepaint) Paint(true);
+ if(fRepaint) {
+ Paint(true);
+ }
return S_OK;
}
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.h b/src/SubPic/SubPicAllocatorPresenterImpl.h
index 99b987299..171078617 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.h
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.h
@@ -95,10 +95,10 @@ public:
STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget) {
return E_NOTIMPL;
}
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
- {
- if (!bScreenSpace)
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) {
+ if (!bScreenSpace) {
return SetPixelShader(pSrcData, pTarget);
+ }
return E_NOTIMPL;
}
};
diff --git a/src/SubPic/SubPicImpl.cpp b/src/SubPic/SubPicImpl.cpp
index 7d6dc5f01..66b85b03f 100644
--- a/src/SubPic/SubPicImpl.cpp
+++ b/src/SubPic/SubPicImpl.cpp
@@ -59,15 +59,17 @@ STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetStop()
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetSegmentStart()
{
- if (m_rtSegmentStart)
+ if (m_rtSegmentStart) {
return(m_rtSegmentStart);
+ }
return(m_rtStart);
}
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetSegmentStop()
{
- if (m_rtSegmentStop)
+ if (m_rtSegmentStop) {
return(m_rtSegmentStop);
+ }
return(m_rtStop);
}
@@ -95,8 +97,9 @@ STDMETHODIMP_(void) CSubPicImpl::SetStop(REFERENCE_TIME rtStop)
STDMETHODIMP CSubPicImpl::CopyTo(ISubPic* pSubPic)
{
- if(!pSubPic)
+ if(!pSubPic) {
return E_POINTER;
+ }
pSubPic->SetStart(m_rtStart);
pSubPic->SetStop(m_rtStop);
@@ -119,8 +122,7 @@ STDMETHODIMP CSubPicImpl::GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* p
CheckPointer (pRcSource, E_POINTER);
CheckPointer (pRcDest, E_POINTER);
- if(m_size.cx > 0 && m_size.cy > 0)
- {
+ if(m_size.cx > 0 && m_size.cy > 0) {
CRect rcTemp = m_rcDirty;
// FIXME
@@ -135,9 +137,9 @@ STDMETHODIMP CSubPicImpl::GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* p
rcTemp.bottom * pSize->cy / m_VirtualTextureSize.cy);
return S_OK;
- }
- else
+ } else {
return E_INVALIDARG;
+ }
}
STDMETHODIMP CSubPicImpl::SetDirtyRect(RECT* pDirtyRect)
@@ -155,20 +157,17 @@ STDMETHODIMP CSubPicImpl::SetSize(SIZE size, RECT vidrect)
m_size = size;
m_vidrect = vidrect;
- if(m_size.cx > m_maxsize.cx)
- {
+ if(m_size.cx > m_maxsize.cx) {
m_size.cy = MulDiv(m_size.cy, m_maxsize.cx, m_size.cx);
m_size.cx = m_maxsize.cx;
}
- if(m_size.cy > m_maxsize.cy)
- {
+ if(m_size.cy > m_maxsize.cy) {
m_size.cx = MulDiv(m_size.cx, m_maxsize.cy, m_size.cy);
m_size.cy = m_maxsize.cy;
}
- if(m_size.cx != size.cx || m_size.cy != size.cy)
- {
+ if(m_size.cx != size.cx || m_size.cy != size.cy) {
m_vidrect.top = MulDiv(m_vidrect.top, m_size.cx, size.cx);
m_vidrect.bottom = MulDiv(m_vidrect.bottom, m_size.cx, size.cx);
m_vidrect.left = MulDiv(m_vidrect.left, m_size.cy, size.cy);
@@ -223,13 +222,14 @@ STDMETHODIMP CSubPicAllocatorImpl::SetCurVidRect(RECT curvidrect)
STDMETHODIMP CSubPicAllocatorImpl::GetStatic(ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return E_POINTER;
+ }
- if(!m_pStatic)
- {
- if(!Alloc(true, &m_pStatic) || !m_pStatic)
+ if(!m_pStatic) {
+ if(!Alloc(true, &m_pStatic) || !m_pStatic) {
return E_OUTOFMEMORY;
+ }
}
m_pStatic->SetSize(m_cursize, m_curvidrect);
@@ -241,11 +241,13 @@ STDMETHODIMP CSubPicAllocatorImpl::GetStatic(ISubPic** ppSubPic)
STDMETHODIMP CSubPicAllocatorImpl::AllocDynamic(ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return E_POINTER;
+ }
- if(!Alloc(false, ppSubPic) || !*ppSubPic)
+ if(!Alloc(false, ppSubPic) || !*ppSubPic) {
return E_OUTOFMEMORY;
+ }
(*ppSubPic)->SetSize(m_cursize, m_curvidrect);
diff --git a/src/SubPic/SubPicImpl.h b/src/SubPic/SubPicImpl.h
index e0de8e943..ad5e3528a 100644
--- a/src/SubPic/SubPicImpl.h
+++ b/src/SubPic/SubPicImpl.h
@@ -37,34 +37,34 @@ protected:
CSize m_VirtualTextureSize;
CPoint m_VirtualTextureTopLeft;
-/*
-
- Texture
- +-------+---------------------------------+
- | . | .
- | . m_maxsize | .
- TextureTopLeft .<=============================== |======> . Video
- | . . . +-------------------------------- | -----+ +-----------------------------------+
- | | . | | | m_vidrect |
- | | . | | | |
- | | . | | | |
- | | +-----------+ . | | | |
- | | | m_rcDirty | . | | | |
- | | | | . | | | |
- | | +-----------+ . | | | |
- | +-------------------------------- | -----+ | |
- | m_size | | |
- | <=========================> | | |
- | | | |
- | | +-----------------------------------+
- | | .
- | | .
- | | .
- +-----------------------------------------+
- m_VirtualTextureSize
- <=========================================>
-
-*/
+ /*
+
+ Texture
+ +-------+---------------------------------+
+ | . | .
+ | . m_maxsize | .
+ TextureTopLeft .<=============================== |======> . Video
+ | . . . +-------------------------------- | -----+ +-----------------------------------+
+ | | . | | | m_vidrect |
+ | | . | | | |
+ | | . | | | |
+ | | +-----------+ . | | | |
+ | | | m_rcDirty | . | | | |
+ | | | | . | | | |
+ | | +-----------+ . | | | |
+ | +-------------------------------- | -----+ | |
+ | m_size | | |
+ | <=========================> | | |
+ | | | |
+ | | +-----------------------------------+
+ | | .
+ | | .
+ | | .
+ +-----------------------------------------+
+ m_VirtualTextureSize
+ <=========================================>
+
+ */
public:
diff --git a/src/SubPic/SubPicQueueImpl.cpp b/src/SubPic/SubPicQueueImpl.cpp
index 59fe3ccd9..7f8d89ec3 100644
--- a/src/SubPic/SubPicQueueImpl.cpp
+++ b/src/SubPic/SubPicQueueImpl.cpp
@@ -36,11 +36,14 @@ CSubPicQueueImpl::CSubPicQueueImpl(ISubPicAllocator* pAllocator, HRESULT* phr)
, m_rtNowLast(0)
, m_fps(25.0)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
- if(!m_pAllocator)
- {
- if(phr) *phr = E_FAIL;
+ if(!m_pAllocator) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
}
@@ -62,7 +65,7 @@ STDMETHODIMP CSubPicQueueImpl::SetSubPicProvider(ISubPicProvider* pSubPicProvide
{
CAutoLock cAutoLock(&m_csSubPicProvider);
-// if(m_pSubPicProvider != pSubPicProvider)
+ // if(m_pSubPicProvider != pSubPicProvider)
{
m_pSubPicProvider = pSubPicProvider;
@@ -74,13 +77,13 @@ STDMETHODIMP CSubPicQueueImpl::SetSubPicProvider(ISubPicProvider* pSubPicProvide
STDMETHODIMP CSubPicQueueImpl::GetSubPicProvider(ISubPicProvider** pSubPicProvider)
{
- if(!pSubPicProvider)
+ if(!pSubPicProvider) {
return E_POINTER;
+ }
CAutoLock cAutoLock(&m_csSubPicProvider);
- if(m_pSubPicProvider)
- {
+ if(m_pSubPicProvider) {
*pSubPicProvider = m_pSubPicProvider;
(*pSubPicProvider)->AddRef();
}
@@ -108,19 +111,21 @@ HRESULT CSubPicQueueImpl::RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REF
{
HRESULT hr = E_FAIL;
- if(!pSubPic)
+ if(!pSubPic) {
return hr;
+ }
CComPtr<ISubPicProvider> pSubPicProvider;
- if(FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider)
+ if(FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider) {
return hr;
+ }
SubPicDesc spd;
hr = pSubPic->ClearDirtyRect(0xFF000000);
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = pSubPic->Lock(spd);
- if (SUCCEEDED(hr))
- {
+ }
+ if (SUCCEEDED(hr)) {
CRect r(0,0,0,0);
hr = pSubPicProvider->Render(spd, bIsAnimated ? rtStart : ((rtStart+rtStop)/2), fps, r);
@@ -144,18 +149,21 @@ CSubPicQueue::CSubPicQueue(int nMaxSubPic, BOOL bDisableAnim, ISubPicAllocator*
,m_rtQueueMin(0)
,m_rtQueueMax(0)
{
- if(phr && FAILED(*phr))
+ if(phr && FAILED(*phr)) {
return;
+ }
- if(m_nMaxSubPic < 1)
- {
- if(phr) *phr = E_INVALIDARG;
+ if(m_nMaxSubPic < 1) {
+ if(phr) {
+ *phr = E_INVALIDARG;
+ }
return;
}
m_fBreakBuffering = false;
- for(ptrdiff_t i = 0; i < EVENT_COUNT; i++)
+ for(ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
m_ThreadEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ }
CAMThread::Create();
}
@@ -164,8 +172,9 @@ CSubPicQueue::~CSubPicQueue()
m_fBreakBuffering = true;
SetEvent(m_ThreadEvents[EVENT_EXIT]);
CAMThread::Close();
- for(ptrdiff_t i = 0; i < EVENT_COUNT; i++)
+ for(ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
CloseHandle(m_ThreadEvents[i]);
+ }
}
// ISubPicQueue
@@ -173,7 +182,9 @@ CSubPicQueue::~CSubPicQueue()
STDMETHODIMP CSubPicQueue::SetFPS(double fps)
{
HRESULT hr = __super::SetFPS(fps);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
SetEvent(m_ThreadEvents[EVENT_TIME]);
@@ -183,7 +194,9 @@ STDMETHODIMP CSubPicQueue::SetFPS(double fps)
STDMETHODIMP CSubPicQueue::SetTime(REFERENCE_TIME rtNow)
{
HRESULT hr = __super::SetTime(rtNow);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
SetEvent(m_ThreadEvents[EVENT_TIME]);
@@ -193,8 +206,8 @@ STDMETHODIMP CSubPicQueue::SetTime(REFERENCE_TIME rtNow)
STDMETHODIMP CSubPicQueue::Invalidate(REFERENCE_TIME rtInvalidate)
{
{
-// CAutoLock cQueueLock(&m_csQueueLock);
-// RemoveAll();
+ // CAutoLock cQueueLock(&m_csQueueLock);
+ // RemoveAll();
m_rtInvalidate = rtInvalidate;
m_fBreakBuffering = true;
@@ -218,43 +231,39 @@ STDMETHODIMP_(bool) CSubPicQueue::LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISu
#if DSubPicTraceLevel > 2
TRACE("Find: ");
#endif
- while(pos)
- {
+ while(pos) {
CComPtr<ISubPic> pSubPic = m_Queue.GetNext(pos);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
- if(rtNow >= rtStart && rtNow < rtSegmentStop)
- {
+ if(rtNow >= rtStart && rtNow < rtSegmentStop) {
REFERENCE_TIME Diff = rtNow - rtStop;
- if (Diff < rtBestStop)
- {
+ if (Diff < rtBestStop) {
rtBestStop = Diff;
-// TRACE(" %f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
+ // TRACE(" %f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
ppSubPic = pSubPic;
}
#if DSubPicTraceLevel > 2
- else
+ else {
TRACE(" !%f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
+ }
#endif
}
#if DSubPicTraceLevel > 2
- else
+ else {
TRACE(" !!%f->%f", double(rtStart) / 10000000.0, double(rtSegmentStop) / 10000000.0);
+ }
#endif
}
#if DSubPicTraceLevel > 2
TRACE("\n");
#endif
- if (!ppSubPic)
- {
+ if (!ppSubPic) {
#if DSubPicTraceLevel > 1
TRACE("NO Display: %f\n", double(rtNow) / 10000000.0);
#endif
- }
- else
- {
+ } else {
#if DSubPicTraceLevel > 0
REFERENCE_TIME rtStart = (ppSubPic)->GetStart();
REFERENCE_TIME rtSegmentStop = (ppSubPic)->GetSegmentStop();
@@ -274,11 +283,13 @@ STDMETHODIMP CSubPicQueue::GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERE
nSubPics = m_Queue.GetCount();
rtNow = m_rtNow;
rtStart = m_rtQueueMin;
- if (rtStart == 0x7fffffffffffffffi64)
+ if (rtStart == 0x7fffffffffffffffi64) {
rtStart = 0;
+ }
rtStop = m_rtQueueMax;
- if (rtStop == 0xffffffffffffffffi64)
+ if (rtStop == 0xffffffffffffffffi64) {
rtStop = 0;
+ }
return S_OK;
}
@@ -289,16 +300,12 @@ STDMETHODIMP CSubPicQueue::GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERE
rtStart = rtStop = -1;
- if(nSubPic >= 0 && nSubPic < (int)m_Queue.GetCount())
- {
- if(POSITION pos = m_Queue.FindIndex(nSubPic))
- {
+ if(nSubPic >= 0 && nSubPic < (int)m_Queue.GetCount()) {
+ if(POSITION pos = m_Queue.FindIndex(nSubPic)) {
rtStart = m_Queue.GetAt(pos)->GetStart();
rtStop = m_Queue.GetAt(pos)->GetStop();
}
- }
- else
- {
+ } else {
return E_INVALIDARG;
}
@@ -314,13 +321,10 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue()
REFERENCE_TIME rtNow = m_rtNow;
REFERENCE_TIME rtNowCompare = rtNow;
- if (rtNow < m_rtNowLast)
- {
+ if (rtNow < m_rtNowLast) {
m_Queue.RemoveAll();
m_rtNowLast = rtNow;
- }
- else
- {
+ } else {
m_rtNowLast = rtNow;
m_rtQueueMin = 0x7fffffffffffffffi64;
@@ -330,18 +334,15 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue()
POSITION SavePos = 0;
{
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter)
- {
+ while(Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
- if(rtNow >= rtStart && rtNow < rtSegmentStop)
- {
+ if(rtNow >= rtStart && rtNow < rtSegmentStop) {
REFERENCE_TIME Diff = rtNow - rtStop;
- if (Diff < rtBestStop)
- {
+ if (Diff < rtBestStop) {
rtBestStop = Diff;
SavePos = ThisPos;
}
@@ -349,35 +350,33 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue()
}
}
- #if DSubPicTraceLevel > 3
- if (SavePos)
- {
+#if DSubPicTraceLevel > 3
+ if (SavePos) {
ISubPic *pSubPic = GetAt(SavePos);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
TRACE("Save: %f->%f\n", double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
}
- #endif
+#endif
{
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter)
- {
+ while(Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
- if (rtStop <= rtNowCompare && ThisPos != SavePos)
- {
- #if DSubPicTraceLevel > 0
+ if (rtStop <= rtNowCompare && ThisPos != SavePos) {
+#if DSubPicTraceLevel > 0
TRACE("Remove: %f->%f\n", double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
- #endif
+#endif
m_Queue.RemoveAt(ThisPos);
continue;
}
- if (rtStop > rtNow)
+ if (rtStop > rtNow) {
rtNow = rtStop;
+ }
m_rtQueueMin = min(m_rtQueueMin, rtStart);
m_rtQueueMax = max(m_rtQueueMax, rtStop);
}
@@ -409,15 +408,15 @@ DWORD CSubPicQueue::ThreadProc()
SetThreadPriority(m_hThread, bDisableAnim ? THREAD_PRIORITY_LOWEST : THREAD_PRIORITY_ABOVE_NORMAL/*THREAD_PRIORITY_BELOW_NORMAL*/);
bool bAgain = true;
- while(1)
- {
+ while(1) {
DWORD Ret = WaitForMultipleObjects(EVENT_COUNT, m_ThreadEvents, FALSE, bAgain ? 0 : INFINITE);
bAgain = false;
- if (Ret == WAIT_TIMEOUT)
+ if (Ret == WAIT_TIMEOUT) {
;
- else if ((Ret - WAIT_OBJECT_0) != EVENT_TIME)
+ } else if ((Ret - WAIT_OBJECT_0) != EVENT_TIME) {
break;
+ }
double fps = m_fps;
REFERENCE_TIME rtTimePerFrame = 10000000.0/fps;
REFERENCE_TIME rtNow = UpdateQueue();
@@ -426,46 +425,46 @@ DWORD CSubPicQueue::ThreadProc()
CComPtr<ISubPicProvider> pSubPicProvider;
if(SUCCEEDED(GetSubPicProvider(&pSubPicProvider)) && pSubPicProvider
- && SUCCEEDED(pSubPicProvider->Lock()))
- {
+ && SUCCEEDED(pSubPicProvider->Lock())) {
for(POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
pos && !m_fBreakBuffering && GetQueueCount() < (size_t)nMaxSubPic;
- pos = pSubPicProvider->GetNext(pos))
- {
+ pos = pSubPicProvider->GetNext(pos)) {
REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
- if(m_rtNow >= rtStart)
- {
-// m_fBufferUnderrun = true;
- if(m_rtNow >= rtStop) continue;
+ if(m_rtNow >= rtStart) {
+ // m_fBufferUnderrun = true;
+ if(m_rtNow >= rtStop) {
+ continue;
+ }
}
- if(rtStart >= m_rtNow + 60*10000000i64) // we are already one minute ahead, this should be enough
+ if(rtStart >= m_rtNow + 60*10000000i64) { // we are already one minute ahead, this should be enough
break;
+ }
- if(rtNow < rtStop)
- {
+ if(rtNow < rtStop) {
REFERENCE_TIME rtCurrent = max(rtNow, rtStart);
bool bIsAnimated = pSubPicProvider->IsAnimated(pos) && !bDisableAnim;
- while (rtCurrent < rtStop)
- {
+ while (rtCurrent < rtStop) {
SIZE MaxTextureSize, VirtualSize;
POINT VirtualTopLeft;
HRESULT hr2;
- if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft)))
+ if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
m_pAllocator->SetMaxTextureSize(MaxTextureSize);
+ }
CComPtr<ISubPic> pStatic;
- if(FAILED(m_pAllocator->GetStatic(&pStatic)))
+ if(FAILED(m_pAllocator->GetStatic(&pStatic))) {
break;
+ }
HRESULT hr;
- if (bIsAnimated)
- {
- if (rtCurrent < m_rtNow + rtTimePerFrame)
+ if (bIsAnimated) {
+ if (rtCurrent < m_rtNow + rtTimePerFrame) {
rtCurrent = min(m_rtNow + rtTimePerFrame, rtStop-1);
+ }
REFERENCE_TIME rtEndThis = min(rtCurrent + rtTimePerFrame, rtStop);
hr = RenderTo(pStatic, rtCurrent, rtEndThis, fps, bIsAnimated);
@@ -479,38 +478,40 @@ DWORD CSubPicQueue::ThreadProc()
rtCurrent = rtEndThis;
- }
- else
- {
+ } else {
hr = RenderTo(pStatic, rtStart, rtStop, fps, bIsAnimated);
rtCurrent = rtStop;
}
#if DSubPicTraceLevel > 0
- if (m_rtNow > rtCurrent)
- {
+ if (m_rtNow > rtCurrent) {
TRACE("BEHIND\n");
}
#endif
- if(FAILED(hr))
+ if(FAILED(hr)) {
break;
+ }
- if(S_OK != hr) // subpic was probably empty
+ if(S_OK != hr) { // subpic was probably empty
continue;
+ }
CComPtr<ISubPic> pDynamic;
if(FAILED(m_pAllocator->AllocDynamic(&pDynamic))
- || FAILED(pStatic->CopyTo(pDynamic)))
+ || FAILED(pStatic->CopyTo(pDynamic))) {
break;
+ }
- if (SUCCEEDED (hr2))
+ if (SUCCEEDED (hr2)) {
pDynamic->SetVirtualTextureSize (VirtualSize, VirtualTopLeft);
+ }
AppendQueue(pDynamic);
bAgain = true;
- if (GetQueueCount() >= (size_t)nMaxSubPic)
+ if (GetQueueCount() >= (size_t)nMaxSubPic) {
break;
+ }
}
}
}
@@ -518,24 +519,21 @@ DWORD CSubPicQueue::ThreadProc()
pSubPicProvider->Unlock();
}
- if(m_fBreakBuffering)
- {
+ if(m_fBreakBuffering) {
bAgain = true;
CAutoLock cQueueLock(&m_csQueueLock);
REFERENCE_TIME rtInvalidate = m_rtInvalidate;
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter)
- {
+ while(Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
- if (rtStop > rtInvalidate)
- {
+ if (rtStop > rtInvalidate) {
#if DSubPicTraceLevel >= 0
TRACE(_T("Removed subtitle because of invalidation: %f->%f\n"), double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
#endif
@@ -544,16 +542,16 @@ DWORD CSubPicQueue::ThreadProc()
}
}
-/*
- while(GetCount() && GetTail()->GetStop() > rtInvalidate)
- {
- if(GetTail()->GetStart() < rtInvalidate) GetTail()->SetStop(rtInvalidate);
- else
- {
- RemoveTail();
- }
- }
-*/
+ /*
+ while(GetCount() && GetTail()->GetStop() > rtInvalidate)
+ {
+ if(GetTail()->GetStart() < rtInvalidate) GetTail()->SetStop(rtInvalidate);
+ else
+ {
+ RemoveTail();
+ }
+ }
+ */
m_fBreakBuffering = false;
}
@@ -593,70 +591,65 @@ STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CCo
{
CAutoLock cAutoLock(&m_csLock);
- if(!m_pSubPic)
- {
- if(FAILED(m_pAllocator->AllocDynamic(&m_pSubPic)))
+ if(!m_pSubPic) {
+ if(FAILED(m_pAllocator->AllocDynamic(&m_pSubPic))) {
return(false);
+ }
}
pSubPic = m_pSubPic;
}
- if(pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop())
- {
+ if(pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop()) {
ppSubPic = pSubPic;
- }
- else
- {
+ } else {
CComPtr<ISubPicProvider> pSubPicProvider;
GetSubPicProvider(&pSubPicProvider);
- if (pSubPicProvider)
- {
+ if (pSubPicProvider) {
double fps = m_fps;
POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
- if(pos != 0)
- {
+ if(pos != 0) {
REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
- if(pSubPicProvider->IsAnimated(pos))
- {
+ if(pSubPicProvider->IsAnimated(pos)) {
rtStart = rtNow;
rtStop = rtNow+1;
}
- if(rtStart <= rtNow && rtNow < rtStop)
- {
+ if(rtStart <= rtNow && rtNow < rtStop) {
SIZE MaxTextureSize, VirtualSize;
POINT VirtualTopLeft;
HRESULT hr2;
- if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft)))
+ if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
m_pAllocator->SetMaxTextureSize(MaxTextureSize);
+ }
- if(m_pAllocator->IsDynamicWriteOnly())
- {
+ if(m_pAllocator->IsDynamicWriteOnly()) {
CComPtr<ISubPic> pStatic;
HRESULT hr = m_pAllocator->GetStatic(&pStatic);
- if(SUCCEEDED(hr))
+ if(SUCCEEDED(hr)) {
hr = RenderTo(pStatic, rtStart, rtStop, fps, false);
- if(SUCCEEDED(hr))
+ }
+ if(SUCCEEDED(hr)) {
hr = pStatic->CopyTo(pSubPic);
- if(SUCCEEDED(hr))
+ }
+ if(SUCCEEDED(hr)) {
ppSubPic = pSubPic;
- }
- else
- {
- if(SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false)))
+ }
+ } else {
+ if(SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false))) {
ppSubPic = pSubPic;
+ }
}
- if (SUCCEEDED(hr2))
+ if (SUCCEEDED(hr2)) {
pSubPic->SetVirtualTextureSize (VirtualSize, VirtualTopLeft);
+ }
}
}
- if(ppSubPic)
- {
+ if(ppSubPic) {
CAutoLock cAutoLock(&m_csLock);
m_pSubPic = ppSubPic;
@@ -675,8 +668,7 @@ STDMETHODIMP CSubPicQueueNoThread::GetStats(int& nSubPics, REFERENCE_TIME& rtNow
rtNow = m_rtNow;
rtStart = rtStop = 0;
- if(m_pSubPic)
- {
+ if(m_pSubPic) {
nSubPics = 1;
rtStart = m_pSubPic->GetStart();
rtStop = m_pSubPic->GetStop();
@@ -689,8 +681,9 @@ STDMETHODIMP CSubPicQueueNoThread::GetStats(int nSubPic, REFERENCE_TIME& rtStart
{
CAutoLock cAutoLock(&m_csLock);
- if(!m_pSubPic || nSubPic != 0)
+ if(!m_pSubPic || nSubPic != 0) {
return E_INVALIDARG;
+ }
rtStart = m_pSubPic->GetStart();
rtStop = m_pSubPic->GetStop();
diff --git a/src/SubPic/SubPicQueueImpl.h b/src/SubPic/SubPicQueueImpl.h
index 9c3d7c4cc..15e612009 100644
--- a/src/SubPic/SubPicQueueImpl.h
+++ b/src/SubPic/SubPicQueueImpl.h
@@ -53,13 +53,13 @@ public:
STDMETHODIMP SetFPS(double fps);
STDMETHODIMP SetTime(REFERENCE_TIME rtNow);
-/*
- STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1) = 0;
- STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, ISubPic** ppSubPic) = 0;
+ /*
+ STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1) = 0;
+ STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, ISubPic** ppSubPic) = 0;
- STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
- STDMETHODIMP GetStats(int nSubPics, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
-*/
+ STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
+ STDMETHODIMP GetStats(int nSubPics, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
+ */
};
class CSubPicQueue : public CSubPicQueueImpl, private CAMThread